Code

Merge and cleanup of GSoC C++-ification project.
authorJon A. Cruz <jon@joncruz.org>
Sun, 12 Dec 2010 08:40:34 +0000 (00:40 -0800)
committerJon A. Cruz <jon@joncruz.org>
Sun, 12 Dec 2010 08:40:34 +0000 (00:40 -0800)
299 files changed:
1  2 
src/arc-context.cpp
src/box3d-context.cpp
src/box3d-side.cpp
src/box3d-side.h
src/box3d.cpp
src/box3d.h
src/color-profile-test.h
src/color-profile.cpp
src/conditions.cpp
src/conn-avoid-ref.cpp
src/connector-context.cpp
src/console-output-undo-observer.cpp
src/console-output-undo-observer.h
src/desktop-events.cpp
src/desktop-style.cpp
src/desktop.cpp
src/desktop.h
src/dialogs/clonetiler.cpp
src/dialogs/export.cpp
src/dialogs/find.cpp
src/dialogs/item-properties.cpp
src/dialogs/spellcheck.cpp
src/dialogs/text-edit.cpp
src/dialogs/xml-tree.cpp
src/display/canvas-grid.cpp
src/display/nr-filter-image.cpp
src/document-private.h
src/document-subset.cpp
src/document-undo.cpp
src/document-undo.h
src/document.cpp
src/document.h
src/draw-context.cpp
src/dropper-context.cpp
src/dyna-draw-context.cpp
src/eraser-context.cpp
src/event-context.cpp
src/extension/dbus/application-interface.cpp
src/extension/dbus/document-interface.cpp
src/extension/effect.cpp
src/extension/execution-env.cpp
src/extension/implementation/script.cpp
src/extension/implementation/xslt.cpp
src/extension/internal/bluredge.cpp
src/extension/internal/cairo-png-out.cpp
src/extension/internal/cairo-ps-out.cpp
src/extension/internal/cairo-ps-out.h
src/extension/internal/cairo-render-context.cpp
src/extension/internal/cairo-renderer-pdf-out.cpp
src/extension/internal/cairo-renderer.cpp
src/extension/internal/cairo-renderer.h
src/extension/internal/emf-win32-inout.cpp
src/extension/internal/emf-win32-print.cpp
src/extension/internal/filter/filter.cpp
src/extension/internal/gdkpixbuf-input.cpp
src/extension/internal/gimpgrad.cpp
src/extension/internal/grid.cpp
src/extension/internal/javafx-out.cpp
src/extension/internal/latex-pstricks-out.cpp
src/extension/internal/latex-pstricks.cpp
src/extension/internal/latex-text-renderer.cpp
src/extension/internal/odf.cpp
src/extension/internal/odf.h
src/extension/internal/pdf-input-cairo.cpp
src/extension/internal/pdfinput/pdf-input.cpp
src/extension/internal/pdfinput/svg-builder.cpp
src/extension/internal/pov-out.cpp
src/extension/internal/svg.cpp
src/extension/internal/win32.cpp
src/extension/internal/wpg-input.cpp
src/extension/param/parameter.cpp
src/extension/print.h
src/extension/system.cpp
src/file.cpp
src/filter-chemistry.cpp
src/filters/blend.cpp
src/filters/colormatrix.cpp
src/filters/componenttransfer-funcnode.cpp
src/filters/componenttransfer.cpp
src/filters/composite.cpp
src/filters/convolvematrix.cpp
src/filters/diffuselighting.cpp
src/filters/displacementmap.cpp
src/filters/distantlight.cpp
src/filters/flood.cpp
src/filters/image.cpp
src/filters/mergenode.cpp
src/filters/morphology.cpp
src/filters/offset.cpp
src/filters/pointlight.cpp
src/filters/specularlighting.cpp
src/filters/spotlight.cpp
src/filters/turbulence.cpp
src/flood-context.cpp
src/forward.h
src/gradient-chemistry.cpp
src/gradient-context.cpp
src/gradient-drag.cpp
src/graphlayout.cpp
src/helper/pixbuf-ops.cpp
src/helper/png-write.cpp
src/helper/stock-items.cpp
src/id-clash.cpp
src/inkscape.cpp
src/inkview.cpp
src/interface.cpp
src/interface.h
src/jabber_whiteboard/node-tracker.cpp
src/jabber_whiteboard/session-manager.cpp
src/knot-holder-entity.cpp
src/knot.cpp
src/knotholder.cpp
src/layer-fns.cpp
src/layer-manager.cpp
src/live_effects/effect.cpp
src/live_effects/lpe-knot.cpp
src/live_effects/lpe-mirror_symmetry.cpp
src/live_effects/lpegroupbbox.cpp
src/live_effects/lpeobject.cpp
src/live_effects/parameter/path-reference.h
src/live_effects/parameter/path.cpp
src/lpe-tool-context.cpp
src/main.cpp
src/marker.cpp
src/object-edit.cpp
src/object-snapper.cpp
src/path-chemistry.cpp
src/persp3d.cpp
src/print.cpp
src/profile-manager.cpp
src/rdf.cpp
src/rdf.h
src/rect-context.cpp
src/removeoverlap.cpp
src/satisfied-guide-cns.cpp
src/selcue.cpp
src/select-context.cpp
src/selection-chemistry.cpp
src/selection-chemistry.h
src/selection-describer.cpp
src/selection.cpp
src/seltrans.cpp
src/sp-anchor.cpp
src/sp-animation.cpp
src/sp-clippath.cpp
src/sp-clippath.h
src/sp-conn-end-pair.cpp
src/sp-defs.cpp
src/sp-defs.h
src/sp-ellipse.cpp
src/sp-filter-primitive.cpp
src/sp-filter.cpp
src/sp-flowdiv.cpp
src/sp-flowregion.cpp
src/sp-flowtext.cpp
src/sp-font-face.cpp
src/sp-font.cpp
src/sp-gaussian-blur.cpp
src/sp-glyph-kerning.cpp
src/sp-glyph.cpp
src/sp-gradient-test.h
src/sp-gradient.cpp
src/sp-guide-attachment.h
src/sp-guide.cpp
src/sp-guide.h
src/sp-image.cpp
src/sp-item-group.cpp
src/sp-item-notify-moveto.cpp
src/sp-item-rm-unsatisfied-cns.cpp
src/sp-item-transform.cpp
src/sp-item-update-cns.cpp
src/sp-item.cpp
src/sp-item.h
src/sp-line.cpp
src/sp-line.h
src/sp-lpe-item.cpp
src/sp-mask.cpp
src/sp-mask.h
src/sp-missing-glyph.cpp
src/sp-namedview.cpp
src/sp-namedview.h
src/sp-object-group.cpp
src/sp-object-group.h
src/sp-object-repr.cpp
src/sp-object-repr.h
src/sp-object.cpp
src/sp-object.h
src/sp-offset.cpp
src/sp-path.cpp
src/sp-pattern.cpp
src/sp-pattern.h
src/sp-polygon.cpp
src/sp-polyline.cpp
src/sp-polyline.h
src/sp-rect.cpp
src/sp-rect.h
src/sp-root.cpp
src/sp-script.cpp
src/sp-shape.cpp
src/sp-shape.h
src/sp-skeleton.cpp
src/sp-spiral.cpp
src/sp-star.cpp
src/sp-stop.cpp
src/sp-string.cpp
src/sp-style-elem-test.h
src/sp-style-elem.cpp
src/sp-switch.cpp
src/sp-symbol.cpp
src/sp-text.cpp
src/sp-textpath.h
src/sp-tref-reference.h
src/sp-tref.cpp
src/sp-tspan.cpp
src/sp-use.cpp
src/spiral-context.cpp
src/splivarot.cpp
src/spray-context.cpp
src/star-context.cpp
src/style-test.h
src/style.cpp
src/svg-view-widget.cpp
src/svg-view.cpp
src/test-helpers.h
src/text-chemistry.cpp
src/text-context.cpp
src/text-editing.cpp
src/text-editing.h
src/trace/trace.cpp
src/tweak-context.cpp
src/ui/clipboard.cpp
src/ui/context-menu.cpp
src/ui/context-menu.h
src/ui/dialog/aboutbox.cpp
src/ui/dialog/align-and-distribute.cpp
src/ui/dialog/color-item.cpp
src/ui/dialog/document-properties.cpp
src/ui/dialog/filedialogimpl-gtkmm.cpp
src/ui/dialog/filedialogimpl-win32.cpp
src/ui/dialog/filter-effects-dialog.cpp
src/ui/dialog/find.cpp
src/ui/dialog/glyphs.cpp
src/ui/dialog/guides.cpp
src/ui/dialog/icon-preview.cpp
src/ui/dialog/layer-properties.cpp
src/ui/dialog/layers.cpp
src/ui/dialog/livepatheffect-editor.cpp
src/ui/dialog/print.cpp
src/ui/dialog/session-player.cpp
src/ui/dialog/svg-fonts-dialog.cpp
src/ui/dialog/swatches.cpp
src/ui/dialog/tile.cpp
src/ui/dialog/transformation.cpp
src/ui/dialog/undo-history.cpp
src/ui/tool/multi-path-manipulator.cpp
src/ui/tool/node-tool.cpp
src/ui/tool/path-manipulator.cpp
src/ui/view/view.cpp
src/ui/widget/color-picker.cpp
src/ui/widget/entity-entry.cpp
src/ui/widget/imageicon.cpp
src/ui/widget/layer-selector.cpp
src/ui/widget/licensor.cpp
src/ui/widget/object-composite-settings.cpp
src/ui/widget/page-sizer.cpp
src/ui/widget/registered-widget.cpp
src/ui/widget/registered-widget.h
src/ui/widget/ruler.cpp
src/ui/widget/selected-style.cpp
src/ui/widget/style-subject.cpp
src/ui/widget/tolerance-slider.cpp
src/unclump.cpp
src/uri-references.h
src/vanishing-point.cpp
src/verbs.cpp
src/widgets/desktop-widget.cpp
src/widgets/desktop-widget.h
src/widgets/fill-style.cpp
src/widgets/gradient-selector.cpp
src/widgets/gradient-toolbar.cpp
src/widgets/gradient-vector.cpp
src/widgets/icon.cpp
src/widgets/paint-selector.cpp
src/widgets/select-toolbar.cpp
src/widgets/sp-attribute-widget.cpp
src/widgets/sp-color-icc-selector.cpp
src/widgets/sp-xmlview-content.cpp
src/widgets/stroke-style.cpp
src/widgets/swatch-selector.cpp
src/widgets/toolbox.cpp
src/xml/helper-observer.cpp
src/xml/node-iterators.h
src/xml/rebase-hrefs.cpp
src/xml/repr-io.cpp
src/xml/repr-sorting.cpp
src/xml/repr-sorting.h
src/xml/repr-util.cpp
src/xml/repr.cpp
src/xml/repr.h

diff --combined src/arc-context.cpp
index b485dd1835c2d3446f4a7d058ff74f9bdad29cb3,2f70e16f361c519fc3fb1b5a0e90af4de5e82761..1c480ecbc6efaeb971230fc2bce45977edf624a8
@@@ -6,6 -6,6 +6,7 @@@
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
   *   Johan Engelen <johan@shouraizou.nl>
++ *   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);
@@@ -107,7 -107,6 +110,7 @@@ static void sp_arc_context_init(SPArcCo
      event_context->tolerance = 0;
      event_context->within_tolerance = false;
      event_context->item_to_select = NULL;
 +    event_context->tool_url = "/tools/shapes/arc";
  
      arc_context->item = NULL;
  
@@@ -252,7 -251,6 +255,7 @@@ static gint sp_arc_context_root_handler
                                      GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
                                      NULL, event->button.time);
                  ret = TRUE;
 +                m.unSetup();
              }
              break;
          case GDK_MOTION_NOTIFY:
                  Geom::Point const motion_w(event->motion.x, event->motion.y);
                  Geom::Point motion_dt(desktop->w2d(motion_w));
                  m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +                m.unSetup();
              }
              break;
          case GDK_BUTTON_RELEASE:
@@@ -410,17 -407,17 +413,17 @@@ 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));
          Inkscape::GC::release(repr);
-         ac->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+         ac->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
          ac->item->updateRepr();
  
          sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
          Geom::Point c = r.midpoint();
          if (!ctrl_save) {
              if (fabs(dir[Geom::X]) > 1E-6 && fabs(dir[Geom::Y]) > 1E-6) {
-                 Geom::Matrix const i2d (sp_item_i2d_affine (ac->item));
+                 Geom::Matrix const i2d ((ac->item)->i2d_affine ());
                  Geom::Point new_dir = pt * i2d - c;
                  new_dir[Geom::X] *= dir[Geom::Y] / dir[Geom::X];
                  double lambda = new_dir.length() / dir[Geom::Y];
@@@ -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));
  }
  
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/box3d-context.cpp
index 14f4470bc1241b9fe240d565846c0fbac8235565,99cf28963e9ae2bd9179dd1b36a7bfbb292c3dd0..f23e4d8836b182eac748e9fdfe972d7b23e5b1b3
@@@ -1,11 -1,11 +1,11 @@@
--#define __SP_BOX3D_CONTEXT_C__
--
  /*
   * 3D box drawing context
   *
   * Author:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2007      Maximilian Albert <Anhalter42@gmx.de>
   * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
@@@ -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<SPDefs *>(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;
@@@ -283,7 -283,6 +285,7 @@@ static gint sp_box3d_context_root_handl
          if ( event->button.button == 1  && !event_context->space_panning) {
              Geom::Point const button_w(event->button.x,
                                         event->button.y);
 +            Geom::Point button_dt(desktop->w2d(button_w));
  
              // save drag origin
              event_context->xp = (gint) button_w[Geom::X];
  
              dragging = true;
  
 -            /*  */
 -            Geom::Point button_dt(desktop->w2d(button_w));
 +            SnapManager &m = desktop->namedview->snap_manager;
 +            m.setup(desktop, true, bc->item);
 +            m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +            m.unSetup();
 +            bc->center = from_2geom(button_dt);
 +
              bc->drag_origin = from_2geom(button_dt);
              bc->drag_ptB = from_2geom(button_dt);
              bc->drag_ptC = from_2geom(button_dt);
              bc->drag_ptC_proj.normalize();
              bc->drag_ptC_proj[Proj::Z] = 0.25;
  
 -            /* Snap center */
 -            SnapManager &m = desktop->namedview->snap_manager;
 -            m.setup(desktop, true, bc->item);
 -            m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -            bc->center = from_2geom(button_dt);
 -
              sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                  ( GDK_KEY_PRESS_MASK |
                                    GDK_BUTTON_RELEASE_MASK       |
              SnapManager &m = desktop->namedview->snap_manager;
              m.setup(desktop, true, bc->item);
              m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -
              bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
  
              if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
                  }
                  m.freeSnapReturnByRef(bc->drag_ptC, Inkscape::SNAPSOURCE_NODE_HANDLE);
              }
 +            m.unSetup();
  
              sp_box3d_drag(*bc, event->motion.state);
  
              Geom::Point const motion_w(event->motion.x, event->motion.y);
              Geom::Point motion_dt(desktop->w2d(motion_w));
              m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +            m.unSetup();
          }
          break;
      case GDK_BUTTON_RELEASE:
  
          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;
  
  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) {
  
              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);
              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;
@@@ -691,4 -723,4 +704,4 @@@ void sp_box3d_context_update_lines(SPEv
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/box3d-side.cpp
index 057d8f7dfcd6e2c9bac68a937a8fad3bb9868ee1,6838008bb2492804dd26c65983a0e7e5f79ea741..72a479ca4ab0957ead622c60404acbdfd15e131b
@@@ -1,10 -1,10 +1,9 @@@
--#define __BOX3D_SIDE_C__
--
  /*
   * 3D box face implementation
   *
   * Authors:
   *   Maximilian Albert <Anhalter42@gmx.de>
++ *   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<SPShape *>(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<SPShape *>(object)->setShape ();
      }
  
      if (((SPObjectClass *) parent_class)->update)
          ((SPObjectClass *) parent_class)->update (object, ctx, flags);
  }
  
 -      box3d_side = (Box3DSide *)box->appendChildRepr(repr_side);
+ /* 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 = static_cast<Box3DSide *>(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));
@@@ -243,43 -263,48 +262,19 @@@ box3d_side_set_shape (SPShape *shape
  
      /* Reset the shape'scurve to the "original_curve"
       * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
-     sp_shape_set_curve_insync (shape, c, TRUE);
+     shape->setCurveInsync( c, TRUE);
      if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
          SPCurve *c_lpe = c->copy();
          bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
          if (success) {
-             sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+             shape->setCurveInsync( c_lpe, TRUE);
          }
          c_lpe->unref();
      }
      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;
  }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/box3d-side.h
index 18c81507312652658ba87dd41eb10a3e14b68fa8,29a4a6b00c0f5b7dc82fdecc62e5c73696c09190..a8d692b01d6d70e55155fb4e0d2f863c03fc8394
@@@ -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 <Anhalter42@gmx.de>
++ *   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 {
  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:
@@@ -57,4 -59,4 +62,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/box3d.cpp
index aa2dc55e36cad3b833b26d9c1a17108f68d68c13,250c1f5004b132029fa93034087a84070f3a72fc..d51df9df3a1e18e3895e3d6a82c2517489317e7a
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_BOX3D_C__
--
  /*
   * SVG <box3d> implementation
   *
@@@ -7,6 -7,6 +5,7 @@@
   *   Maximilian Albert <Anhalter42@gmx.de>
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
++ *   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);
              }
@@@ -268,7 -268,7 +267,7 @@@ box3d_update(SPObject *object, SPCtx *c
  }
  
  
- static Inkscape::XML::Node *box3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
+ static Inkscape::XML::Node * box3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
  {
      SPBox3D *box = SP_BOX3D(object);
  
                  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(_("<b>3D Box</b>"));
  }
  
--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,21 -352,21 +347,21 @@@ 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);
  
              // Adjust stroke width
-             sp_item_adjust_stroke(childitem, sqrt(fabs(sw * sh)));
+             childitem->adjust_stroke(sqrt(fabs(sw * sh)));
  
              // Adjust pattern fill
-             sp_item_adjust_pattern(childitem, xform);
+             childitem->adjust_pattern(xform);
  
              // Adjust gradient fill
-             sp_item_adjust_gradient(childitem, xform);
+             childitem->adjust_gradient(xform);
  
              // Adjust LPE
-             sp_item_adjust_livepatheffect(childitem, xform);
+             childitem->adjust_livepatheffect(xform);
          }
      }
  
@@@ -393,7 -395,7 +390,7 @@@ box3d_get_corner_screen (SPBox3D const 
      if (!box3d_get_perspective(box)) {
          return Geom::Point (NR_HUGE, NR_HUGE);
      }
-     Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box)));
+     Geom::Matrix const i2d (SP_ITEM(box)->i2d_affine ());
      if (item_coords) {
          return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_corner).affine() * i2d.inverse();
      } else {
@@@ -417,7 -419,7 +414,7 @@@ box3d_get_center_screen (SPBox3D *box) 
      if (!box3d_get_perspective(box)) {
          return Geom::Point (NR_HUGE, NR_HUGE);
      }
-     Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box)));
+     Geom::Matrix const i2d (SP_ITEM(box)->i2d_affine ());
      return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_center).affine() * i2d.inverse();
  }
  
@@@ -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<SPBox3D *>(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<int, Box3DSide *>
--box3d_get_sides (SPBox3D *box) {
++static std::map<int, Box3DSide *> box3d_get_sides(SPBox3D *box)
++{
      std::map<int, Box3DSide *> 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<SPBox3D *> &boxes) {
++static void box3d_extract_boxes_rec(SPObject *obj, std::list<SPBox3D *> &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<SPObject *>(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<SPObject *>(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<SPObject *>(box)->getAttribute("id");
 -    gchar const *style = static_cast<SPObject *>(box)->getAttribute("style");
 -    gchar const *mask = static_cast<SPObject *>(box)->getAttribute("mask");
 -    gchar const *clip_path = static_cast<SPObject *>(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.");
  
      // add the new group to the box's parent and set remembered position
      SPObject *parent = SP_OBJECT_PARENT(box);
-     SP_OBJECT_REPR(parent)->appendChild(grepr);
+     parent->appendChild(grepr);
      grepr->setPosition(pos);
      grepr->setAttribute("style", style);
      if (mask)
@@@ -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 --combined src/box3d.h
index 8273e35420324c6f2ace6011dfd98763f19dcc73,e313f428521cdcbbbbb6884f1d13ec875f24465b..5dbf0cf5e4912aeea30a82ae10cfe35a171a5425
@@@ -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 <box3d> implementation
@@@ -7,6 -7,6 +7,7 @@@
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   Maximilian Albert <Anhalter42@gmx.de>
++ *   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;
      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:
@@@ -89,4 -92,4 +97,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/color-profile-test.h
index 42893039a070b5e82274334964920a41b8b9f066,4da3c579a8b221eee6c966f59a69098c23826deb..4b679e5b7e1eeff0dea1d1c035e49e9550085d97
@@@ -25,7 -25,7 +25,7 @@@ public
      {
          if ( _doc )
          {
-             sp_document_unref( _doc );
+             _doc->doUnref();
          }
      }
  
@@@ -80,7 -80,7 +80,7 @@@
  
          for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) {
              std::string descr(cases[i].attr);
-             sp_object_set(SP_OBJECT(prof), SP_ATTR_RENDERING_INTENT, cases[i].attr);
+             SP_OBJECT(prof)->setKeyValue( SP_ATTR_RENDERING_INTENT, cases[i].attr);
              TSM_ASSERT_EQUALS( descr, prof->rendering_intent, (guint)cases[i].intVal );
          }
  
          SP_OBJECT(prof)->document = _doc;
  
          for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) {
-             sp_object_set(SP_OBJECT(prof), SP_ATTR_LOCAL, cases[i]);
+             SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, cases[i]);
              TS_ASSERT( prof->local );
              if ( prof->local ) {
                  TS_ASSERT_EQUALS( std::string(prof->local), std::string(cases[i]) );
              }
          }
-         sp_object_set(SP_OBJECT(prof), SP_ATTR_LOCAL, NULL);
+         SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, NULL);
          TS_ASSERT_EQUALS( prof->local, (gchar*)0 );
  
          g_object_unref(prof);
          SP_OBJECT(prof)->document = _doc;
  
          for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) {
-             sp_object_set(SP_OBJECT(prof), SP_ATTR_NAME, cases[i]);
+             SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, cases[i]);
              TS_ASSERT( prof->name );
              if ( prof->name ) {
                  TS_ASSERT_EQUALS( std::string(prof->name), std::string(cases[i]) );
              }
          }
-         sp_object_set(SP_OBJECT(prof), SP_ATTR_NAME, NULL);
+         SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, NULL);
          TS_ASSERT_EQUALS( prof->name, (gchar*)0 );
  
          g_object_unref(prof);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/color-profile.cpp
index 4c71fd72b47d356f5383abcea339797150da1ba0,ee4118e4f0b625b09ad6b00914096cd1e6837cba..e08a416d3b829a9ac84379956186d5c5166ffb6a
@@@ -2,12 -2,11 +2,12 @@@
  # include "config.h"
  #endif
  
 -#define DEBUG_LCMS
 +#define noDEBUG_LCMS
  
  #include <glib/gstdio.h>
  #include <sys/fcntl.h>
  #include <gdkmm/color.h>
 +#include <glib/gi18n.h>
  
  #ifdef DEBUG_LCMS
  #include <gtk/gtkmessagedialog.h>
@@@ -15,7 -14,6 +15,7 @@@
  
  #include <cstring>
  #include <string>
 +#include <io/sys.h>
  
  #ifdef WIN32
  #ifndef _WIN32_WINDOWS         // Allow use of features specific to Windows 98 or later. Required for correctly including icm.h
@@@ -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);
@@@ -249,14 -247,14 +248,14 @@@ void ColorProfile::build( SPObject *obj
      if (cprof_parent_class->build) {
          (* cprof_parent_class->build)(object, document, repr);
      }
-     sp_object_read_attr( object, "xlink:href" );
-     sp_object_read_attr( object, "local" );
-     sp_object_read_attr( object, "name" );
-     sp_object_read_attr( object, "rendering-intent" );
+     object->readAttr( "xlink:href" );
+     object->readAttr( "local" );
+     object->readAttr( "name" );
+     object->readAttr( "rendering-intent" );
  
      // 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);
@@@ -558,6 -556,9 +557,6 @@@ bool ColorProfile::GamutCheck(SPColor c
      return (outofgamut == 255);
  }
  
 -
 -#include <io/sys.h>
 -
  class ProfileInfo
  {
  public:
@@@ -629,14 -630,7 +628,14 @@@ Glib::ustring Inkscape::get_path_for_pr
  }
  #endif // ENABLE_LCMS
  
 -std::list<Glib::ustring> ColorProfile::getProfileDirs() {
 +std::list<Glib::ustring> ColorProfile::getBaseProfileDirs() {
 +#if ENABLE_LCMS
 +    static bool warnSet = false;
 +    if (!warnSet) {
 +        cmsErrorAction( LCMS_ERROR_SHOW );
 +        warnSet = true;
 +    }
 +#endif // ENABLE_LCMS
      std::list<Glib::ustring> sources;
  
      gchar* base = profile_path("XXX");
      }
  
      // On OS X:
 -    if ( g_file_test("/Library/ColorSync/Profiles", G_FILE_TEST_EXISTS)  && g_file_test("/Library/ColorSync/Profiles", G_FILE_TEST_IS_DIR) ) {
 -        sources.push_back("/Library/ColorSync/Profiles");
 -
 -        gchar* path = g_build_filename(g_get_home_dir(), "Library", "ColorSync", "Profiles", NULL);
 -        if ( g_file_test(path, G_FILE_TEST_EXISTS)  && g_file_test(path, G_FILE_TEST_IS_DIR) ) {
 -            sources.push_back(path);
 +    {
 +        bool onOSX = false;
 +        std::list<Glib::ustring> possible;
 +        possible.push_back("/System/Library/ColorSync/Profiles");
 +        possible.push_back("/Library/ColorSync/Profiles");
 +        for ( std::list<Glib::ustring>::const_iterator it = possible.begin(); it != possible.end(); ++it ) {
 +            if ( g_file_test(it->c_str(), G_FILE_TEST_EXISTS)  && g_file_test(it->c_str(), G_FILE_TEST_IS_DIR) ) {
 +                sources.push_back(it->c_str());
 +                onOSX = true;
 +            }
 +        }
 +        if ( onOSX ) {
 +            gchar* path = g_build_filename(g_get_home_dir(), "Library", "ColorSync", "Profiles", NULL);
 +            if ( g_file_test(path, G_FILE_TEST_EXISTS)  && g_file_test(path, G_FILE_TEST_IS_DIR) ) {
 +                sources.push_back(path);
 +            }
 +            g_free(path);
          }
 -        g_free(path);
      }
  
 -
  #ifdef WIN32
      wchar_t pathBuf[MAX_PATH + 1];
      pathBuf[0] = 0;
      return sources;
  }
  
 +static bool isIccFile( gchar const *filepath )
 +{
 +    bool isIccFile = false;
 +    struct stat st;
 +    if ( g_stat(filepath, &st) == 0 && (st.st_size > 128) ) {
 +        //0-3 == size
 +        //36-39 == 'acsp' 0x61637370
 +        int fd = g_open( filepath, O_RDONLY, S_IRWXU);
 +        if ( fd != -1 ) {
 +            guchar scratch[40] = {0};
 +            size_t len = sizeof(scratch);
 +
 +            //size_t left = 40;
 +            ssize_t got = read(fd, scratch, len);
 +            if ( got != -1 ) {
 +                size_t calcSize = (scratch[0] << 24) | (scratch[1] << 16) | (scratch[2] << 8) | scratch[3];
 +                if ( calcSize > 128 && calcSize <= static_cast<size_t>(st.st_size) ) {
 +                    isIccFile = (scratch[36] == 'a') && (scratch[37] == 'c') && (scratch[38] == 's') && (scratch[39] == 'p');
 +                }
 +            }
 +
 +            close(fd);
  #if ENABLE_LCMS
 -static void findThings() {
 -    std::list<Glib::ustring> sources = ColorProfile::getProfileDirs();
 +            if (isIccFile) {
 +                cmsHPROFILE prof = cmsOpenProfileFromFile( filepath, "r" );
 +                if ( prof ) {
 +                    icProfileClassSignature profClass = cmsGetDeviceClass(prof);
 +                    if ( profClass == icSigNamedColorClass ) {
 +                        isIccFile = false; // Ignore named color profiles for now.
 +                    }
 +                    cmsCloseProfile( prof );
 +                }
 +            }
 +#endif // ENABLE_LCMS
 +        }
 +    }
 +    return isIccFile;
 +}
 +
 +std::list<Glib::ustring> ColorProfile::getProfileFiles()
 +{
 +    std::list<Glib::ustring> files;
  
 +    std::list<Glib::ustring> sources = ColorProfile::getBaseProfileDirs();
      for ( std::list<Glib::ustring>::const_iterator it = sources.begin(); it != sources.end(); ++it ) {
          if ( g_file_test( it->c_str(), G_FILE_TEST_EXISTS ) && g_file_test( it->c_str(), G_FILE_TEST_IS_DIR ) ) {
              GError *err = 0;
              if (dir) {
                  for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) {
                      gchar *filepath = g_build_filename(it->c_str(), file, NULL);
 -
 -
                      if ( g_file_test( filepath, G_FILE_TEST_IS_DIR ) ) {
                          sources.push_back(g_strdup(filepath));
                      } else {
 -                        bool isIccFile = false;
 -                        struct stat st;
 -                        if ( g_stat(filepath, &st) == 0 && (st.st_size > 128) ) {
 -                            //0-3 == size
 -                            //36-39 == 'acsp' 0x61637370
 -                            int fd = g_open( filepath, O_RDONLY, S_IRWXU);
 -                            if ( fd != -1 ) {
 -                                guchar scratch[40] = {0};
 -                                size_t len = sizeof(scratch);
 -
 -                                //size_t left = 40;
 -                                ssize_t got = read(fd, scratch, len);
 -                                if ( got != -1 ) {
 -                                    size_t calcSize = (scratch[0] << 24) | (scratch[1] << 16) | (scratch[2] << 8) | scratch[3];
 -                                    if ( calcSize > 128 && calcSize <= static_cast<size_t>(st.st_size) ) {
 -                                        isIccFile = (scratch[36] == 'a') && (scratch[37] == 'c') && (scratch[38] == 's') && (scratch[39] == 'p');
 -                                    }
 -                                }
 -
 -                                close(fd);
 -                            }
 -                        }
 -
 -                        if ( isIccFile ) {
 -                            cmsHPROFILE prof = cmsOpenProfileFromFile( filepath, "r" );
 -                            if ( prof ) {
 -                                ProfileInfo info( prof, Glib::filename_to_utf8( filepath ) );
 -                                cmsCloseProfile( prof );
 -
 -                                bool sameName = false;
 -                                for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
 -                                    if ( it->getName() == info.getName() ) {
 -                                        sameName = true;
 -                                        break;
 -                                    }
 -                                }
 -
 -                                if ( !sameName ) {
 -                                    knownProfiles.push_back(info);
 -                                }
 -                            }
 +                        if ( isIccFile( filepath ) ) {
 +                            files.push_back( filepath );
                          }
                      }
  
                      g_free(filepath);
                  }
 +                g_dir_close(dir);
 +                dir = 0;
 +            } else {
 +                gchar *safeDir = Inkscape::IO::sanitizeString(it->c_str());
 +                g_warning(_("Color profiles directory (%s) is unavailable."), safeDir);
 +                g_free(safeDir);
 +            }
 +        }
 +    }
 +
 +    return files;
 +}
 +
 +#if ENABLE_LCMS
 +static void findThings() {
 +    std::list<Glib::ustring> files = ColorProfile::getProfileFiles();
 +
 +    for ( std::list<Glib::ustring>::const_iterator it = files.begin(); it != files.end(); ++it ) {
 +        cmsHPROFILE prof = cmsOpenProfileFromFile( it->c_str(), "r" );
 +        if ( prof ) {
 +            ProfileInfo info( prof, Glib::filename_to_utf8( it->c_str() ) );
 +            cmsCloseProfile( prof );
 +
 +            bool sameName = false;
 +            for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
 +                if ( it->getName() == info.getName() ) {
 +                    sameName = true;
 +                    break;
 +                }
 +            }
 +
 +            if ( !sameName ) {
 +                knownProfiles.push_back(info);
              }
          }
      }
@@@ -1192,4 -1145,4 +1191,4 @@@ cmsHTRANSFORM Inkscape::colorprofile_ge
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/conditions.cpp
index 8d1770d6abc7f26fa135b315c5bddcf4e2189060,7087abac252753cedaa028fa633807d8544d3fd6..d35f18cf1f66391e942ce2ef2422ec77c9de0ca6
@@@ -1,10 -1,10 +1,9 @@@
--#define __SP_CONDITIONS_CPP__
--
  /*
   * SVG conditional attribute evaluation
   *
   * Authors:
   *   Andrius R. <knutux@gmail.com>
++ *   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'))
@@@ -459,4 -460,4 +454,4 @@@ zu Zul
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/conn-avoid-ref.cpp
index fe25fa418f5ad29b1f9179ee1eda0fa5ab35af9c,3e8359c579730a121735d954a1ab4010675e45f5..21ef2deab53c14bd87502c68c47648ea9c14d249
@@@ -3,6 -3,6 +3,7 @@@
   *
   * Authors:
   *   Michael Wybrow <mjwybrow@users.sourceforge.net>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2005 Michael Wybrow
   *
@@@ -28,7 -28,6 +29,7 @@@
  #include "libavoid/router.h"
  #include "libavoid/connector.h"
  #include "libavoid/geomtypes.h"
 +#include "libavoid/shape.h"
  #include "xml/node.h"
  #include "document.h"
  #include "desktop.h"
@@@ -38,7 -37,7 +39,7 @@@
  #include "inkscape.h"
  #include <glibmm/i18n.h>
  
--
++using Inkscape::DocumentUndo;
  
  using Avoid::Router;
  
@@@ -64,8 -63,8 +65,8 @@@ SPAvoidRef::~SPAvoidRef(
      const bool routerInstanceExists = (item->document->router != NULL);
  
      if (shapeRef && routerInstanceExists) {
 -        Router *router = shapeRef->router();
 -        router->removeShape(shapeRef);
 +        // Deleting the shapeRef will remove it completely from 
 +        // an existing Router instance.
          delete shapeRef;
      }
      shapeRef = NULL;
@@@ -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;
      }
              _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.
      {
          g_assert(shapeRef);
  
 -        router->removeShape(shapeRef);
 +        // Deleting the shapeRef will remove it completely from 
 +        // an existing Router instance.
          delete shapeRef;
          shapeRef = NULL;
      }
@@@ -389,12 -388,14 +390,12 @@@ 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 )
      {
          // For now, just default to the centre of the item
-         Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect bbox = item->getBounds(item->i2doc_affine());
          pos = (bbox) ? bbox->midpoint() : Geom::Point(0, 0);
      }
      else
@@@ -446,12 -447,6 +447,12 @@@ static std::vector<Geom::Point> approxC
      {
          Geom::Path::const_iterator cit = pit->begin();
          while (cit != pit->end())
 +        {
 +            if (cit == pit->begin())
 +            {
 +                poly_points.push_back(cit->initialPoint());
 +            }
 +
              if (dynamic_cast<Geom::CubicBezier const*>(&*cit))
              {
                  at += seg_size;
                  poly_points.push_back(cit->finalPoint());
                  ++cit;
              }
 +        }
          ++pit;
      }
      return poly_points;
@@@ -491,7 -485,7 +492,7 @@@ static std::vector<Geom::Point> approxI
      }
      else if (SP_IS_SHAPE(item))
      {
-         SPCurve* item_curve = sp_shape_get_curve(SP_SHAPE(item));
+         SPCurve* item_curve = SP_SHAPE(item)->getCurve();
          // make sure it has an associated curve
          if (item_curve)
          {
@@@ -511,7 -505,7 +512,7 @@@ static Avoid::Polygon avoid_item_poly(S
      g_assert(desktop != NULL);
      double spacing = desktop->namedview->connector_spacing;
  
-     Geom::Matrix itd_mat = sp_item_i2doc_affine(item);
+     Geom::Matrix itd_mat = item->i2doc_affine();
      std::vector<Geom::Point> hull_points;
      hull_points = approxItemWithPoints(item, itd_mat);
  
      prev_parallel_hull_edge.origin(hull_edge.origin()+hull_edge.versor().ccw()*spacing);
      prev_parallel_hull_edge.versor(hull_edge.versor());
      int hull_size = hull.boundary.size();
 -    for (int i = 0; i <= hull_size; ++i)
 +    for (int i = 0; i < hull_size; ++i)
      {
          hull_edge.setBy2Points(hull[i], hull[i+1]);
          Geom::Line parallel_hull_edge;
  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,
      if (items) {
          g_slist_free(items);
      }
-     sp_document_set_undo_sensitive(document, saved);
 -      SPDocumentUndo::set_undo_sensitive(document, saved);
++    DocumentUndo::setUndoSensitive(document, saved);
  }
  
  
index adc54a1ae228b68e08b129030f19b17415caec16,a419af44aea6b6b03437cafea56125548dac4eeb..b1061c1247a47452fb5b6d2aa5d30d4504ed5808
@@@ -3,6 -3,6 +3,7 @@@
   *
   * Authors:
   *   Michael Wybrow <mjwybrow@users.sourceforge.net>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2005-2008  Michael Wybrow
   * Copyright (C) 2009  Monash University
  #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);
@@@ -768,6 -768,7 +771,6 @@@ connector_handle_button_press(SPConnect
              Geom::Point const event_dt = cc->desktop->w2d(event_w);
  
              SnapManager &m = cc->desktop->namedview->snap_manager;
 -            m.setup(cc->desktop);
  
              switch (cc->state) {
                  case SP_CONNECTOR_CONTEXT_STOP:
                          if (!found) {
                              // This is the first point, so just snap it to the grid
                              // as there's no other points to go off.
 +                            m.setup(cc->desktop);
                              m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 +                            m.unSetup();
                          }
                          spcc_connector_set_initial_point(cc, p);
  
                  case SP_CONNECTOR_CONTEXT_DRAGGING:
                  {
                      // This is the second click of a connector creation.
 +                    m.setup(cc->desktop);
                      m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 +                    m.unSetup();
  
                      spcc_connector_set_subsequent_point(cc, p);
                      spcc_connector_finish_segment(cc, p);
@@@ -945,6 -942,7 +948,6 @@@ connector_handle_motion_notify(SPConnec
      if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE )
      {
          SnapManager &m = dt->namedview->snap_manager;
 -        m.setup(dt);
  
          switch (cc->state) {
              case SP_CONNECTOR_CONTEXT_DRAGGING:
                  gobble_motion_events(mevent.state);
                  // This is movement during a connector creation.
                  if ( cc->npoints > 0 ) {
 +                    m.setup(dt);
                      m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 +                    m.unSetup();
                      cc->selection->clear();
                      spcc_connector_set_subsequent_point(cc, p);
                      ret = TRUE;
                  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;
                  break;
              default:
                  if (!sp_event_context_knot_mouseover(cc)) {
 +                    m.setup(dt);
                      m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE));
 +                    m.unSetup();
                  }
                  break;
          }
@@@ -1036,6 -1028,7 +1039,6 @@@ connector_handle_button_release(SPConne
          SPDocument *doc = sp_desktop_document(desktop);
  
          SnapManager &m = desktop->namedview->snap_manager;
 -        m.setup(desktop);
  
          Geom::Point const event_w(revent.x, revent.y);
  
                  //case SP_CONNECTOR_CONTEXT_POINT:
                  case SP_CONNECTOR_CONTEXT_DRAGGING:
                  {
 +                    m.setup(desktop);
                      m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 +                    m.unSetup();
  
                      if (cc->within_tolerance)
                      {
                  }
                  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;
  
                      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);
                      }
  
  
  
                  case SP_CONNECTOR_CONTEXT_NEWCONNPOINT:
 +                    m.setup(desktop);
                      m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 +                    m.unSetup();
  
                      sp_knot_set_position(cc->selected_handle, p, 0);
  
                      ConnectionPoint cp;
                      cp.type = ConnPointUserDefined;
-                     cp.pos = p * sp_item_dt2i_affine(cc->active_shape);
+                     cp.pos = p * (cc->active_shape)->dt2i_affine();
                      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,
                      // Obtain original position
                      ConnectionPoint const& cp = cc->connpthandles[cc->selected_handle];
                      SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
-                     const Geom::Matrix& i2doc = sp_item_i2doc_affine(cc->active_shape);
+                     const Geom::Matrix& i2doc = (cc->active_shape)->i2doc_affine();
                      sp_knot_set_position(cc->selected_handle, cp.pos * i2doc * desktop->doc2dt(), 0);
                      cc->state = SP_CONNECTOR_CONTEXT_IDLE;
                      desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE,
                  {
                      // Put connection point at current position
  
 -                    SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
 -                    SnapManager &m = desktop->namedview->snap_manager;
 -                    m.setup(desktop);
                      Geom::Point p = cc->selected_handle->pos;
 -//                     SPEventContext* event_context = SP_EVENT_CONTEXT( cc );
  
                      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);
                      }
  
                      SnapManager &m = desktop->namedview->snap_manager;
                      m.setup(desktop);
                      Geom::Point p = cc->selected_handle->pos;
 -
                      m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 -
 +                    m.unSetup();
                      sp_knot_set_position(cc->selected_handle, p, 0);
  
                      ConnectionPoint cp;
                      cp.type = ConnPointUserDefined;
-                     cp.pos = p * sp_item_dt2i_affine(cc->active_shape);
+                     cp.pos = p * (cc->active_shape)->dt2i_affine();
                      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);
          }
      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 */
  
          /* 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.
  
      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"));
  }
  
  
@@@ -1607,7 -1593,7 +1604,7 @@@ endpt_handler(SPKnot */*knot*/, GdkEven
  
                  // Show the red path for dragging.
                  cc->red_curve = SP_PATH(cc->clickeditem)->original_curve ? SP_PATH(cc->clickeditem)->original_curve->copy() : SP_PATH(cc->clickeditem)->curve->copy();
-                 Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem);
+                 Geom::Matrix i2d = (cc->clickeditem)->i2d_affine();
                  cc->red_curve->transform(i2d);
                  sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve);
  
@@@ -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<int> seen;
          for  ( ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end() ;)
@@@ -1766,26 -1752,16 +1763,26 @@@ cc_set_active_conn(SPConnectorContext *
      g_assert( SP_IS_PATH(item) );
  
      SPCurve *curve = SP_PATH(item)->original_curve ? SP_PATH(item)->original_curve : SP_PATH(item)->curve;
-     Geom::Matrix i2d = sp_item_i2d_affine(item);
+     Geom::Matrix i2d = item->i2d_affine();
  
      if (cc->active_conn == item)
      {
 -        // Just adjust handle positions.
 -        Geom::Point startpt = *(curve->first_point()) * i2d;
 -        sp_knot_set_position(cc->endpt_handle[0], startpt, 0);
 +        if (curve->is_empty())
 +        {
 +            // Connector is invisible because it is clipped to the boundary of
 +            // two overlpapping shapes.
 +            sp_knot_hide(cc->endpt_handle[0]);
 +            sp_knot_hide(cc->endpt_handle[1]);
 +        }
 +        else
 +        {
 +            // Just adjust handle positions.
 +            Geom::Point startpt = *(curve->first_point()) * i2d;
 +            sp_knot_set_position(cc->endpt_handle[0], startpt, 0);
  
 -        Geom::Point endpt = *(curve->last_point()) * i2d;
 -        sp_knot_set_position(cc->endpt_handle[1], endpt, 0);
 +            Geom::Point endpt = *(curve->last_point()) * i2d;
 +            sp_knot_set_position(cc->endpt_handle[1], endpt, 0);
 +        }
  
          return;
      }
                  G_CALLBACK(endpt_handler), cc);
      }
  
 +    if (curve->is_empty())
 +    {
 +        // Connector is invisible because it is clipped to the boundary 
 +        // of two overlpapping shapes.  So, it doesn't need endpoints.
 +        return;
 +    }
 +
      Geom::Point startpt = *(curve->first_point()) * i2d;
      sp_knot_set_position(cc->endpt_handle[0], startpt, 0);
  
@@@ -1918,10 -1887,8 +1915,10 @@@ static bool cc_item_is_shape(SPItem *it
  bool cc_item_is_connector(SPItem *item)
  {
      if (SP_IS_PATH(item)) {
 -        if (SP_PATH(item)->connEndPair.isAutoRoutingConn()) {
 -            g_assert( SP_PATH(item)->original_curve ? !(SP_PATH(item)->original_curve->is_closed()) : !(SP_PATH(item)->curve->is_closed()) );
 +        bool closed = SP_PATH(item)->original_curve ? SP_PATH(item)->original_curve->is_closed() : SP_PATH(item)->curve->is_closed();
 +        if (SP_PATH(item)->connEndPair.isAutoRoutingConn() && !closed) {
 +            // To be considered a connector, an object must be a non-closed 
 +            // path that is marked with a "inkscape:connector-type" attribute.
              return true;
          }
      }
@@@ -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++;
          }
      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);
  }
  
  
@@@ -2052,4 -2019,4 +2048,4 @@@ shape_event_attr_changed(Inkscape::XML:
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 18782c1638279172303d9511b43a4f97674a16e9,9369b5db5e59f3978fea54354dd8eec53fc6d14e..2cbac74f891f8a51b58e96a50d80e7eb9422e437
@@@ -1,9 -1,9 +1,10 @@@
  /**
   * Inkscape::ConsoleOutputUndoObserver - observer for tracing calls to
-  * sp_document_undo, sp_document_redo, sp_document_maybe_done
+  * SPDocumentUndo::undo, SPDocumentUndo::redo, SPDocumentUndo::maybe_done
   *
   * Authors:
   * David Yip <yipdw@alumni.rose-hulman.edu>
++ *   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);
  }
  
  }
@@@ -57,4 -57,4 +58,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index f7d1c7d291fbe3c789b6e7efba60998a7aba711d,f8667d567bad1c718ed7b7827280635deb7a7d8b..b5c08a8b54aa151ef301136ce398e7fd26f4dba4
@@@ -1,17 -1,17 +1,18 @@@
  /**
   * Inkscape::ConsoleOutputUndoObserver - observer for tracing calls to
-  * sp_document_undo, sp_document_redo, sp_document_maybe_done
+  * SPDocumentUndo::undo, SPDocumentUndo::redo, SPDocumentUndo::maybe_done
   *
   * Authors:
   * David Yip <yipdw@alumni.rose-hulman.edu>
++ *   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:
@@@ -42,4 -42,4 +43,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/desktop-events.cpp
index f7697a6c06d4ebe93dc7ffa5ae5897986c876566,9e97aa432fd1ebe4830f841ba7267de837c33832..71c865879cba626876eb012fb6513d01e4c86e4c
@@@ -3,6 -3,6 +3,7 @@@
   */
  /* Author:
   *   Lauris Kaplinski <lauris@kaplinski.com>
++ *   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);
                  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
                      // Because the guide snapper only looks in the document for guides to snap to,
                      // we don't have to worry about a guide snapping to itself here
                      m.guideFreeSnap(event_dt, normal, SP_DRAG_MOVE_ORIGIN);
 +                    m.unSetup();
                  }
  
                  sp_guideline_set_position(SP_GUIDELINE(guide), from_2geom(event_dt));
                      // Because the guide snapper only looks in the document for guides to snap to,
                      // we don't have to worry about a guide snapping to itself here
                      m.guideFreeSnap(event_dt, normal, SP_DRAG_MOVE_ORIGIN);
 +                    m.unSetup();
                  }
  
                  dragging = false;
                  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));
@@@ -298,11 -299,11 +299,11 @@@ gint sp_dt_guide_event(SPCanvasItem *it
                      if (!(event->motion.state & GDK_SHIFT_MASK)) {
                          m.guideConstrainedSnap(motion_dt, *guide);
                      }
 -                } else if (!(event->motion.state & GDK_SHIFT_MASK)) {
 -                    if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
 -                        m.guideFreeSnap(motion_dt, guide->normal_to_line, drag_type);
 -                    }
 +                } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
 +                    // cannot use shift here to disable snapping, because we already use it for rotating the guide
 +                    m.guideFreeSnap(motion_dt, guide->normal_to_line, drag_type);
                  }
 +                m.unSetup();
  
                  switch (drag_type) {
                      case SP_DRAG_TRANSLATE:
                          if (!(event->button.state & GDK_SHIFT_MASK)) {
                              m.guideConstrainedSnap(event_dt, *guide);
                          }
 -                    } else if (!(event->button.state & GDK_SHIFT_MASK)) {
 -                        if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
 -                            m.guideFreeSnap(event_dt, guide->normal_to_line, drag_type);
 -                        }
 +                    } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
 +                        // cannot use shift here to disable snapping, because we already use it for rotating the guide
 +                        m.guideFreeSnap(event_dt, guide->normal_to_line, drag_type);
                      }
 +                    m.unSetup();
  
                      if (sp_canvas_world_pt_inside_window(item->canvas, event_w)) {
                          switch (drag_type) {
                                  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;
                  {
                      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;
@@@ -621,5 -622,5 +622,5 @@@ void snoop_extended(GdkEvent* event, SP
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  
diff --combined src/desktop-style.cpp
index 5615a8ea96d1cca3b259d2999b0cff14ac2dbe62,049b5fcf80604bab290882db2933b793a83bbd85..c580d6767636a641c2036e2dd62600fe1b081af9
@@@ -1,11 -1,11 +1,11 @@@
--#define __SP_DESKTOP_STYLE_C__
--
  /** \file
   * Desktop style management
   *
   * Authors:
   *   bulia byak
   *   verbalshadow
++ *   Jon A. Cruz <jon@joncruz.org> 
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004, 2006 authors
   *
  #include "xml/repr.h"
  #include "libnrtype/font-style-to-pos.h"
  #include "sp-path.h"
 +#include "event-context.h"
  
  #include "desktop-style.h"
  #include "svg/svg-icc-color.h"
 -#include "svg/svg-device-color.h"
  #include "box3d-side.h"
  
  /**
@@@ -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) ||
  
          // Scale the style by the inverse of the accumulated parent transform in the paste context.
          {
-             Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o)));
+             Geom::Matrix const local(SP_ITEM(o)->i2doc_affine());
              double const ex(local.descrim());
              if ( ( ex != 0. )
                   && ( ex != 1. ) ) {
              }
          }
  
-         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);
      }
      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.
@@@ -196,10 -197,6 +196,10 @@@ sp_desktop_set_style(SPDesktop *desktop
  
  // 3. If nobody has intercepted the signal, apply the style to the selection
      if (!intercepted) {
 +        // If we have an event context, update its cursor (TODO: it could be neater to do this with the signal sent above, but what if the signal gets intercepted?)
 +        if (desktop->event_context) {
 +            sp_event_context_update_cursor(desktop->event_context);
 +        }
  
          // Remove text attributes if not text...
          // Do this once in case a zillion objects are selected.
@@@ -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);
  
      return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked);
  }
  
 +static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> const &rhs )
 +{
 +    static double epsilon = 1e-6;
 +    bool isClose = false;
 +    if ( lhs.size() == rhs.size() ) {
 +        isClose = true;
 +        for ( size_t i = 0; (i < lhs.size()) && isClose; ++i ) {
 +            isClose = fabs(lhs[i] - rhs[i]) < epsilon;
 +        }
 +    }
 +    return isClose;
 +}
 +
 +
  /**
   * Write to style_res the average fill or stroke of list of objects, if applicable.
   */
@@@ -470,6 -453,7 +470,6 @@@ objects_query_fillstroke (GSList *objec
      paint_res->set = TRUE;
  
      SVGICCColor* iccColor = 0;
 -    SVGDeviceColor* devColor = 0;
  
      bool iccSeen = false;
      gfloat c[4];
                  iccColor = paint->value.color.icc;
                  iccSeen = true;
              } else {
 -                if (same_color && (prev[0] != d[0] || prev[1] != d[1] || prev[2] != d[2]))
 +                if (same_color && (prev[0] != d[0] || prev[1] != d[1] || prev[2] != d[2])) {
                      same_color = false;
 -                if ( iccSeen ) {
 -                    if(paint->value.color.icc) {
 -                        // TODO fix this
 +                    iccColor = 0;
 +                }
 +                if ( iccSeen && iccColor ) {
 +                    if ( !paint->value.color.icc
 +                         || (iccColor->colorProfile != paint->value.color.icc->colorProfile)
 +                         || !vectorsClose(iccColor->colors, paint->value.color.icc->colors) ) {
 +                        same_color = false;
                          iccColor = 0;
                      }
                  }
              c[2] += d[2];
              c[3] += SP_SCALE24_TO_FLOAT (isfill? style->fill_opacity.value : style->stroke_opacity.value);
  
 -            // average device color
 -            unsigned int it;
 -            if (i==objects /*if this is the first object in the GList*/
 -                && paint->value.color.device){
 -                devColor = new SVGDeviceColor(*paint->value.color.device);
 -                for (it=0; it < paint->value.color.device->colors.size(); it++){
 -                    devColor->colors[it] = 0;
 -                }
 -            }
 -
 -            if (devColor && paint->value.color.device && paint->value.color.device->type == devColor->type){
 -                for (it=0; it < paint->value.color.device->colors.size(); it++){
 -                    devColor->colors[it] += paint->value.color.device->colors[it];
 -                }
 -            }
 -
              num ++;
          }
  
              paint_res->value.color.icc = tmp;
          }
  
 -        // divide and store the device-color
 -        if (devColor){
 -            for (unsigned int it=0; it < devColor->colors.size(); it++){
 -                devColor->colors[it] /= num;
 -            }
 -            paint_res->value.color.device = devColor;
 -        }
 -
          if (num > 1) {
              if (same_color)
                  return QUERY_STYLE_MULTIPLE_SAME;
@@@ -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;
          }
  
  
          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)
@@@ -932,7 -936,7 +932,7 @@@ objects_query_fontnumbers (GSList *obje
          if (!style) continue;
  
          texts ++;
-         size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here
+         size += style->font_size.computed * Geom::Matrix(SP_ITEM(obj)->i2d_affine()).descrim(); /// \todo FIXME: we assume non-% units here
  
          if (style->letter_spacing.normal) {
              if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing))
@@@ -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<SPObject*>(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<SPObject*>(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 --combined src/desktop.cpp
index 83a6f40219717352957ad0f7659cd591290da120,e7ef2897e9e22fa57de4e9c1c0b233de749e3e46..0b17fb385aead21accff281c1d3cc646cdf92955
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_DESKTOP_C__
--
  /** \file
   * Editable view 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 Jon A. Cruz
   * Copyright (C) 2006-2008 Johan Engelen
@@@ -90,6 -90,7 +90,7 @@@
  #include "display/canvas-grid.h"
  #include "widgets/desktop-widget.h"
  #include "box3d-context.h"
+ #include "desktop-style.h"
  
  // TODO those includes are only for node tool quick zoom. Remove them after fixing it.
  #include "ui/tool/node-tool.h"
@@@ -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);
      // display rect and zoom are now handled in sp_desktop_widget_realize()
  
      Geom::Rect const d(Geom::Point(0.0, 0.0),
-                        Geom::Point(sp_document_width(document), sp_document_height(document)));
+                        Geom::Point(document->getWidth(), document->getHeight()));
  
      SP_CTRLRECT(page)->setRectangle(d);
      SP_CTRLRECT(page_border)->setRectangle(d);
  
  
      /* 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() {
          _setDisplayMode(Inkscape::RENDERMODE_OUTLINE);
          break;
      case Inkscape::RENDERMODE_OUTLINE:
 -        _setDisplayMode(Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
 +        _setDisplayMode(Inkscape::RENDERMODE_NORMAL);
          break;
 -    case Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW:
 +//    case Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW:
      default:
          _setDisplayMode(Inkscape::RENDERMODE_NORMAL);
      }
@@@ -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);
  }
  
@@@ -552,7 -553,7 +553,7 @@@ bool SPDesktop::isLayer(SPObject *objec
  bool SPDesktop::isWithinViewport (SPItem *item) const
  {
      Geom::Rect const viewport = get_display_area();
-     Geom::OptRect const bbox = sp_item_bbox_desktop(item);
+     Geom::OptRect const bbox = item->getBboxDesktop();
      if (bbox) {
          return viewport.contains(*bbox);
      } else {
@@@ -636,15 -637,9 +637,15 @@@ SPDesktop::set_event_context (GtkType t
          event_context = next;
      }
  
 +    // The event_context will be null. This means that it will be impossible
 +    // to process any event invoked by the lines below. See for example bug
 +    // LP #622350. Cutting and undoing again in the node tool resets the event
 +    // context to the node tool. In this bug the line bellow invokes GDK_LEAVE_NOTIFY
 +    // events which cannot be handled and must be discarded.
      ec = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC);
      ec->next = event_context;
      event_context = ec;
 +    // Now the event_context has been set again and we can process all events again
      sp_event_context_activate (ec);
      _event_context_changed_signal.emit (this, ec);
  }
@@@ -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);
  }
  
 -      SPCSSAttr *css_current = sp_desktop_get_style(this, with_text);
+ /**
+   * 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)
+ {
 -        //sp_repr_css_set(obj->getRepr(), css_current, "style");
 -              obj->setCSS(css_current,"style");
++    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, "style");
 -              obj->setCSS(css,"style");
++        obj->setCSS(css_current,"style");
+     } else {
+         SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/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.
   */
@@@ -1020,7 -1038,7 +1038,7 @@@ voi
  SPDesktop::zoom_page()
  {
      Geom::Rect d(Geom::Point(0, 0),
-                  Geom::Point(sp_document_width(doc()), sp_document_height(doc())));
+                  Geom::Point(doc()->getWidth(), doc()->getHeight()));
  
      if (d.minExtent() < 1.0) {
          return;
@@@ -1037,12 -1055,12 +1055,12 @@@ SPDesktop::zoom_page_width(
  {
      Geom::Rect const a = get_display_area();
  
-     if (sp_document_width(doc()) < 1.0) {
+     if (doc()->getWidth() < 1.0) {
          return;
      }
  
      Geom::Rect d(Geom::Point(0, a.midpoint()[Geom::Y]),
-                  Geom::Point(sp_document_width(doc()), a.midpoint()[Geom::Y]));
+                  Geom::Point(doc()->getWidth(), a.midpoint()[Geom::Y]));
  
      set_display_area(d, 10);
  }
  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.
@@@ -1373,7 -1391,7 +1391,7 @@@ SPDesktop::emitToolSubselectionChanged(
  void
  SPDesktop::updateNow()
  {
 -  sp_canvas_update_now(canvas);
 +    sp_canvas_update_now(canvas);
  }
  
  void
@@@ -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) {
      _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);
          _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);
@@@ -1816,4 -1837,4 +1832,4 @@@ Geom::Point SPDesktop::dt2doc(Geom::Poi
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/desktop.h
index af2473bafaa729759e18de38bb564f9989b4a2e2,160a335580d0ab788e63a5026d42b34a7812bdae..957c3b342509629fe39367dfd64d75f7723185ca
@@@ -11,6 -11,6 +11,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>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;
      void setDisplayModeOutline() {
          _setDisplayMode(Inkscape::RENDERMODE_OUTLINE);
      }
 -    void setDisplayModePrintColorsPreview() {
 -        _setDisplayMode(Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
 -    }
 +//    void setDisplayModePrintColorsPreview() {
 +//        _setDisplayMode(Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
 +//    }
      void displayModeToggle();
      Inkscape::RenderMode _display_mode;
      Inkscape::RenderMode getMode() const { return _display_mode; }
      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;
      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);
      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;
index 864cf8927e884029e2f63c303e075f76fe1e2591,e25f2602b70cc6a709cdf03639148b6be2a94a29..8045675b4022ac097f522747e6523d2f60774551
@@@ -4,6 -4,6 +4,8 @@@
  /* Authors:
   *   bulia byak <buliabyak@users.sf.net>
   *   Johan Engelen <goejendaagh@zonnet.nl>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2006 Authors
   * Released under GNU GPL, read the file 'COPYING' for more information
@@@ -16,6 -16,8 +18,6 @@@
  #include <gtk/gtk.h>
  #include <glibmm/i18n.h>
  
 -#include "application/application.h"
 -#include "application/editor.h"
  #include "../desktop.h"
  #include "../desktop-handles.h"
  #include "dialog-events.h"
@@@ -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;
@@@ -81,7 -83,15 +85,7 @@@ static Inkscape::UI::Widget::ColorPicke
  static void
  clonetiler_dialog_destroy( GtkObject */*object*/, gpointer /*data*/ )
  {
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        _shutdown_connection.disconnect();
 -        _dialogs_hidden_connection.disconnect();
 -        _dialogs_unhidden_connection.disconnect();
 -        _desktop_activated_connection.disconnect();
 -    } else {
 -        sp_signal_disconnect_by_data (INKSCAPE, dlg);
 -    }
 +    sp_signal_disconnect_by_data (INKSCAPE, dlg);
      _color_changed_connection.disconnect();
  
      delete color_picker;
@@@ -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);
          }
  
      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
@@@ -1222,7 -1231,7 +1221,7 @@@ clonetiler_apply( GtkWidget */*widget*/
          bool prefs_bbox = prefs->getBool("/tools/bounding_box", false);
          SPItem::BBoxType bbox_type = ( prefs_bbox ? 
              SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX );
-         Geom::OptRect r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)),
+         Geom::OptRect r = SP_ITEM(obj)->getBounds(SP_ITEM(obj)->i2doc_affine(),
                                                          bbox_type);
          if (r) {
              w = r->dimensions()[Geom::X];
                  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
  
      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 *
@@@ -1850,10 -1859,18 +1849,10 @@@ clonetiler_dialog (void
          gtk_signal_connect ( GTK_OBJECT (dlg), "destroy", G_CALLBACK (clonetiler_dialog_destroy), dlg);
          gtk_signal_connect ( GTK_OBJECT (dlg), "delete_event", G_CALLBACK (clonetiler_dialog_delete), dlg);
  
 -        if (Inkscape::NSApplication::Application::getNewGui())
 -        {
 -            _shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (&on_delete);
 -            _dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::bind (&on_dialog_hide, dlg));
 -            _dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::bind (&on_dialog_unhide, dlg));
 -            _desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::bind (&on_transientize, &wd));
 -        } else {
 -            g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
 -            g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
 -            g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
 -            g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
 -        }
 +        g_signal_connect   ( G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (clonetiler_dialog_delete), dlg);
 +        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg);
 +        g_signal_connect   ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg);
 +        g_signal_connect   ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
  
          GtkTooltips *tt = gtk_tooltips_new();
  
                      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B);
                  }
                  {
 -                    //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
 -                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|H"));
 +                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H"));
                      gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the hue of the color"), NULL);
                      clonetiler_table_attach (table, radio, 0.0, 1, 3);
                      gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H);
                  }
                  {
 -                    //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
 -                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|S"));
 +                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S"));
                      gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the saturation of the color"), NULL);
                      clonetiler_table_attach (table, radio, 0.0, 2, 3);
                      gtk_signal_connect (GTK_OBJECT (radio), "toggled",
                      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S);
                  }
                  {
 -                    //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
 -                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), Q_("clonetiler|L"));
 +                    radio = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L"));
                      gtk_tooltips_set_tip (GTK_TOOLTIPS (tt), radio, _("Pick the lightness of the color"), NULL);
                      clonetiler_table_attach (table, radio, 0.0, 3, 3);
                      gtk_signal_connect (GTK_OBJECT (radio), "toggled",
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/dialogs/export.cpp
index 82e2d45e1b18df482aa835864742b66c161027f2,649918742e723a7e0c486bbd1ce606d7d41894bd..7e99c2496efb96fb12b2de617fe2ca73db65cc7f
@@@ -5,6 -5,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-2007 Authors
   * Copyright (C) 2001-2002 Ximian, Inc.
@@@ -66,6 -66,6 +68,8 @@@
  #include <gdk/gdkwin32.h>
  #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) {
                  }
              case SELECTION_PAGE:
                  bbox = Geom::Rect(Geom::Point(0.0, 0.0),
-                                   Geom::Point(sp_document_width(doc), sp_document_height(doc)));
+                                   Geom::Point(doc->getWidth(), doc->getHeight()));
  
                  // std::cout << "Using selection: PAGE" << std::endl;
                  key = SELECTION_PAGE;
@@@ -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<SPItem *>(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);
              }
  
              // 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);
              }
  
              Geom::OptRect area;
-             sp_item_invoke_bbox(item, area, sp_item_i2d_affine((SPItem *) item), TRUE);
 -            item->invoke_bbox( area, static_cast<SPItem *>(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);
          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;
                  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();
              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) {
  
                  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);
                      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) ) {
                  doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
  
                  Geom::Point x(0.0, 0.0);
-                 Geom::Point y(sp_document_width(doc),
-                               sp_document_height(doc));
+                 Geom::Point y(doc->getWidth(),
+                               doc->getHeight());
                  Geom::Rect bbox(x, y);
  
                  // std::cout << "Page " << bbox;
@@@ -2054,4 -2054,4 +2057,4 @@@ sp_export_filename_modified (GtkObject 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/dialogs/find.cpp
index a3612f60e18f7f1cb0fa763739f4688337737fb9,89b389d441f0c2da3d512e4417b7fe46ff59b0ee..fe264892abdcdf7175bac6f0400bfae0aff92c79
@@@ -3,6 -3,6 +3,8 @@@
   */
  /* Authors:
   *   bulia byak <bulia@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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);
          }
  
@@@ -682,10 -684,10 +684,10 @@@ sp_find_dialog_old (void
          GtkWidget *vb = gtk_vbox_new (FALSE, 0);
          gtk_container_add (GTK_CONTAINER (dlg), vb);
  
 -        sp_find_new_searchfield (dlg, vb, _("_Text: "), "text", tt, _("Find objects by their text content (exact or partial match)"));
 -        sp_find_new_searchfield (dlg, vb, _("_ID: "), "id", tt, _("Find objects by the value of the id attribute (exact or partial match)"));
 -        sp_find_new_searchfield (dlg, vb, _("_Style: "), "style", tt, _("Find objects by the value of the style attribute (exact or partial match)"));
 -        sp_find_new_searchfield (dlg, vb, _("_Attribute: "), "attr", tt ,_("Find objects by the name of an attribute (exact or partial match)"));
 +        sp_find_new_searchfield (dlg, vb, _("_Text:"), "text", tt, _("Find objects by their text content (exact or partial match)"));
 +        sp_find_new_searchfield (dlg, vb, _("_ID:"), "id", tt, _("Find objects by the value of the id attribute (exact or partial match)"));
 +        sp_find_new_searchfield (dlg, vb, _("_Style:"), "style", tt, _("Find objects by the value of the style attribute (exact or partial match)"));
 +        sp_find_new_searchfield (dlg, vb, _("_Attribute:"), "attr", tt ,_("Find objects by the name of an attribute (exact or partial match)"));
  
          gtk_widget_show_all (vb);
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 40665e08ea5de165c092c9a29a241c4f25f8b59f,d96b364ef4fdb82ab43bbef07b7bf7dbc34ac922..8b5ac1784ce9bd29d59b9f22147c572ea5406b5f
@@@ -5,6 -5,6 +5,7 @@@
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
   *   Johan Engelen <goejendaagh@zonnet.nl>
++ *   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;
@@@ -117,7 -117,7 +120,7 @@@ sp_item_widget_new (void
  
  
      /* Create the label for the object id */
 -    l = gtk_label_new_with_mnemonic (_("_Id"));
 +    l = gtk_label_new_with_mnemonic (_("_ID:"));
      gtk_misc_set_alignment (GTK_MISC (l), 1, 0.5);
      gtk_table_attach ( GTK_TABLE (t), l, 0, 1, 0, 1,
                         (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ),
                           spw );
  
      /* Create the label for the object label */
 -    l = gtk_label_new_with_mnemonic (_("_Label"));
 +    l = gtk_label_new_with_mnemonic (_("_Label:"));
      gtk_misc_set_alignment (GTK_MISC (l), 1, 0.5);
      gtk_table_attach ( GTK_TABLE (t), l, 0, 1, 1, 2,
                         (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ),
      g_signal_connect ( G_OBJECT (tf), "activate", G_CALLBACK (sp_item_widget_label_changed), spw);
  
      /* Create the label for the object title */
 -    l = gtk_label_new_with_mnemonic (_("_Title"));
 +    l = gtk_label_new_with_mnemonic (_("_Title:"));
      gtk_misc_set_alignment (GTK_MISC (l), 1, 0.5);
      gtk_table_attach ( GTK_TABLE (t), l, 0, 1, 2, 3,
                         (GtkAttachOptions)( GTK_SHRINK | GTK_FILL ),
@@@ -331,7 -331,7 +334,7 @@@ sp_item_widget_setup ( SPWidget *spw, I
          gtk_entry_set_text (GTK_ENTRY (w), obj->getId());
          gtk_widget_set_sensitive (w, TRUE);
          w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
 -        gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_Id"));
 +        gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_ID:"));
  
          /* Label */
          w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
@@@ -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));
  }
@@@ -440,18 -440,18 +443,18 @@@ sp_item_widget_label_changed( GtkWidge
      g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_');
      GtkWidget *id_label = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
      if (!strcmp (id, item->getId())) {
 -        gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_Id"));
 +        gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_ID:"));
      } else if (!*id || !isalnum (*id)) {
          gtk_label_set_text (GTK_LABEL (id_label), _("Id invalid! "));
      } else if (SP_ACTIVE_DOCUMENT->getObjectById(id) != NULL) {
          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 */
      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"));
      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));
@@@ -560,4 -560,4 +563,4 @@@ sp_item_dialog (void
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 476a551f13269f3df0e9889e06ab109ac602f060,f95dce0e6d7a969f738ce2262dc0fa971588e9d4..12105c8c045f14c1250dce472d6c19fec908a804
@@@ -3,6 -3,6 +3,8 @@@
   */
  /* Authors:
   *   bulia byak <bulia@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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))
@@@ -236,8 -236,8 +239,8 @@@ gint compare_text_bboxes (gconstpointe
      SPItem *i1 = SP_ITEM(a);
      SPItem *i2 = SP_ITEM(b);
  
-     Geom::OptRect bbox1 = i1->getBounds(sp_item_i2d_affine(i1));
-     Geom::OptRect bbox2 = i2->getBounds(sp_item_i2d_affine(i2));
+     Geom::OptRect bbox1 = i1->getBounds(i1->i2d_affine());
+     Geom::OptRect bbox2 = i2->getBounds(i2->i2d_affine());
      if (!bbox1 || !bbox2) {
          return 0;
      }
@@@ -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);
@@@ -570,7 -570,7 +573,7 @@@ spellcheck_next_word(
  
          // draw rect
          std::vector<Geom::Point> points =
-             _layout->createSelectionShape(_begin_w, _end_w, sp_item_i2d_affine(_text));
+             _layout->createSelectionShape(_begin_w, _end_w, _text->i2d_affine());
          Geom::Point tl, br;
          tl = br = points.front();
          for (unsigned i = 0 ; i < points.size() ; i ++) {
@@@ -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"));
          }
      }
  
@@@ -1031,4 -1031,4 +1034,4 @@@ void sp_spellcheck_dialog (void) {
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 8a8fe6a29c972c2654ee503533d23e35a8874723,ab0de514ad1445de86ab9070d67d4c5a6d52f867..61f56e3f7fec8ac12aa32c4d3e1434937700173a
@@@ -5,6 -5,6 +5,7 @@@
   *   Lauris Kaplinski <lauris@ximian.com>
   *   bulia byak <buliabyak@users.sf.net>
   *   Johan Engelen <goejendaagh@zonnet.nl>
++ *   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 <xml/repr.h>
  
++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<SPObject*>(item_list->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
  
              ++items;
          }
      }
  
      // 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);
@@@ -964,4 -964,4 +967,4 @@@ sp_ted_get_selected_text_count (void
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/dialogs/xml-tree.cpp
index bd442b8872a1ec375b0f36f38f9722b7c3b4cc37,515b49360d20f1705764328647d8d57632cfe857..c90cde490ba02dfd0812b1c57a19ddadfbe2934f
@@@ -7,6 -7,6 +7,8 @@@
   *   bulia byak <buliabyak@users.sf.net>
   *   Johan Engelen <goejendaagh@zonnet.nl>
   *   David Turner
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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);
          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);
  
@@@ -1609,4 -1609,4 +1612,4 @@@ bool in_dt_coordsys(SPObject const &ite
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 34c60b140e0382f4d37544ef3198f08561bdd4e3,7a21c19b824c228d010c04e4c4c75db6e047ab54..df73eb78e0496470ec00255661e57c5d0ca4ff14
@@@ -3,6 -3,6 +3,7 @@@
   */
  /* Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
   * 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));
      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"));
  }
  
  /*
@@@ -1056,4 -1056,4 +1057,4 @@@ bool CanvasXYGridSnapper::ThisSnapperMi
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index b0b3ee184eed8eec3fbd584891b33bad05234cfe,73082f4c053ed14cdc47cd32c1165c4f87653f6f..9a39168c29368743cf1b5cbf38de554812bf6efc
@@@ -4,6 -4,6 +4,7 @@@
   * Authors:
   *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
   *   Tavmjong Bah <tavmjong@free.fr>
++ *   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);
          {
              g_warning("FilterImage::render: not enough memory to create pixel buffer. Need %ld.", 4L * width * height);
          }
-         sp_item_invoke_hide(SVGElem, key);
+         SVGElem->invoke_hide(key);
          nr_object_unref((NRObject *) arena);
      }
  
              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 ) ) {
@@@ -252,4 -252,4 +253,4 @@@ FilterTraits FilterImage::get_input_tra
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/document-private.h
index fa4754248f082b84ff2eea883dd0bec593da7977,fa4754248f082b84ff2eea883dd0bec593da7977..61e6bad67beff4b1f69070662badafd0b7949af0
@@@ -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 <lauris@kaplinski.com>
++ *   Jon A. Cruz <jon@joncruz.org>
   *
   * 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 --combined src/document-subset.cpp
index 6a7f8822c1d1d32b8c5a2d2f7f199fbd60869cfc,a25205db9f5c8df55305a9a5e2943f9a109bfd65..e71b9bad5bd6af2919f10d936106b419a1cb4f19
@@@ -3,6 -3,6 +3,7 @@@
   *                            of nodes
   *
   * Copyright 2006  MenTaLguY  <mental@rydia.net>
++ *   Abhishek Sharma
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
@@@ -60,7 -60,7 +61,7 @@@ struct DocumentSubset::Relations : publ
  
                  while ( first != last ) {
                      Siblings::const_iterator mid = first + ( last - first + 1 ) / 2;
 -                    int pos = sp_object_compare_position(*mid,obj);
 +                    int pos = sp_object_compare_position(*mid, obj);
                      if ( pos < 0 ) {
                          first = mid;
                      } else if ( pos > 0 ) {
@@@ -76,7 -76,7 +77,7 @@@
  
                  if ( first == last ) {
                      // compare to the single possiblity left
 -                    int pos = sp_object_compare_position(*last,obj);
 +                    int pos = sp_object_compare_position(*last, obj);
                      if ( pos < 0 ) {
                          last++;
                      }
@@@ -408,4 -408,4 +409,4 @@@ DocumentSubset::connectRemoved(sigc::sl
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/document-undo.cpp
index e63fe8a529c552e19f12a82419d4ef6a1635f8f1,280eea24317f6d2802bbbbd5a07fd6adaa2cf79a..1559dc5ba6cb10945fcb6ddc8aa37d00c37441c3
@@@ -1,11 -1,11 +1,10 @@@
--#define __SP_DOCUMENT_UNDO_C__
--
  /** \file
   * Undo/Redo stack implementation
   *
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   MenTaLguY <mental@rydia.net>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2007  MenTaLguY <mental@rydia.net>
   * 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"
  /*
   * 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);
   * 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<SPDocument *>(base);
 +    doc->actionkey.clear();
  }
  
  namespace {
@@@ -163,24 -165,21 +150,23 @@@ 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);
        g_assert (doc->priv->sensitive);
 +        if ( key && !*key ) {
 +            g_warning("Blank undo key specified.");
 +        }
  
          Inkscape::Debug::EventTracker<CommitEvent> tracker(doc, key, event_type);
  
        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;
                return;
        }
  
 -      if (key && doc->actionkey && !strcmp (key, doc->actionkey) && doc->priv->undo) {
 +      if (key && !doc->actionkey.empty() && (doc->actionkey == key) && doc->priv->undo) {
                  ((Inkscape::Event *)doc->priv->undo->data)->event =
                      sp_repr_coalesce_log (((Inkscape::Event *)doc->priv->undo->data)->event, log);
        } else {
                doc->priv->undoStackObservers.notifyUndoCommitEvent(event);
        }
  
 -      doc->actionkey = key;
 +        if ( key ) {
 +            doc->actionkey = key;
 +        } else {
 +            doc->actionkey.clear();
 +        }
  
        doc->virgin = FALSE;
          doc->setModifiedSinceSave();
    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;
        doc->priv->sensitive = FALSE;
          doc->priv->seeking = true;
  
 -      doc->actionkey = NULL;
 +      doc->actionkey.clear();
  
        finish_incomplete_transaction(*doc);
  
        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;
        doc->priv->sensitive = FALSE;
          doc->priv->seeking = true;
  
 -      doc->actionkey = NULL;
 +      doc->actionkey.clear();
  
        finish_incomplete_transaction(*doc);
  
        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();
        }
  }
  
--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 --combined src/document-undo.h
index 0000000000000000000000000000000000000000,9fc49b112c5e1bcff3b3920f1d2de949eef73253..9be260fa227646c15821961dee186b2a78454140
mode 000000,100644..100644
--- /dev/null
@@@ -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 --combined src/document.cpp
index 677883112660bfcd219f73d696f43316f11be0cf,702c58d5dc871025201e4792edcfe8eb3042252b..a473daa3ca640d341daf92bb280947ef7d8b784c
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_DOCUMENT_C__
--
  /** \file
   * SPDocument manipulation
   *
@@@ -7,6 -7,6 +5,8 @@@
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   MenTaLguY <mental@rydia.net>
   *   bulia byak <buliabyak@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2005 MenTaLguY
   * Copyright (C) 1999-2002 Lauris Kaplinski
@@@ -41,6 -41,8 +41,6 @@@
  #include <string>
  #include <cstring>
  
 -#include "application/application.h"
 -#include "application/editor.h"
  #include "desktop.h"
  #include "dir-util.h"
  #include "display/nr-arena-item.h"
@@@ -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)
  
@@@ -90,7 -92,7 +92,7 @@@ SPDocument::SPDocument() 
      base(0),
      name(0),
      priv(0), // reset in ctor
 -    actionkey(0),
 +    actionkey(),
      modified_id(0),
      rerouting_handler_id(0),
      profileManager(0), // deferred until after other initialization
@@@ -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();
  
      if (oldSignalsConnected) {
          g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE),
-                                              reinterpret_cast<gpointer>(sp_document_reset_key),
 -                                             reinterpret_cast<gpointer>(SPDocumentUndo::reset_key),
++                                             reinterpret_cast<gpointer>(DocumentUndo::resetKey),
                                               static_cast<gpointer>(this));
      } else {
          _selection_changed_connection.disconnect();
          inkscape_unref();
          keepalive = FALSE;
      }
 -
      //delete this->_whiteboard_session_manager;
  }
  
@@@ -239,12 -242,12 +241,13 @@@ SPDocument::setCurrentPersp3D(Persp3D 
      //current_persp3d_impl = persp->perspective_impl;
  }
  
--void
--SPDocument::getPerspectivesInDefs(std::vector<Persp3D*> &list) {
++void SPDocument::getPerspectivesInDefs(std::vector<Persp3D*> &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;
  
      // 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);
          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;
  }
   * 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;
      //# These should be set by now
      g_assert(name);
  
-     doc = sp_document_create(rdoc, uri, base, name, keepalive);
+     doc = createDoc(rdoc, uri, base, name, keepalive);
  
      g_free(base);
      g_free(name);
      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;
  
      name = g_strdup_printf(_("Memory document %d"), ++doc_count);
  
-     doc = sp_document_create(rdoc, NULL, NULL, name, keepalive);
+     doc = createDoc(rdoc, NULL, NULL, name, keepalive);
  
      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);
      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);
      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
@@@ -653,7 -665,7 +610,7 @@@ void SPDocument::fitToRect(Geom::Rect c
      double const w = rect.width();
      double const h = rect.height();
  
-     double const old_height = sp_document_height(this);
+     double const old_height = getHeight();
      SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX));
      
      /* in px */
      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);
              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);
          }
      }
      
              rect.max() + Geom::Point(margin_right, margin_top));
      
      
-     sp_document_set_width(this, rect_with_margins.width(), &px);
-     sp_document_set_height(this, rect_with_margins.height(), &px);
+     setWidth(rect_with_margins.width(), &px);
+     setHeight(rect_with_margins.height(), &px);
  
      Geom::Translate const tr(
              Geom::Point(0, old_height - rect_with_margins.height())
      }
  }
  
- 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
      } else {
          new_uri = g_strdup_printf(_("Unnamed document %d"), ++doc_count);
          new_base = NULL;
-         new_name = g_strdup(document->uri);
+         new_name = g_strdup(this->uri);
      }
  
      // 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);
  }
  
  /**
   *
   * \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);
  }
  
  /**
   *
   * \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);
      }
  }
  
--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))
  
  /* 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();
      }
   * 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.
      int counter = 32;
      for (unsigned int pass = 1; pass <= 2; ++pass) {
          // Process document updates.
-         while (!doc->_updateDocument()) {
+         while (!_updateDocument()) {
              if (counter == 0) {
-                 g_warning("More than 32 iteration while updating document '%s'", doc->uri);
+                 g_warning("More than 32 iteration while updating document '%s'", uri);
                  break;
              }
              counter--;
          // changed objects and provide new routings.  This may cause some objects
              // to be modified, hence the second update pass.
          if (pass == 1) {
-             doc->router->processTransaction();
+             router->processTransaction();
          }
      }
      
-     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
                  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
  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) {
          }
          if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) {
              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 groups pickable at this point
              if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL) {
   * 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);
  }
  
  /*
   *
   */
  
- 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<Geom::Point> points)
 -SPDocument::items_at_points(unsigned const key, std::vector<Geom::Point> points)
++GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
  {
      GSList *items = NULL;
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
      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);
      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;
      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);
  
@@@ -1479,4 -1497,4 +1417,4 @@@ bool SPDocument::isSeeking() const 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/document.h
index 4f5f045c5566fb5819fcb59a5898740637b844a3,a91d1e57f797d1ba06ad90331fb07c7872b5e8f7..82c874cb73678f284b2e62e67dad2d7efdd93e9e
@@@ -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 <lauris@kaplinski.com>
   *   MenTaLguY <mental@rydia.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2005 MenTaLguY
   * Copyright (C) 1999-2002 Lauris Kaplinski
@@@ -28,6 -28,7 +30,7 @@@
  #include "gc-anchored.h"
  #include <glibmm/ustring.h>
  #include "verbs.h"
+ #include "document-undo.h"
  #include <vector>
  #include <set>
  
@@@ -64,10 -65,11 +67,11 @@@ namespace Proj 
  class SPDocumentPrivate;
  
  /// Typed SVG document implementation.
struct SPDocument : public Inkscape::GC::Managed<>,
class SPDocument : public Inkscape::GC::Managed<>,
                      public Inkscape::GC::Finalized,
                      public Inkscape::GC::Anchored
  {
 -      public:
++public:
      typedef sigc::signal<void, SPObject *> IDChangedSignal;
      typedef sigc::signal<void> ResourcesChangedSignal;
      typedef sigc::signal<void, guint> ModifiedSignal;
      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
 -    const gchar *actionkey;
 +    Glib::ustring actionkey;
 +
      /// Handler ID
      guint modified_id;
      
  
      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; }
      /*
       */
      Persp3D * getCurrentPersp3D();
      Persp3DImpl * getCurrentPersp3DImpl();
--    void getPerspectivesInDefs(std::vector<Persp3D*> &list);
--    unsigned int numPerspectivesInDefs() {
++
++    void getPerspectivesInDefs(std::vector<Persp3D*> &list) const;
++
++    unsigned int numPerspectivesInDefs() const {
          std::vector<Persp3D*> 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();
      void setModifiedSinceSave(bool modified = true) {
          modified_since_save = modified;
      }
 -      //Inkscape::XML::Document * getRdoc(){ return rdoc; }
  
  private:
 -    //Inkscape::XML::Document *rdoc; ///< Our Inkscape::XML::Document
      SPDocument(SPDocument const &); // no copy
      void operator=(SPDocument const &); // no assign
  
@@@ -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<Geom::Point> 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<Geom::Point> 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
   *
   *
   */
  
--/*
-- * 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<Geom::Point> 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<Geom::Point> 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:
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/draw-context.cpp
index 3f33f9499809ff22f9c5410e5cc60742a58e66d1,a3c3601cc8ccd98f35740bd8a8ae89fdfbd05a8e..62ae67336cad48236adbbcb3c29132257aa716b6
@@@ -1,10 -1,10 +1,9 @@@
--#define __SP_DRAW_CONTEXT_C__
--
  /*
   * Generic drawing context
   *
   * Author:
   *   Lauris Kaplinski <lauris@kaplinski.com>
++ *   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);
@@@ -438,7 -438,7 +439,7 @@@ spdc_attach_selection(SPDrawContext *dc
          /* Curve list */
          /* We keep it in desktop coordinates to eliminate calculation errors */
          SPCurve *norm = sp_path_get_curve_for_edit (SP_PATH(item));
-         norm->transform(sp_item_i2d_affine(dc->white_item));
+         norm->transform((dc->white_item)->i2d_affine());
          g_return_if_fail( norm != NULL );
          dc->white_curves = g_slist_reverse(norm->split());
          norm->unref();
   *  \param dc draw context
   *  \param p cursor point (to be changed by snapping)
   *  \param o origin point
 - *  \param state  keyboard state to check if ctrl was pressed
 + *  \param state  keyboard state to check if ctrl or shift was pressed
  */
  
  void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o,
  {
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
      unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
 -    /* 0 means no snapping. */
 -
 -    /* mirrored by fabs, so this corresponds to 15 degrees */
 -    Geom::Point best; /* best solution */
 -    double bn = NR_HUGE; /* best normal */
 -    double bdot = 0;
 -    Geom::Point v = Geom::Point(0, 1);
 -    double const r00 = cos(M_PI / snaps), r01 = sin(M_PI / snaps);
 -    double const r10 = -r01, r11 = r00;
 -
 -    Geom::Point delta = p - o;
 -
 -    for (unsigned i = 0; i < snaps; i++) {
 -        double const ndot = fabs(dot(v,Geom::rot90(delta)));
 -        Geom::Point t(r00*v[Geom::X] + r01*v[Geom::Y],
 -                    r10*v[Geom::X] + r11*v[Geom::Y]);
 -        if (ndot < bn) {
 -            /* I think it is better numerically to use the normal, rather than the dot product
 -             * to assess solutions, but I haven't proven it. */
 -            bn = ndot;
 -            best = v;
 -            bdot = dot(v, delta);
 -        }
 -        v = t;
 +    SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
 +    m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
 +
 +    bool snap_enabled = m.snapprefs.getSnapEnabledGlobally();
 +    if (state & GDK_SHIFT_MASK) {
 +        // SHIFT disables all snapping, except the angular snapping. After all, the user explicitly asked for angular
 +        // snapping by pressing CTRL, otherwise we wouldn't have arrived here. But although we temporarily disable
 +        // the snapping here, we must still call for a constrained snap in order to apply the constraints (i.e. round
 +        // to the nearest angle increment)
 +        m.snapprefs.setSnapEnabledGlobally(false);
      }
  
 -    if (fabs(bdot) > 0) {
 -        p = o + bdot * best;
 +    Inkscape::SnappedPoint dummy = m.constrainedAngularSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_NODE_HANDLE), boost::optional<Geom::Point>(), o, snaps);
 +    p = dummy.getPoint();
  
 -        if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
 -                                         //After all, the user explicitly asked for angular snapping by
 -                                         //pressing CTRL
 -            /* Snap it along best vector */
 -            SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
 -            m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
 -            m.constrainedSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE, Inkscape::Snapper::ConstraintLine(best));
 -        }
 +    if (state & GDK_SHIFT_MASK) {
 +        m.snapprefs.setSnapEnabledGlobally(snap_enabled); // restore the original setting
      }
 +
 +    m.unSetup();
  }
  
  
@@@ -510,7 -528,6 +511,7 @@@ void spdc_endpoint_snap_free(SPEventCon
  
      m.setup(dt, true, selection->singleItem());
      m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +    m.unSetup();
  }
  
  static SPCurve *
@@@ -639,12 -656,12 +640,12 @@@ spdc_flush_white(SPDrawContext *dc, SPC
  
      /* Now we have to go back to item coordinates at last */
      c->transform( dc->white_item
-                             ? sp_item_dt2i_affine(dc->white_item)
+                             ? (dc->white_item)->dt2i_affine()
                              : SP_EVENT_CONTEXT_DESKTOP(dc)->dt2doc() );
  
      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 */
  
              dc->selection->set(repr);
              Inkscape::GC::release(repr);
-             item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+             item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
              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
      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));
         current stroke width, multiplied by the amount specified in the preferences */
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  
-     Geom::Matrix const i2d (sp_item_i2d_affine (item));
-     Geom::Point pp = pt * i2d.inverse();
+     Geom::Matrix const i2d (item->i2d_affine ());
+     Geom::Point pp = pt;
      double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0);
      if (event_state & GDK_MOD1_MASK) {
          /* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
      sp_repr_set_svg_double (repr, "sodipodi:rx", rad * stroke_width);
      sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width);
      item->updateRepr();
+     item->set_item_transform(i2d.inverse());
  
      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"));
  }
  
  /*
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/dropper-context.cpp
index 5415fdc80fb050af4193d3c11cab77911811b5b9,513963692bade15bbc9bd1574e02a6aacf56ed86..b7344889ff67836fe81fac969ca6db79a291d001
@@@ -1,11 -1,11 +1,10 @@@
--#define __SP_DROPPER_CONTEXT_C__
--
  /*
   * Tool for picking colors from drawing
   *
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
++ *   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;
index 98f57b5bcfc742296501bad82e43fe6e16917adb,ab57872cde0ccab109400a51f7d95852fb9e2f0d..93d4262cd172512dbfe53d9fe6befc064f398009
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_DYNA_DRAW_CONTEXT_C__
--
  /*
   * Handwriting-like drawing mode
   *
@@@ -8,6 -8,6 +6,7 @@@
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
   *   MenTaLguY <mental@rydia.net>
++ *   Abhishek Sharma
   *
   * The original dynadraw code:
   *   Paul Haeberli <paul@sgi.com>
@@@ -65,6 -65,6 +64,8 @@@
  
  #include "dyna-draw-context.h"
  
++using Inkscape::DocumentUndo;
++
  #define DDC_RED_RGBA 0xff0000ff
  
  #define TOLERANCE_CALLIGRAPHIC 0.1
@@@ -599,7 -599,7 +600,7 @@@ sp_dyna_draw_context_root_handler(SPEve
                      }
  
                      // calculate pointer point in the guide item's coords
-                     motion_to_curve = sp_item_dt2i_affine(selected) * sp_item_i2doc_affine(selected);
+                     motion_to_curve = selected->dt2i_affine() * selected->i2doc_affine();
                      pointer = motion_dt * motion_to_curve;
  
                      // calculate the nearest point on the guide path
@@@ -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 */
  
              SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr));
              Inkscape::GC::release(dc->repr);
-             item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+             item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
              item->updateRepr();
          }
          Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc();
          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
@@@ -1284,4 -1284,4 +1285,4 @@@ draw_temporary_box(SPDynaDrawContext *d
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/eraser-context.cpp
index 9b00dcd036eaa13ed3ba3b1a7d4b22bc3ad217f1,fdb0813ce7d065f6df373eafa77fdc5db65093fe..68c0989bc945b1a80c8ad3e5b6764ad2df468ecf
@@@ -7,6 -7,6 +7,7 @@@
   *   bulia byak <buliabyak@users.sf.net>
   *   MenTaLguY <mental@rydia.net>
   *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * The original dynadraw code:
   *   Paul Haeberli <paul@sgi.com>
@@@ -65,6 -65,6 +66,8 @@@
  
  #include "eraser-context.h"
  
++using Inkscape::DocumentUndo;
++
  #define ERC_RED_RGBA 0xff0000ff
  
  #define TOLERANCE_ERASER 0.1
@@@ -576,13 -576,10 +579,13 @@@ sp_eraser_context_root_handler(SPEventC
                  dc->repr = NULL;
              }
  
 -            Inkscape::Rubberband::get(desktop)->stop();
              dc->_message_context->clear();
              ret = TRUE;
          }
 +        if (Inkscape::Rubberband::get(desktop)->is_started()) {
 +            Inkscape::Rubberband::get(desktop)->stop();
 +        }
 +            
          break;
      }
  
@@@ -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 */
  
              SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr));
              Inkscape::GC::release(dc->repr);
-             item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+             item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
              item->updateRepr();
          }
          Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc();
              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());
              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 {
  
  
      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));
      }
  }
  
@@@ -1074,4 -1071,4 +1077,4 @@@ draw_temporary_box(SPEraserContext *dc
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/event-context.cpp
index a4109a91cb754a2877c379c91431f40575ae79b8,6184fb4c7352f3a27c20d12b51283c33337a6187..828ce3d5b1d02ab950dc31ab76eb789603ca24d3
@@@ -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 <lauris@kaplinski.com>
   *   Frank Felfe <innerspace@iname.com>
   *   bulia byak <buliabyak@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
   *
   * Copyright (C) 1999-2010 authors
   * Copyright (C) 2001-2002 Ximian, Inc.
@@@ -44,7 -44,6 +43,7 @@@
  #include "desktop.h"
  #include "desktop-handles.h"
  #include "desktop-events.h"
 +#include "desktop-style.h"
  #include "widgets/desktop-widget.h"
  #include "sp-namedview.h"
  #include "selection.h"
@@@ -63,7 -62,6 +62,7 @@@
  #include "ui/tool/control-point.h"
  #include "shape-editor.h"
  #include "sp-guide.h"
 +#include "color.h"
  
  static void sp_event_context_class_init(SPEventContextClass *klass);
  static void sp_event_context_init(SPEventContext *event_context);
@@@ -143,7 -141,6 +142,7 @@@ static void sp_event_context_init(SPEve
      event_context->shape_editor = NULL;
      event_context->_delayed_snap_event = NULL;
      event_context->_dse_callback_in_process = false;
 +    event_context->tool_url = NULL;
  }
  
  /**
@@@ -186,38 -183,17 +185,38 @@@ void sp_event_context_update_cursor(SPE
      if (w->window) {
          /* fixme: */
          if (ec->cursor_shape) {
 -            GdkBitmap *bitmap = NULL;
 -            GdkBitmap *mask = NULL;
 -            sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape);
 -            if ((bitmap != NULL) && (mask != NULL)) {
 -                if (ec->cursor)
 -                    gdk_cursor_unref(ec->cursor);
 -                ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask,
 -                        &w->style->black, &w->style->white, ec->hot_x,
 -                        ec->hot_y);
 -                g_object_unref(bitmap);
 -                g_object_unref(mask);
 +            GdkDisplay *display = gdk_display_get_default();
 +            if (ec->tool_url && gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) {
 +                bool fillHasColor=false, strokeHasColor=false;
 +                guint32 fillColor = sp_desktop_get_color_tool(ec->desktop, ec->tool_url, true, &fillHasColor);
 +                guint32 strokeColor = sp_desktop_get_color_tool(ec->desktop, ec->tool_url, false, &strokeHasColor);
 +                double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(ec->desktop, ec->tool_url, true) : 0;
 +                double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(ec->desktop, ec->tool_url, false) : 0;
 +                GdkPixbuf *pixbuf = sp_cursor_pixbuf_from_xpm(
 +                    ec->cursor_shape,
 +                    w->style->black, w->style->white,
 +                    SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(fillColor),SP_RGBA32_G_U(fillColor),SP_RGBA32_B_U(fillColor),SP_COLOR_F_TO_U(fillOpacity)),
 +                    SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(strokeColor),SP_RGBA32_G_U(strokeColor),SP_RGBA32_B_U(strokeColor),SP_COLOR_F_TO_U(strokeOpacity))
 +                    );
 +                if (pixbuf != NULL) {
 +                    if (ec->cursor)
 +                        gdk_cursor_unref(ec->cursor);
 +                    ec->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, ec->hot_x, ec->hot_y);
 +                    g_object_unref(pixbuf);
 +                }
 +            } else {
 +                GdkBitmap *bitmap = NULL;
 +                GdkBitmap *mask = NULL;
 +                sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape);
 +                if ((bitmap != NULL) && (mask != NULL)) {
 +                    if (ec->cursor)
 +                        gdk_cursor_unref(ec->cursor);
 +                    ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask,
 +                            &w->style->black, &w->style->white, ec->hot_x,
 +                            ec->hot_y);
 +                    g_object_unref(bitmap);
 +                    g_object_unref(mask);
 +                }
              }
          }
          gdk_window_set_cursor(w->window, ec->cursor);
@@@ -961,12 -937,8 +960,12 @@@ gint sp_event_context_root_handler(SPEv
  }
  
  gint sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event) {
 -    gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
 -    set_event_location(event_context->desktop, event);
 +    gint ret = false;
 +    if (event_context) {    // If no event-context is available then do nothing, otherwise Inkscape would crash
 +                            // (see the comment in SPDesktop::set_event_context, and bug LP #622350)
 +        ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
 +        set_event_location(event_context->desktop, event);
 +    }
      return ret;
  }
  
@@@ -1000,15 -972,12 +999,15 @@@ gint sp_event_context_item_handler(SPEv
  }
  
  gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event) {
 -    gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
 -
 -    if (!ret) {
 -        ret = sp_event_context_virtual_root_handler(event_context, event);
 -    } else {
 -        set_event_location(event_context->desktop, event);
 +    gint ret = false;
 +    if (event_context) {    // If no event-context is available then do nothing, otherwise Inkscape would crash
 +                            // (see the comment in SPDesktop::set_event_context, and bug LP #622350)
 +        ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
 +        if (!ret) {
 +            ret = sp_event_context_virtual_root_handler(event_context, event);
 +        } else {
 +            set_event_location(event_context->desktop, event);
 +        }
      }
  
      return ret;
@@@ -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;
@@@ -1373,4 -1342,4 +1373,4 @@@ void sp_event_context_discard_delayed_s
   fill-column:99
   End:
   */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index b183be93cbf5e367576cd412c83fb34cce932e54,0000000000000000000000000000000000000000..a652b7c969b423daf90a1b2928bc9e262987f438
mode 100644,000000..100644
--- /dev/null
@@@ -1,129 -1,0 +1,129 @@@
-     Inkscape::XML::Node     *repr = sp_document_repr_root(doc);
 +/*
 + * 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 <Glimmer07@gmail.com>
 + *
 + * Copyright (C) 2009 Soren Berg
 + *
 + * Released under GNU GPL, read the file 'COPYING' for more information
 + */
 + 
 +#include "application-interface.h"
 +#include <string.h>
 +#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 = doc->getReprRoot();
 +    g_assert(repr != NULL);
 +*/
 +
index b8b0c2ade314f609f3d5632e6e3184a38d6a40d2,0000000000000000000000000000000000000000..836ad33976cb284358636fa65a722587a175ac3f
mode 100644,000000..100644
--- /dev/null
@@@ -1,1336 -1,0 +1,1335 @@@
- #include "document.h" // sp_document_repr_doc
 +/*
 + * 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 <Glimmer07@gmail.com>
 + *
 + * Copyright (C) 2009 Soren Berg
 + *
 + * Released under GNU GPL, read the file 'COPYING' for more information
 + */
 +
 +#include "document-interface.h"
 +#include <string.h>
 +
 +#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"
 +
-     Inkscape::XML::Document *xml_doc = sp_document_repr_doc(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);
- gchar* 
- document_interface_node (DocumentInterface *object, gchar *type, GError **error)
++    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"));
 +}
 +
-     Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
++gchar *document_interface_node (DocumentInterface *object, gchar *type, GError **error)
 +{
 +    SPDocument * doc = sp_desktop_document (object->desk);
++    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 --combined src/extension/effect.cpp
index 9a22c07b7c4e3ed809deef3e3170586cd6662336,79bd96a7edf70a7515d6817b0059d09c9bf17dc0..51aa42da67fe8699770247393ed1931f235e7572
@@@ -1,6 -1,6 +1,7 @@@
  /*
   * Authors:
   *   Ted Gould <ted@gould.cx>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2002-2007 Authors
   *
@@@ -258,7 -258,7 +259,7 @@@ Effect::prefs (Inkscape::UI::View::Vie
      This function first insures that the extension is loaded, and if not,
      loads it.  It then calls the implemention to do the actual work.  It
      also resets the last effect pointer to be this effect.  Finally, it
-     executes a \c sp_document_done to commit the changes to the undo
+     executes a \c SPDocumentUndo::done to commit the changes to the undo
      stack.
  */
  void
@@@ -295,19 -295,6 +296,19 @@@ Effect::effect (Inkscape::UI::View::Vie
  void
  Effect::set_last_effect (Effect * in_effect)
  {
 +    gchar const * verb_id = in_effect->get_verb()->get_id();
 +    gchar const * help_id_prefix = "org.inkscape.help.";
 +
 +    // We don't want these "effects" to register as the last effect,
 +    // this wouldn't be helpful to the user who selects a real effect,
 +    // then goes to the help file (implemented as an effect), then goes
 +    // back to the effect, only to see it written over by the help file
 +    // selection.
 +
 +    // This snippet should fix this bug:
 +    // https://bugs.launchpad.net/inkscape/+bug/600671
 +    if (strncmp(verb_id, help_id_prefix, strlen(help_id_prefix)) == 0) return;
 +
      if (in_effect == NULL) {
          Inkscape::Verb::get(SP_VERB_EFFECT_LAST)->sensitive(NULL, false);
          Inkscape::Verb::get(SP_VERB_EFFECT_LAST_PREF)->sensitive(NULL, false);
index 7ed3891951c33a38ebd6328d7a57dfc0f3c2a4bb,d97c8c6de89039ad1cc44a052ce56b0c62d643ad..f9e099c26f3e27be229adfcb4c073847d11b4be9
@@@ -1,6 -1,6 +1,7 @@@
  /*
   * Authors:
   *   Ted Gould <ted@gould.cx>
++ *   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();
index 04c7c15a671e40bfb438be45d5dd81aa1864c4bb,36cc5787b0ab4d3862edfbb8fbdca3cfcacbc7e2..bc143fd14ece526f129b0c68576dc9d107e8081e
@@@ -6,6 -6,6 +6,7 @@@
   *   Bryce Harrington <bryce@osdl.org>
   *   Ted Gould <ted@gould.cx>
   *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2002-2005,2007 Authors
   *
@@@ -39,7 -39,7 +40,7 @@@
  #include "extension/db.h"
  #include "script.h"
  #include "dialogs/dialog-events.h"
 -#include "application/application.h"
 +#include "inkscape.h"
  #include "xml/node.h"
  #include "xml/attribute-record.h"
  
@@@ -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
@@@ -602,14 -602,10 +602,14 @@@ void Script::save(Inkscape::Extension::
  
  
      file_listener fileout;
 -    execute(command, params, tempfilename_in, fileout);
 +    int data_read = execute(command, params, tempfilename_in, fileout);
 +    
 +    bool success = false;
  
 -    std::string lfilename = Glib::filename_from_utf8(filenameArg);
 -    bool success = fileout.toFile(lfilename);
 +    if (data_read > 0) {
 +        std::string lfilename = Glib::filename_from_utf8(filenameArg);
 +        success = fileout.toFile(lfilename);
 +    }
  
      // make sure we don't leak file descriptors from g_file_open_tmp
      close(tempfd_in);
@@@ -983,7 -979,7 +983,7 @@@ int Script::execute (const std::list<st
  
      Glib::ustring stderr_data = fileerr.string();
      if (stderr_data.length() != 0 &&
 -        Inkscape::NSApplication::Application::getUseGui()
 +        inkscape_use_gui()
         ) {
          checkStderr(stderr_data, Gtk::MESSAGE_INFO,
                                   _("Inkscape has received additional data from the script executed.  "
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 2ab821e445635da2f1fe53d3f4274b436c78096c,75edacdb759c5c165bf9f63a5cf7cc03ffa9d245..c929ba19a429c6e0062ea0daca978b9e2234b8c4
@@@ -4,6 -4,6 +4,8 @@@
  /*
   * Authors:
   *   Ted Gould <ted@gould.cx>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006-2007 Authors
   *
@@@ -174,7 -174,7 +176,7 @@@ XSLT::open(Inkscape::Extension::Input *
      }
      g_free(s);
  
-     SPDocument * doc = sp_document_create(rdoc, filename, base, name, true);
+     SPDocument * doc = SPDocument::createDoc(rdoc, filename, base, name, true);
  
      g_free(base); g_free(name);
  
@@@ -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;
      }
  
      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();
      }
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index a82c7ba7778559c215a171f4c359f0d3efde46a4,e32012070ae6082549d8fc6d9eae1cc530a58105..ba6b8383c3d0e133803a93f84b36ba2c359684e0
@@@ -72,7 -72,7 +72,7 @@@ BlurEdge::effect (Inkscape::Extension::
          SPItem * spitem = *item;
  
          std::vector<Inkscape::XML::Node *> 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);
  
@@@ -133,8 -133,8 +133,8 @@@ BlurEdge::init (void
          "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
              "<name>" N_("Inset/Outset Halo") "</name>\n"
              "<id>org.inkscape.effect.bluredge</id>\n"
 -            "<param name=\"blur-width\" gui-text=\"" N_("Width") "\" gui-description=\"" N_("Width in px of the halo") "\" scope=\"document\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n"
 -            "<param name=\"num-steps\" gui-text=\"" N_("Number of steps") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" scope=\"document\" type=\"int\" min=\"5\" max=\"100\">11</param>\n"
 +            "<param name=\"blur-width\" gui-text=\"" N_("Width:") "\" gui-description=\"" N_("Width in px of the halo") "\" scope=\"document\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n"
 +            "<param name=\"num-steps\" gui-text=\"" N_("Number of steps:") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" scope=\"document\" type=\"int\" min=\"5\" max=\"100\">11</param>\n"
              "<effect>\n"
                  "<object-type>all</object-type>\n"
                  "<effects-menu>\n"
index c81fdd0298df8286fa35fdc7ff56aa14811e404e,14a2f1b17006849d4b71234913e83b27cfa0a4e2..eb26fc58148bb61320121c8a7fe7ab8a2255526e
@@@ -5,6 -5,6 +5,8 @@@
   * Authors:
   *   Ted Gould <ted@gould.cx>
   *   Ulf Erikson <ulferikson@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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();
@@@ -76,7 -76,7 +78,7 @@@
      renderer->destroyContext(ctx);
  
      /* Release arena */
-     sp_item_invoke_hide(base, dkey);
+     base->invoke_hide(dkey);
      nr_object_unref((NRObject *) arena);
  /* end */
      delete renderer;
index d9fd51ffd579567406a53f94b65acdc57ff944f6,76b68bf2c0ffb92a9e5d1c2ee4738cd23b0a29a9..07312aab180d8c948fd86ac4dc4ba19a21839a03
@@@ -6,6 -6,6 +6,8 @@@
   *   Ted Gould <ted@gould.cx>
   *   Ulf Erikson <ulferikson@users.sf.net>
   *   Adib Taraben <theAdib@yahoo.com>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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;
      }
  
@@@ -86,8 -86,8 +88,8 @@@
  
      /* Create new arena */
      NRArena *arena = NRArena::create();
-     unsigned dkey = sp_item_display_key_new(1);
-     sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+     unsigned dkey = SPItem::display_key_new(1);
+     base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
  
      /* Create renderer and context */
      CairoRenderer *renderer = new CairoRenderer();
      }
  
      /* Release arena */
-     sp_item_invoke_hide(base, dkey);
+     base->invoke_hide(dkey);
      nr_object_unref((NRObject *) arena);
  
      renderer->destroyContext(ctx);
@@@ -195,7 -195,12 +197,7 @@@ CairoPsOutput::save(Inkscape::Extension
  
      // Create LaTeX file (if requested)
      if (new_textToLaTeX) {
 -        gchar * tex_filename;
 -        //strip filename of ".ps", do not add ".tex" here.
 -        gsize n = g_str_has_suffix(filename, ".ps") ? strlen(filename)-3 : strlen(filename);
 -        tex_filename = g_strndup(filename, n);
 -        ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
 -        g_free(tex_filename);
 +        ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
  
          if (!ret)
              throw Inkscape::Extension::Output::save_failed();
@@@ -278,7 -283,12 +280,7 @@@ CairoEpsOutput::save(Inkscape::Extensio
  
      // Create LaTeX file (if requested)
      if (new_textToLaTeX) {
 -        gchar * tex_filename;
 -        //strip filename of ".eps", do not add ".tex" here.
 -        gsize n = g_str_has_suffix(filename, ".eps") ? strlen(filename)-4 : strlen(filename);
 -        tex_filename = g_strndup(filename, n);
 -        ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
 -        g_free(tex_filename);
 +        ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
  
          if (!ret)
              throw Inkscape::Extension::Output::save_failed();
@@@ -314,7 -324,7 +316,7 @@@ CairoPsOutput::init (void
                "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
                        "<name>" N_("PostScript") "</name>\n"
                        "<id>" SP_MODULE_KEY_PRINT_CAIRO_PS "</id>\n"
 -                      "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level") "\" type=\"enum\" >\n"
 +                      "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
                                "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
  #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
                  "<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
                        "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"textToLaTeX\" gui-text=\"" N_("PS+LaTeX: Omit text in PS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
 -                      "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi)") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
 +                      "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
                        "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">true</param>\n"
                        "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">true</param>\n"
 -                      "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
 +                      "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
                        "<output>\n"
                                "<extension>.ps</extension>\n"
                                  "<mimetype>image/x-postscript</mimetype>\n"
@@@ -352,7 -362,7 +354,7 @@@ CairoEpsOutput::init (void
                "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
                        "<name>" N_("Encapsulated PostScript") "</name>\n"
                        "<id>" SP_MODULE_KEY_PRINT_CAIRO_EPS "</id>\n"
 -                      "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level") "\" type=\"enum\" >\n"
 +                      "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
                                "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
  #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
                  "<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
                        "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"textToLaTeX\" gui-text=\"" N_("EPS+LaTeX: Omit text in EPS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
 -                      "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi)") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
 +                      "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
                        "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">true</param>\n"
                        "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">true</param>\n"
 -                      "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
 +                      "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
                        "<output>\n"
                                "<extension>.eps</extension>\n"
                                  "<mimetype>image/x-e-postscript</mimetype>\n"
index 368d827b172e1e7eecf8010fe3eb2cf16709e51c,40c7bf7e34f7a5e4b3dac12ef357d4a7eebfd611..7eda3c5104d942ab480265af364b285fd6fedc7a
@@@ -6,6 -6,6 +6,7 @@@
   *   Ted Gould <ted@gould.cx>
   *   Ulf Erikson <ulferikson@users.sf.net>
   *   Adib Taraben <theAdib@yahoo.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2006 Authors
   *
@@@ -16,6 -16,7 +17,7 @@@
  #define EXTENSION_INTERNAL_CAIRO_PS_OUT_H
  
  #include "extension/implementation/implementation.h"
+ #include "sp-item.h"
  
  #ifdef HAVE_CAIRO_PDF
  
@@@ -62,4 -63,4 +64,4 @@@ public
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 6caa21d248f80a469625b6fcdc669c86bd2b43f1,b6b411e0e59fac1f4eeb3b1f13831e5e7dee2804..18a654e275731310005e360bdc1c76c49a1518c3
@@@ -1,11 -1,11 +1,11 @@@
--#define __SP_CAIRO_RENDER_CONTEXT_C__
--
  /** \file
   * Rendering with Cairo.
   */
  /*
   * Author:
   *   Miklos Erdelyi <erdelyim@gmail.com>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006 Miklos Erdelyi
   *
@@@ -108,7 -108,7 +108,7 @@@ static cairo_status_t _write_callback(v
  
  CairoRenderContext::CairoRenderContext(CairoRenderer *parent) :
      _dpi(72),
 -    _pdf_level(0),
 +    _pdf_level(1),
      _ps_level(1),
      _eps(false),
      _is_texttopath(FALSE),
@@@ -670,11 -670,6 +670,11 @@@ CairoRenderContext::popLayer(void
              }
              TRACE(("mask surface: %f x %f at %i dpi\n", surface_width, surface_height, _dpi ));
  
 +            // Mask should start black, but it is created white.
 +            cairo_set_source_rgba(mask_ctx->_cr, 0.0, 0.0, 0.0, 1.0);
 +            cairo_rectangle(mask_ctx->_cr, 0, 0, surface_width, surface_height);
 +            cairo_fill(mask_ctx->_cr);
 +
              // set rendering mode to normal
              setRenderMode(RENDER_MODE_NORMAL);
  
              int stride = cairo_image_surface_get_stride(mask_image);
              unsigned char *pixels = cairo_image_surface_get_data(mask_image);
  
 -            // premultiply with opacity
              // In SVG, the rgb channels as well as the alpha channel is used in masking.
              // In Cairo, only the alpha channel is used thus requiring this conversion.
 +            // SVG specifies that RGB be converted to alpha using luminance-to-alpha.
 +            // Notes: This calculation assumes linear RGB values. VERIFY COLOR SPACE!
 +            // The incoming pixel values already include alpha, fill-opacity, etc.,
 +            // however, opacity must still be applied.
              TRACE(("premul w/ %f\n", opacity));
 -            guint8 int_opacity = (guint8)(255 * opacity);
 +            const float coeff_r = 0.2125 / 255.0;
 +            const float coeff_g = 0.7154 / 255.0;
 +            const float coeff_b = 0.0721 / 255.0;
              for (int row = 0 ; row < height; row++) {
                  unsigned char *row_data = pixels + (row * stride);
                  for (int i = 0 ; i < width; i++) {
                      guint32 *pixel = (guint32 *)row_data + i;
 -                    *pixel = ((((*pixel & 0x00ff0000) >> 16) * 13817 +
 -                               ((*pixel & 0x0000ff00) >>  8) * 46518 +
 -                               ((*pixel & 0x000000ff)      ) * 4688) *
 -                              int_opacity);
 +                    float lum_alpha = (((*pixel & 0x00ff0000) >> 16) * coeff_r +
 +                                       ((*pixel & 0x0000ff00) >>  8) * coeff_g +
 +                                       ((*pixel & 0x000000ff)      ) * coeff_b );
 +                    // lum_alpha can be slightly greater than 1 due to rounding errors...
 +                    // but this should be OK since it doesn't matter what the lower
 +                    // six hexadecimal numbers of *pixel are.
 +                    *pixel = (guint32)(0xff000000 * lum_alpha * opacity);
                  }
              }
  
@@@ -795,9 -782,6 +795,9 @@@ CairoRenderContext::setupSurface(doubl
  #ifdef CAIRO_HAS_PDF_SURFACE
          case CAIRO_SURFACE_TYPE_PDF:
              surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, width, height);
 +#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0))
 +            cairo_pdf_surface_restrict_to_version(surface, (cairo_pdf_version_t)_pdf_level);  
 +#endif
              break;
  #endif
  #ifdef CAIRO_HAS_PS_SURFACE
                  return FALSE;
              }
  #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
 -            cairo_ps_surface_restrict_to_level (surface, (cairo_ps_level_t)_ps_level);
 -            cairo_ps_surface_set_eps (surface, (cairo_bool_t) _eps);
 +            cairo_ps_surface_restrict_to_level(surface, (cairo_ps_level_t)_ps_level);
 +            cairo_ps_surface_set_eps(surface, (cairo_bool_t) _eps);
 +#endif
 +            // Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501
 +#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2))
 +            if (override_bbox) {
 +                cairo_ps_dsc_comment(surface, "%%BoundingBox: 100 100 200 200");
 +                cairo_ps_dsc_comment(surface, "%%PageBoundingBox: 100 100 200 200");
 +            }
  #endif
              break;
  #endif
@@@ -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*
@@@ -1086,14 -1063,14 +1087,14 @@@ CairoRenderContext::_createPatternPaint
  
      // create arena and group
      NRArena *arena = NRArena::create();
-     unsigned dkey = sp_item_display_key_new(1);
+     unsigned dkey = SPItem::display_key_new(1);
  
      // 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));
                  }
              }
      // 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
@@@ -1288,7 -1265,7 +1289,7 @@@ CairoRenderContext::_setStrokeStyle(SPS
  
          cairo_set_source_rgba(_cr, rgb[0], rgb[1], rgb[2], alpha);
      } else {
 -        g_assert( style->fill.isPaintserver()
 +        g_assert( style->stroke.isPaintserver()
                    || SP_IS_GRADIENT(SP_STYLE_STROKE_SERVER(style))
                    || SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) );
  
@@@ -1500,19 -1477,18 +1501,19 @@@ CairoRenderContext::_showGlyphs(cairo_
          glyphs = (cairo_glyph_t*)g_malloc(sizeof(cairo_glyph_t) * num_glyphs);
  
      unsigned int num_invalid_glyphs = 0;
 -    unsigned int i = 0;
 +    unsigned int i = 0; // is a counter for indexing the glyphs array, only counts the valid glyphs
      for (std::vector<CairoGlyphInfo>::const_iterator it_info = glyphtext.begin() ; it_info != glyphtext.end() ; it_info++) {
          // skip glyphs which are PANGO_GLYPH_EMPTY (0x0FFFFFFF)
          // or have the PANGO_GLYPH_UNKNOWN_FLAG (0x10000000) set
          if (it_info->index == 0x0FFFFFFF || it_info->index & 0x10000000) {
              TRACE(("INVALID GLYPH found\n"));
 +            g_message("Invalid glyph found, continuing...");
              num_invalid_glyphs++;
              continue;
          }
 -        glyphs[i - num_invalid_glyphs].index = it_info->index;
 -        glyphs[i - num_invalid_glyphs].x = it_info->x;
 -        glyphs[i - num_invalid_glyphs].y = it_info->y;
 +        glyphs[i].index = it_info->index;
 +        glyphs[i].x     = it_info->x;
 +        glyphs[i].y     = it_info->y;
          i++;
      }
  
@@@ -1700,4 -1676,4 +1701,4 @@@ _write_callback(void *closure, const un
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 32df1193b97730eac1072dd09be3c484a2956c77,6536361bdc13130bbf2e9ed478049857a2841ff0..8406e2a3b53d951f251a89728299a7450ae7253a
@@@ -6,6 -6,6 +6,8 @@@
   *   Ted Gould <ted@gould.cx>
   *   Ulf Erikson <ulferikson@users.sf.net>
   *   Johan Engelen <goejendaagh@zonnet.nl>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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 */
  
      }
      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();
      nr_arena_set_renderoffscreen (arena);
-     unsigned dkey = sp_item_display_key_new(1);
-     sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+     unsigned dkey = SPItem::display_key_new(1);
+     base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
  
      /* Create renderer and context */
      CairoRenderer *renderer = new CairoRenderer();
      }
  
      /* Release arena */
-     sp_item_invoke_hide(base, dkey);
+     base->invoke_hide(dkey);
      nr_object_unref((NRObject *) arena);
  
      renderer->destroyContext(ctx);
@@@ -135,11 -135,11 +138,11 @@@ CairoRendererPdfOutput::save(Inkscape::
      int level = 0;
      try {
          new_level = mod->get_param_enum("PDFversion");
 -//        if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.x", new_level) == 0))
 -//            level = 1;
 +        if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.5", new_level) == 0))
 +            level = 1;
      }
      catch(...) {
 -//        g_warning("Parameter <PDFversion> might not exist");
 +        g_warning("Parameter <PDFversion> might not exist");
      }
  
      bool new_textToPath  = FALSE;
  
      // Create LaTeX file (if requested)
      if (new_textToLaTeX) {
 -        gchar * tex_filename;
 -        //strip filename of ".pdf", do not add ".tex" here.
 -        gsize n = g_str_has_suffix(filename, ".pdf") ? strlen(filename)-4 : strlen(filename);
 -        tex_filename = g_strndup(filename, n);
 -        ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
 -        g_free(tex_filename);
 +        ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
  
          if (!ret)
              throw Inkscape::Extension::Output::save_failed();
@@@ -236,19 -241,16 +239,19 @@@ CairoRendererPdfOutput::init (void
                "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
                        "<name>Portable Document Format</name>\n"
                        "<id>org.inkscape.output.pdf.cairorenderer</id>\n"
 -                      "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version") "\" type=\"enum\" >\n"
 -                              "<_item value='PDF14'>" N_("PDF 1.4") "</_item>\n"
 +                      "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n"
 +#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0))
 +                              "<_item value='PDF-1.5'>" N_("PDF 1.5") "</_item>\n"
 +#endif
 +                "<_item value='PDF-1.4'>" N_("PDF 1.4") "</_item>\n"
                        "</param>\n"
                        "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
 -                      "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi)") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
 +                      "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
                        "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">false</param>\n"
 -                      "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
 +                      "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
                        "<output>\n"
                                "<extension>.pdf</extension>\n"
                                "<mimetype>application/pdf</mimetype>\n"
index 988f6126385a1d5f9539abaa8d391d58261e3c1a,3c5cfc7c18934e85d6ed9d3111f42876a3837ec4..67f9354d8cac97085e57fc87b6f18d90cbc29df8
@@@ -1,11 -1,11 +1,11 @@@
--#define __SP_CAIRO_RENDERER_C__
--
  /** \file
   * Rendering with Cairo.
   */
  /*
   * Author:
   *   Miklos Erdelyi <erdelyim@gmail.com>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006 Miklos Erdelyi
   *
@@@ -186,12 -186,11 +186,12 @@@ static void sp_shape_render (SPItem *it
  
      if (!shape->curve) return;
  
-     sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
+     item->invoke_bbox( &pbox, Geom::identity(), TRUE);
  
      SPStyle* style = SP_OBJECT_STYLE (item);
  
      Geom::PathVector const & pathv = shape->curve->get_pathvector();
 +    if (pathv.empty()) return;
  
      ctx->renderPathVector(pathv, style, &pbox);
  
@@@ -450,7 -449,7 +450,7 @@@ static void sp_asbitmap_render(SPItem *
  
      // Get the bounding box of the selection in document coordinates.
      Geom::OptRect bbox = 
-            item->getBounds(sp_item_i2d_affine(item), SPItem::RENDERING_BBOX);
+            item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX);
  
      if (!bbox) // no bbox, e.g. empty group
          return;
                                   (Geom::Matrix)(Geom::Translate (shift_x, shift_y));
  
      // ctx matrix already includes item transformation. We must substract.
-     Geom::Matrix t_item =  sp_item_i2d_affine (item);
+     Geom::Matrix t_item =  item->i2d_affine ();
      Geom::Matrix t = t_on_document * t_item.inverse();
  
      // Do the export
@@@ -603,16 -602,16 +603,17 @@@ 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) {
          d.x0 = d.y0 = 0;
-         d.x1 = sp_document_width(doc);
-         d.y1 = sp_document_height(doc);
+         d.x1 = doc->getWidth();
+         d.y1 = doc->getHeight();
      } else {
-         sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
+         base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
      }
  
      if (ctx->_vector_based_target) {
  
      if (ret && !pageBoundingBox)
      {
-         double high = sp_document_height(doc);
+         double high = doc->getHeight();
          if (ctx->_vector_based_target)
              high *= PT_PER_PX;
  
@@@ -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);
@@@ -813,4 -812,4 +814,4 @@@ calculatePreserveAspectRatio(unsigned i
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index f1a26a3134c4cde8b77090c3defb9f46b2f7973c,094922bbfeed611f69af50f3c5e742ec0fe8e45b..7fa7c7ff5fad95ac6c9da0e42b1cc7579274784a
@@@ -7,6 -7,6 +7,7 @@@
  /*
   * Authors:
   *       Miklos Erdelyi <erdelyim@gmail.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006 Miklos Erdelyi
   * 
@@@ -23,7 -23,7 +24,7 @@@
  
  //#include "libnrtype/font-instance.h"
  #include "style.h"
+ #include "sp-item.h"
  #include <cairo.h>
  
  class SPClipPath;
@@@ -81,4 -81,4 +82,4 @@@ void calculatePreserveAspectRatio(unsig
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 474dd17932b1fa9d7d453d30c5335e072222bc95,aa856e910b40ef237725655cd6066da73b49d21c..7d379477b37169fbc0278cdd3cb3562ac4e86e72
@@@ -3,6 -3,6 +3,8 @@@
   */
  /* Authors:
   *   Ulf Erikson <ulferikson@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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");
      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);
@@@ -733,7 -733,7 +735,7 @@@ assert_empty_path(PEMF_CALLBACK_DATA d
  
  
  static int CALLBACK
 -myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD *lpEMFR, int /*nObj*/, LPARAM lpData)
 +myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *lpEMFR, int /*nObj*/, LPARAM lpData)
  {
      PEMF_CALLBACK_DATA d;
      SVGOStringStream tmp_outsvg;
@@@ -2353,8 -2353,7 +2355,8 @@@ EmfWin32::open( Inkscape::Extension::In
                  d.pDesc[lstrlen(d.pDesc)] = '#';
          }
  
 -        EnumEnhMetaFile(NULL, hemf, myEnhMetaFileProc, (LPVOID) &d, NULL);
 +        // This ugly reinterpret_cast is to prevent old versions of gcc from whining about a mismatch in the const-ness of the arguments
 +        EnumEnhMetaFile(NULL, hemf, reinterpret_cast<ENHMFENUMPROC>(myEnhMetaFileProc), (LPVOID) &d, NULL);
          DeleteEnhMetaFile(hemf);
      }
      else {
  
  //    std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl;
  
-     SPDocument *doc = sp_document_new_from_mem(d.outsvg->c_str(), d.outsvg->length(), TRUE);
+     SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg->c_str(), d.outsvg->length(), TRUE);
  
      delete d.outsvg;
      delete d.path;
@@@ -2454,4 -2453,4 +2456,4 @@@ EmfWin32::init (void
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index bd42b0eb6e8a03358533ca00dc0426167265820a,e8e6b3187e30e3bc0ac9617543a74ef9b86e1887..58249620b6dc7918e43a300a652791117a456ac0
@@@ -3,6 -3,6 +3,8 @@@
   */
  /* Authors:
   *   Ulf Erikson <ulferikson@users.sf.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006-2009 Authors
   *
@@@ -135,8 -135,8 +137,8 @@@ PrintEmfWin32::begin (Inkscape::Extensi
      WCHAR *unicode_uri = (WCHAR *) unicode_fn;
  
      // width and height in px
-     _width = sp_document_width(doc);
-     _height = sp_document_height(doc);
+     _width = doc->getWidth();
+     _height = doc->getHeight();
  
      NRRect d;
      bool pageBoundingBox;
          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;
      g_free(local_fn);
      g_free(unicode_fn);
  
-     m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, sp_document_height(doc)));
+     m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight()));
  
      return 0;
  }
@@@ -1020,4 -1020,4 +1022,4 @@@ PrintEmfWin32::init (void
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index c2d80b28b4e02dc0d9e235e2d186dc4c2914fcbb,c2d80b28b4e02dc0d9e235e2d186dc4c2914fcbb..90dc5dd6f0c61ea2a53ebf8a065846e3bdaa881e
@@@ -132,7 -132,7 +132,7 @@@ Filter::effect (Inkscape::Extension::Ef
      std::list<SPItem *> items;
      items.insert<GSListConstIterator<SPItem *> >(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<SPItem *>::iterator item = items.begin();
index ff272d28d524abb1e68777713472970f13cfe2b5,69fdbcfd1dc02e1f1ca9023a6f211257c0432aae..c3a30a2f002f072dcc1ed128a2274d1058b7857a
@@@ -2,7 -2,6 +2,7 @@@
  # include <config.h>
  #endif
  #include <glib/gprintf.h>
 +#include <glibmm/i18n.h>
  #include "document-private.h"
  #include <dir-util.h>
  #include "extension/input.h"
@@@ -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);
          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");
      }
@@@ -144,10 -143,10 +144,10 @@@ GdkpixbufInput::init(void
              if (strcmp(extensions[i], "svg.gz") == 0) {
                  continue;
              }
 -
 +            gchar *caption = g_strdup_printf(_("%s GDK pixbuf Input"), name);
              gchar *xmlString = g_strdup_printf(
                  "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
 -                    "<name>" N_("%s GDK pixbuf Input") "</name>\n"
 +                    "<name>%s</name>\n"
                      "<id>org.inkscape.input.gdkpixbuf.%s</id>\n"
                      "<param name='link' type='optiongroup'  appearance='full' _gui-text='" N_("Link or embed image:") "' >\n"
                          "<_option value='embed'>" N_("embed") "</_option>\n"
                          "<filetypetooltip>%s</filetypetooltip>\n"
                      "</input>\n"
                  "</inkscape-extension>",
 -                name,
 +                caption,
                  extensions[i],
                  extensions[i],
                  mimetypes[j],
  
              Inkscape::Extension::build_from_mem(xmlString, new GdkpixbufInput());
              g_free(xmlString);
 +            g_free(caption);
          }}
  
          g_free(name);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 5b3e0c16ef2e37bf7427d6951906fd7777730ed7,6b11aa994dd90159bae5aa072a437c2f0ffb212a..e92a4e17e0e14f0ccb6257abac3cce709f39b1cc
@@@ -5,6 -5,6 +5,7 @@@
  /*
   * Authors:
   *   Ted Gould <ted@gould.cx>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2005 Authors
   *
@@@ -256,7 -256,7 +257,7 @@@ GimpGrad::open (Inkscape::Extension::In
  
          fclose(gradient);
  
-         return sp_document_new_from_mem(outsvg.c_str(), outsvg.length(), TRUE);
+         return SPDocument::createNewDocFromMem(outsvg.c_str(), outsvg.length(), TRUE);
      }
  
  error:
index ed41dd97b6002fb0a5d0fcd165891dc3ae046726,4d07e401dc140fbbf9b52c43029f972047affcfc..a19ab75388c49e36a1d4ab0a44f63d4487481752
@@@ -6,6 -6,6 +6,7 @@@
  /*
   * Copyright (C) 2004-2005  Ted Gould <ted@gould.cx>
   * Copyright (C) 2007  MenTaLguY <mental@rydia.net>
++ *   Abhishek Sharma
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
@@@ -87,14 -87,14 +88,14 @@@ Grid::effect (Inkscape::Extension::Effe
          /* get page size */
          SPDocument * doc = document->doc();
          bounding_area = Geom::Rect(  Geom::Point(0,0),
-                                      Geom::Point(sp_document_width(doc), sp_document_height(doc))  );
+                                      Geom::Point(doc->getWidth(), doc->getHeight())  );
      } else {
          Geom::OptRect bounds = selection->bounds();
          if (bounds) {
              bounding_area = *bounds;
          }
  
-         gdouble doc_height  =  sp_document_height(document->doc());
+         gdouble doc_height  =  (document->doc())->getHeight();
          Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
                                      Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
  
  
      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<SPDesktop *>(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<SPDesktop *>(document)->currentLayer()->getRepr();
      Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
  
      path->setAttribute("d", path_data.c_str());
@@@ -195,11 -197,11 +198,11 @@@ Grid::init (void
          "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
              "<name>" N_("Grid") "</name>\n"
              "<id>org.inkscape.effect.grid</id>\n"
 -            "<param name=\"lineWidth\" gui-text=\"" N_("Line Width") "\" type=\"float\">1.0</param>\n"
 -            "<param name=\"xspacing\" gui-text=\"" N_("Horizontal Spacing") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n"
 -            "<param name=\"yspacing\" gui-text=\"" N_("Vertical Spacing") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n"
 -            "<param name=\"xoffset\" gui-text=\"" N_("Horizontal Offset") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n"
 -            "<param name=\"yoffset\" gui-text=\"" N_("Vertical Offset") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n"
 +            "<param name=\"lineWidth\" gui-text=\"" N_("Line Width:") "\" type=\"float\">1.0</param>\n"
 +            "<param name=\"xspacing\" gui-text=\"" N_("Horizontal Spacing:") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n"
 +            "<param name=\"yspacing\" gui-text=\"" N_("Vertical Spacing:") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n"
 +            "<param name=\"xoffset\" gui-text=\"" N_("Horizontal Offset:") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n"
 +            "<param name=\"yoffset\" gui-text=\"" N_("Vertical Offset:") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n"
              "<effect>\n"
                  "<object-type>all</object-type>\n"
                  "<effects-menu>\n"
index b371b01058543d0a79a9d29e7c05ce19887fc773,813a1726465b323a416a9dda61f3e6f49431d48e..7098027c7847dd4dfc3316c1cff9b1ba0b50902d
@@@ -9,6 -9,6 +9,7 @@@
   *   Silveira Neto <silveiraneto@gmail.com>
   *   Jim Clarke <Jim.Clarke@sun.com>
   *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2008,2009 Authors
   *
@@@ -386,7 -386,7 +387,7 @@@ bool JavaFXOutput::doStyle(SPStyle *sty
      /**
       * Fill
       */
 -    SPIPaint fill = style->fill;
 +    SPIPaint const &fill = style->fill;
      if (fill.isColor())
          {
          // see color.h for how to parse SPColor
       */
      if (style->stroke_opacity.value > 0)
          {
 -        SPIPaint stroke = style->stroke;
 +        SPIPaint const &stroke = style->stroke;
          out("            stroke: %s\n",
              rgba(stroke.value.color, SP_SCALE24_TO_FLOAT(style->stroke_opacity.value)).c_str());
          double strokewidth = style->stroke_width.value;
@@@ -493,7 -493,7 +494,7 @@@ bool JavaFXOutput::doCurve(SPItem *item
  
      // convert the path to only lineto's and cubic curveto's:
      Geom::Scale yflip(1.0, -1.0);
-     Geom::Matrix tf = sp_item_i2d_affine(item) * yflip;
+     Geom::Matrix tf = item->i2d_affine() * yflip;
      Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
  
      //Count the NR_CURVETOs/LINETOs (including closing line segment)
@@@ -635,7 -635,7 +636,7 @@@ bool JavaFXOutput::doCurve(SPItem *item
  
      // convert the path to only lineto's and cubic curveto's:
      Geom::Scale yflip(1.0, -1.0);
-     Geom::Matrix tf = sp_item_i2d_affine(item) * yflip;
+     Geom::Matrix tf = item->i2d_affine() * yflip;
      Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
  
      //Count the NR_CURVETOs/LINETOs (including closing line segment)
@@@ -993,4 -993,4 +994,4 @@@ JavaFXOutput::init(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 4a469a7500a0da118ed649fa5ff19fad21ebe443,a474193651c0baf94e265f84fa2af08b0802ac48..1477d5daf78985605a31d6b1a613d67e733403be
@@@ -1,6 -1,6 +1,8 @@@
  /*
   * Authors:
   *   Michael Forbes <miforbes@mbhs.edu>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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");
      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);
index ed6024adfc1124a2127f7e0eccfcf522b8695f71,63e9d3803fe7c37cc97fe5c3961446406fb842b5..44b64c5f8f999fdb3da78ec39b81ce0846d696d0
@@@ -1,10 -1,10 +1,9 @@@
--#define __SP_LATEX_C__
--
  /*
   * LaTeX Printing
   *
   * Author:
   *  Michael Forbes <miforbes@mbhs.edu>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004 Authors
   * 
@@@ -128,8 -128,8 +127,8 @@@ PrintLatex::begin (Inkscape::Extension:
      }
  
      // width and height in pt
-     _width = sp_document_width(doc) * PT_PER_PX;
-     _height = sp_document_height(doc) * PT_PER_PX;
+     _width = doc->getWidth() * PT_PER_PX;
+     _height = doc->getHeight() * PT_PER_PX;
  
      if (res >= 0) {
  
          os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n";
          // from now on we can output px, but they will be treated as pt
      
-         os << "\\begin{pspicture}(" << sp_document_width(doc) << "," << sp_document_height(doc) << ")\n";
+         os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\n";
      }
  
-     m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, sp_document_height(doc)));
+     m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight()));
  
      return fprintf(_stream, "%s", os.str().c_str());
  }
@@@ -369,5 -369,5 +368,5 @@@ PrintLatex::init (void
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  
index b37316d8fc6a77c5d628d6d328068b1196f85f7b,d944de71ad22bdde1aa0c59e63ac7b039a3d0899..fd99afe31b71f2fedd8c9dd503d97e277ce4d44d
@@@ -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 <goejendaagh@zonnet.nl>
   *   Miklos Erdelyi <erdelyim@gmail.com>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006-2010 Authors
   *
@@@ -51,14 -51,14 +51,14 @@@ namespace Internal 
  
  /**
   * This method is called by the PDF, EPS and PS output extensions.
 - * @param filename This should be the filename without extension to which the tex code should be written. Output goes to <filename>.tex.
 + * @param filename This should be the filename without '_tex' extension to which the tex code should be written. Output goes to <filename>_tex, note the underscore instead of period.
   */
  bool
  latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
                                      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;
      }
  
@@@ -132,7 -132,7 +132,7 @@@ LaTeXTextRenderer::setTargetFile(gchar 
  
          _filename = g_path_get_basename(filename);
  
 -        gchar *filename_ext = g_strdup_printf("%s.tex", filename);
 +        gchar *filename_ext = g_strdup_printf("%s_tex", filename);
          Inkscape::IO::dump_fopen_call(filename_ext, "K");
          FILE *osf = Inkscape::IO::fopen_utf8name(filename_ext, "w+");
          if (!osf) {
  
  static char const preamble[] =
  "%% To include the image in your LaTeX document, write\n"
 -"%%   \\input{<filename>.tex}\n"
 +"%%   \\input{<filename>.pdf_tex}\n"
  "%%  instead of\n"
  "%%   \\includegraphics{<filename>.pdf}\n"
  "%% To scale the image, write\n"
 -"%%   \\def{\\svgwidth}{<desired width>}\n"
 -"%%   \\input{<filename>.tex}\n"
 +"%%   \\def\\svgwidth{<desired width>}\n"
 +"%%   \\input{<filename>.pdf_tex}\n"
  "%%  instead of\n"
  "%%   \\includegraphics[width=<desired width>]{<filename>.pdf}\n"
  "%%\n"
  "%% installed) using\n"
  "%%   \\usepackage{import}\n"
  "%% in the preamble, and then including the image with\n"
 -"%%   \\import{<path to file>}{<filename>.tex}\n"
 +"%%   \\import{<path to file>}{<filename>.pdf_tex}\n"
  "%% Alternatively, one can specify\n"
  "%%   \\graphicspath{{<path to file>/}}\n"
  "%% \n"
@@@ -311,7 -311,7 +311,7 @@@ LaTeXTextRenderer::sp_text_render(SPIte
      }
  
      // get rotation
-     Geom::Matrix i2doc = sp_item_i2doc_affine(item);
+     Geom::Matrix i2doc = item->i2doc_affine();
      Geom::Matrix wotransl = i2doc.without_translation();
      double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis());
      bool has_rotation = !Geom::are_near(degrees,0.);
@@@ -412,7 -412,7 +412,7 @@@ Flowing in rectangle is possible, not i
      }
  
      // get rotation
-     Geom::Matrix i2doc = sp_item_i2doc_affine(item);
+     Geom::Matrix i2doc = item->i2doc_affine();
      Geom::Matrix wotransl = i2doc.without_translation();
      double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis());
      bool has_rotation = !Geom::are_near(degrees,0.);
@@@ -490,15 -490,15 +490,16 @@@ 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) {
          d = Geom::Rect( Geom::Point(0,0),
-                         Geom::Point(sp_document_width(doc), sp_document_height(doc)) );
+                         Geom::Point(doc->getWidth(), doc->getHeight()) );
      } else {
-         sp_item_invoke_bbox(base, d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
+         base->invoke_bbox( d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
      }
      if (!d) {
          g_message("LaTeXTextRenderer: could not retrieve boundingbox.");
      }
  
      // flip y-axis
-     push_transform( Geom::Scale(1,-1) * Geom::Translate(0, sp_document_height(doc)) );
+     push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) );
  
      // write the info to LaTeX
      Inkscape::SVGOStringStream os;
@@@ -578,4 -578,4 +579,4 @@@ LaTeXTextRenderer::pop_transform(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 4f3f1ac89bc8f4b9c8932afdb32a445c32ede929,bf8a70a1492b49ea079b4789b549e952eb5e52e5..b5c842a40c6dbf6b3857b1874f893ae54d89e522
@@@ -14,6 -14,6 +14,7 @@@
   *
   * Authors:
   *   Bob Jamison
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006, 2007 Bob Jamison
   *
@@@ -945,9 -945,9 +946,9 @@@ static Glib::ustring formatTransform(Ge
  static Geom::Matrix getODFTransform(const SPItem *item)
  {
      //### Get SVG-to-ODF transform
-     Geom::Matrix tf (sp_item_i2d_affine(item));
+     Geom::Matrix tf (item->i2d_affine());
      //Flip Y into document coordinates
-     double doc_height    = sp_document_height(SP_ACTIVE_DOCUMENT);
+     double doc_height    = SP_ACTIVE_DOCUMENT->getHeight();
      Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0));
      doc2dt_tf            = doc2dt_tf * Geom::Matrix(Geom::Translate(0, doc_height));
      tf                   = tf * doc2dt_tf;
   */
  static Geom::OptRect getODFBoundingBox(const SPItem *item)
  {
-     Geom::OptRect bbox_temp = sp_item_bbox_desktop((SPItem *)item);
+     Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop();
      Geom::OptRect bbox;
      if (bbox_temp) {
          bbox = *bbox_temp;
-         double doc_height    = sp_document_height(SP_ACTIVE_DOCUMENT);
+         double doc_height    = SP_ACTIVE_DOCUMENT->getHeight();
          Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0));
          doc2dt_tf            = doc2dt_tf * Geom::Matrix(Geom::Translate(0, doc_height));
          bbox                 = *bbox * doc2dt_tf;
@@@ -2002,7 -2002,7 +2003,7 @@@ bool OdfOutput::writeTree(Writer &couts
      else if (SP_IS_SHAPE(item))
          {
          //g_message("### %s is a shape", nodeName.c_str());
-         curve = sp_shape_get_curve(SP_SHAPE(item));
+         curve = SP_SHAPE(item)->getCurve();
          }
      else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
          {
@@@ -2482,4 -2482,4 +2483,4 @@@ OdfOutput::check (Inkscape::Extension::
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 3854ddfe126a785d763254b6659a9f4ce2b0d4e2,08eda3767fdc27120df50c28029016223ea6566d..9ad2610989b6da0dfa60856ba91084c2a9f5ecef
@@@ -11,6 -11,6 +11,7 @@@
   *
   * Authors:
   *   Bob Jamison
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006 Bob Jamison
   *
@@@ -47,7 -47,7 +48,7 @@@
  
  #include <dom/util/ziptool.h>
  #include <dom/io/domstream.h>
+ #include "sp-item.h"
  
  namespace Inkscape
  {
index 937fefb1117636f7c1cba87534697813c7e4960c,62c6b7f369b3007d2883a66eb3e706128427e0af..2c7ea3b33f7f35fc08294931af1b593a54b0aa14
@@@ -3,6 -3,6 +3,7 @@@
   *
   * Authors:
   *   miklos erdelyi
++ *   Abhishek Sharma
   *
   * Copyright (C) 2007 Authors
   *
@@@ -58,7 -58,7 +59,7 @@@ PdfInputCairo::open(Inkscape::Extension
      cairo_destroy(cr);
      cairo_surface_destroy(surface);
  
-     SPDocument * doc = sp_document_new_from_mem(output->c_str(), output->length(), TRUE);
+     SPDocument * doc = SPDocument::createNewDocFromMem(output->c_str(), output->length(), TRUE);
  
      delete output;
      g_object_unref(page);
index 8dd4698b5f28c15014d68304f68458df40282e05,b507118035e053acac0efe1be82e0bf688f2faaf..ae3e473a5d72d3dd187adb56505ecbe5d29b0c47
@@@ -3,6 -3,6 +3,7 @@@
   *
   * Authors:
   *   miklos erdelyi
++ *   Abhishek Sharma
   *
   * Copyright (C) 2007 Authors
   *
@@@ -36,7 -36,7 +37,7 @@@
  #include "pdf-parser.h"
  
  #include "document-private.h"
 -#include "application/application.h"
 +#include "inkscape.h"
  
  #include "dialogs/dialog-events.h"
  #include <gtk/gtkdialog.h>
@@@ -390,10 -390,12 +391,10 @@@ void PdfImportDialog::getImportSettings
  void PdfImportDialog::_onPrecisionChanged() {
  
      static Glib::ustring precision_comments[] = {
 -        Glib::ustring(_("rough")),
 -        //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
 -        Glib::ustring(Q_("pdfinput|medium")),
 -        Glib::ustring(_("fine")),
 -        Glib::ustring(_("very fine"))
 +        Glib::ustring(C_("PDF input precision", "rough")),
 +        Glib::ustring(C_("PDF input precision", "medium")),
 +        Glib::ustring(C_("PDF input precision", "fine")),
 +        Glib::ustring(C_("PDF input precision", "very fine"))
      };
  
      double min = _fallbackPrecisionSlider_adj->get_lower();
@@@ -641,7 -643,7 +642,7 @@@ PdfInput::open(::Inkscape::Extension::I
      }
  
      PdfImportDialog *dlg = NULL;
 -    if (Inkscape::NSApplication::Application::getUseGui()) {
 +    if (inkscape_use_gui()) {
          dlg = new PdfImportDialog(pdf_doc, uri);
          if (!dlg->showDialog()) {
              delete dlg;
      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);
      delete dlg;
  
      // Restore undo
-     sp_document_set_undo_sensitive(doc, saved);
 -      SPDocumentUndo::set_undo_sensitive(doc, saved);
++    DocumentUndo::setUndoSensitive(doc, saved);
  
      return doc;
  }
index e343dbf338a62d404c7c2f6c12679d7acc532dcb,b9583545fb3ed237f0b336769b625aa775e5f11f..8b414239a708d9c8e5a8a537491aeef07518801e
@@@ -3,6 -3,6 +3,7 @@@
   * 
   * Authors:
   *   miklos erdelyi
++ *   Jon A. Cruz <jon@joncruz.org>
   *
   * 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();
@@@ -1291,8 -1291,8 +1293,8 @@@ void SvgBuilder::_flushText() 
          last_delta_pos = delta_pos;
  
          // Append the character to the text buffer
 -      if (0 != glyph.code[0]) {
 -            text_buffer.append((char *)&glyph.code, 1);
 +      if ( !glyph.code.empty() ) {
 +            text_buffer.append(1, glyph.code[0]);
        }
  
          glyphs_in_a_row++;
@@@ -1333,8 -1333,8 +1335,8 @@@ void SvgBuilder::addChar(GfxState *stat
           return;
      }
      // Allow only one space in a row
 -    if ( is_space && _glyphs[_glyphs.size() - 1].code_size == 1 &&
 -         _glyphs[_glyphs.size() - 1].code[0] == 32 ) {
 +    if ( is_space && (_glyphs[_glyphs.size() - 1].code.size() == 1) &&
 +         (_glyphs[_glyphs.size() - 1].code[0] == 32) ) {
          Geom::Point delta(dx, dy);
          _text_position += delta;
          return;
      _text_position += delta;
  
      // Convert the character to UTF-8 since that's our SVG document's encoding
 -    static UnicodeMap *u_map = NULL;
 -    if ( u_map == NULL ) {
 -        GooString *enc = new GooString("UTF-8");
 -        u_map = globalParams->getUnicodeMap(enc);
 -        u_map->incRefCnt();
 -        delete enc;
 -    }
 -    int code_size = 0;
 -    for ( int i = 0 ; i < uLen ; i++ ) {
 -        code_size += u_map->mapUnicode(u[i], (char *)&new_glyph.code[code_size], sizeof(new_glyph.code) - code_size);
 +    {
 +        gunichar2 uu[8] = {0};
 +
 +        for (int i = 0; i < uLen; i++) {
 +            uu[i] = u[i];
 +        }
 +
 +        gchar *tmp = g_utf16_to_utf8(uu, uLen, NULL, NULL, NULL);
 +        if ( tmp && *tmp ) {
 +            new_glyph.code = tmp;
 +        } else {
 +            new_glyph.code.clear();
 +        }
 +        g_free(tmp);
      }
 -    new_glyph.code_size = code_size;
  
      // Copy current style if it has changed since the previous glyph
      if (_invalidated_style || _glyphs.size() == 0 ) {
index 7b1fe8b870f25174eec19d6484b7ac224a75985e,fc8c1a6668bdecffe88848fcd0f5c2544f7f6406..a130b692354142786208ac3b1bd8fcfe97aa75bd
@@@ -10,6 -10,6 +10,7 @@@
   *
   * Authors:
   *   Bob Jamison <ishmal@inkscape.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2008 Authors
   *
@@@ -300,7 -300,7 +301,7 @@@ bool PovOutput::doCurve(SPItem *item, c
      povShapes.push_back(shapeInfo); //passed all tests.  save the info
  
      // convert the path to only lineto's and cubic curveto's:
-     Geom::Matrix tf = sp_item_i2d_affine(item);
+     Geom::Matrix tf = item->i2d_affine();
      Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
  
      /*
@@@ -727,4 -727,4 +728,4 @@@ PovOutput::init(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index b10aa87ec0d4d62fbe6b04be28f8056b801d12da,e80e316cfe975ceb968f1663633c893d80435ba4..946ff22fe196a7651d2efce60f1efc866f864aed
@@@ -6,6 -6,6 +6,8 @@@
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   Ted Gould <ted@gould.cx>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2002-2003 Authors
   *
@@@ -182,19 -182,19 +184,19 @@@ Svg::open (Inkscape::Extension::Input *
  #ifdef WITH_GNOME_VFS
      if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) {
          // Use built-in loader instead of VFS for this
-         return sp_document_new(uri, TRUE);
+         return SPDocument::createNewDoc(uri, TRUE);
      }
      gchar * buffer = _load_uri(uri);
      if (buffer == NULL) {
          g_warning("Error:  Could not open file '%s' with VFS\n", uri);
          return NULL;
      }
-     SPDocument * doc = sp_document_new_from_mem(buffer, strlen(buffer), 1);
+     SPDocument * doc = SPDocument::createNewDocFromMem(buffer, strlen(buffer), 1);
  
      g_free(buffer);
      return doc;
  #else
-     return sp_document_new (uri, TRUE);
+     return SPDocument::createNewDoc(uri, TRUE);
  #endif
  }
  
@@@ -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();
      }
  
index 0c711824ce75b191f9d6d36bb5560d7904b549a8,3522ab2479442d76d395962598a5cfc4bc702f0f..8b4ff13c840b34138f4bd1cb202a5be47fa50251
@@@ -3,6 -3,6 +3,7 @@@
   */
  /* Author:
   *   Lauris Kaplinski <lauris@kaplinski.com>
++ *   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;
  
@@@ -506,4 -506,4 +507,4 @@@ PrintWin32::init (void
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index c37d5705b4bc0b0077fc2506a9b129ed0b6bd79f,02247ffa049c68c9bac38738d654762f31130062..70fa28967aa72ba21a7b1b73d2edd02dbdf43cb1
@@@ -6,6 -6,6 +6,7 @@@
   *
   * Authors:
   *   Ted Gould <ted@gould.cx>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006 Authors
   *
@@@ -86,7 -86,7 +87,7 @@@ WpgInput::open(Inkscape::Extension::Inp
  
      //printf("I've got a doc: \n%s", painter.document.c_str());
  
-     SPDocument * doc = sp_document_new_from_mem(output.cstr(), strlen(output.cstr()), TRUE);
+     SPDocument * doc = SPDocument::createNewDocFromMem(output.cstr(), strlen(output.cstr()), TRUE);
      delete input;
      return doc;
  }
index 94260cc56523e59ed3bdd0416d86a952e21c6e5f,3320cddcac2fd2ea8047d1563fa75b0bcf476ce1..ac7c8b8dd7df668cda1b4d9dd8f95496b88beac9
@@@ -4,6 -4,6 +4,7 @@@
  /* Author:
   *   Ted Gould <ted@gould.cx>
   *   Johan Engelen <johan@shouraizou.nl>
++ *   Jon A. Cruz <jon@joncruz.org>
   *
   * Copyright (C) 2005-2007 Authors
   *
@@@ -35,7 -35,6 +36,7 @@@
  #include "bool.h"
  #include "color.h"
  #include "description.h"
 +#include "groupheader.h"
  #include "enum.h"
  #include "float.h"
  #include "int.h"
@@@ -135,8 -134,6 +136,8 @@@ Parameter::make (Inkscape::XML::Node * 
          }
      } else if (!strcmp(type, "description")) {
          param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
 +    } else if (!strcmp(type, "groupheader")) {
 +        param = new ParamGroupHeader(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);        
      } else if (!strcmp(type, "enum")) {
          param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
      } else if (!strcmp(type, "notebook")) {
      return param;
  }
  
 -
 -
  /** \brief  Wrapper to cast to the object and use it's function.  */
  bool
  Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node)
@@@ -295,7 -294,7 +296,7 @@@ Parameter::Parameter (const gchar * nam
      }
      if (desc != NULL) {
          _desc = g_strdup(desc);
 -        // printf("Adding description: '%s' on '%s'\n", _desc, _name);
 +//        printf("Adding description: '%s' on '%s'\n", _desc, _name);
      }
      if (gui_tip != NULL) {
          _gui_tip = g_strdup(gui_tip);
@@@ -316,7 -315,6 +317,7 @@@ Parameter::~Parameter (void
      g_free(_name);
      g_free(_text);
        g_free(_gui_tip);
 +    g_free(_desc);
  }
  
  /** \brief  Build the name to write the parameter from the extension's
@@@ -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;
  
@@@ -407,13 -405,6 +407,13 @@@ Parameter::string (std::list <std::stri
      return;
  }
  
 +/** \brief  All the code in Notebook::get_param to get the notebook content */
 +Parameter *
 +Parameter::get_param(const gchar * name)
 +{
 +    return NULL;
 +}
 +
  Glib::ustring const extension_pref_root = "/extensions/";
  
  }  /* namespace Extension */
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/extension/print.h
index 8ae71b8e6a31bc5f9244e4e5d059ccc56a12c095,bc275b3b5589847641723018911be53cf62f0512..0f0435c0f9ac58c1ada30d9b2af26403ed85f08b
@@@ -1,6 -1,6 +1,7 @@@
  /*
   * Authors:
   *   Ted Gould <ted@gould.cx>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2002-2004 Authors
   *
@@@ -14,7 -14,7 +15,7 @@@
  
  #include "display/nr-arena-forward.h"
  #include "forward.h"
+ #include "sp-item.h"
  namespace Inkscape {
  namespace Extension {
  
diff --combined src/extension/system.cpp
index 5412a5cc0b2a5de3c9e59cbcefa8060917be3016,8cfc58797c84b3e74b4a14566640f01585fdfc78..cf58f2733f27285224af9f974934699ca93a16c2
@@@ -7,6 -7,6 +7,8 @@@
   * Authors:
   *   Ted Gould <ted@gould.cx>
   *   Johan Engelen <johan@shouraizou.nl>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006-2007 Johan Engelen
   * Copyright (C) 2002-2004 Ted Gould
@@@ -111,7 -111,7 +113,7 @@@ open(Extension *key, gchar const *filen
         to make sure for this release -- TJG */
      doc->setModifiedSinceSave(false);
  
-     sp_document_set_uri(doc, filename);
+     doc->setUri(filename);
  
      return doc;
  }
@@@ -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;
      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);
                  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);
      }
  
      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
  
      // 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");
              }
              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 --combined src/file.cpp
index f7cd6a09afb06e30f1811cd91eb8e23422171eb2,15e5bbe721e59549b5cb88042cb868299d937b1a..bde985ea56c2e3f670d6d41eafac6358b7ccd8f7
@@@ -7,6 -7,6 +7,8 @@@
   *   bulia byak <buliabyak@users.sf.net>
   *   Bruno Dilly <bruno.dilly@gmail.com>
   *   Stephen Silver <sasilver@users.sourceforge.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
   * Copyright (C) 1999-2008 Authors
@@@ -31,6 -31,8 +33,6 @@@
  #include <glibmm/i18n.h>
  #include <libnr/nr-pixops.h>
  
 -#include "application/application.h"
 -#include "application/editor.h"
  #include "desktop.h"
  #include "desktop-handles.h"
  #include "dialogs/export.h"
  #include "uri.h"
  #include "xml/rebase-hrefs.h"
  
++using Inkscape::DocumentUndo;
++
  #ifdef WITH_GNOME_VFS
  # include <libgnomevfs/gnome-vfs.h>
  #endif
  
 +#ifdef WITH_DBUS
 +#include "extension/dbus/dbus-init.h"
 +#endif
 +
  //#ifdef WITH_INKBOARD
  //#include "jabber_whiteboard/session-manager.h"
  //#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<SPDesktop*>(dtw->view);
++    SPDesktop *dt = static_cast<SPDesktop *>(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<SPDesktop*>(dtw->view);
 -        sp_namedview_window_from_document(dt);
 -        sp_namedview_update_layers_from_document(dt);
 -    }
      return dt;
  }
  
@@@ -236,25 -234,29 +235,25 @@@ 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<SPDesktop*>(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<SPDesktop*>(dtw->view);
          }
  
          doc->virgin = FALSE;
          // everyone who cares now has a reference, get rid of ours
-         sp_document_unref(doc);
+         doc->doUnref();
          // resize the window to match the document properties
          sp_namedview_window_from_document(desktop);
          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;
  /**
   *  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);
      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 &lt;defs&gt;"));
++    DocumentUndo::done(doc, SP_VERB_FILE_VACUUM,
++                       _("Vacuum &lt;defs&gt;"));
  
      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);
              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);
      }
  
          // 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
              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.
          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);
  
              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));
                  }
              }
          }
              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() );
              }
          }
  
-         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<Gtk::RecentManager> 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 --combined src/filter-chemistry.cpp
index 63e618dcf8fc2f297a2d98cbb7328ea1f922f191,9e0ee8383767f47ff5bf9346a70ada2a6190f81e..d6900b1f675ae8f28cffe0b598d8b0a42598cbcc
@@@ -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 <jon@joncruz.org>
++ *   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
  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;
      }
  
      //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;
      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;
      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
  SPFilter *
  new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, gdouble radius)
  {
-     Geom::OptRect const r = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX);
+     Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX);
  
      double width;
      double height;
          width = height = 0;
      }
  
-     Geom::Matrix i2d (sp_item_i2d_affine (item) );
+     Geom::Matrix i2d (item->i2d_affine () );
  
      return (new_filter_blend_gaussian_blur (document, mode, radius, i2d.descrim(), i2d.expansionX(), i2d.expansionY(), width, height));
  }
   * 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);
      }
  
      // Determine the required standard deviation value
-     Geom::Matrix i2d (sp_item_i2d_affine (item));
+     Geom::Matrix i2d (item->i2d_affine ());
      double expansion = i2d.descrim();
      double stdDeviation = radius;
      if (expansion != 0)
          stdDeviation /= expansion;
  
      // Get the object size
-     Geom::OptRect const r = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX);
+     Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX);
      double width;
      double height;
      if (r) {
@@@ -492,4 -498,4 +489,4 @@@ double get_single_gaussian_blur_radius(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/filters/blend.cpp
index 4c41184db4f9f4c6652538cae6c15910e1f377f7,f297ac199a6e309c8d848ea8ccc9e3ec0dde62fb..9a52d86f751c56929a4da47aa812521353af3558
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEBLEND_CPP__
--
  /** \file
   * SVG <feBlend> 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
   *
@@@ -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
      {
          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) {
@@@ -298,4 -300,4 +299,4 @@@ static void sp_feBlend_build_renderer(S
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index da1c91632fe6f9e646e60b3f3ffe0fc4ca0dd3c1,1b189ef377ea5e933b6253137a95e72fbc4ae1e9..6018afe093c0b445a85d7d5b1b14fbbeac6dc08c
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FECOLORMATRIX_CPP__
--
  /** \file
   * SVG <feColorMatrix> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   Felipe Sanches <juca@members.fsf.org>
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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" );
  }
  
  /**
@@@ -227,4 -227,4 +226,4 @@@ static void sp_feColorMatrix_build_rend
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 2fad817971c2e16ca20edc374a5cb9348f67d430,a45716e08e8f3551a22f103b827b3f9441291aac..a245e1c89f21349c81d16e0e2ca1ba2a9fe60bb2
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEFUNCNODE_CPP__
--
  /** \file
   * SVG <funcR>, <funcG>, <funcB> and <funcA> implementations.
   */
@@@ -8,6 -8,6 +6,7 @@@
   *   Hugo Rodrigues <haa.rodrigues@gmail.com>
   *   Niko Kiirala <niko@kiirala.com>
   *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
++ *   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) {
@@@ -342,4 -342,4 +341,4 @@@ TODO: I'm not sure what to do here..
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index f1d4a709bbeb06a43c6a4eaa3612b0177ca2db9b,e8a5739987630f8b33552667e9e4cc9495e7d682..c6ff4f5f200c0a835c6e74fbb084ab3fa5d60055
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FECOMPONENTTRANSFER_CPP__
--
  /** \file
   * SVG <feComponentTransfer> implementation.
   *
@@@ -7,6 -7,6 +5,7 @@@
  /*
   * Authors:
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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)
@@@ -259,4 -259,4 +258,4 @@@ static void sp_feComponentTransfer_buil
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 9398aeea766666c3bb9ffc5986ee8cbfc8879748,ae5be1a81be5a889d1eada458c8e486a465b3022..c2b47c4c2d487c1ab5597e00437bf761b456ca55
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FECOMPOSITE_CPP__
--
  /** \file
   * SVG <feComposite> implementation.
   *
@@@ -7,6 -7,6 +5,7 @@@
  /*
   * Authors:
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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. */
@@@ -240,7 -240,9 +239,9 @@@ sp_feComposite_update(SPObject *object
      {
          SPFilter *parent = SP_FILTER(object->parent);
          comp->in2 = sp_filter_primitive_name_previous_out(comp);
-         object->repr->setAttribute("in2", sp_filter_name_for_image(parent, comp->in2));
+               //XML Tree being used directly here while it shouldn't be.
+         object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, comp->in2));
      }
  
      if (((SPObjectClass *) feComposite_parent_class)->update) {
@@@ -344,4 -346,4 +345,4 @@@ static void sp_feComposite_build_render
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 45c0a080efea76dd69a69df128ef5fd684a6b343,2f91c9db5daef7437263f773ec534fae9a550c9f..3f141996793a39df1e18191e2827e5a9de84de62
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FECONVOLVEMATRIX_CPP__
--
  /** \file
   * SVG <feConvolveMatrix> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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" );
  }
  
  /**
@@@ -343,4 -343,4 +342,4 @@@ static void sp_feConvolveMatrix_build_r
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index ca7a8423cacee396063133dcb5c6409646c48829,5681bddc1ff0ece0b478d0160efeea354ebbb3c9..95faa4a2923546bbba6618a94958ad30513a1fca
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEDIFFUSELIGHTING_CPP__
--
  /** \file
   * SVG <feDiffuseLighting> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
   *   Jean-Rene Reinhard <jr@komite.net>
++ *   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) {
@@@ -380,4 -380,4 +379,4 @@@ static void sp_feDiffuseLighting_build_
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 956719d10c909bdc91d58a5bc86bb0cdbf5aed7f,ded7aab4520a4902d8d54b6638276de2752209ea..a6ad8b81aa70295b54b6b341652a6df5a3ea1453
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEDISPLACEMENTMAP_CPP__
--
  /** \file
   * SVG <feDisplacementMap> implementation.
   *
@@@ -7,6 -7,6 +5,7 @@@
  /*
   * Authors:
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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) {
@@@ -310,4 -312,4 +311,4 @@@ static void sp_feDisplacementMap_build_
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index ee366a23d95f2479bafa00e007cf5abe85a1e220,3a56f682b418b24689098d25626dfd324fb22f29..2207bc8e449535829a2b842388ccfba3986e8397
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEDISTANTLIGHT_CPP__
--
  /** \file
   * SVG <fedistantlight> implementation.
   */
@@@ -8,6 -8,6 +6,7 @@@
   *   Hugo Rodrigues <haa.rodrigues@gmail.com>
   *   Niko Kiirala <niko@kiirala.com>
   *   Jean-Rene Reinhard <jr@komite.net>
++ *   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) {
@@@ -231,4 -231,4 +230,4 @@@ sp_fedistantlight_write(SPObject *objec
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/filters/flood.cpp
index cf7ce662fc3eba7ff2ac9b3052076b6895d777c2,f5179cb41a2e330e7984330d55c71260131396ff..25780c1aec9cb4cc1062b3ae66ae5a8164ef6dc3
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEFLOOD_CPP__
--
  /** \file
   * SVG <feFlood> implementation.
   *
@@@ -7,6 -7,6 +5,7 @@@
  /*
   * Authors:
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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" );
  }
  
  /**
@@@ -241,4 -241,4 +240,4 @@@ static void sp_feFlood_build_renderer(S
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/filters/image.cpp
index 69a4b601833c72a1e8560a2168e5d2e298893438,1180799f4c677ad3fd14cbe730bdb24be5b1a5bc..bbe775c18b5e294f938769841047a68b994c738b
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEIMAGE_CPP__
--
  /** \file
   * SVG <feImage> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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" );
  
  }
  
@@@ -274,4 -274,4 +273,4 @@@ static void sp_feImage_build_renderer(S
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 1f92df4d662cedcd707fb13a6c61f46a6dd4e321,c135c06fb5e06c3fa5c021c2ac30bc62181789eb..b7b06a94a4dd2bb82b68a575b950e1667945ff40
@@@ -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 <kees@outflux.net>
   *   Niko Kiirala <niko@kiirala.com>
++ *   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" );
  }
  
  /**
@@@ -174,4 -174,4 +173,4 @@@ sp_feMergeNode_write(SPObject *object, 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 668f94c4c37bd6d5ce0500b4bad1654b978796d6,2724dc5b634f9f882c61408af4392b714ce42a54..7ae65c48ded2734434862fbe8adc66b6b76f0126
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEMORPHOLOGY_CPP__
--
  /** \file
   * SVG <feMorphology> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   Felipe Sanches <juca@members.fsf.org>
   *   Hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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" );
  }
  
  /**
@@@ -222,4 -222,4 +221,4 @@@ static void sp_feMorphology_build_rende
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/filters/offset.cpp
index 2db9316500c1e46e4566c60d82f378bd94d191ec,64f6661fe4af4167b835272f1adbaedc66ef8081..48ee895dc88d9c0657ca3f5999d37949db8d82de
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEOFFSET_CPP__
--
  /** \file
   * SVG <feOffset> 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
   *
@@@ -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) {
@@@ -206,4 -206,4 +205,4 @@@ static void sp_feOffset_build_renderer(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index a4939023eaabc6e134e4cd1202d7ca9a949e916b,55513ccb83a9ab8b160212608d55b349c0065514..c9eebcb18868dfa371ac17bf4645cd5822908894
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FEPOINTLIGHT_CPP__
--
  /** \file
   * SVG <fepointlight> implementation.
   */
@@@ -8,6 -8,6 +6,7 @@@
   *   Hugo Rodrigues <haa.rodrigues@gmail.com>
   *   Niko Kiirala <niko@kiirala.com>
   *   Jean-Rene Reinhard <jr@komite.net>
++ *   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) {
@@@ -256,4 -256,4 +255,4 @@@ sp_fepointlight_write(SPObject *object
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 6ed540892e640d2d902b6772bc62c92eed32cef3,fcc6c697a559db9dd3d326064a36c5e104d90e36..41eb38e61aa78c09a193c42670cd9d5f2642c5af
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FESPECULARLIGHTING_CPP__
--
  /** \file
   * SVG <feSpecularLighting> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
   *   Jean-Rene Reinhard <jr@komite.net>
++ *   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) {
@@@ -404,4 -404,4 +403,4 @@@ static void sp_feSpecularLighting_build
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 6d13479756015a6e48d3e241a54213a053778a42,6e0c0cbd09d4543d7ddb3f24e4898e522c4fb902..dac9b87e7d11f7cf3cb75aec066758e2ee51cca6
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FESPOTLIGHT_CPP__
--
  /** \file
   * SVG <fespotlight> implementation.
   */
@@@ -8,6 -8,6 +6,7 @@@
   *   Hugo Rodrigues <haa.rodrigues@gmail.com>
   *   Niko Kiirala <niko@kiirala.com>
   *   Jean-Rene Reinhard <jr@komite.net>
++ *   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) {
@@@ -369,4 -369,4 +368,4 @@@ sp_fespotlight_write(SPObject *object, 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 268eca643b0b21863c364c5f5f22d47c93589db6,8c2d0387e73e58a2fd6dc0d9f6b83f18620f3593..739001311da63814c822c86d3f9dcf51114d587b
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_FETURBULENCE_CPP__
--
  /** \file
   * SVG <feTurbulence> implementation.
   *
@@@ -8,6 -8,6 +6,7 @@@
   * Authors:
   *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
   *   hugo Rodrigues <haa.rodrigues@gmail.com>
++ *   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" );
  }
  
  /**
@@@ -279,4 -279,4 +278,4 @@@ static void sp_feTurbulence_build_rende
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/flood-context.cpp
index 282ccbeb6285b81004fb5f6bce783c080997a24e,b9aaf902e39fd5fd075bb95a2f934484f02b3945..dd26782a37897239b14882be3fad5febee95c517
@@@ -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 <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
   *   John Bintz <jcoswell@coswellproductions.org>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
   * 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);
@@@ -261,10 -261,10 +263,10 @@@ GList * flood_channels_dropdown_items_l
  GList * flood_autogap_dropdown_items_list() {
      GList *glist = NULL;
  
 -    glist = g_list_append (glist, _("None"));
 -    glist = g_list_append (glist, _("Small"));
 -    glist = g_list_append (glist, _("Medium"));
 -    glist = g_list_append (glist, _("Large"));
 +    glist = g_list_append (glist, (void*) C_("Flood autogap", "None"));
 +    glist = g_list_append (glist, (void*) C_("Flood autogap", "Small"));
 +    glist = g_list_append (glist, (void*) C_("Flood autogap", "Medium"));
 +    glist = g_list_append (glist, (void*) C_("Flood autogap", "Large"));
  
      return glist;
  }
@@@ -417,8 -417,9 +419,8 @@@ static void do_trace(bitmap_coords_inf
      std::vector<Inkscape::Trace::TracingEngineResult> 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;
  
              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) {
-             sp_item_write_transform(SP_ITEM(reprobj), pathRepr, transform, NULL);
+             SP_ITEM(reprobj)->doWriteTransform(pathRepr, transform, NULL);
              
              // premultiply the item transform by the accumulated parent transform in the paste layer
-             Geom::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer())));
+             Geom::Matrix local (SP_GROUP(desktop->currentLayer())->i2doc_affine());
              if (!local.isIdentity()) {
                  gchar const *t_str = pathRepr->attribute("transform");
                  Geom::Matrix item_t (Geom::identity());
@@@ -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) {
      unsigned int height = (int)ceil(screen.height() * zoom_scale * padding);
  
      Geom::Point origin(screen.min()[Geom::X],
-                        sp_document_height(document) - screen.height() - screen.min()[Geom::Y]);
+                        document->getHeight() - screen.height() - screen.min()[Geom::Y]);
                      
      origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2));
      origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2));
      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);
      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);
      
      }
  
      for (unsigned int i = 0; i < fill_points.size(); i++) {
-         Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, sp_document_height(document) + (fill_points[i][Geom::Y] / zoom_scale)) * affine;
+         Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, document->getHeight() + (fill_points[i][Geom::Y] / zoom_scale)) * affine;
  
          pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X]));
          pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[Geom::Y]));
  
      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)
              
              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;
@@@ -1300,4 -1303,4 +1301,4 @@@ void flood_channels_set_channels( gint 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/forward.h
index d4a98fbff915016f7c4b14e848307406fecccffe,e090b68b7891ca520ecf4b87dad98040596daf2d..97d2c15ed437b70f925189699b5520f6514cdc29
@@@ -6,6 -6,6 +6,7 @@@
   *
   * Author:
   *   Lauris Kaplinski <lauris@kaplinski.com>
++ *   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;
  
index d5b3ddb0978ab1d12193525f9176d51030958361,0d99e7fa6d4aee14c729e4edb36c73e87d5f68a1..fb5dab648249b11873d83796c86b256a48b483d4
@@@ -6,6 -6,6 +6,7 @@@
   *   bulia byak
   *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
   *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2010 Authors
   * Copyright (C) 2007 Johan Engelen
@@@ -40,7 -40,6 +41,7 @@@
  #include "svg/css-ostringstream.h"
  #include "preferences.h"
  
 +#define noSP_GR_VERBOSE
  
  // Terminology:
  //
  
  static void sp_gradient_repr_set_link(Inkscape::XML::Node *repr, SPGradient *gr);
  
 -SPGradient *
 -sp_gradient_ensure_vector_normalized(SPGradient *gr)
 +SPGradient *sp_gradient_ensure_vector_normalized(SPGradient *gr)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_ensure_vector_normalized(%p)", gr);
 +#endif
      g_return_val_if_fail(gr != NULL, NULL);
      g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
  
   * Creates new private gradient for the given vector
   */
  
 -static SPGradient *
 -sp_gradient_get_private_normalized(SPDocument *document, SPGradient *vector, SPGradientType type)
 +static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGradient *vector, SPGradientType type)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_get_private_normalized(%p, %p, %d)", document, vector, type);
 +#endif
 +
      g_return_val_if_fail(document != NULL, NULL);
      g_return_val_if_fail(vector != NULL, NULL);
      g_return_val_if_fail(SP_IS_GRADIENT(vector), NULL);
  
      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) {
  /**
  Count how many times gr is used by the styles of o and its descendants
  */
 -guint
 -count_gradient_hrefs(SPObject *o, SPGradient *gr)
 +guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
  {
      if (!o)
          return 1;
          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);
      }
  
  /**
   * If gr has other users, create a new private; also check if gr links to vector, relink if not
   */
 -SPGradient *
 -sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector,
 -                                      SPGradientType type, SPObject *o)
 +SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector,
 +                                                  SPGradientType type, SPObject *o)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_fork_private_if_necessary(%p, %p, %d, %p)", gr, vector, type, o);
 +#endif
      g_return_val_if_fail(gr != NULL, NULL);
      g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
  
  
      // 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 */
      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
      }
  }
  
 -SPGradient *
 -sp_gradient_fork_vector_if_necessary (SPGradient *gr)
 +SPGradient *sp_gradient_fork_vector_if_necessary(SPGradient *gr)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_fork_vector_if_necessary(%p)", gr);
 +#endif
      // Some people actually prefer their gradient vectors to be shared...
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
      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);
  /**
   *  Obtain the vector from the gradient. A forked vector will be created and linked to this gradient if another gradient uses it.
   */
 -SPGradient *
 -sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector)
 +SPGradient *sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_get_forked_vector_if_necessary(%p, %d)", gradient, force_vector);
 +#endif
      SPGradient *vector = gradient->getVector(force_vector);
      vector = sp_gradient_fork_vector_if_necessary (vector);
      if ( gradient != vector && gradient->ref->getObject() != vector ) {
   * instead. No forking or reapplying is done because this is only called for newly created privates.
   * @return The new gradient.
   */
 -SPGradient *
 -sp_gradient_reset_to_userspace (SPGradient *gr, SPItem *item)
 +SPGradient *sp_gradient_reset_to_userspace(SPGradient *gr, SPItem *item)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_reset_to_userspace(%p, %p)", gr, item);
 +#endif
      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)
   * Convert an item's gradient to userspace if necessary, also fork it if necessary.
   * @return The new gradient.
   */
 -SPGradient *
 -sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar const *property)
 +SPGradient *sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar const *property)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_convert_to_userspace(%p, %p, \"%s\")", gr, item, property);
 +#endif
      g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
  
 +    if ( gr && gr->isSolid() ) {
 +        return gr;
 +    }
 +
      // First, fork it if it is shared
      gr = sp_gradient_fork_private_if_necessary(gr, gr->getVector(),
                                                 SP_IS_RADIALGRADIENT(gr) ? SP_GRADIENT_TYPE_RADIAL : SP_GRADIENT_TYPE_LINEAR, SP_OBJECT(item));
          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 ) {
      return gr;
  }
  
 -void
 -sp_gradient_transform_multiply(SPGradient *gradient, Geom::Matrix postmul, bool set)
 +void sp_gradient_transform_multiply(SPGradient *gradient, Geom::Matrix postmul, bool set)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_transform_multiply(%p, , %d)", gradient, set);
 +#endif
      if (set) {
          gradient->gradientTransform = postmul;
      } else {
      g_free(c);
  }
  
 -SPGradient *
 -sp_item_gradient (SPItem *item, bool fill_or_stroke)
 +SPGradient *sp_item_gradient(SPItem *item, bool fill_or_stroke)
  {
 -    SPStyle *style = SP_OBJECT_STYLE (item);
 -    SPGradient *gradient = NULL;
 +    SPStyle *style = item->style;
 +    SPGradient *gradient = 0;
  
      if (fill_or_stroke) {
          if (style && (style->fill.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
 -            if (SP_IS_GRADIENT (server)) {
 -                gradient = SP_GRADIENT (server);
 +            SPPaintServer *server = item->style->getFillPaintServer();
 +            if ( SP_IS_GRADIENT(server) ) {
 +                gradient = SP_GRADIENT(server);
              }
          }
      } else {
          if (style && (style->stroke.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
 -            if (SP_IS_GRADIENT (server)) {
 -                gradient = SP_GRADIENT (server);
 +            SPPaintServer *server = item->style->getStrokePaintServer();
 +            if ( SP_IS_GRADIENT(server) ) {
 +                gradient = SP_GRADIENT(server);
              }
          }
      }
     return gradient;
  }
  
 -SPStopsp_last_stop(SPGradient *gradient)
 +SPStop *sp_last_stop(SPGradient *gradient)
  {
      for (SPStop *stop = gradient->getFirstStop(); stop != NULL; stop = stop->getNextStop()) {
          if (stop->getNextStop() == NULL)
      return NULL;
  }
  
 -SPStop*
 -sp_get_stop_i(SPGradient *gradient, guint stop_i)
 +SPStop *sp_get_stop_i(SPGradient *gradient, guint stop_i)
  {
      SPStop *stop = gradient->getFirstStop();
  
      return stop;
  }
  
 -guint32
 -average_color (guint32 c1, guint32 c2, gdouble p)
 +guint32 average_color(guint32 c1, guint32 c2, gdouble p)
  {
      guint32 r = (guint32) (SP_RGBA32_R_U (c1) * (1 - p) + SP_RGBA32_R_U (c2) * p);
      guint32 g = (guint32) (SP_RGBA32_G_U (c1) * (1 - p) + SP_RGBA32_G_U (c2) * p);
      guint32 b = (guint32) (SP_RGBA32_B_U (c1) * (1 - p) + SP_RGBA32_B_U (c2) * p);
      guint32 a = (guint32) (SP_RGBA32_A_U (c1) * (1 - p) + SP_RGBA32_A_U (c2) * p);
  
 -    return SP_RGBA32_U_COMPOSE (r, g, b, a);
 +    return SP_RGBA32_U_COMPOSE(r, g, b, a);
  }
  
 -SPStop *
 -sp_vector_add_stop (SPGradient *vector, SPStop* prev_stop, SPStop* next_stop, gfloat offset)
 +SPStop *sp_vector_add_stop(SPGradient *vector, SPStop* prev_stop, SPStop* next_stop, gfloat offset)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_vector_add_stop(%p, %p, %p, %f)", vector, prev_stop, next_stop, offset);
 +#endif
 +
      Inkscape::XML::Node *new_stop_repr = NULL;
      new_stop_repr = SP_OBJECT_REPR(prev_stop)->duplicate(SP_OBJECT_REPR(vector)->document());
      SP_OBJECT_REPR(vector)->addChild(new_stop_repr, SP_OBJECT_REPR(prev_stop));
      return newstop;
  }
  
 -void
 -sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
 +void sp_item_gradient_edit_stop(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
  {
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
  
      }
  }
  
 -guint32
 -sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
 +guint32 sp_item_gradient_stop_query_style(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
  {
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
  
      return 0;
  }
  
 -void
 -sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop)
 +void sp_item_gradient_stop_set_style(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_item_gradient_stop_set_style(%p, %d, %d, %d, %p)", item, point_type, point_i, fill_or_stroke, stop);
 +#endif
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
  
      if (!gradient || !SP_IS_GRADIENT(gradient))
      }
  }
  
 -void
 -sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke)
 +void sp_item_gradient_reverse_vector(SPItem *item, bool fill_or_stroke)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_item_gradient_reverse_vector(%p, %d)", item, fill_or_stroke);
 +#endif
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
      if (!gradient || !SP_IS_GRADIENT(gradient))
          return;
      GSList *child_reprs = NULL;
      GSList *child_objects = NULL;
      std::vector<double> 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));
  Set the position of point point_type of the gradient applied to item (either fill_or_stroke) to
  p_w (in desktop coordinates). Write_repr if you want the change to become permanent.
  */
 -void
 -sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, Geom::Point p_w, bool fill_or_stroke, bool write_repr, bool scale)
 +void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i, Geom::Point p_w, bool fill_or_stroke, bool write_repr, bool scale)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_item_gradient_set_coords(%p, %d, %d, ...)", item, point_type, point_i );
 +#endif
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
  
      if (!gradient || !SP_IS_GRADIENT(gradient))
  
      gradient = sp_gradient_convert_to_userspace (gradient, item, fill_or_stroke? "fill" : "stroke");
  
-     Geom::Matrix i2d (sp_item_i2d_affine (item));
+     Geom::Matrix i2d (item->i2d_affine ());
      Geom::Point p = p_w * i2d.inverse();
      p *= (gradient->gradientTransform).inverse();
      // now p is in gradient's original coordinates
      }
  }
  
 -SPGradient *
 -sp_item_gradient_get_vector (SPItem *item, bool fill_or_stroke)
 +SPGradient *sp_item_gradient_get_vector(SPItem *item, bool fill_or_stroke)
  {
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
  
      return NULL;
  }
  
 -SPGradientSpread
 -sp_item_gradient_get_spread (SPItem *item, bool fill_or_stroke)
 +SPGradientSpread sp_item_gradient_get_spread(SPItem *item, bool fill_or_stroke)
  {
      SPGradientSpread spread = SP_GRADIENT_SPREAD_PAD;
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
@@@ -1006,11 -983,9 +1005,11 @@@ Returns the position of point point_typ
  in desktop coordinates.
  */
  
 -Geom::Point
 -sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
 +Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_item_gradient_get_coords(%p, %d, %d, %d)", item, point_type, point_i, fill_or_stroke);
 +#endif
      SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
  
      Geom::Point p (0, 0);
      }
  
      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,
                              bbox->min()[Geom::X], bbox->min()[Geom::Y]);
          }
      }
-     p *= Geom::Matrix(gradient->gradientTransform) * (Geom::Matrix)sp_item_i2d_affine(item);
+     p *= Geom::Matrix(gradient->gradientTransform) * (Geom::Matrix)item->i2d_affine();
      return from_2geom(p);
  }
  
   * gr has to be a normalized vector.
   */
  
 -SPGradient *
 -sp_item_set_gradient(SPItem *item, SPGradient *gr, SPGradientType type, bool is_fill)
 +SPGradient *sp_item_set_gradient(SPItem *item, SPGradient *gr, SPGradientType type, bool is_fill)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_item_set_gradient(%p, %p, %d, %d)", item, gr, type, is_fill);
 +#endif
      g_return_val_if_fail(item != NULL, NULL);
      g_return_val_if_fail(SP_IS_ITEM(item), NULL);
      g_return_val_if_fail(gr != NULL, NULL);
          /* 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
  
  static void sp_gradient_repr_set_link(Inkscape::XML::Node *repr, SPGradient *link)
  {
 +#ifdef SP_GR_VERBOSE
 +    g_message("sp_gradient_repr_set_link(%p, %p)", repr, link);
 +#endif
      g_return_if_fail(repr != NULL);
      if (link) {
          g_return_if_fail(SP_IS_GRADIENT(link));
      }
  }
  
 -/*
 - * Get default normalized gradient vector of document, create if there is none
 - */
  
 -SPGradient *
 -sp_document_default_gradient_vector(SPDocument *document, guint32 color)
 +static void addStop( Inkscape::XML::Node *parent, Glib::ustring const &color, gint opacity, gchar const *offset )
  {
 -    SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
 -    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
 -
 -    Inkscape::XML::Node *repr = xml_doc->createElement("svg:linearGradient");
 -
 -    repr->setAttribute("inkscape:collect", "always");
 -    // set here, but removed when it's edited in the gradient editor
 -    // to further reduce clutter, we could
 -    // (1) here, search gradients by color and return what is found without duplication
 -    // (2) in fill & stroke, show only one copy of each gradient in list
 -
 -    Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop");
 -
 -    gchar b[64];
 -    sp_svg_write_color(b, sizeof(b), color);
 -
 +#ifdef SP_GR_VERBOSE
 +    g_message("addStop(%p, %s, %d, %s)", parent, color.c_str(), opacity, offset);
 +#endif
 +    Inkscape::XML::Node *stop = parent->document()->createElement("svg:stop");
      {
 -        gchar *t = g_strdup_printf("stop-color:%s;stop-opacity:1;", b);
 -        stop->setAttribute("style", t);
 -        g_free(t);
 +        gchar *tmp = g_strdup_printf( "stop-color:%s;stop-opacity:%d;", color.c_str(), opacity );
 +        stop->setAttribute( "style", tmp );
 +        g_free(tmp);
      }
  
 -    stop->setAttribute("offset", "0");
 +    stop->setAttribute( "offset", offset );
  
 -    repr->appendChild(stop);
 +    parent->appendChild(stop);
      Inkscape::GC::release(stop);
 +}
  
 -    stop = xml_doc->createElement("svg:stop");
 +/*
 + * Get default normalized gradient vector of document, create if there is none
 + */
 +SPGradient *sp_document_default_gradient_vector( SPDocument *document, SPColor const &color, bool singleStop )
 +{
 +    SPDefs *defs = static_cast<SPDefs *>(SP_DOCUMENT_DEFS(document));
 +    Inkscape::XML::Document *xml_doc = document->rdoc;
  
 -    {
 -        gchar *t = g_strdup_printf("stop-color:%s;stop-opacity:0;", b);
 -        stop->setAttribute("style", t);
 -        g_free(t);
 -    }
 +    Inkscape::XML::Node *repr = xml_doc->createElement("svg:linearGradient");
  
 -    stop->setAttribute("offset", "1");
 +    if ( !singleStop ) {
 +        repr->setAttribute("inkscape:collect", "always");
 +        // set here, but removed when it's edited in the gradient editor
 +        // to further reduce clutter, we could
 +        // (1) here, search gradients by color and return what is found without duplication
 +        // (2) in fill & stroke, show only one copy of each gradient in list
 +    }
  
 -    repr->appendChild(stop);
 -    Inkscape::GC::release(stop);
 +    Glib::ustring colorStr = color.toString();
 +    addStop( repr, colorStr, 1, "0" );
 +    if ( !singleStop ) {
 +        addStop( repr, colorStr, 0, "1" );
 +    }
  
      SP_OBJECT_REPR(defs)->addChild(repr, NULL);
      Inkscape::GC::release(repr);
  
      /* fixme: This does not look like nice */
 -    SPGradient *gr;
 -    gr = (SPGradient *) document->getObjectByRepr(repr);
 +    SPGradient *gr = static_cast<SPGradient *>(document->getObjectByRepr(repr));
      g_assert(gr != NULL);
      g_assert(SP_IS_GRADIENT(gr));
      /* fixme: Maybe add extra sanity check here */
  Return the preferred vector for \a o, made from (in order of preference) its current vector,
  current fill or stroke color, or from desktop style if \a o is NULL or doesn't have style.
  */
 -SPGradient *
 -sp_gradient_vector_for_object(SPDocument *const doc, SPDesktop *const desktop,
 -                              SPObject *const o, bool const is_fill)
 +SPGradient *sp_gradient_vector_for_object( SPDocument *const doc, SPDesktop *const desktop,
 +                                           SPObject *const o, bool const is_fill, bool singleStop )
  {
 -    guint32 rgba = 0;
 +    SPColor color;
      if (o == NULL || SP_OBJECT_STYLE(o) == NULL) {
 -        rgba = sp_desktop_get_color(desktop, is_fill);
 +        color = sp_desktop_get_color(desktop, is_fill);
      } else {
          // take the color of the object
          SPStyle const &style = *SP_OBJECT_STYLE(o);
                                    ? style.fill
                                    : style.stroke );
          if (paint.isPaintserver()) {
 -            SPObject *server = is_fill? SP_OBJECT_STYLE_FILL_SERVER(o) : SP_OBJECT_STYLE_STROKE_SERVER(o);
 -            if (SP_IS_GRADIENT (server)) {
 +            SPObject *server = is_fill? o->style->getFillPaintServer() : o->style->getStrokePaintServer();
 +            if ( SP_IS_GRADIENT(server) ) {
                  return SP_GRADIENT(server)->getVector(true);
              } else {
 -                rgba = sp_desktop_get_color(desktop, is_fill);
 +                color = sp_desktop_get_color(desktop, is_fill);
              }
          } else if (paint.isColor()) {
 -            rgba = paint.value.color.toRGBA32( 0xff );
 +            color = paint.value.color;
          } else {
              // if o doesn't use flat color, then take current color of the desktop.
 -            rgba = sp_desktop_get_color(desktop, is_fill);
 +            color = sp_desktop_get_color(desktop, is_fill);
          }
      }
  
 -    return sp_document_default_gradient_vector(doc, rgba);
 +    return sp_document_default_gradient_vector( doc, color, singleStop );
  }
  
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/gradient-context.cpp
index f104bbd413aad9a0666b4b15d3ec29a9f242420c,2e6544b637a975162e2401cf6eb6f287ce7bf89e..d37e9b02270ba0e21149dda51c2842161893f18e
@@@ -1,9 -1,11 +1,10 @@@
 -#define __SP_GRADIENT_CONTEXT_C__
 -
  /*
   * Gradient drawing and editing tool
   *
   * Authors:
   *   bulia byak <buliabyak@users.sf.net>
   *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
++ *   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;
          }
                  SnapManager &m = desktop->namedview->snap_manager;
                  m.setup(desktop);
                  m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +                m.unSetup();
                  rc->origin = from_2geom(button_dt);
              }
  
  
                  Geom::Point const motion_w(event->motion.x, event->motion.y);
                  Geom::Point const motion_dt = event_context->desktop->w2d(motion_w);
 +
                  m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +                m.unSetup();
              }
  
              bool over_line = false;
                      }
                  }
                  // 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;
@@@ -925,7 -924,7 +927,7 @@@ static void sp_gradient_drag(SPGradient
                                     -1, // ignore number (though it is always 1)
                                     fill_or_stroke, 99999, 99999, etime);
          }
-         // We did an undoable action, but sp_document_done will be called by the knot when released
+         // We did an undoable action, but SPDocumentUndo::done will be called by the knot when released
  
          // status text; we do not track coords because this branch is run once, not all the time
          // during drag
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/gradient-drag.cpp
index d5ab64794cb33ad544bc56c102c6afd073273ebe,e6dc22cea61f4e7761c7134cd97214ae17c20b55..2e9a21acf2ccceb0786e36ae253a8c716c073e9d
@@@ -1,3 -1,5 +1,3 @@@
 -#define __GRADIENT_DRAG_C__
 -
  /*
   * On-canvas gradient dragging
   *
@@@ -5,6 -7,6 +5,7 @@@
   *   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) 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,91 -178,41 +179,91 @@@ 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
  
      // any of color properties, in order of increasing priority:
 -    if (css->attribute("flood-color"))
 +    if (css->attribute("flood-color")) {
          sp_repr_css_set_property (stop, "stop-color", css->attribute("flood-color"));
 +    }
  
 -    if (css->attribute("lighting-color"))
 +    if (css->attribute("lighting-color")) {
          sp_repr_css_set_property (stop, "stop-color", css->attribute("lighting-color"));
 +    }
  
 -    if (css->attribute("color"))
 +    if (css->attribute("color")) {
          sp_repr_css_set_property (stop, "stop-color", css->attribute("color"));
 +    }
  
 -    if (css->attribute("stroke") && strcmp(css->attribute("stroke"), "none"))
 +    if (css->attribute("stroke") && strcmp(css->attribute("stroke"), "none")) {
          sp_repr_css_set_property (stop, "stop-color", css->attribute("stroke"));
 +    }
  
 -    if (css->attribute("fill") && strcmp(css->attribute("fill"), "none"))
 +    if (css->attribute("fill") && strcmp(css->attribute("fill"), "none")) {
          sp_repr_css_set_property (stop, "stop-color", css->attribute("fill"));
 +    }
  
 -    if (css->attribute("stop-color"))
 +    if (css->attribute("stop-color")) {
          sp_repr_css_set_property (stop, "stop-color", css->attribute("stop-color"));
 +    }
 +
 +    // Make sure the style is allowed for gradient stops.
 +    if ( !sp_repr_css_property_is_unset( stop, "stop-color") ) {
 +        bool stopIsNull = false;
 +        Glib::ustring tmp = makeStopSafeColor( sp_repr_css_property( stop, "stop-color", "" ), stopIsNull );
 +        if ( !stopIsNull && !tmp.empty() ) {
 +            sp_repr_css_set_property( stop, "stop-color", tmp.c_str() );
 +        }
 +    }
  
  
      if (css->attribute("stop-opacity")) { // direct setting of stop-opacity has priority
 -        sp_repr_css_set_property (stop, "stop-opacity", css->attribute("stop-opacity"));
 +        sp_repr_css_set_property(stop, "stop-opacity", css->attribute("stop-opacity"));
      } else {  // multiply all opacity properties:
          gdouble accumulated = 1.0;
          accumulated *= sp_svg_read_percentage(css->attribute("flood-opacity"), 1.0);
  
          Inkscape::CSSOStringStream os;
          os << accumulated;
 -        sp_repr_css_set_property (stop, "stop-opacity", os.str().c_str());
 +        sp_repr_css_set_property(stop, "stop-opacity", os.str().c_str());
  
          if ((css->attribute("fill") && !css->attribute("stroke") && !strcmp(css->attribute("fill"), "none")) ||
 -            (css->attribute("stroke") && !css->attribute("fill") && !strcmp(css->attribute("stroke"), "none")))
 -            sp_repr_css_set_property (stop, "stop-opacity", "0"); // if a single fill/stroke property is set to none, don't change color, set opacity to 0
 +            (css->attribute("stroke") && !css->attribute("fill") && !strcmp(css->attribute("stroke"), "none"))) {
 +            sp_repr_css_set_property(stop, "stop-opacity", "0"); // if a single fill/stroke property is set to none, don't change color, set opacity to 0
 +        }
      }
  
      if (!stop->attributeList()) { // nothing for us here, pass it on
          return false;
      }
  
 -    for (GList const* sel = drag->selected; sel != NULL; sel = sel->next) { // for all selected draggers
 -        GrDragger* dragger = (GrDragger*) sel->data;
 +    for (GList const* sel = selected; sel != NULL; sel = sel->next) { // for all selected draggers
 +        GrDragger* dragger = reinterpret_cast<GrDragger*>(sel->data);
          for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
 -               GrDraggable *draggable = (GrDraggable *) i->data;
 +            GrDraggable *draggable = reinterpret_cast<GrDraggable *>(i->data);
  
 -               drag->local_change = true;
 -               sp_item_gradient_stop_set_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop);
 +            local_change = true;
 +            sp_item_gradient_stop_set_style(draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop);
          }
      }
  
@@@ -410,18 -361,14 +413,18 @@@ GrDrag::addStopNearPoint (SPItem *item
  bool
  GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p)
  {
 +    // Note: not sure if a null pointer can come in for the style, but handle that just in case
 +    bool stopIsNull = false;
 +    Glib::ustring toUse = makeStopSafeColor( c, stopIsNull );
 +
      // first, see if we can drop onto one of the existing draggers
      for (GList *i = draggers; i != NULL; i = i->next) { // for all draggables of dragger
          GrDragger *d = (GrDragger *) i->data;
  
          if (Geom::L2(p - d->point)*desktop->current_zoom() < 5) {
             SPCSSAttr *stop = sp_repr_css_attr_new ();
 -           sp_repr_css_set_property (stop, "stop-color", c);
 -           sp_repr_css_set_property (stop, "stop-opacity", "1");
 +           sp_repr_css_set_property( stop, "stop-color", stopIsNull ? 0 : toUse.c_str() );
 +           sp_repr_css_set_property( stop, "stop-opacity", "1" );
             for (GSList *j = d->draggables; j != NULL; j = j->next) { // for all draggables of dragger
                 GrDraggable *draggable = (GrDraggable *) j->data;
                 local_change = true;
                  SPStop *stop = addStopNearPoint (line->item, p, 5/desktop->current_zoom());
                  if (stop) {
                      SPCSSAttr *css = sp_repr_css_attr_new ();
 -                    sp_repr_css_set_property (css, "stop-color", c);
 -                    sp_repr_css_set_property (css, "stop-opacity", "1");
 +                    sp_repr_css_set_property( css, "stop-color", stopIsNull ? 0 : toUse.c_str() );
 +                    sp_repr_css_set_property( css, "stop-opacity", "1" );
                      sp_repr_css_change (SP_OBJECT_REPR (stop), css, "style");
                      return true;
                  }
  }
  
  
 -GrDrag::GrDrag(SPDesktop *desktop) {
 -
 -    this->desktop = desktop;
 -
 -    this->selection = sp_desktop_selection(desktop);
 -
 -    this->draggers = NULL;
 -    this->lines = NULL;
 -    this->selected = NULL;
 -
 -    this->hor_levels.clear();
 -    this->vert_levels.clear();
 -
 -    this->local_change = false;
 -
 -    this->sel_changed_connection = this->selection->connectChanged(
 -        sigc::bind (
 +GrDrag::GrDrag(SPDesktop *desktop) :
 +    selected(0),
 +    keep_selection(false),
 +    local_change(false),
 +    desktop(desktop),
 +    hor_levels(),
 +    vert_levels(),
 +    draggers(0),
 +    lines(0),
 +    selection(sp_desktop_selection(desktop)),
 +    sel_changed_connection(),
 +    sel_modified_connection(),
 +    style_set_connection(),
 +    style_query_connection()
 +{
 +    sel_changed_connection = selection->connectChanged(
 +        sigc::bind(
              sigc::ptr_fun(&gr_drag_sel_changed),
              (gpointer)this )
  
          );
 -    this->sel_modified_connection = this->selection->connectModified(
 +    sel_modified_connection = selection->connectModified(
          sigc::bind(
              sigc::ptr_fun(&gr_drag_sel_modified),
              (gpointer)this )
          );
  
 -    this->style_set_connection = this->desktop->connectSetStyle(
 -        sigc::bind(
 -            sigc::ptr_fun(&gr_drag_style_set),
 -            (gpointer)this )
 -        );
 +    style_set_connection = desktop->connectSetStyle( sigc::mem_fun(*this, &GrDrag::styleSet) );
  
 -    this->style_query_connection = this->desktop->connectQueryStyle(
 +    style_query_connection = desktop->connectQueryStyle(
          sigc::bind(
              sigc::ptr_fun(&gr_drag_style_query),
              (gpointer)this )
          );
  
 -    this->updateDraggers ();
 -    this->updateLines ();
 -    this->updateLevels ();
 +    updateDraggers();
 +    updateLines();
 +    updateLevels();
  
      if (desktop->gr_item) {
 -        this->setSelected (getDraggerFor (desktop->gr_item, desktop->gr_point_type, desktop->gr_point_i, desktop->gr_fill_or_stroke));
 +        setSelected(getDraggerFor(desktop->gr_item, desktop->gr_point_type, desktop->gr_point_i, desktop->gr_fill_or_stroke));
      }
  }
  
@@@ -552,20 -503,35 +555,20 @@@ GrDraggable::~GrDraggable (
  }
  
  
 -SPObject *
 -GrDraggable::getServer ()
 +SPObject *GrDraggable::getServer()
  {
 -    if (!item)
 +    if (!item) {
          return NULL;
 +    }
  
      SPObject *server = NULL;
 -    if (fill_or_stroke)
 -        server = SP_OBJECT_STYLE_FILL_SERVER (item);
 -    else
 -        server = SP_OBJECT_STYLE_STROKE_SERVER (item);
 -
 -    return server;
 -}
 -
 -static
 -boost::optional<Geom::Point>
 -get_snap_vector (Geom::Point p, Geom::Point o, double snap, double initial)
 -{
 -    double r = L2 (p - o);
 -    if (r < 1e-3) {
 -        return boost::optional<Geom::Point>();
 +    if (fill_or_stroke) {
 +        server = item->style->getFillPaintServer();
 +    }else {
 +        server = item->style->getStrokePaintServer();
      }
  
 -    double angle = atan2 (p - o);
 -    // snap angle to snaps increments, starting from initial:
 -    double a_snapped = initial + floor((angle - initial)/snap + 0.5) * snap;
 -    // calculate the new position and subtract p to get the vector:
 -    return (o + r * Geom::Point(cos(a_snapped), sin(a_snapped)) - p);
 +    return server;
  }
  
  static void
@@@ -622,24 -588,22 +625,24 @@@ 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;
              }
          }
      }
  
 -    m.setup(desktop);
      if (!((state & GDK_SHIFT_MASK) || (state & GDK_CONTROL_MASK))) {
 +        m.setup(desktop);
          Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE));
 +        m.unSetup();
          if (s.getSnapped()) {
              p = s.getPoint();
              sp_knot_moveto (knot, p);
          }
      } else if (state & GDK_CONTROL_MASK) {
          SnappedConstraints sc;
 +        Inkscape::SnapCandidatePoint scp = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE);
          Inkscape::Preferences *prefs = Inkscape::Preferences::get();
          unsigned snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
          /* 0 means no snapping. */
                  dr_snap = dragger->point_original;
              }
  
 -            boost::optional<Geom::Point> snap_vector;
 +            // dr_snap contains the origin of the gradient, whereas p will be the new endpoint which we will try to snap now
 +            Inkscape::SnappedPoint sp;
              if (dr_snap.isFinite()) {
 +                m.setup(desktop);
                  if (state & GDK_MOD1_MASK) {
                      // with Alt, snap to the original angle and its perpendiculars
 -                    snap_vector = get_snap_vector (p, dr_snap, M_PI/2, Geom::atan2 (dragger->point_original - dr_snap));
 +                    sp = m.constrainedAngularSnap(scp, dragger->point_original, dr_snap, 2);
                  } else {
                      // with Ctrl, snap to M_PI/snaps
 -                    snap_vector = get_snap_vector (p, dr_snap, M_PI/snaps, 0);
 -                }
 -                if (snap_vector) {
 -                    Inkscape::Snapper::ConstraintLine cl(dr_snap, p + *snap_vector - dr_snap);
 -                    Inkscape::SnappedPoint s = m.constrainedSnap(Inkscape::SnapCandidatePoint(p + *snap_vector, Inkscape::SNAPSOURCE_OTHER_HANDLE), cl);
 -                    if (s.getSnapped()) {
 -                        s.setTransformation(s.getPoint() - p);
 -                        sc.points.push_back(s);
 -                    } else {
 -                        Inkscape::SnappedPoint dummy(p + *snap_vector, Inkscape::SNAPSOURCE_OTHER_HANDLE, 0, Inkscape::SNAPTARGET_CONSTRAINED_ANGLE, Geom::L2(*snap_vector), 10000, true, true, false);
 -                        dummy.setTransformation(*snap_vector);
 -                        sc.points.push_back(dummy);
 -                    }
 +                    sp = m.constrainedAngularSnap(scp, boost::optional<Geom::Point>(), dr_snap, snaps);
                  }
 +                m.unSetup();
 +                sc.points.push_back(sp);
              }
          }
  
 -        Inkscape::SnappedPoint bsp = m.findBestSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE), sc, true); // snap indicator will be displayed if needed
 -
 -        if (bsp.getSnapped()) {
 -            p += bsp.getTransformation();
 -            sp_knot_moveto (knot, p);
 +        m.setup(desktop, false); // turn of the snap indicator temporarily
 +        Inkscape::SnappedPoint bsp = m.findBestSnap(scp, sc, true);
 +        m.unSetup();
 +        if (!bsp.getSnapped()) {
 +            // If we didn't truly snap to an object or to a grid, then we will still have to look for the
 +            // closest projection onto one of the constraints. findBestSnap() will not do this for us
 +            for (std::list<Inkscape::SnappedPoint>::const_iterator i = sc.points.begin(); i != sc.points.end(); i++) {
 +                if (i == sc.points.begin() || (Geom::L2((*i).getPoint() - p) < Geom::L2(bsp.getPoint() - p))) {
 +                    bsp.setPoint((*i).getPoint());
 +                    bsp.setTarget(Inkscape::SNAPTARGET_CONSTRAINED_ANGLE);
 +                }
 +            }
          }
 +        //p = sc.points.front().getPoint();
 +        p = bsp.getPoint();
 +        sp_knot_moveto (knot, p);
      }
  
      drag->keep_selection = (bool) g_list_find(drag->selected, dragger);
@@@ -847,12 -809,10 +850,12 @@@ gr_knot_moved_midpoint_handler(SPKnot *
      } else {
          p = snap_vector_midpoint (p, low_lim, high_lim, 0);
          if (!(state & GDK_SHIFT_MASK)) {
 +            Inkscape::Snapper::SnapConstraint cl(low_lim, high_lim - low_lim);
              SPDesktop *desktop = dragger->parent->desktop;
              SnapManager &m = desktop->namedview->snap_manager;
 -            Inkscape::Snapper::ConstraintLine cl(low_lim, high_lim - low_lim);
 +            m.setup(desktop);
              m.constrainedSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE, cl);
 +            m.unSetup();
          }
      }
      Geom::Point displacement = p - dragger->point;
@@@ -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
@@@ -1140,7 -1100,7 +1143,7 @@@ GrDragger::updateTip (
  
      if (g_slist_length (this->draggables) == 1) {
          GrDraggable *draggable = (GrDraggable *) this->draggables->data;
-         char *item_desc = sp_item_description(draggable->item);
+         char *item_desc = draggable->item->description();
          switch (draggable->point_type) {
              case POINT_LG_MID:
              case POINT_RG_MID1:
@@@ -1663,43 -1623,41 +1666,43 @@@ GrDrag::grabKnot (SPItem *item, gint po
  Regenerates the draggers list from the current selection; is called when selection is changed or
  modified, also when a radial dragger needs to update positions of other draggers in the gradient
  */
 -void
 -GrDrag::updateDraggers ()
 +void GrDrag::updateDraggers ()
  {
      while (selected) {
          selected = g_list_remove(selected, selected->data);
      }
      // delete old draggers
      for (GList const* i = this->draggers; i != NULL; i = i->next) {
 -        delete ((GrDragger *) i->data);
 +        delete static_cast<GrDragger *>(i->data);
      }
 -    g_list_free (this->draggers);
 +    g_list_free(this->draggers);
      this->draggers = NULL;
  
 -    g_return_if_fail (this->selection != NULL);
 +    g_return_if_fail(this->selection != NULL);
  
      for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) {
 -
          SPItem *item = SP_ITEM(i->data);
 -        SPStyle *style = SP_OBJECT_STYLE (item);
 +        SPStyle *style = item->style;
  
          if (style && (style->fill.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
 -            if (SP_IS_LINEARGRADIENT (server)) {
 -                addDraggersLinear (SP_LINEARGRADIENT (server), item, true);
 -            } else if (SP_IS_RADIALGRADIENT (server)) {
 -                addDraggersRadial (SP_RADIALGRADIENT (server), item, true);
 +            SPPaintServer *server = style->getFillPaintServer();
 +            if ( server && server->isSolid() ) {
 +                // Suppress "gradientness" of solid paint
 +            } else if ( SP_IS_LINEARGRADIENT(server) ) {
 +                addDraggersLinear( SP_LINEARGRADIENT(server), item, true );
 +            } else if ( SP_IS_RADIALGRADIENT(server) ) {
 +                addDraggersRadial( SP_RADIALGRADIENT(server), item, true );
              }
          }
  
          if (style && (style->stroke.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
 -            if (SP_IS_LINEARGRADIENT (server)) {
 -                addDraggersLinear (SP_LINEARGRADIENT (server), item, false);
 -            } else if (SP_IS_RADIALGRADIENT (server)) {
 -                addDraggersRadial (SP_RADIALGRADIENT (server), item, false);
 +            SPPaintServer *server = style->getStrokePaintServer();
 +            if ( server && server->isSolid() ) {
 +                // Suppress "gradientness" of solid paint
 +            } else if ( SP_IS_LINEARGRADIENT(server) ) {
 +                addDraggersLinear( SP_LINEARGRADIENT(server), item, false );
 +            } else if ( SP_IS_RADIALGRADIENT(server) ) {
 +                addDraggersRadial( SP_RADIALGRADIENT(server), item, false );
              }
          }
      }
@@@ -1744,12 -1702,10 +1747,12 @@@ GrDrag::updateLines (
          SPStyle *style = SP_OBJECT_STYLE (item);
  
          if (style && (style->fill.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
 -            if (SP_IS_LINEARGRADIENT (server)) {
 +            SPPaintServer *server = item->style->getFillPaintServer();
 +            if ( server && server->isSolid() ) {
 +                // Suppress "gradientness" of solid paint
 +            } else if ( SP_IS_LINEARGRADIENT(server) ) {
                  this->addLine (item, sp_item_gradient_get_coords (item, POINT_LG_BEGIN, 0, true), sp_item_gradient_get_coords (item, POINT_LG_END, 0, true), GR_LINE_COLOR_FILL);
 -            } else if (SP_IS_RADIALGRADIENT (server)) {
 +            } else if ( SP_IS_RADIALGRADIENT(server) ) {
                  Geom::Point center = sp_item_gradient_get_coords (item, POINT_RG_CENTER, 0, true);
                  this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R1, 0, true), GR_LINE_COLOR_FILL);
                  this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R2, 0, true), GR_LINE_COLOR_FILL);
          }
  
          if (style && (style->stroke.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
 -            if (SP_IS_LINEARGRADIENT (server)) {
 +            SPPaintServer *server = item->style->getStrokePaintServer();
 +            if ( server && server->isSolid() ) {
 +                // Suppress "gradientness" of solid paint
 +            } else if ( SP_IS_LINEARGRADIENT(server) ) {
                  this->addLine (item, sp_item_gradient_get_coords (item, POINT_LG_BEGIN, 0, false), sp_item_gradient_get_coords (item, POINT_LG_END, 0, false), GR_LINE_COLOR_STROKE);
 -            } else if (SP_IS_RADIALGRADIENT (server)) {
 +            } else if ( SP_IS_RADIALGRADIENT(server) ) {
                  Geom::Point center = sp_item_gradient_get_coords (item, POINT_RG_CENTER, 0, false);
                  this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R1, 0, false), GR_LINE_COLOR_STROKE);
                  this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R2, 0, false), GR_LINE_COLOR_STROKE);
@@@ -1784,7 -1738,7 +1787,7 @@@ GrDrag::updateLevels (
  
      for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) {
          SPItem *item = SP_ITEM(i->data);
-         Geom::OptRect rect = sp_item_bbox_desktop (item);
+         Geom::OptRect rect = item->getBboxDesktop ();
          if (rect) {
              // Remember the edges of the bbox and the center axis
              hor_levels.push_back(rect->min()[Geom::Y]);
@@@ -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;
      }
  
          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)
          {
      }
  
      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 --combined src/graphlayout.cpp
index 0905cd94c96f3b8b0d57ce3ab2c9fbfa983c7cc0,13838d4cffa7ccfe933b1252a99855b014ac334e..4f536beb3a4cbe5f1fc31799aeb3309368eecdc0
@@@ -4,6 -4,6 +4,7 @@@
  /*
   * Authors:
   *   Tim Dwyer <Tim.Dwyer@infotech.monash.edu.au>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2005 Authors
   *
@@@ -126,7 -126,7 +127,7 @@@ void graphlayout(GSList const *const it
           ++i)
      {
          SPItem *u=*i;
-         Geom::OptRect const item_box(sp_item_bbox_desktop(u));
+         Geom::OptRect const item_box(u->getBboxDesktop());
          if(item_box) {
              Geom::Point ll(item_box->min());
              Geom::Point ur(item_box->max());
              map<string,unsigned>::iterator i=nodelookup.find(u->getId());
              if(i!=nodelookup.end()) {
                  Rectangle* r=rs[i->second];
-                 Geom::OptRect item_box(sp_item_bbox_desktop(u));
+                 Geom::OptRect item_box(u->getBboxDesktop());
                  if(item_box) {
                      Geom::Point const curr(item_box->midpoint());
                      Geom::Point const dest(r->getCentreX(),r->getCentreY());
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index f50062d2dab062152625d4167191643269e9b40d,b5630edd399b4be89c06ca1ee3b272a340e62391..69becad5dd421f83ed7a8bcad092680acd801045
@@@ -1,10 -1,10 +1,10 @@@
--#define __SP_PIXBUF_OPS_C__
--
  /*
   * Helpers for SPItem -> gdk_pixbuf related stuff
   *
   * Authors:
   *   John Cliff <simarilius@yahoo.com>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2008 John Cliff
   *
  
  #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)
           && !SP_IS_USE(o)
           && !g_slist_find(list, o) )
      {
-         sp_item_invoke_hide(SP_ITEM(o), dkey);
+         SP_ITEM(o)->invoke_hide(dkey);
      }
  
      // 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,16 -104,16 +104,16 @@@ 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));
  
       double padding = 1.0;
  
       Geom::Point origin(screen.min()[Geom::X],
-                       sp_document_height(doc) - screen[Geom::Y].extent() - screen.min()[Geom::Y]);
+                       doc->getHeight() - screen[Geom::Y].extent() - screen.min()[Geom::Y]);
  
       origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2));
       origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2));
       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);
       // 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;
      {
          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);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/helper/png-write.cpp
index 754372f23b35e40b22d22c2d2961c0a96090dac4,5ccb6c7fac2533d68fd1754840ea5c5a9df93a0e..d3fe2771ff8d07970153b3b1427879a0d08a0977
@@@ -1,11 -1,11 +1,11 @@@
--#define __SP_PNG_WRITE_C__
--
  /*
   * PNG file format utilities
   *
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   Whoever wrote this example in libpng documentation
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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)
           && !SP_IS_GROUP(o)
           && !g_slist_find(list, o) )
      {
-         sp_item_invoke_hide(SP_ITEM(o), dkey);
+         SP_ITEM(o)->invoke_hide(dkey);
      }
  
      // 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
      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;
      }
  
      // 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);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 1c184da725c75c4dc9eb0700c380f255aa8b3e64,6cdb50c351aaa8fad669b1d8ee4fbf4cce074d3d..4ec61c54aeb5b16a212723ae5b177582e075a966
@@@ -1,5 -1,5 +1,3 @@@
--#define __INK_STOCK_ITEMS__
--
  /*
   * Stock-items
   *
@@@ -7,6 -7,6 +5,8 @@@
   *
   * Authors:
   *  John Cliff <simarilius@yahoo.com>
++ *  Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright 2004 John Cliff
   *
@@@ -56,11 -56,11 +56,11 @@@ static SPObject * sp_marker_load_from_s
      if (!edoc && !doc) {
          gchar *markers = g_build_filename(INKSCAPE_MARKERSDIR, "/markers.svg", NULL);
          if (Inkscape::IO::file_test(markers, G_FILE_TEST_IS_REGULAR)) {
-             doc = sp_document_new(markers, FALSE);
+             doc = SPDocument::createNewDoc(markers, FALSE);
          }
          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);
@@@ -94,16 -94,16 +94,16 @@@ sp_pattern_load_from_svg(gchar const *n
      if (!edoc && !doc) {
          gchar *patterns = g_build_filename(INKSCAPE_PATTERNSDIR, "/patterns.svg", NULL);
          if (Inkscape::IO::file_test(patterns, G_FILE_TEST_IS_REGULAR)) {
-             doc = sp_document_new(patterns, FALSE);
+             doc = SPDocument::createNewDoc(patterns, FALSE);
          }
          if (!doc) {
          gchar *patterns = g_build_filename(CREATE_PATTERNSDIR, "/patterns.svg", NULL);
          if (Inkscape::IO::file_test(patterns, G_FILE_TEST_IS_REGULAR)) {
-             doc = sp_document_new(patterns, FALSE);
+             doc = SPDocument::createNewDoc(patterns, FALSE);
          }
          g_free(patterns);
          if (doc) {
-             sp_document_ensure_up_to_date(doc);
 -            doc->ensure_up_to_date();
++            doc->ensureUpToDate();
          } else {
              edoc = TRUE;
          }
          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);
@@@ -137,16 -137,16 +137,16 @@@ sp_gradient_load_from_svg(gchar const *
      if (!edoc && !doc) {
          gchar *gradients = g_build_filename(INKSCAPE_GRADIENTSDIR, "/gradients.svg", NULL);
          if (Inkscape::IO::file_test(gradients, G_FILE_TEST_IS_REGULAR)) {
-             doc = sp_document_new(gradients, FALSE);
+             doc = SPDocument::createNewDoc(gradients, FALSE);
          }
          if (!doc) {
          gchar *gradients = g_build_filename(CREATE_GRADIENTSDIR, "/gradients.svg", NULL);
          if (Inkscape::IO::file_test(gradients, G_FILE_TEST_IS_REGULAR)) {
-             doc = sp_document_new(gradients, FALSE);
+             doc = SPDocument::createNewDoc(gradients, FALSE);
          }
          g_free(gradients);
          if (doc) {
-             sp_document_ensure_up_to_date(doc);
 -            doc->ensure_up_to_date();
++            doc->ensureUpToDate();
          } else {
              edoc = TRUE;
          }
          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<SPDefs *>(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")) &&
              
          }
          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))
                  {
              
          }
          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 --combined src/id-clash.cpp
index 43ce393ddf6c82fa2999797b10664b8e2625a9d7,7572e6a42269a79cf5d71db604075f80bf08e3d1..0594fe8e66f6191d82faf2169bd553e98a12f659
@@@ -1,9 -1,9 +1,10 @@@
--#define __ID_CLASH_C__
  /** \file
   * Routines for resolving ID clashes when importing or pasting.
   *
   * Authors:
   *   Stephen Silver <sasilver@users.sourceforge.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2008 authors
   *
@@@ -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 --combined src/inkscape.cpp
index e4edb9d108c4a1369d1c98af324619dc08941de7,c10581a9161e683a7cf052b0b68b43df7fe41965..4309775675cd95924f7bb72ee6b2affc72059513
@@@ -45,6 -45,8 +45,6 @@@ using Inkscape::Extension::Internal::Pr
  #include <gtkmm/messagedialog.h>
  #include <signal.h>
  #include <string>
 -#include "application/application.h"
 -#include "application/editor.h"
  #include "desktop.h"
  #include "desktop-handles.h"
  #include "device-manager.h"
@@@ -91,6 -93,8 +91,6 @@@ enum 
  # FORWARD DECLARATIONS
  ################################*/
  
 -gboolean inkscape_app_use_gui( Inkscape::Application const * app );
 -
  static void inkscape_class_init (Inkscape::ApplicationClass *klass);
  static void inkscape_init (SPObject *object);
  static void inkscape_dispose (GObject *object);
@@@ -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;
  }
  
  
@@@ -553,13 -557,6 +553,13 @@@ inkscape_deactivate_desktop_private (In
  #define SP_INDENT 8
  
  
 +static bool crashIsHappening = false;
 +
 +bool inkscapeIsCrashing()
 +{
 +    return crashIsHappening;
 +}
 +
  static void
  inkscape_crash_handler (int /*signum*/)
  {
      }
      recursion = TRUE;
  
 +    crashIsHappening = true;
 +
      EventTracker<SimpleEvent<Inkscape::Debug::Event::CORE> > tracker("crash");
      tracker.set<SimpleEvent<> >("emergency-save");
  
            ++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, '.');
  
              // Find a location
              const char* locations[] = {
--                doc->base,
++                doc->getBase(),
                  g_get_home_dir(),
                  g_get_tmp_dir(),
                  curdir,
                  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++;
          }
      }
      *(b + pos) = '\0';
  
 -    if ( inkscape_get_instance() && inkscape_app_use_gui( inkscape_get_instance() ) ) {
 +    if ( inkscape_get_instance() && inkscape_use_gui() ) {
          GtkWidget *msgbox = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", b);
          gtk_dialog_run (GTK_DIALOG (msgbox));
          gtk_widget_destroy (msgbox);
@@@ -866,9 -861,9 +866,9 @@@ inkscape_get_instance(
          return inkscape;
  }
  
 -gboolean inkscape_app_use_gui( Inkscape::Application const * app )
 +gboolean inkscape_use_gui()
  {
 -    return app->use_gui;
 +    return inkscape_get_instance()->use_gui;
  }
  
  /**
@@@ -898,6 -893,10 +898,6 @@@ bool inkscape_load_menus (Inkscape::App
  void
  inkscape_selection_modified (Inkscape::Selection *selection, guint flags)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui()) {
 -        Inkscape::NSApplication::Editor::selectionModified (selection, flags);
 -        return;
 -    }
      g_return_if_fail (selection != NULL);
  
      if (DESKTOP_IS_ACTIVE (selection->desktop())) {
  void
  inkscape_selection_changed (Inkscape::Selection * selection)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui()) {
 -        Inkscape::NSApplication::Editor::selectionChanged (selection);
 -        return;
 -    }
      g_return_if_fail (selection != NULL);
  
      if (DESKTOP_IS_ACTIVE (selection->desktop())) {
  void
  inkscape_subselection_changed (SPDesktop *desktop)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui()) {
 -        Inkscape::NSApplication::Editor::subSelectionChanged (desktop);
 -        return;
 -    }
      g_return_if_fail (desktop != NULL);
  
      if (DESKTOP_IS_ACTIVE (desktop)) {
  void
  inkscape_selection_set (Inkscape::Selection * selection)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui()) {
 -        Inkscape::NSApplication::Editor::selectionSet (selection);
 -        return;
 -    }
      g_return_if_fail (selection != NULL);
  
      if (DESKTOP_IS_ACTIVE (selection->desktop())) {
  void
  inkscape_eventcontext_set (SPEventContext * eventcontext)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui()) {
 -        Inkscape::NSApplication::Editor::eventContextSet (eventcontext);
 -        return;
 -    }
      g_return_if_fail (eventcontext != NULL);
      g_return_if_fail (SP_IS_EVENT_CONTEXT (eventcontext));
  
@@@ -955,6 -970,12 +955,6 @@@ voi
  inkscape_add_desktop (SPDesktop * desktop)
  {
      g_return_if_fail (desktop != NULL);
 -
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        Inkscape::NSApplication::Editor::addDesktop (desktop);
 -        return;
 -    }
      g_return_if_fail (inkscape != NULL);
  
      g_assert (!g_slist_find (inkscape->desktops, desktop));
@@@ -973,6 -994,11 +973,6 @@@ voi
  inkscape_remove_desktop (SPDesktop * desktop)
  {
      g_return_if_fail (desktop != NULL);
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        Inkscape::NSApplication::Editor::removeDesktop (desktop);
 -        return;
 -    }
      g_return_if_fail (inkscape != NULL);
  
      g_assert (g_slist_find (inkscape->desktops, desktop));
@@@ -1008,6 -1034,11 +1008,6 @@@ voi
  inkscape_activate_desktop (SPDesktop * desktop)
  {
      g_return_if_fail (desktop != NULL);
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        Inkscape::NSApplication::Editor::activateDesktop (desktop);
 -        return;
 -    }
      g_return_if_fail (inkscape != NULL);
  
      if (DESKTOP_IS_ACTIVE (desktop)) {
@@@ -1037,6 -1068,11 +1037,6 @@@ voi
  inkscape_reactivate_desktop (SPDesktop * desktop)
  {
      g_return_if_fail (desktop != NULL);
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        Inkscape::NSApplication::Editor::reactivateDesktop (desktop);
 -        return;
 -    }
      g_return_if_fail (inkscape != NULL);
  
      if (DESKTOP_IS_ACTIVE (desktop))
@@@ -1150,8 -1186,13 +1150,8 @@@ inkscape_switch_desktops_prev (
  void
  inkscape_dialogs_hide ()
  {
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -        Inkscape::NSApplication::Editor::hideDialogs();
 -    else
 -    {
 -        g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0);
 -        inkscape->dialogs_toggle = FALSE;
 -    }
 +    g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_HIDE], 0);
 +    inkscape->dialogs_toggle = FALSE;
  }
  
  
  void
  inkscape_dialogs_unhide ()
  {
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -        Inkscape::NSApplication::Editor::unhideDialogs();
 -    else
 -    {
 -        g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0);
 -        inkscape->dialogs_toggle = TRUE;
 -    }
 +    g_signal_emit (G_OBJECT (inkscape), inkscape_signals[DIALOGS_UNHIDE], 0);
 +    inkscape->dialogs_toggle = TRUE;
  }
  
  
@@@ -1191,17 -1237,24 +1191,17 @@@ inkscape_add_document (SPDocument *docu
  {
      g_return_if_fail (document != NULL);
  
 -    if (!Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        // try to insert the pair into the list
 -        if (!(inkscape->document_set.insert(std::make_pair(document, 1)).second)) {
 -            //insert failed, this key (document) is already in the list
 -            for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
 -                   iter != inkscape->document_set.end();
 -                   ++iter) {
 -                if (iter->first == document) {
 -                    // found this document in list, increase its count
 -                    iter->second ++;
 -                }
 -           }
 -        }
 -    }
 -    else
 -    {
 -        Inkscape::NSApplication::Editor::addDocument (document);
 +    // try to insert the pair into the list
 +    if (!(inkscape->document_set.insert(std::make_pair(document, 1)).second)) {
 +        //insert failed, this key (document) is already in the list
 +        for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
 +               iter != inkscape->document_set.end();
 +               ++iter) {
 +            if (iter->first == document) {
 +                // found this document in list, increase its count
 +                iter->second ++;
 +            }
 +       }
      }
  }
  
@@@ -1212,21 -1265,28 +1212,21 @@@ inkscape_remove_document (SPDocument *d
  {
      g_return_val_if_fail (document != NULL, false);
  
 -    if (!Inkscape::NSApplication::Application::getNewGui())
 -    {
 -        for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
 -                  iter != inkscape->document_set.end();
 -                  ++iter) {
 -            if (iter->first == document) {
 -                // found this document in list, decrease its count
 -                iter->second --;
 -                if (iter->second < 1) {
 -                    // this was the last one, remove the pair from list
 -                    inkscape->document_set.erase (iter);
 -                    return true;
 -                } else {
 -                    return false;
 -                }
 +    for (std::map<SPDocument*,int>::iterator iter = inkscape->document_set.begin();
 +              iter != inkscape->document_set.end();
 +              ++iter) {
 +        if (iter->first == document) {
 +            // found this document in list, decrease its count
 +            iter->second --;
 +            if (iter->second < 1) {
 +                // this was the last one, remove the pair from list
 +                inkscape->document_set.erase (iter);
 +                return true;
 +            } else {
 +                return false;
              }
          }
      }
 -    else
 -    {
 -        Inkscape::NSApplication::Editor::removeDocument (document);
 -    }
  
      return false;
  }
  SPDesktop *
  inkscape_active_desktop (void)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -        return Inkscape::NSApplication::Editor::getActiveDesktop();
 -
      if (inkscape->desktops == NULL) {
          return NULL;
      }
  SPDocument *
  inkscape_active_document (void)
  {
 -    if (Inkscape::NSApplication::Application::getNewGui())
 -        return Inkscape::NSApplication::Editor::getActiveDocument();
 -
      if (SP_ACTIVE_DESKTOP) {
          return sp_desktop_document (SP_ACTIVE_DESKTOP);
      }
diff --combined src/inkview.cpp
index c151991dd8f469721d6c6b6bd9176f944bc0fbf0,35f150707d16b1c8713bb712f0734e5f918f113f..09adb8c2d3c684c763004bfa175fe272e4821a3b
@@@ -1,5 -1,5 +1,3 @@@
--#define __SPSVGVIEW_C__
--
  /*
   * Inkscape - an ambitious vector drawing program
   *
@@@ -14,6 -14,6 +12,7 @@@
   *   Chema Celorio <chema@celorio.com>
   *   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;
  }
  
@@@ -273,13 -273,13 +272,13 @@@ main (int argc, const char **argv
                            ss.slides = g_renew (char *, ss.slides, ss.size);
                        }
  
-                       ss.doc = sp_document_new_from_mem ((const gchar *)gba->data,
+                       ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data,
                                                           gba->len,
                                                           TRUE);
                        gchar *last_filename = jar_file_reader.get_last_filename();
                        if (ss.doc) {
                            ss.slides[ss.length++] = strdup (last_filename);
-                           sp_document_set_uri (ss.doc, strdup(last_filename));
+                           (ss.doc)->setUri (strdup(last_filename));
                        }
                        g_byte_array_free(gba, TRUE);
                        g_free(last_filename);
                ss.slides[ss.length++] = strdup (argv[i]);
  
                  if (!ss.doc) {
-                     ss.doc = sp_document_new (ss.slides[ss.current], TRUE, false);
+                     ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false);
                      if (!ss.doc)
                          ++ss.current;
                }
         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<SPSVGView*>(SP_VIEW_WIDGET_VIEW (ss->view))->setDocument (doc);
          ss->doc = doc;
          ss->current = current;
@@@ -459,7 -459,7 +458,7 @@@ sp_svgview_show_next (struct SPSlideSho
      SPDocument *doc = NULL;
      int current = ss->current;
      while (!doc && (current < ss->length - 1)) {
-         doc = sp_document_new (ss->slides[++current], TRUE, false);
+         doc = SPDocument::createNewDoc (ss->slides[++current], TRUE, false);
      }
  
      sp_svgview_set_document(ss, doc, current);
@@@ -475,7 -475,7 +474,7 @@@ sp_svgview_show_prev (struct SPSlideSho
      SPDocument *doc = NULL;
      int current = ss->current;
      while (!doc && (current > 0)) {
-         doc = sp_document_new (ss->slides[--current], TRUE, false);
+         doc = SPDocument::createNewDoc (ss->slides[--current], TRUE, false);
      }
  
      sp_svgview_set_document(ss, doc, current);
@@@ -493,7 -493,7 +492,7 @@@ sp_svgview_goto_first (struct SPSlideSh
      while ( !doc && (current < ss->length - 1)) {
          if (current == ss->current)
              break;
-         doc = sp_document_new (ss->slides[current++], TRUE, false);
+         doc = SPDocument::createNewDoc (ss->slides[current++], TRUE, false);
      }
  
      sp_svgview_set_document(ss, doc, current - 1);
@@@ -511,7 -511,7 +510,7 @@@ sp_svgview_goto_last (struct SPSlideSho
      while (!doc && (current >= 0)) {
          if (current == ss->current)
              break;
-         doc = sp_document_new (ss->slides[current--], TRUE, false);
+         doc = SPDocument::createNewDoc (ss->slides[current--], TRUE, false);
      }
  
      sp_svgview_set_document(ss, doc, current + 1);
diff --combined src/interface.cpp
index b51178eb8c4813f53bd47ea58223c0d0cedf59f3,4b95e8de6660575d76c39bd9a5a4511c035acbfc..0fd2b65ead4617801f81823cb04f3e033729d4b9
@@@ -1,3 -1,5 +1,3 @@@
 -#define __SP_INTERFACE_C__
 -
  /** @file
   * @brief Main UI stuff
   */
@@@ -5,6 -7,6 +5,8 @@@
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   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.
@@@ -71,6 -73,6 +73,8 @@@
  #include "ige-mac-menu.h"
  #endif
  
++using Inkscape::DocumentUndo;
++
  /* Drag and Drop */
  typedef enum {
      URI_LIST,
@@@ -132,8 -134,6 +136,8 @@@ static void sp_ui_menu_item_set_name(SP
                                       void *data);
  static void sp_recent_open(GtkRecentChooser *, gpointer);
  
 +static void injectRenamedIcons();
 +
  SPActionEventVector menu_item_event_vector = {
      {NULL},
      NULL,
@@@ -408,11 -408,6 +412,11 @@@ sp_ui_menu_deselect(gpointer object
  void
  sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name )
  {
 +    static bool iconsInjected = false;
 +    if ( !iconsInjected ) {
 +        iconsInjected = true;
 +        injectRenamedIcons();
 +    }
      GtkWidget *icon;
  
      icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name );
@@@ -461,12 -456,85 +465,12 @@@ sp_ui_menu_append_item( GtkMenu *menu, 
  
  } // end of sp_ui_menu_append_item()
  
 -/**
 -\brief  a wrapper around gdk_keyval_name producing (when possible) characters, not names
 - */
 -static gchar const *
 -sp_key_name(guint keyval)
 -{
 -    /* TODO: Compare with the definition of gtk_accel_label_refetch in gtk/gtkaccellabel.c (or
 -       simply use GtkAccelLabel as the TODO comment in sp_ui_shortcut_string suggests). */
 -    gchar const *n = gdk_keyval_name(gdk_keyval_to_upper(keyval));
 -
 -    if      (!strcmp(n, "asciicircum"))  return "^";
 -    else if (!strcmp(n, "parenleft"  ))  return "(";
 -    else if (!strcmp(n, "parenright" ))  return ")";
 -    else if (!strcmp(n, "plus"       ))  return "+";
 -    else if (!strcmp(n, "minus"      ))  return "-";
 -    else if (!strcmp(n, "asterisk"   ))  return "*";
 -    else if (!strcmp(n, "KP_Multiply"))  return "*";
 -    else if (!strcmp(n, "Delete"     ))  return "Del";
 -    else if (!strcmp(n, "Page_Up"    ))  return "PgUp";
 -    else if (!strcmp(n, "Page_Down"  ))  return "PgDn";
 -    else if (!strcmp(n, "grave"      ))  return "`";
 -    else if (!strcmp(n, "numbersign" ))  return "#";
 -    else if (!strcmp(n, "bar"        ))  return "|";
 -    else if (!strcmp(n, "slash"      ))  return "/";
 -    else if (!strcmp(n, "exclam"     ))  return "!";
 -    else if (!strcmp(n, "percent"    ))  return "%";
 -    else return n;
 -}
 -
 -
 -/**
 - * \param shortcut A GDK keyval OR'd with SP_SHORTCUT_blah_MASK values.
 - * \param c Points to a buffer at least 256 bytes long.
 - */
 -void
 -sp_ui_shortcut_string(unsigned const shortcut, gchar *const c)
 -{
 -    /* TODO: This function shouldn't exist.  Our callers should use GtkAccelLabel instead of
 -     * a generic GtkLabel containing this string, and should call gtk_widget_add_accelerator.
 -     * Will probably need to change sp_shortcut_invoke callers.
 -     *
 -     * The existing gtk_label_new_with_mnemonic call can be replaced with
 -     * g_object_new(GTK_TYPE_ACCEL_LABEL, NULL) followed by
 -     * gtk_label_set_text_with_mnemonic(lbl, str).
 -     */
 -    static GtkAccelLabelClass const &accel_lbl_cls
 -        = *(GtkAccelLabelClass const *) g_type_class_peek_static(GTK_TYPE_ACCEL_LABEL);
 -
 -    struct { unsigned test; char const *name; } const modifier_tbl[] = {
 -        { SP_SHORTCUT_SHIFT_MASK,   accel_lbl_cls.mod_name_shift   },
 -        { SP_SHORTCUT_CONTROL_MASK, accel_lbl_cls.mod_name_control },
 -        { SP_SHORTCUT_ALT_MASK,     accel_lbl_cls.mod_name_alt     }
 -    };
 -
 -    gchar *p = c;
 -    gchar *end = p + 256;
 -
 -    for (unsigned i = 0; i < G_N_ELEMENTS(modifier_tbl); ++i) {
 -        if ((shortcut & modifier_tbl[i].test)
 -            && (p < end))
 -        {
 -            p += g_snprintf(p, end - p, "%s%s",
 -                            modifier_tbl[i].name,
 -                            accel_lbl_cls.mod_separator);
 -        }
 -    }
 -    if (p < end) {
 -        p += g_snprintf(p, end - p, "%s", sp_key_name(shortcut & 0xffffff));
 -    }
 -    end[-1] = '\0';  // snprintf doesn't guarantee to nul-terminate the string.
 -}
 -
  void
  sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c)
  {
      SPAction     *action;
      unsigned int shortcut;
      gchar        *s;
 -    gchar        key[256];
      gchar        *atitle;
  
      action = verb->get_action(NULL);
      g_free(atitle);
  
      shortcut = sp_shortcut_get_primary(verb);
 -    if (shortcut) {
 +    if (shortcut!=GDK_VoidSymbol) {
 +        gchar* key = sp_shortcut_get_label(shortcut);
          s = g_stpcpy(s, " (");
 -        sp_ui_shortcut_string(shortcut, key);
          s = g_stpcpy(s, key);
          s = g_stpcpy(s, ")");
 +        g_free(key);
      }
  }
  
@@@ -515,8 -582,9 +519,8 @@@ sp_ui_menu_append_item_from_verb(GtkMen
          if (!action) return NULL;
  
          shortcut = sp_shortcut_get_primary(verb);
 -        if (shortcut) {
 -            gchar c[256];
 -            sp_ui_shortcut_string(shortcut, c);
 +        if (shortcut!=GDK_VoidSymbol) {
 +            gchar* c = sp_shortcut_get_label(shortcut);
              GtkWidget *const hb = gtk_hbox_new(FALSE, 16);
              GtkWidget *const name_lbl = gtk_label_new("");
              gtk_label_set_markup_with_mnemonic(GTK_LABEL(name_lbl), action->name);
                  item = gtk_image_menu_item_new();
              }
              gtk_container_add((GtkContainer *) item, hb);
 +            g_free(c);
          } else {
              if (radio) {
                  item = gtk_radio_menu_item_new (group);
@@@ -687,8 -754,9 +691,8 @@@ sp_ui_menu_append_check_item_from_verb(
      SPAction *action = (verb) ? verb->get_action(view) : 0;
      GtkWidget *item = gtk_check_menu_item_new();
  
 -    if (verb && shortcut) {
 -        gchar c[256];
 -        sp_ui_shortcut_string(shortcut, c);
 +    if (verb && shortcut!=GDK_VoidSymbol) {
 +        gchar* c = sp_shortcut_get_label(shortcut);
  
          GtkWidget *hb = gtk_hbox_new(FALSE, 16);
  
          gtk_widget_show_all(hb);
  
          gtk_container_add((GtkContainer *) item, hb);
 +        g_free(c);
      } else {
          GtkWidget *l = gtk_label_new_with_mnemonic(action ? action->name : label);
          gtk_misc_set_alignment((GtkMisc *) l, 0.0, 0.5);
@@@ -837,7 -904,7 +841,7 @@@ void addTaskMenuItems(GtkMenu *menu, In
      gchar const* data[] = {
          _("Default"), _("Default interface setup"),
          _("Custom"), _("Set the custom task"),
 -        _("Wide"), _("Setup for widescreen work."),
 +        _("Wide"), _("Setup for widescreen work"),
          0, 0
      };
  
@@@ -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);
                              g_free(str);
                              str = 0;
  
-                             sp_object_setAttribute( SP_OBJECT(item),
+                             SP_OBJECT(item)->setAttribute( 
                                                      fillnotstroke ? "inkscape:x-fill-tag":"inkscape:x-stroke-tag",
                                                      palName.c_str(),
                                                      false );
                      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"));
  
                      if ( srgbProf ) {
                                          //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();
                      }
                  }
                  //if (!consumed && tools_active(desktop, TOOLS_TEXT)) {
                  //    consumed = sp_text_context_drop_color(c, button_doc);
                  //    if (consumed) {
-                 //        sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient stop"));
+                 //        SPDocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient stop"));
                  //    }
                  //}
  
                                  ( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
                                    desktop->current_zoom() *
                                    SP_OBJECT_STYLE (item)->stroke_width.computed *
-                                   to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5
+                                   to_2geom(item->i2d_affine()).descrim() * 0.5
                                    : 0.0)
                                  + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
  
                      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") );
                  }
              }
          }
                          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() ) {
                  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();
                      }
                  }
                                  ( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
                                    desktop->current_zoom() *
                                    SP_OBJECT_STYLE (item)->stroke_width.computed *
-                                   to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5
+                                   to_2geom(item->i2d_affine()).descrim() * 0.5
                                    : 0.0)
                                  + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
  
                      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") );
                  }
              }
          }
              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);
  
              // 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() );
              }
  
              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;
          }
  
  
              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;
          }
      }
@@@ -1600,32 -1667,6 +1604,32 @@@ sp_ui_menu_item_set_name(SPAction */*ac
      //a menu item in yet another way...
  }
  
 +void injectRenamedIcons()
 +{
 +    Glib::RefPtr<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default();
 +
 +    std::vector< std::pair<Glib::ustring, Glib::ustring> > renamed;
 +    renamed.push_back(std::make_pair("gtk-file", "document-x-generic"));
 +    renamed.push_back(std::make_pair("gtk-directory", "folder"));
 +
 +    for ( std::vector< std::pair<Glib::ustring, Glib::ustring> >::iterator it = renamed.begin(); it < renamed.end(); ++it ) {
 +        bool hasIcon = iconTheme->has_icon(it->first);
 +        bool hasSecondIcon = iconTheme->has_icon(it->second);
 +
 +        if ( !hasIcon && hasSecondIcon ) {
 +            Glib::ArrayHandle<int> sizes = iconTheme->get_icon_sizes(it->second);
 +            for ( Glib::ArrayHandle<int>::iterator it2 = sizes.begin(); it2 < sizes.end(); ++it2 ) {
 +                Glib::RefPtr<Gdk::Pixbuf> pb = iconTheme->load_icon( it->second, *it2 );
 +                if ( pb ) {
 +                    // install a private copy of the pixbuf to avoid pinning a theme
 +                    Glib::RefPtr<Gdk::Pixbuf> pbCopy = pb->copy();
 +                    Gtk::IconTheme::add_builtin_icon( it->first, *it2, pbCopy );
 +                }
 +            }
 +        }
 +    }
 +}
 +
  
  /*
    Local Variables:
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/interface.h
index 30fda6a392b468b74e3be8dd3ffe0a00d6a0b7f7,a9cf584710ce72a44d3b5e1a80cb854201661f8a..01732e911002afab5952ba629790d5e398e2be17
@@@ -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 <lauris@kaplinski.com>
   *   Frank Felfe <innerspace@iname.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 1999-2002 authors
   * Copyright (C) 2001-2002 Ximian, Inc.
@@@ -17,7 -17,7 +18,7 @@@
  #include <gtk/gtkstyle.h>
  
  #include "forward.h"
+ #include "sp-item.h"
  
  /**
   *  Create a new document window.
@@@ -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:
@@@ -80,4 -82,4 +81,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index a506d472a8c999ec1e9888f0fea3da8ce3e351de,a506d472a8c999ec1e9888f0fea3da8ce3e351de..9f40a7dc6ff39cdfb0ed6e7851422eaf7944e283
@@@ -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)));
      }
  }
  
index 0dcd744c34026242469711f017d4a8319f174eea,b46aacaaef4f96ca8bafa327a30678c6ffd54e45..60d0b73781a47d1bbb7d4247af9496a4f70dfbe3
@@@ -4,6 -4,6 +4,7 @@@
   * Authors:
   * David Yip <yipdw@rose-hulman.edu>
   * Bob Jamison (Pedro port)
++ *   Abhishek Sharma
   *
   * Copyright (c) 2005 Authors
   *
@@@ -29,6 -29,9 +30,6 @@@
  
  #include "ui/view/view-widget.h"
  
 -#include "application/application.h"
 -#include "application/editor.h"
 -
  #include "document-private.h"
  #include "interface.h"
  #include "sp-namedview.h"
@@@ -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 = 
              "<span weight=\"bold\" size=\"larger\">" + 
              String::ucompose(_("<b>%1</b> has invited you to a whiteboard session."), from) + 
              "</span>\n\n" + 
@@@ -366,7 -369,7 +367,7 @@@ makeInkboardDocument(int code, gchar co
      Glib::ustring name = String::ucompose(
          _("Inkboard session (%1 to %2)"), SessionManager::instance().getClient().getJid(), to);
  
-     doc = sp_document_create(rdoc, NULL, NULL, name.c_str(), TRUE);
+     doc = SPDocument::createDoc(rdoc, NULL, NULL, name.c_str(), TRUE);
      g_return_val_if_fail(doc != NULL, NULL);
  
      return doc;
  // 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<SPDesktop*>(dtw->view);
 -        sp_namedview_window_from_document(dt);
 -        sp_namedview_update_layers_from_document(dt);
 -    }
 +    sp_create_window(dtw, TRUE);
-     dt = static_cast<SPDesktop*>(dtw->view);
++    SPDesktop *dt = static_cast<SPDesktop*>(dtw->view);
 +    sp_namedview_window_from_document(dt);
 +    sp_namedview_update_layers_from_document(dt);
  
      return dt;
  }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index f8f4866637afa5746f2fdeb3bf21586ac5303747,9e3a3babcf8c4b369fa2379c349a510aed702bd2..005ca24c71c1fbe2e1b8bbb8112c5c5401f4ed26
@@@ -1,11 -1,11 +1,10 @@@
--#define __KNOT_HOLDER_ENTITY_C__
--
  /** \file
   * KnotHolderEntity definition.
   *
   * Authors:
   *   Mitsuru Oka <oka326@parkcity.ne.jp>
   *   Maximilian Albert <maximilian.albert@gmail.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 1999-2001 Lauris Kaplinski
   * Copyright (C) 2000-2001 Ximian, Inc.
@@@ -77,7 -77,7 +76,7 @@@ KnotHolderEntity::~KnotHolderEntity(
  void
  KnotHolderEntity::update_knot()
  {
-     Geom::Matrix const i2d(sp_item_i2d_affine(item));
+     Geom::Matrix const i2d(item->i2d_affine());
  
      Geom::Point dp(knot_get() * i2d);
  
  Geom::Point
  KnotHolderEntity::snap_knot_position(Geom::Point const &p)
  {
-     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;
      m.setup(desktop, true, item);
 -
      m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +    m.unSetup();
  
      return s * i2d.inverse();
  }
  
  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;
      m.setup(desktop, true, item);
  
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 -    if ((prefs->getBool("/options/snapmousepointer/value", false))) { // legacy behavior (pre v0.47)
 -        // Snapping the mouse pointer instead of the constrained position of the knot allows to snap to
 -        // things which don't intersect with the constraint line. This should be handled by the
 -        // smart dynamic guides which are yet to be implemented, making this behavior more clean and
 -        // transparent. With the current implementation it leads to unexpected results, and it doesn't
 -        // allow accurately controlling what is being snapped to.
 -
 -        // freeSnap() will try snapping point p. This will not take into account the constraint, which
 -        // is therefore to be enforced after snap_knot_position_constrained() has finished
 -        m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -    } else {
 -        // constrainedSnap() will first project the point p onto the constraint line and then try to snap along that line.
 -        // This way the constraint is already enforced, no need to worry about that later on
 -        Inkscape::Snapper::ConstraintLine transformed_constraint = Inkscape::Snapper::ConstraintLine(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
 -        m.constrainedSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE, transformed_constraint);
 -    }
 +    // constrainedSnap() will first project the point p onto the constraint line and then try to snap along that line.
 +    // This way the constraint is already enforced, no need to worry about that later on
 +    Inkscape::Snapper::SnapConstraint transformed_constraint = Inkscape::Snapper::SnapConstraint(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
 +    m.constrainedSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE, transformed_constraint);
 +    m.unSetup();
  
      return s * i2d.inverse();
  }
@@@ -159,7 -170,7 +158,7 @@@ PatternKnotHolderEntityXY::knot_set(Geo
  
      if (state)  {
          Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat);
-         sp_item_adjust_pattern(item, Geom::Matrix(Geom::Translate(q)));
+         item->adjust_pattern(Geom::Matrix(Geom::Translate(q)));
      }
  
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@@ -209,7 -220,7 +208,7 @@@ PatternKnotHolderEntityAngle::knot_set(
      Geom::Point const t = sp_pattern_extract_trans(pat);
      rot[4] = t[Geom::X];
      rot[5] = t[Geom::Y];
-     sp_item_adjust_pattern(item, rot, true);
+     item->adjust_pattern(rot, true);
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
@@@ -243,7 -254,7 +242,7 @@@ PatternKnotHolderEntityScale::knot_set(
      Geom::Point const t = sp_pattern_extract_trans(pat);
      rot[4] = t[Geom::X];
      rot[5] = t[Geom::Y];
-     sp_item_adjust_pattern(item, rot, true);
+     item->adjust_pattern(rot, true);
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
@@@ -273,4 -284,4 +272,4 @@@ PatternKnotHolderEntityScale::knot_get(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/knot.cpp
index 824f16c3e596766a995a0f7c2756d57ca5d339b8,95a9ec1482b675614228b1c0bc2291aa0a597ae6..28c991fdec590cb479cc3df875db2493452acfa2
@@@ -1,11 -1,11 +1,10 @@@
--#define __SP_KNOT_C__
--
  /** \file
   * SPKnot implementation
   *
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   bulia byak <buliabyak@users.sf.net>
++ *   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;
  
      g_object_unref(knot);
  
 -    return consumed;
 +    return consumed || grabbed;
  }
  
  void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot)
diff --combined src/knotholder.cpp
index df5c1cad9d4f93e104786b1c98ffe9b3439afd72,23d610ad015cf90606fed98ea80ea835dffaa382..f5e28618eff8fb641fd5f2acfbc4a1cb85cfcde0
@@@ -1,5 -1,5 +1,3 @@@
--#define __KNOT_HOLDER_C__
--
  /*
   * Container for SPKnot visual handles
   *
@@@ -7,12 -7,12 +5,15 @@@
   *   Mitsuru Oka <oka326@parkcity.ne.jp>
   *   bulia byak <buliabyak@users.sf.net>
   *   Maximilian Albert <maximilian.albert@gmail.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2001-2008 authors
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
  
++#include <glibmm/i18n.h>
++
  #include "document.h"
  #include "sp-shape.h"
  #include "knot.h"
  
  #include "xml/repr.h" // for debugging only
  
--#include <glibmm/i18n.h>
++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");
@@@ -83,7 -84,7 +85,7 @@@ KnotHolder::~KnotHolder() 
  void
  KnotHolder::update_knots()
  {
-     Geom::Matrix const i2d(sp_item_i2d_affine(item));
+     Geom::Matrix const i2d(item->i2d_affine());
  
      for(std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i) {
          KnotHolderEntity *e = *i;
@@@ -121,7 -122,7 +123,7 @@@ KnotHolder::knot_clicked_handler(SPKno
      }
  
      if (SP_IS_SHAPE(item)) {
-         sp_shape_set_shape(SP_SHAPE(item));
+         SP_SHAPE(item)->setShape();
      }
  
      knot_holder->update_knots();
      }
  
      // 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
@@@ -163,14 -164,14 +165,14 @@@ KnotHolder::knot_moved_handler(SPKnot *
      for(std::list<KnotHolderEntity *>::iterator i = this->entity.begin(); i != this->entity.end(); ++i) {
          KnotHolderEntity *e = *i;
          if (e->knot == knot) {
-             Geom::Point const q = p * sp_item_i2d_affine(item).inverse();
-             e->knot_set(q, e->knot->drag_origin * sp_item_i2d_affine(item).inverse(), state);
+             Geom::Point const q = p * item->i2d_affine().inverse();
+             e->knot_set(q, e->knot->drag_origin * item->i2d_affine().inverse(), state);
              break;
          }
      }
  
      if (SP_IS_SHAPE (item)) {
-         sp_shape_set_shape(SP_SHAPE (item));
+         SP_SHAPE (item)->setShape();
      }
  
      this->update_knots();
@@@ -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"));
      }
  }
  
@@@ -270,4 -271,4 +272,4 @@@ KnotHolder::add_pattern_knotholder(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/layer-fns.cpp
index 7cf582f7af5506bf527b51809f2cb07b63a267b8,ca7c1c493f5d0dc4939d542df28f39bd332ce87f..84f21cd979b2377dc214c5e384a28a8294ea2ce7
@@@ -3,6 -3,6 +3,7 @@@
   *
   * Authors:
   *   MenTaLguY <mental@rydia.net>
++ *   Jon A. Cruz <jon@joncruz.org>
   *
   * 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<SPObject::SiblingIterator>(
--        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);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/layer-manager.cpp
index 1e1bb8c339ae9e9f9f8770e907e5ab6ac9fcc66b,0ee7f76a99a29f0442e581dcdc6ee6c66cb543a1..95cefc229f44351203035c37a2136e61a7bf4d39
@@@ -3,6 -3,6 +3,7 @@@
   *                          to a particular desktop
   *
   * Copyright 2006  MenTaLguY  <mental@rydia.net>
++ *   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<Glib::ustring> 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);
                          if ( group->layerMode() == SPGroup::LAYER ) {
                              // If we have a layer-group as the one or a parent, ensure it is listed as a valid layer.
                              needsAdd &= ( g_slist_find(const_cast<GSList *>(layers), curr) != NULL );
-                             if ( (!(group->repr)) || (!(group->repr->parent())) ) {
+                                                       // XML Tree being used here directly while it shouldn't be...
+                             if ( (!(group->getRepr())) || (!(group->getRepr()->parent())) ) {
                                  needsAdd = false;
                              }
                          } else {
                              // If a non-layer group is a parent of layer groups, then show it also as a layer.
                              // TODO add the magic Inkscape group mode?
-                             if ( group->repr && group->repr->parent() ) {
+                                                       // XML Tree being used directly while it shouldn't be...
+                             if ( group->getRepr() && group->getRepr()->parent() ) {
                                  additional.insert(group);
                              } else {
                                  needsAdd = false;
@@@ -341,4 -343,4 +344,4 @@@ void LayerManager::_selectedLayerChange
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 9dbd27b5041383c10ff45e94ed130433e367f429,2cc26e4e10ef88f58da2b2901c5eac571ec99855..3ea57de23f3f3110134db2e8654e8dd82d19c7ca
@@@ -1,7 -1,7 +1,6 @@@
--#define INKSCAPE_LIVEPATHEFFECT_CPP
--
  /*
   * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
++ *   Abhishek Sharma
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
@@@ -75,7 -75,6 +74,7 @@@
  #include "live_effects/lpe-line_segment.h"
  #include "live_effects/lpe-recursiveskeleton.h"
  #include "live_effects/lpe-extrude.h"
 +#include "live_effects/lpe-powerstroke.h"
  
  
  namespace Inkscape {
@@@ -101,7 -100,6 +100,7 @@@ const Util::EnumData<EffectType> LPETyp
      {PATH_LENGTH,           N_("Path length"),             "path_length"},
      {PERP_BISECTOR,         N_("Perpendicular bisector"),  "perp_bisector"},
      {PERSPECTIVE_PATH,      N_("Perspective path"),        "perspective_path"},
 +    {POWERSTROKE,           N_("Power stroke"),            "powerstroke"},
      {COPY_ROTATE,           N_("Rotate copies"),           "copy_rotate"},
      {RECURSIVE_SKELETON,    N_("Recursive skeleton"),      "recursive_skeleton"},
      {TANGENT_TO_CURVE,      N_("Tangent to curve"),        "tangent_to_curve"},
      {ROUGH_HATCHES,         N_("Hatches (rough)"),         "rough_hatches"},
      {SKETCH,                N_("Sketch"),                  "sketch"},
      {RULER,                 N_("Ruler"),                   "ruler"},
 +/* 0.49 */
  };
  const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
  
@@@ -240,9 -237,6 +239,9 @@@ Effect::New(EffectType lpenr, LivePathE
          case EXTRUDE:
              neweffect = static_cast<Effect*> ( new LPEExtrude(lpeobj) );
              break;
 +        case POWERSTROKE:
 +            neweffect = static_cast<Effect*> ( new LPEPowerStroke(lpeobj) );
 +            break;
          default:
              g_warning("LivePathEffect::Effect::New   called with invalid patheffect type (%d)", lpenr);
              neweffect = NULL;
      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);
  
@@@ -524,7 -518,7 +522,7 @@@ Effect::getHelperPaths(SPLPEItem *lpeit
      //       rather than copying PathVectors all over the place
      if (show_orig_path) {
          // add original path to helperpaths
-         SPCurve* curve = sp_shape_get_curve (SP_SHAPE(lpeitem));
+         SPCurve* curve = SP_SHAPE(lpeitem)->getCurve ();
          hp_vec.push_back(curve->get_pathvector());
      }
  
index 86d0907a1e75c81dcb807e9b6fe04983e1b3d44e,d43213fe95be76a09f7552aa68f9814f66636c40..fef4e1f8777573e3e58e7ceadcd65caff833d2e7
@@@ -3,6 -3,6 +3,7 @@@
   */
  /* Authors:
   *   Jean-Francois Barraud <jf.barraud@gmail.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2007 Authors
   *
@@@ -47,17 -47,6 +48,17 @@@ public
  };
  
  
 +Geom::Path::size_type size_nondegenerate(Geom::Path const &path) {
 +    Geom::Path::size_type retval = path.size_open();
 +
 +    // if path is closed and closing segment is not degenerate
 +    if (path.closed() && !path.back_closed().isDegenerate()) {
 +        retval = path.size_closed();
 +    }
 +
 +    return retval;
 +}
 +
  //---------------------------------------------------------------------------
  //LPEKnot specific Interval manipulation.
  //---------------------------------------------------------------------------
@@@ -101,7 -90,7 +102,7 @@@ findShadowedTime(Geom::Path const &path
      std::vector<double> times;
      
      //TODO: explore the path fwd/backward from ta (worth?)
 -    for (unsigned i=0; i<patha.size(); i++){
 +    for (unsigned i = 0; i < size_nondegenerate(patha); i++){
          D2<SBasis> f = p[i].toSBasis();
          std::vector<double> times_i, temptimes;
          temptimes = roots(f[Y]-width);
      std::vector<double>::iterator new_end = std::unique( times.begin(),  times.end() );
      times.resize( new_end - times.begin() );
  
 -    double tmin = 0, tmax = patha.size();
 -    double period = patha.size();//hm... Should this be patha.size()+1? 
 +    double tmin = 0, tmax = size_nondegenerate(patha);
 +    double period = size_nondegenerate(patha);
      if (times.size()>0){
          unsigned rk = upper_bound( times.begin(),  times.end(), ta ) - times.begin();
          if ( rk < times.size() ) 
@@@ -152,9 -141,9 +153,9 @@@ namespace LPEKnotNS {//just in case..
  CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vector<CrossingPoint>(){
  //    std::cout<<"\nCrossingPoints creation from path vector\n";
      for( unsigned i=0; i<paths.size(); i++){
 -        for( unsigned ii=0; ii<paths[i].size(); ii++){
 +        for( unsigned ii=0; ii < size_nondegenerate(paths[i]); ii++){
              for( unsigned j=i; j<paths.size(); j++){
 -                for( unsigned jj=(i==j?ii:0); jj<paths[j].size(); jj++){
 +                for( unsigned jj=(i==j?ii:0); jj < size_nondegenerate(paths[j]); jj++){
                      std::vector<std::pair<double,double> > times;
                      if ( i==j && ii==jj){
  
                              if ( i==j && fabs(times[k].first+ii - times[k].second-jj)<=zero ){//this is just end=start of successive curves in a path.
                                  continue;
                              }
 -                            if ( i==j && ii == 0 && jj==paths[i].size()-1 &&
 +                            if ( i==j && ii == 0 && jj == size_nondegenerate(paths[i])-1 &&
                                   paths[i].closed() &&
                                   fabs(times[k].first) <= zero && 
                                   fabs(times[k].second - 1) <= zero ){//this is just end=start of a closed path.
@@@ -339,11 -328,11 +340,11 @@@ CrossingPoints::inherit_signs(CrossingP
  LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) :
      Effect(lpeobject),
      // initialise your parameters here:
 -    interruption_width(_("Fixed width"), _("Size of hidden region of lower string"), "interruption_width", &wr, this, 3),
 +    interruption_width(_("Fixed width:"), _("Size of hidden region of lower string"), "interruption_width", &wr, this, 3),
      prop_to_stroke_width(_("In units of stroke width"), _("Consider 'Interruption width' as a ratio of stroke width"), "prop_to_stroke_width", &wr, this, true),
      add_stroke_width(_("Stroke width"), _("Add the stroke width to the interruption size"), "add_stroke_width", &wr, this, true),
      add_other_stroke_width(_("Crossing path stroke width"), _("Add crossed stroke width to the interruption size"), "add_other_stroke_width", &wr, this, true),
 -    switcher_size(_("Switcher size"), _("Orientation indicator/switcher size"), "switcher_size", &wr, this, 15),
 +    switcher_size(_("Switcher size:"), _("Orientation indicator/switcher size"), "switcher_size", &wr, this, 15),
      crossing_points_vector(_("Crossing Signs"), _("Crossings signs"), "crossing_points_vector", &wr, this),
      gpaths(),gstroke_widths()
  {
@@@ -404,7 -393,7 +405,7 @@@ LPEKnot::doEffect_path (std::vector<Geo
          if (i0 == gpaths.size() ) {THROW_EXCEPTION("lpe-knot error: group member not recognized");}// this should not happen...
  
          std::vector<Interval> dom;
 -        dom.push_back(Interval(0.,gpaths[i0].size()));
 +        dom.push_back(Interval(0., size_nondegenerate(gpaths[i0])));
          for (unsigned p = 0; p < crossing_points.size(); p++){
              if (crossing_points[p].i == i0 || crossing_points[p].j == i0){
                  unsigned i = crossing_points[p].i;
                  double curveidx, t;
                  
                  t = modf(ti, &curveidx);
 -                if(curveidx == gpaths[i].size() ) { curveidx--; t = 1.;}
 -                assert(curveidx >= 0 && curveidx < gpaths[i].size());
 +                if(curveidx == size_nondegenerate(gpaths[i]) ) { curveidx--; t = 1.;}
 +                assert(curveidx >= 0 && curveidx < size_nondegenerate(gpaths[i]));
                  std::vector<Point> flag_i = gpaths[i][curveidx].pointAndDerivatives(t,1);
  
                  t = modf(tj, &curveidx);
 -                if(curveidx == gpaths[j].size() ) { curveidx--; t = 1.;}
 -                assert(curveidx >= 0 && curveidx < gpaths[j].size());
 +                if(curveidx == size_nondegenerate(gpaths[j]) ) { curveidx--; t = 1.;}
 +                assert(curveidx >= 0 && curveidx < size_nondegenerate(gpaths[j]));
                  std::vector<Point> flag_j = gpaths[j][curveidx].pointAndDerivatives(t,1);
  
  
                          width += gstroke_widths[j];
                      }
                      Interval hidden = findShadowedTime(gpaths[i0], flag_j, ti, width/2);
 -                    double period  = gpaths[i0].size();//hm... Should this be gpaths[i0].size()+1?
 +                    double period  = size_nondegenerate(gpaths[i0]);
                      if (hidden.max() > period ) hidden -= period;
                      if (hidden.min()<0){
                          dom = complementOf( Interval(0,hidden.max()) ,dom);
  
          //If the current path is closed and the last/first point is still there, glue first and last piece.
          unsigned beg_comp = 0, end_comp = dom.size();
 -        if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() ==  gpaths[i0].size() ){
 +        if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() ==  size_nondegenerate(gpaths[i0]) ){
              if ( dom.size() == 1){
                  path_out.push_back(gpaths[i0]);
                  continue;
              }
          }
          for (unsigned comp = beg_comp; comp < end_comp; comp++){
 -            assert(dom.at(comp).min() >=0 and dom.at(comp).max() <= gpaths.at(i0).size());
 +            assert(dom.at(comp).min() >=0 and dom.at(comp).max() <= size_nondegenerate(gpaths.at(i0)));
              path_out.push_back(gpaths[i0].portion(dom.at(comp)));
          }
      }
@@@ -509,7 -498,7 +510,7 @@@ void collectPathsAndWidths (SPLPEItem c
          if (SP_IS_PATH(lpeitem)) {
              c = sp_path_get_curve_for_edit(SP_PATH(lpeitem));
          } else {
-             c = sp_shape_get_curve(SP_SHAPE(lpeitem));
+             c = SP_SHAPE(lpeitem)->getCurve();
          }
          if (c) {
              Geom::PathVector subpaths = c->get_pathvector();
@@@ -647,8 -636,8 +648,8 @@@ KnotHolderEntityCrossingSwitcher::knot_
              //std::cout<<"crossing set to"<<lpe->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);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
 +
index a3a0faf3755b37e8f38d1ae75aef8b70d743003e,dabeb5682c650a6c1e476e844d895e419ab7e421..1af2ed6caeb13f1480e076b1bdb245fa180d09a2
@@@ -1,4 -1,4 +1,3 @@@
--#define INKSCAPE_LPE_MIRROR_SYMMETRY_CPP
  /** \file
   * LPE <mirror_symmetry> 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 <j.b.c.engelen@utwente.nl>
   * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
@@@ -46,7 -46,7 +46,7 @@@ LPEMirrorSymmetry::doOnApply (SPLPEIte
      using namespace Geom;
  
      SPItem *item = SP_ITEM(lpeitem);
-     Geom::Matrix t = sp_item_i2d_affine(item);
+     Geom::Matrix t = item->i2d_affine();
      Geom::Rect bbox = *item->getBounds(t); // fixme: what happens if getBounds does not return a valid rect?
  
      Point A(bbox.left(), bbox.bottom());
index 3820b5ba741c1ff8bee27a5e40f723fd0e081b81,6eac43c43074fb26fd229cbdf9c96c57d9a9444a..e6fc95f866e2ec01aee2ed4b09c12e1757f2bb65
@@@ -1,7 -1,7 +1,6 @@@
--#define INKSCAPE_LPEGROUPBBOX_CPP
--
  /*
   * Copyright (C) Steren Giannini 2008 <steren.giannini@gmail.com>
++ *   Abhishek Sharma
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
@@@ -31,7 -31,7 +30,7 @@@ GroupBBoxEffect::original_bbox(SPLPEIte
      
      Geom::Matrix transform;
      if (absolute) {
-         transform = sp_item_i2doc_affine(item);
+         transform = item->i2doc_affine();
      }
      else {
          transform = Geom::identity();
index aa916318d8da70ab7586da2aa859837d5194633c,a77b9817a84494e6b60a1e49d540f4fd1b42530b..389e18d20cf56d9cb5cbcb887c02206629f91a65
@@@ -1,7 -1,7 +1,6 @@@
--#define INKSCAPE_LIVEPATHEFFECT_OBJECT_CPP
--
  /*
   * Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
++ *   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);
index 67508e5316618ecb82bec919a6ee8aaa7bdde431,53b9ade04a43e468cb03d1137b7374e78d26a17e..3bedecccbfc969aa84c5ff77232753a32815e829
@@@ -5,11 -5,12 +5,13 @@@
   * 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.
   */
  
  #include <forward.h>
+ #include "sp-item.h"
  #include <uri-references.h>
  #include <sigc++/sigc++.h>
  
index d8d5b0a7ccbba05e80a89c3cc23c516ebd707098,bdbe126e284bd9028be74bb4acb72c0a42ef5870..8d9b2376ff586770d7b5b8da664c629fa6b770f0
@@@ -1,7 -1,7 +1,6 @@@
--#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_CPP
--
  /*
   * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
++ *   Abhishek Sharma
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
@@@ -209,7 -209,7 +208,7 @@@ PathParam::param_editOncanvas(SPItem *i
      ShapeRecord r;
  
      r.role = SHAPE_ROLE_LPE_PARAM;
-     r.edit_transform = sp_item_i2d_affine(item); // TODO is it right?
+     r.edit_transform = item->i2d_affine(); // TODO is it right?
      if (!href) {
          r.item = reinterpret_cast<SPItem*>(param_effect->getLPEObj());
          r.lpe_key = param_key;
@@@ -366,7 -366,7 +365,7 @@@ PathParam::linked_modified(SPObject *li
  {
      SPCurve *curve = NULL;
      if (SP_IS_SHAPE(linked_obj)) {
-         curve = sp_shape_get_curve(SP_SHAPE(linked_obj));
+         curve = SP_SHAPE(linked_obj)->getCurve();
      }
      if (SP_IS_TEXT(linked_obj)) {
          curve = SP_TEXT(linked_obj)->getNormalizedBpath();
@@@ -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 --combined src/lpe-tool-context.cpp
index 8aa350d86a1ca5f073f714a9b55ae6e030d1407b,1459cb4602780108c0a7eed25197a6ea08a1d0be..f259492962d927d3d5421be5e529f26887428894
@@@ -4,6 -4,6 +4,7 @@@
   * Authors:
   *   Maximilian Albert <maximilian.albert@gmail.com>
   *   Lauris Kaplinski <lauris@kaplinski.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 1998 The Free Software Foundation
   * Copyright (C) 1999-2005 authors
@@@ -392,8 -392,8 +393,8 @@@ lpetool_context_switch_mode(SPLPEToolCo
  
  void
  lpetool_get_limiting_bbox_corners(SPDocument *document, Geom::Point &A, Geom::Point &B) {
-     Geom::Coord w = sp_document_width(document);
-     Geom::Coord h = sp_document_height(document);
+     Geom::Coord w = document->getWidth();
+     Geom::Coord h = document->getHeight();
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  
      double ulx = prefs->getDouble("/tools/lpetool/bbox_upperleftx", 0);
@@@ -472,7 -472,7 +473,7 @@@ lpetool_create_measuring_items(SPLPEToo
      for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
          if (SP_IS_PATH(i->data)) {
              path = SP_PATH(i->data);
-             curve = sp_shape_get_curve(SP_SHAPE(path));
+             curve = SP_SHAPE(path)->getCurve();
              Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(curve->get_pathvector());
              canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), "");
              if (!show)
@@@ -514,7 -514,7 +515,7 @@@ lpetool_update_measuring_items(SPLPEToo
      std::map<SPPath *, SPCanvasItem*>::iterator i;
      for (i = lc->measuring_items->begin(); i != lc->measuring_items->end(); ++i) {
          path = i->first;
-         curve = sp_shape_get_curve(SP_SHAPE(path));
+         curve = SP_SHAPE(path)->getCurve();
          Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector());
          SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX));
          SPUnit unit = sp_unit_get_by_id(unitid);
@@@ -550,4 -550,4 +551,4 @@@ lpetool_show_measuring_info(SPLPEToolCo
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/main.cpp
index eda6d0b03ca9882163bf6ced1d040dca62ff4a84,a25343991077ce4af4018041e76b1fe7b9fee625..a1b21cc4d0f65b1cf1fb3ad2cba4787ab2648ec0
@@@ -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 <bryce@bryceharrington.com>
   * ... and various people who have worked with various projects
++ *   Jon A. Cruz <jon@oncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 1999-2004 authors
   * Copyright (C) 2001-2002 Ximian, Inc.
@@@ -114,6 -114,7 +114,6 @@@ using Inkscape::Extension::Internal::Pr
  #define bind_textdomain_codeset(p,c)
  #endif
  
 -#include "application/application.h"
  #include "main-cmdlineact.h"
  #include "widgets/icon.h"
  #include "ui/widget/panel.h"
@@@ -207,6 -208,7 +207,6 @@@ static gboolean sp_query_width = FALSE
  static gboolean sp_query_height = FALSE;
  static gboolean sp_query_all = FALSE;
  static gchar *sp_query_id = NULL;
 -static int sp_new_gui = FALSE;
  static gboolean sp_shell = FALSE;
  static gboolean sp_vacuum_defs = FALSE;
  
@@@ -711,15 -713,10 +711,15 @@@ main(int argc, char **argv
      }
  #endif // WIN32
  
 -    /// \todo  Should this be a static object (see inkscape.cpp)?
 -    Inkscape::NSApplication::Application app(argc, argv, use_gui, sp_new_gui);
 +    int retcode;
 +
 +    if (use_gui) {
 +        retcode = sp_main_gui(argc, (const char **) argv);
 +    } else {
 +        retcode = sp_main_console(argc, (const char **) argv);
 +    }
  
 -    return app.run();
 +    return retcode;
  }
  
  
@@@ -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
                  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,15 -1193,15 +1196,15 @@@ 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
-         Geom::OptRect area = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect area = item->getBounds(item->i2doc_affine());
          if (area) {
              Inkscape::SVGOStringStream os;
              if (extent) {
      }
  }
  
--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);
      }
  }
@@@ -1237,7 -1234,7 +1234,7 @@@ do_query_all_recurse (SPObject *o
  {
      SPItem *item = ((SPItem *) o);
      if (o->getId() && SP_IS_ITEM(item)) {
-         Geom::OptRect area = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect area = item->getBounds(item->i2doc_affine());
          if (area) {
              Inkscape::SVGOStringStream os;
              os << o->getId();
@@@ -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;
          }
  
              }
  
              // 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<SPItem *>(o_area)->invoke_bbox( areaMaybe, static_cast<SPItem *>(o_area)->i2d_affine(), TRUE);
              if (areaMaybe) {
                  area = *areaMaybe;
              } else {
      if (sp_export_area) {
          /* Try to parse area (given in SVG pixels) */
          gdouble x0,y0,x1,y1;
 -        if (!sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &x0, &y0, &x1, &y1) == 4) {
 +        if (sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &x0, &y0, &x1, &y1) != 4) {
              g_warning("Cannot parse export area '%s'; use 'x0:y0:x1:y1'. Nothing exported.", sp_export_area);
              return;
          }
          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
      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 --combined src/marker.cpp
index e4c2e0c305633929ea8df52a65a2e748b3250ea7,376b4fa28ca08ee27fa7dd19d828dad58023e14d..0ec92a1ff2147b00573ad9703e86d10a7628083c
@@@ -1,11 -1,11 +1,10 @@@
--#define __MARKER_C__
--
  /*
   * SVG <marker> implementation
   *
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   Bryce Harrington <bryce@bryceharrington.org>
++ *   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);
@@@ -524,8 -524,10 +523,10 @@@ sp_marker_write (SPObject *object, Inks
                repr->setAttribute("orient", NULL);
        }
        /* fixme: */
-       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....
+       repr->setAttribute("viewBox", object->getRepr()->attribute("viewBox"));
+       //XML Tree being used directly here while it shouldn't be....
+       repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio"));
  
        if (((SPObjectClass *) (parent_class))->write)
                ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
@@@ -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");
  
              dup_transform = Geom::identity();
          dup_transform *= move;
  
-         sp_item_write_transform(copy, SP_OBJECT_REPR(copy), dup_transform);
+         copy->doWriteTransform(SP_OBJECT_REPR(copy), dup_transform);
      }
  
      Inkscape::GC::release(repr);
diff --combined src/object-edit.cpp
index 9c0b61b9c6f7e78ee5c7672b2f12c7b1c075c2de,4cd365bb859e9e1635ed0dacd1adc7aa707f2d1a..27e75afab1340151367e3dd5db22cdc65f5446ef
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_OBJECT_EDIT_C__
--
  /*
   * Node editing extension to objects
   *
@@@ -7,6 -7,6 +5,7 @@@
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   Mitsuru Oka
   *   Maximilian Albert <maximilian.albert@gmail.com>
++ *   Abhishek Sharma
   *
   * Licensed under GNU GPL
   */
@@@ -141,7 -141,7 +140,7 @@@ RectKnotHolderEntityRX::knot_set(Geom::
      //In general we cannot just snap this radius to an arbitrary point, as we have only a single
      //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
      //the radius then we should have a constrained snap. snap_knot_position() is unconstrained
 -    Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)));
 +    Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)));
  
      if (state & GDK_CONTROL_MASK) {
          gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
@@@ -172,6 -172,7 +171,6 @@@ RectKnotHolderEntityRX::knot_click(guin
          SP_OBJECT_REPR(rect)->setAttribute("ry", SP_OBJECT_REPR(rect)->attribute("rx"));
      }
  
 -    update_knot();
  }
  
  Geom::Point
@@@ -190,7 -191,7 +189,7 @@@ RectKnotHolderEntityRY::knot_set(Geom::
      //In general we cannot just snap this radius to an arbitrary point, as we have only a single
      //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
      //the radius then we should have a constrained snap. snap_knot_position() is unconstrained
 -    Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)));
 +    Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)));
  
      if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry,
                                      // resulting in a perfect circle (and not an ellipse)
@@@ -279,13 -280,13 +278,13 @@@ RectKnotHolderEntityWH::set_internal(Ge
              // snap to horizontal or diagonal
              if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) {
                  // closer to the diagonal and in same-sign quarters, change both using ratio
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(-ratio, -1)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->height.computed = MAX(h_orig + minx / ratio, 0);
              } else {
                  // closer to the horizontal, change only width, height is h_orig
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(-1, 0)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->height.computed = MAX(h_orig, 0);
              // snap to vertical or diagonal
              if (miny != 0 && fabs(minx/miny) > 0.5 * ratio && (SGN(minx) == SGN(miny))) {
                  // closer to the diagonal and in same-sign quarters, change both using ratio
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(-ratio, -1)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->width.computed = MAX(w_orig + miny * ratio, 0);
              } else {
                  // closer to the vertical, change only height, width is w_orig
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(0, -1)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->width.computed = MAX(w_orig, 0);
@@@ -369,14 -370,14 +368,14 @@@ RectKnotHolderEntityXY::knot_set(Geom::
              // snap to horizontal or diagonal
              if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) {
                  // closer to the diagonal and in same-sign quarters, change both using ratio
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(-ratio, -1)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->y.computed = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
                  rect->height.computed = MAX(h_orig - minx / ratio, 0);
              } else {
                  // closer to the horizontal, change only width, height is h_orig
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(-1, 0)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->y.computed = MIN(origin[Geom::Y], opposite_y);
              // snap to vertical or diagonal
              if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) {
                  // closer to the diagonal and in same-sign quarters, change both using ratio
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(-ratio, -1)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->x.computed = MIN(origin[Geom::X] + miny * ratio, opposite_x);
                  rect->width.computed = MAX(w_orig - miny * ratio, 0);
              } else {
                  // closer to the vertical, change only height, width is w_orig
 -                s = snap_knot_position_constrained(p, Inkscape::Snapper::ConstraintLine(p_handle, Geom::Point(0, -1)));
 +                s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)));
                  minx = s[Geom::X] - origin[Geom::X];
                  miny = s[Geom::Y] - origin[Geom::Y];
                  rect->x.computed = MIN(origin[Geom::X], opposite_x);
@@@ -482,7 -483,7 +481,7 @@@ Box3DKnotHolderEntity::knot_set_generic
  
      g_assert(item != NULL);
      SPBox3D *box = SP_BOX3D(item);
-     Geom::Matrix const i2d (sp_item_i2d_affine (item));
+     Geom::Matrix const i2d (item->i2d_affine ());
  
      Box3D::Axis movement;
      if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) {
@@@ -658,7 -659,7 +657,7 @@@ Box3DKnotHolderEntityCenter::knot_set(G
      Geom::Point const s = snap_knot_position(new_pos);
  
      SPBox3D *box = SP_BOX3D(item);
-     Geom::Matrix const i2d (sp_item_i2d_affine (item));
+     Geom::Matrix const i2d (item->i2d_affine ());
  
      box3d_set_center (SP_BOX3D(item), s * i2d, origin * i2d, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z,
                        state & GDK_CONTROL_MASK);
@@@ -1364,4 -1365,4 +1363,4 @@@ FlowtextKnotHolder::FlowtextKnotHolder(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/object-snapper.cpp
index 51b4944980cff4a0ddc24b5f25d7e1e6d6b6825d,00bd10fe2c97319af9c31f7940f29e09d9d99f2b..43651f002405e12ced35ea1743a6862668ec5bfb
@@@ -5,19 -5,17 +5,21 @@@
   * Authors:
   *   Carl Hetherington <inkscape@carlh.net>
   *   Diederik van Lierop <mail@diedenrezi.nl>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
 - * Copyright (C) 2005 - 2008 Authors
 + * Copyright (C) 2005 - 2010 Authors
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
  
  #include "svg/svg.h"
  #include <2geom/path-intersection.h>
 +#include <2geom/pathvector.h>
  #include <2geom/point.h>
  #include <2geom/rect.h>
  #include <2geom/line.h>
 +#include <2geom/circle.h>
  #include "document.h"
  #include "sp-namedview.h"
  #include "sp-image.h"
@@@ -75,24 -73,24 +77,24 @@@ bool Inkscape::ObjectSnapper::getSnappe
   *  \param parent Pointer to the document's root, or to a clipped path or mask object
   *  \param it List of items to ignore
   *  \param bbox_to_snap Bounding box hulling the whole bunch of points, all from the same selection and having the same transformation
 - *  \param DimensionToSnap Snap in X, Y, or both directions.
   */
  
  void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
                                                std::vector<SPItem const *> const *it,
                                                bool const &first_point,
                                                Geom::Rect const &bbox_to_snap,
 -                                              DimensionToSnap const snap_dim,
                                                bool const clip_or_mask,
                                                Geom::Matrix const additional_affine) const // transformation of the item being clipped / masked
  {
 -    bool const c1 = (snap_dim == TRANSL_SNAP_XY) && ThisSnapperMightSnap();
 -    bool const c2 = (snap_dim != TRANSL_SNAP_XY) && GuidesMightSnap();
 -
 -    if (!(c1 || c2)) {
 +    if (!ThisSnapperMightSnap()) {
          return;
      }
  
 +    if (_snapmanager->getDesktop() == NULL) {
 +        g_warning("desktop == NULL, so we cannot snap; please inform the developpers of this bug");
 +        // Apparently the etup() method from the SnapManager class hasn't been called before trying to snap.
 +    }
 +
      if (first_point) {
          _candidates->clear();
      }
      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
                          // 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());
                          }
                      }
                  }
  
                  if (SP_IS_GROUP(o)) {
 -                    _findCandidates(o, it, false, bbox_to_snap, snap_dim, clip_or_mask, additional_affine);
 +                    _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine);
                  } else {
                      Geom::OptRect bbox_of_item = Geom::Rect();
                      if (clip_or_mask) {
                          // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to
                          // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
-                         sp_item_invoke_bbox(item,
-                             bbox_of_item,
-                             sp_item_i2doc_affine(item) * additional_affine * _snapmanager->getDesktop()->doc2dt(),
+                         item->invoke_bbox(bbox_of_item,
+                             item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt(),
                              true);
                      } else {
-                         sp_item_invoke_bbox(item, bbox_of_item, sp_item_i2d_affine(item), true);
+                         item->invoke_bbox( bbox_of_item, item->i2d_affine(), true);
                      }
                      if (bbox_of_item) {
                          // See if the item is within range
 -                        if (bbox_to_snap_incl.intersects(*bbox_of_item)) {
 +                        if (bbox_to_snap_incl.intersects(*bbox_of_item)
 +                                || (_snapmanager->snapprefs.getIncludeItemCenter() && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box
                              // This item is within snapping range, so record it as a candidate
                              _candidates->push_back(SnapCandidateItem(item, clip_or_mask, additional_affine));
                              // For debugging: print the id of the candidate to the console
@@@ -229,24 -226,11 +231,24 @@@ void Inkscape::ObjectSnapper::_collectN
                      _snapmanager->snapprefs.setSnapIntersectionCS(false);
                  }
  
-                 sp_item_snappoints(root_item, *_points_to_snap_to, &_snapmanager->snapprefs);
 +                // 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<SPItem*>(itemlist->data)) {
 +                            // don't snap to this item's rotation center
 +                            _snapmanager->snapprefs.setIncludeItemCenter(false);
 +                            break;
 +                        }
 +                    }
 +                }
 +
+                 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
                  // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox
                  // of the item AND the bbox of the clipping path at the same time
                  if (!(*i).clip_or_mask) {
-                     Geom::OptRect b = sp_item_bbox_desktop(root_item, bbox_type);
+                     Geom::OptRect b = root_item->getBboxDesktop(bbox_type);
                      getBBoxPoints(b, _points_to_snap_to, true, _snapmanager->snapprefs.getSnapToBBoxNode(), _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints(), _snapmanager->snapprefs.getSnapBBoxMidpoints());
                  }
              }
  
  void Inkscape::ObjectSnapper::_snapNodes(SnappedConstraints &sc,
                                           Inkscape::SnapCandidatePoint const &p,
 -                                         std::vector<SnapCandidatePoint> *unselected_nodes) const
 +                                         std::vector<SnapCandidatePoint> *unselected_nodes,
 +                                         SnapConstraint const &c,
 +                                         Geom::Point const &p_proj_on_constraint) const
  {
      // Iterate through all nodes, find out which one is the closest to p, and snap to it!
  
 -    _collectNodes(p.getSourceType(), p.getSourceNum() == 0);
 +    _collectNodes(p.getSourceType(), p.getSourceNum() <= 0);
  
 -    if (unselected_nodes != NULL) {
 +    if (unselected_nodes != NULL && unselected_nodes->size() > 0) {
 +        g_assert(_points_to_snap_to != NULL);
          _points_to_snap_to->insert(_points_to_snap_to->end(), unselected_nodes->begin(), unselected_nodes->end());
      }
  
      bool success = false;
  
      for (std::vector<SnapCandidatePoint>::const_iterator k = _points_to_snap_to->begin(); k != _points_to_snap_to->end(); k++) {
 -        Geom::Coord dist = Geom::L2((*k).getPoint() - p.getPoint());
 +        Geom::Point target_pt = (*k).getPoint();
 +        Geom::Coord dist = NR_HUGE;
 +        if (!c.isUndefined()) {
 +            // We're snapping to nodes along a constraint only, so find out if this node
 +            // is at the constraint, while allowing for a small margin
 +            if (Geom::L2(target_pt - c.projection(target_pt)) > 1e-9) {
 +                // The distance from the target point to its projection on the constraint
 +                // is too large, so this point is not on the constraint. Skip it!
 +                continue;
 +            }
 +            dist = Geom::L2(target_pt - p_proj_on_constraint);
 +        } else {
 +            // Free (unconstrained) snapping
 +            dist = Geom::L2(target_pt - p.getPoint());
 +        }
 +
          if (dist < getSnapperTolerance() && dist < s.getSnapDistance()) {
 -            s = SnappedPoint((*k).getPoint(), p.getSourceType(), p.getSourceNum(), (*k).getTargetType(), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox());
 +            s = SnappedPoint(target_pt, p.getSourceType(), p.getSourceNum(), (*k).getTargetType(), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox());
              success = true;
          }
      }
      }
  }
  
 -void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &sc,
 +void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc,
                                           Geom::Point const &p,
                                           Geom::Point const &guide_normal) const
  {
      // Iterate through all nodes, find out which one is the closest to this guide, and snap to it!
      _collectNodes(SNAPSOURCE_GUIDE, true);
  
 -    // Although we won't snap to paths here (which would give us under constrained snaps) we can still snap to intersections of paths.
      if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) {
 -        _collectPaths(Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), true);
 +        _collectPaths(p, SNAPSOURCE_GUIDE, true);
          _snapPaths(sc, Inkscape::SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL);
 -        // The paths themselves should be discarded in findBestSnap(), as we should only snap to their intersections
      }
  
      SnappedPoint s;
      Geom::Coord tol = getSnapperTolerance();
  
      for (std::vector<SnapCandidatePoint>::const_iterator k = _points_to_snap_to->begin(); k != _points_to_snap_to->end(); k++) {
 +        Geom::Point target_pt = (*k).getPoint();
          // Project each node (*k) on the guide line (running through point p)
 -        Geom::Point p_proj = Geom::projection((*k).getPoint(), Geom::Line(p, p + Geom::rot90(guide_normal)));
 -        Geom::Coord dist = Geom::L2((*k).getPoint() - p_proj); // distance from node to the guide
 +        Geom::Point p_proj = Geom::projection(target_pt, Geom::Line(p, p + Geom::rot90(guide_normal)));
 +        Geom::Coord dist = Geom::L2(target_pt - p_proj); // distance from node to the guide
          Geom::Coord dist2 = Geom::L2(p - p_proj); // distance from projection of node on the guide, to the mouse location
          if ((dist < tol && dist2 < tol) || getSnapperAlwaysSnap()) {
 -            s = SnappedPoint((*k).getPoint(), SNAPSOURCE_GUIDE, 0, (*k).getTargetType(), dist, tol, getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox());
 +            s = SnappedPoint(target_pt, SNAPSOURCE_GUIDE, 0, (*k).getTargetType(), dist, tol, getSnapperAlwaysSnap(), false, true, (*k).getTargetBBox());
              sc.points.push_back(s);
          }
      }
   * 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,
          // Determine the type of bounding box we should snap to
          SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
  
 -        bool p_is_a_node = p.getSourceType() & Inkscape::SNAPSOURCE_NODE_CATEGORY;
 -        bool p_is_other = p.getSourceType() & Inkscape::SNAPSOURCE_OTHER_CATEGORY;
 +        bool p_is_a_node = source_type & Inkscape::SNAPSOURCE_NODE_CATEGORY;
 +        bool p_is_other = source_type & Inkscape::SNAPSOURCE_OTHER_CATEGORY;
  
          if (_snapmanager->snapprefs.getSnapToBBoxPath()) {
              Inkscape::Preferences *prefs = Inkscape::Preferences::get();
          }
  
          // Consider the page border for snapping
 -        if (_snapmanager->snapprefs.getSnapToPageBorder()) {
 +        if (_snapmanager->snapprefs.getSnapToPageBorder() && _snapmanager->snapprefs.getSnapModeBBoxOrNodes()) {
              Geom::PathVector *border_path = _getBorderPathv();
              if (border_path != NULL) {
                  _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect()));
                  root_item = sp_use_root(SP_USE((*i).item));
                  g_return_if_fail(root_item);
              } else {
-                 i2doc = sp_item_i2doc_affine((*i).item);
+                 i2doc = (*i).item->i2doc_affine();
                  root_item = (*i).item;
              }
  
              //Build a list of all paths considered for snapping to
  
              //Add the item's path to snap to
 -            if (_snapmanager->snapprefs.getSnapToItemPath()) {
 +            if (_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapModeNode()) {
                  if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && !p_is_a_node)) {
                      // Snapping to the path of characters is very cool, but for a large
                      // chunk of text this will take ages! So limit snapping to text paths
                      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();
                          }
                      }
              }
  
              //Add the item's bounding box to snap to
 -            if (_snapmanager->snapprefs.getSnapToBBoxPath()) {
 +            if (_snapmanager->snapprefs.getSnapToBBoxPath() && _snapmanager->snapprefs.getSnapModeBBox()) {
                  if (p_is_other || !(_snapmanager->snapprefs.getStrictSnapping() && p_is_a_node)) {
                      // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox
                      // of the item AND the bbox of the clipping path at the same time
                      if (!(*i).clip_or_mask) {
                          Geom::OptRect rect;
-                         sp_item_invoke_bbox(root_item, rect, i2doc, TRUE, bbox_type);
+                         root_item->invoke_bbox( rect, i2doc, TRUE, bbox_type);
                          if (rect) {
                              Geom::PathVector *path = _getPathvFromRect(*rect);
-                             rect = sp_item_bbox_desktop(root_item, bbox_type);
+                             rect = root_item->getBboxDesktop(bbox_type);
                              _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect));
                          }
                      }
@@@ -454,7 -415,7 +456,7 @@@ void Inkscape::ObjectSnapper::_snapPath
                                       std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes,
                                       SPPath const *selected_path) const
  {
 -    _collectPaths(p, p.getSourceNum() == 0);
 +    _collectPaths(p.getPoint(), p.getSourceType(), p.getSourceNum() <= 0);
      // Now we can finally do the real snapping, using the paths collected above
  
      g_assert(_snapmanager->getDesktop() != NULL);
  
      bool const node_tool_active = _snapmanager->snapprefs.getSnapToItemPath() && selected_path != NULL;
  
 -    if (p.getSourceNum() == 0) {
 +    if (p.getSourceNum() <= 0) {
          /* findCandidates() is used for snapping to both paths and nodes. It ignores the path that is
           * currently being edited, because that path requires special care: when snapping to nodes
           * only the unselected nodes of that path should be considered, and these will be passed on separately.
@@@ -555,92 -516,52 +557,92 @@@ bool Inkscape::ObjectSnapper::isUnselec
  
  void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
                                       Inkscape::SnapCandidatePoint const &p,
 -                                     ConstraintLine const &c) const
 +                                     SnapConstraint const &c,
 +                                     Geom::Point const &p_proj_on_constraint) const
  {
  
 -    _collectPaths(p, p.getSourceNum() == 0);
 +    _collectPaths(p_proj_on_constraint, p.getSourceType(), p.getSourceNum() <= 0);
  
      // Now we can finally do the real snapping, using the paths collected above
  
      g_assert(_snapmanager->getDesktop() != NULL);
 -    Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p.getPoint());
 +    Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p_proj_on_constraint);
  
      Geom::Point direction_vector = c.getDirection();
      if (!is_zero(direction_vector)) {
          direction_vector = Geom::unit_vector(direction_vector);
      }
  
 -    // The intersection point of the constraint line with any path,
 -    // must lie within two points on the constraintline: p_min_on_cl and p_max_on_cl
 -    // The distance between those points is twice the snapping tolerance
 -    Geom::Point const p_proj_on_cl = p.getPoint(); // projection has already been taken care of in constrainedSnap in the snapmanager;
 -    Geom::Point const p_min_on_cl = _snapmanager->getDesktop()->dt2doc(p_proj_on_cl - getSnapperTolerance() * direction_vector);
 -    Geom::Point const p_max_on_cl = _snapmanager->getDesktop()->dt2doc(p_proj_on_cl + getSnapperTolerance() * direction_vector);
 +    // The intersection point of the constraint line with any path, must lie within two points on the
 +    // SnapConstraint: p_min_on_cl and p_max_on_cl. The distance between those points is twice the snapping tolerance
 +    Geom::Point const p_min_on_cl = _snapmanager->getDesktop()->dt2doc(p_proj_on_constraint - getSnapperTolerance() * direction_vector);
 +    Geom::Point const p_max_on_cl = _snapmanager->getDesktop()->dt2doc(p_proj_on_constraint + getSnapperTolerance() * direction_vector);
 +    Geom::Coord tolerance = getSnapperTolerance();
 +
 +    // PS: Because the paths we're about to snap to are all expressed relative to document coordinate system, we will have
 +    // to convert the snapper coordinates from the desktop coordinates to document coordinates
  
 -    Geom::Path cl;
 -    std::vector<Geom::Path> clv;
 -    cl.start(p_min_on_cl);
 -    cl.appendNew<Geom::LineSegment>(p_max_on_cl);
 -    clv.push_back(cl);
 +    std::vector<Geom::Path> constraint_path;
 +    if (c.isCircular()) {
 +        Geom::Circle constraint_circle(_snapmanager->getDesktop()->dt2doc(c.getPoint()), c.getRadius());
 +        constraint_circle.getPath(constraint_path);
 +    } else {
 +        Geom::Path constraint_line;
 +        constraint_line.start(p_min_on_cl);
 +        constraint_line.appendNew<Geom::LineSegment>(p_max_on_cl);
 +        constraint_path.push_back(constraint_line);
 +    }
 +    // Length of constraint_path will always be one
  
 +    // Find all intersections of the constrained path with the snap target candidates
 +    std::vector<Geom::Point> intersections;
      for (std::vector<Inkscape::SnapCandidatePath >::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); k++) {
          if (k->path_vector) {
 -            Geom::CrossingSet cs = Geom::crossings(clv, *(k->path_vector));
 -            if (cs.size() > 0) {
 -                // We need only the first element of cs, because cl is only a single straight linesegment
 -                // This first element contains a vector filled with crossings of cl with k->first
 -                for (std::vector<Geom::Crossing>::const_iterator m = cs[0].begin(); m != cs[0].end(); m++) {
 -                    if ((*m).ta >= 0 && (*m).ta <= 1 ) {
 -                        // Reconstruct the point of intersection
 -                        Geom::Point p_inters = p_min_on_cl + ((*m).ta) * (p_max_on_cl - p_min_on_cl);
 -                        // When it's within snapping range, then return it
 -                        // (within snapping range == between p_min_on_cl and p_max_on_cl == 0 < ta < 1)
 -                        Geom::Coord dist = Geom::L2(_snapmanager->getDesktop()->dt2doc(p_proj_on_cl) - p_inters);
 -                        SnappedPoint s(_snapmanager->getDesktop()->doc2dt(p_inters), p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, k->target_bbox);
 -                        sc.points.push_back(s);
 +            // Do the intersection math
 +            Geom::CrossingSet cs = Geom::crossings(constraint_path, *(k->path_vector));
 +            // Store the results as intersection points
 +            unsigned int index = 0;
 +            for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); i++) {
 +                if (index >= constraint_path.size()) {
 +                    break;
 +                }
 +                // Reconstruct and store the points of intersection
 +                for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); m++) {
 +                    intersections.push_back(constraint_path[index].pointAt((*m).ta));
 +                }
 +                index++;
 +            }
 +
 +            //Geom::crossings will not consider the closing segment apparently, so we'll handle that separately here
 +            //TODO: This should have been fixed in rev. #9859, which makes this workaround obsolete
 +            for(Geom::PathVector::iterator it_pv = k->path_vector->begin(); it_pv != k->path_vector->end(); ++it_pv) {
 +                if (it_pv->closed()) {
 +                    // Get the closing linesegment and convert it to a path
 +                    Geom::Path cls;
 +                    cls.close(false);
 +                    cls.append(it_pv->back_closed());
 +                    // Intersect that closing path with the constrained path
 +                    Geom::Crossings cs = Geom::crossings(constraint_path.front(), cls);
 +                    // Reconstruct and store the points of intersection
 +                    index = 0; // assuming the constraint path vector has only one path
 +                    for (Geom::Crossings::const_iterator m = cs.begin(); m != cs.end(); m++) {
 +                        intersections.push_back(constraint_path[index].pointAt((*m).ta));
                      }
                  }
              }
 +
 +            // Convert the collected points of intersection to snapped points
 +            for (std::vector<Geom::Point>::iterator p_inters = intersections.begin(); p_inters != intersections.end(); p_inters++) {
 +                // Convert to desktop coordinates
 +                (*p_inters) = _snapmanager->getDesktop()->doc2dt(*p_inters);
 +                // Construct a snapped point
 +                Geom::Coord dist = Geom::L2(p.getPoint() - *p_inters);
 +                SnappedPoint s = SnappedPoint(*p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, k->target_bbox);;
 +                // Store the snapped point
 +                if (dist <= tolerance) { // If the intersection is within snapping range, then we might snap to it
 +                    sc.points.push_back(s);
 +                }
 +            }
          }
      }
  }
@@@ -657,33 -578,20 +659,33 @@@ 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);
      }
  
 -    if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) {
 +    if ((_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getSnapToItemPath()) ||
 +        (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxPath()) ||
 +        (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && _snapmanager->snapprefs.getSnapToPageBorder())) {
          unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size();
          if (n > 0) {
              /* While editing a path in the node tool, findCandidates must ignore that path because
  void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
                                                    Inkscape::SnapCandidatePoint const &p,
                                                    Geom::OptRect const &bbox_to_snap,
 -                                                  ConstraintLine const &c,
 -                                                  std::vector<SPItem const *> const *it) const
 +                                                  SnapConstraint const &c,
 +                                                  std::vector<SPItem const *> const *it,
 +                                                  std::vector<SnapCandidatePoint> *unselected_nodes) const
  {
      if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) {
          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).
      // This is useful for example when scaling an object while maintaining a fixed aspect ratio. It's
      // nodes are only allowed to move in one direction (i.e. in one degree of freedom).
  
 -    // When snapping to objects, we either snap to their nodes or their paths. It is however very
 -    // unlikely that any node will be exactly at the constrained line, so for a constrained snap
 -    // to objects we will only consider the object's paths. Beside, the nodes will be at these paths,
 -    // so we will more or less snap to them anyhow.
 +    // 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, c, pp);
 +    }
  
      if (_snapmanager->snapprefs.getSnapToItemPath() || _snapmanager->snapprefs.getSnapToBBoxPath() || _snapmanager->snapprefs.getSnapToPageBorder()) {
 -        _snapPathsConstrained(sc, p, c);
 +        _snapPathsConstrained(sc, p, c, pp);
      }
  }
  
@@@ -763,8 -653,17 +765,8 @@@ void Inkscape::ObjectSnapper::guideFree
      std::vector<SPItem*> cand;
      std::vector<SPItem const *> 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);
  
  }
  
  void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc,
                                          Geom::Point const &p,
                                          Geom::Point const &guide_normal,
 -                                        ConstraintLine const &/*c*/) const
 +                                        SnapConstraint const &/*c*/) const
  {
      /* Get a list of all the SPItems that we will try to snap to */
      std::vector<SPItem*> cand;
      std::vector<SPItem const *> 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);
  
  }
  
   */
  bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const
  {
 -    bool snap_to_something = _snapmanager->snapprefs.getSnapToItemPath()
 -                        || _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes()
 -                        || _snapmanager->snapprefs.getSnapToBBoxPath()
 -                        || _snapmanager->snapprefs.getSnapToBBoxNode()
 -                        || _snapmanager->snapprefs.getSnapToPageBorder()
 -                        || _snapmanager->snapprefs.getSnapLineMidpoints() || _snapmanager->snapprefs.getSnapObjectMidpoints()
 -                        || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()
 -                        || _snapmanager->snapprefs.getIncludeItemCenter();
 -
 -    return (_snap_enabled && _snapmanager->snapprefs.getSnapModeBBoxOrNodes() && snap_to_something);
 -}
 -
 -bool Inkscape::ObjectSnapper::GuidesMightSnap() const // almost the same as ThisSnapperMightSnap above, but only looking at points (and not paths)
 -{
 -    bool snap_to_something = _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes()
 -                        || _snapmanager->snapprefs.getSnapToPageBorder()
 -                        || (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxNode())
 -                        || (_snapmanager->snapprefs.getSnapModeBBox() && (_snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()))
 -                        || (_snapmanager->snapprefs.getSnapModeNode() && (_snapmanager->snapprefs.getSnapLineMidpoints() || _snapmanager->snapprefs.getSnapObjectMidpoints()))
 -                        || (_snapmanager->snapprefs.getSnapModeNode() && _snapmanager->snapprefs.getIncludeItemCenter())
 -                        || (_snapmanager->snapprefs.getSnapModeNode() && (_snapmanager->snapprefs.getSnapToItemPath() && _snapmanager->snapprefs.getSnapIntersectionCS()));
 -
 -    return (_snap_enabled && _snapmanager->snapprefs.getSnapModeGuide() && snap_to_something);
 +    bool snap_to_something = (_snapmanager->snapprefs.getSnapModeNode() && (
 +                                _snapmanager->snapprefs.getSnapToItemPath() ||
 +                                _snapmanager->snapprefs.getSnapToItemNode() ||
 +                                _snapmanager->snapprefs.getSnapSmoothNodes() ||
 +                                _snapmanager->snapprefs.getSnapLineMidpoints() ||
 +                                _snapmanager->snapprefs.getSnapObjectMidpoints()
 +                            )) || (_snapmanager->snapprefs.getSnapModeBBox() && (
 +                                _snapmanager->snapprefs.getSnapToBBoxPath() ||
 +                                _snapmanager->snapprefs.getSnapToBBoxNode() ||
 +                                _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() ||
 +                                _snapmanager->snapprefs.getSnapBBoxMidpoints()
 +                            )) || (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && (
 +                                _snapmanager->snapprefs.getSnapToPageBorder() ||
 +                                _snapmanager->snapprefs.getIncludeItemCenter()
 +                            ));
 +
 +    return (_snap_enabled && snap_to_something);
  }
  
  void Inkscape::ObjectSnapper::_clear_paths() const
  
  Geom::PathVector* Inkscape::ObjectSnapper::_getBorderPathv() const
  {
-     Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point(sp_document_width(_snapmanager->getDocument()),sp_document_height(_snapmanager->getDocument())));
+     Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point((_snapmanager->getDocument())->getWidth(),(_snapmanager->getDocument())->getHeight()));
      return _getPathvFromRect(border_rect);
  }
  
@@@ -834,8 -748,8 +836,8 @@@ Geom::PathVector* Inkscape::ObjectSnapp
  
  void Inkscape::ObjectSnapper::_getBorderNodes(std::vector<SnapCandidatePoint> *points) const
  {
-     Geom::Coord w = sp_document_width(_snapmanager->getDocument());
-     Geom::Coord h = sp_document_height(_snapmanager->getDocument());
+     Geom::Coord w = (_snapmanager->getDocument())->getWidth();
+     Geom::Coord h = (_snapmanager->getDocument())->getHeight();
      points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER));
      points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER));
      points->push_back(Inkscape::SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER));
@@@ -853,15 -767,15 +855,15 @@@ void Inkscape::getBBoxPoints(Geom::OptR
          // collect the corners of the bounding box
          for ( unsigned k = 0 ; k < 4 ; k++ ) {
              if (includeCorners) {
 -                points->push_back(Inkscape::SnapCandidatePoint(bbox->corner(k), Inkscape::SNAPSOURCE_BBOX_CORNER, 0, Inkscape::SNAPTARGET_BBOX_CORNER, *bbox));
 +                points->push_back(Inkscape::SnapCandidatePoint(bbox->corner(k), Inkscape::SNAPSOURCE_BBOX_CORNER, -1, Inkscape::SNAPTARGET_BBOX_CORNER, *bbox));
              }
              // optionally, collect the midpoints of the bounding box's edges too
              if (includeLineMidpoints) {
 -                points->push_back(Inkscape::SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, Inkscape::SNAPSOURCE_BBOX_EDGE_MIDPOINT, 0, Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox));
 +                points->push_back(Inkscape::SnapCandidatePoint((bbox->corner(k) + bbox->corner((k+1) % 4))/2, Inkscape::SNAPSOURCE_BBOX_EDGE_MIDPOINT, -1, Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, *bbox));
              }
          }
          if (includeObjectMidpoints) {
 -            points->push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_BBOX_MIDPOINT, 0, Inkscape::SNAPTARGET_BBOX_MIDPOINT, *bbox));
 +            points->push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_BBOX_MIDPOINT, -1, Inkscape::SNAPTARGET_BBOX_MIDPOINT, *bbox));
          }
      }
  }
diff --combined src/path-chemistry.cpp
index 6a796b2ed01504dcfb96a669e27000fc1ebd1b90,12913fd858d97fc53900b32ec71f8f4c97fe8aa4..bec3c5cbff27f23c51bd27e83da0d13fad7c6c6c
@@@ -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 <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-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)
  {
          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);
  
          // 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
          // 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;
  
      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, _("<b>No path(s)</b> 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, _("<b>No objects</b> to convert to path in the selection."));
              return;
@@@ -532,7 -534,7 +539,7 @@@ sp_selected_item_to_curved_repr(SPItem 
  
      SPCurve *curve = NULL;
      if (SP_IS_SHAPE(item)) {
-         curve = sp_shape_get_curve(SP_SHAPE(item));
+         curve = SP_SHAPE(item)->getCurve();
      } 
  
      if (!curve)
@@@ -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, _("<b>No paths</b> to reverse in the selection."));
      }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/persp3d.cpp
index 543d7efde48969e800621dd1d11905bf05008eeb,60bfa765aa9a9517a033497b15d061d9b6d56a32..74208444b04418be0e1b862fffad32cb71c8f6d0
@@@ -1,10 -1,10 +1,10 @@@
--#define __PERSP3D_C__
--
  /*
   * Class modelling a 3D perspective as an SPObject
   *
   * Authors:
   *   Maximilian Albert <Anhalter42@gmx.de>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2007 authors
   *
@@@ -23,6 -23,6 +23,8 @@@
  #include "desktop-handles.h"
  #include <glibmm/i18n.h>
  
++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,20 -206,20 +208,19 @@@ 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 */
      repr = xml_doc->createElement("inkscape:perspective");
      repr->setAttribute("sodipodi:type", "inkscape:persp3d");
  
-     Proj::Pt2 proj_vp_x = Proj::Pt2 (0.0, sp_document_height(document)/2, 1.0);
+     Proj::Pt2 proj_vp_x = Proj::Pt2 (0.0, document->getHeight()/2, 1.0);
      Proj::Pt2 proj_vp_y = Proj::Pt2 (0.0, 1000.0, 0.0);
-     Proj::Pt2 proj_vp_z = Proj::Pt2 (sp_document_width(document), sp_document_height(document)/2, 1.0);
-     Proj::Pt2 proj_origin = Proj::Pt2 (sp_document_width(document)/2, sp_document_height(document)/3, 1.0);
+     Proj::Pt2 proj_vp_z = Proj::Pt2 (document->getWidth(), document->getHeight()/2, 1.0);
+     Proj::Pt2 proj_origin = Proj::Pt2 (document->getWidth()/2, document->getHeight()/3, 1.0);
  
      if (dup) {
          proj_vp_x = dup->tmat.column (Proj::X);
      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<Persp3D *
      for (std::list<Persp3D *>::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));
          }
@@@ -612,4 -612,4 +608,4 @@@ void print_current_persp3d(gchar *func_
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/print.cpp
index ba29b17ad55b3db9edea6dcb4dadd0e285e69e3b,43f0113a0cccde3e9e68ad2007f8d724f81e4c1d..e0601aa339eb930a9568868011416e79f08e9533
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_PRINT_C__
--
  /** \file
   * Frontend to printing
   */
@@@ -7,6 -7,6 +5,8 @@@
   * Author:
   *   Lauris Kaplinski <lauris@kaplinski.com>
   *   Kees Cook <kees@outflux.net>
++ *   Jon A. Cruz <jon@joncruz.org>
++ *   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);
  
  
          /* 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);
  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);
      (void)res; // TODO handle this
  
      // Release arena
-     sp_item_invoke_hide(base, dkey);
+     base->invoke_hide(dkey);
      nr_object_unref((NRObject *) arena);
  }
  
@@@ -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");
      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);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/profile-manager.cpp
index b70926947605ea5c8f14a06a5772e67c191c26de,d557fdd39f3bed216d80451737719a7c71b126e8..27ab7549715bad75a6ab20dc650503c2c375ce6b
@@@ -2,6 -2,6 +2,7 @@@
   * Inkscape::ProfileManager - a view of a document's color profiles.
   *
   * Copyright 2007  Jon A. Cruz  <jon@joncruz.org>
++ *   Abhishek Sharma
   *
   * Released under GNU GPL, read the file 'COPYING' for more information
   */
@@@ -18,20 -18,18 +19,20 @@@ 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()
  {
 +    _resource_connection.disconnect();
 +    _doc = 0;
  }
  
  void ProfileManager::_resourcesChanged()
  {
      std::vector<SPObject*> 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);
@@@ -96,4 -94,4 +97,4 @@@ ColorProfile* ProfileManager::find(gcha
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/rdf.cpp
index 99b56a103ad295edd1f50289960ca0042e9fca4e,0a8fd51f6de4e39e4b64593a31965bcb2a1b068e..c9378cf530a8aec6b4332c9d4ded4b7514458b06
@@@ -6,6 -6,6 +6,7 @@@
  /* Authors:
   *   Kees Cook <kees@outflux.net>
   *   Jon Phillips <jon@rejon.org>
++ *   Jon A. Cruz <jon@joncruz.org>
   *
   * Copyright (C) 2004 Kees Cook <kees@outflux.net>
   * Copyright (C) 2006 Jon Phillips <jon@rejon.org>
@@@ -226,68 -226,68 +227,68 @@@ struct rdf_license_t rdf_licenses [] = 
  // Remember when using the "title" and "tip" elements to pass them through
  // the localization functions when you use them!
  struct rdf_work_entity_t rdf_work_entities [] = {
 -    { "title", N_("Title"), "dc:title", RDF_CONTENT,
 -      N_("Name by which this document is formally known."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "title", N_("Title:"), "dc:title", RDF_CONTENT,
 +      N_("Name by which this document is formally known"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "date", N_("Date"), "dc:date", RDF_CONTENT,
 -      N_("Date associated with the creation of this document (YYYY-MM-DD)."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "date", N_("Date:"), "dc:date", RDF_CONTENT,
 +      N_("Date associated with the creation of this document (YYYY-MM-DD)"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "format", N_("Format"), "dc:format", RDF_CONTENT,
 -      N_("The physical or digital manifestation of this document (MIME type)."), RDF_FORMAT_LINE, RDF_EDIT_HARDCODED,
 +    { "format", N_("Format:"), "dc:format", RDF_CONTENT,
 +      N_("The physical or digital manifestation of this document (MIME type)"), RDF_FORMAT_LINE, RDF_EDIT_HARDCODED,
      },
 -    { "type", N_("Type"), "dc:type", RDF_RESOURCE,
 -      N_("Type of document (DCMI Type)."), RDF_FORMAT_LINE, RDF_EDIT_HARDCODED,
 +    { "type", N_("Type:"), "dc:type", RDF_RESOURCE,
 +      N_("Type of document (DCMI Type)"), RDF_FORMAT_LINE, RDF_EDIT_HARDCODED,
      },
  
 -    { "creator", N_("Creator"), "dc:creator", RDF_AGENT,
 -      N_("Name of entity primarily responsible for making the content of this document."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "creator", N_("Creator:"), "dc:creator", RDF_AGENT,
 +      N_("Name of entity primarily responsible for making the content of this document"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "rights", N_("Rights"), "dc:rights", RDF_AGENT,
 -      N_("Name of entity with rights to the Intellectual Property of this document."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "rights", N_("Rights:"), "dc:rights", RDF_AGENT,
 +      N_("Name of entity with rights to the Intellectual Property of this document"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "publisher", N_("Publisher"), "dc:publisher", RDF_AGENT,
 -      N_("Name of entity responsible for making this document available."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "publisher", N_("Publisher:"), "dc:publisher", RDF_AGENT,
 +      N_("Name of entity responsible for making this document available"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
  
 -    { "identifier", N_("Identifier"), "dc:identifier", RDF_CONTENT,
 -      N_("Unique URI to reference this document."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "identifier", N_("Identifier:"), "dc:identifier", RDF_CONTENT,
 +      N_("Unique URI to reference this document"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "source", N_("Source"), "dc:source", RDF_CONTENT,
 -      N_("Unique URI to reference the source of this document."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "source", N_("Source:"), "dc:source", RDF_CONTENT,
 +      N_("Unique URI to reference the source of this document"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "relation", N_("Relation"), "dc:relation", RDF_CONTENT,
 -      N_("Unique URI to a related document."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "relation", N_("Relation:"), "dc:relation", RDF_CONTENT,
 +      N_("Unique URI to a related document"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "language", N_("Language"), "dc:language", RDF_CONTENT,
 -      N_("Two-letter language tag with optional subtags for the language of this document (e.g. 'en-GB')"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "language", N_("Language:"), "dc:language", RDF_CONTENT,
 +      N_("Two-letter language tag with optional subtags for the language of this document (e.g. 'en-GB')"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
 -    { "subject", N_("Keywords"), "dc:subject", RDF_BAG,
 -      N_("The topic of this document as comma-separated key words, phrases, or classifications."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "subject", N_("Keywords:"), "dc:subject", RDF_BAG,
 +      N_("The topic of this document as comma-separated key words, phrases, or classifications"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
      // TRANSLATORS: "Coverage": the spatial or temporal characteristics of the content.
      // For info, see Appendix D of http://www.w3.org/TR/1998/WD-rdf-schema-19980409/
 -    { "coverage", N_("Coverage"), "dc:coverage", RDF_CONTENT,
 -      N_("Extent or scope of this document."), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
 +    { "coverage", N_("Coverage:"), "dc:coverage", RDF_CONTENT,
 +      N_("Extent or scope of this document"), RDF_FORMAT_LINE, RDF_EDIT_GENERIC,
      },
  
 -    { "description", N_("Description"), "dc:description", RDF_CONTENT,
 -      N_("A short account of the content of this document."), RDF_FORMAT_MULTILINE, RDF_EDIT_GENERIC,
 +    { "description", N_("Description:"), "dc:description", RDF_CONTENT,
 +      N_("A short account of the content of this document"), RDF_FORMAT_MULTILINE, RDF_EDIT_GENERIC,
      },
  
      // FIXME: need to handle 1 agent per line of input
 -    { "contributor", N_("Contributors"), "dc:contributor", RDF_AGENT,
 -      N_("Names of entities responsible for making contributions to the content of this document."), RDF_FORMAT_MULTILINE, RDF_EDIT_GENERIC,
 +    { "contributor", N_("Contributors:"), "dc:contributor", RDF_AGENT,
 +      N_("Names of entities responsible for making contributions to the content of this document"), RDF_FORMAT_MULTILINE, RDF_EDIT_GENERIC,
      },
  
      // TRANSLATORS: URL to a page that defines the license for the document
 -    { "license_uri", N_("URI"), "cc:license", RDF_RESOURCE,
 +    { "license_uri", N_("URI:"), "cc:license", RDF_RESOURCE,
        // TRANSLATORS: this is where you put a URL to a page that defines the license
 -      N_("URI to this document's license's namespace definition."), RDF_FORMAT_LINE, RDF_EDIT_SPECIAL,
 +      N_("URI to this document's license's namespace definition"), RDF_FORMAT_LINE, RDF_EDIT_SPECIAL,
      },
  
        // TRANSLATORS: fragment of XML representing the license of the document
 -    { "license_fragment", N_("Fragment"), "License", RDF_XML,
 -      N_("XML fragment for the RDF 'License' section."), RDF_FORMAT_MULTILINE, RDF_EDIT_SPECIAL,
 +    { "license_fragment", N_("Fragment:"), "License", RDF_XML,
 +      N_("XML fragment for the RDF 'License' section"), RDF_FORMAT_MULTILINE, RDF_EDIT_SPECIAL,
      },
      
      { NULL, NULL, NULL, RDF_CONTENT,
      }
  };
  
++
++// Simple start of C++-ification:
++class RDFImpl
++{
++public:
++    /**
++     * Some implementations do not put RDF stuff inside <metadata>,
++     * 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;
      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;
      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 ) {
      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 <metadata> 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 <metadata>,
--     * 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<SPDocument const *>(doc), name );
  
--        xml->setAttribute("rdf:about", "" );
++    return const_cast<Inkscape::XML::Node *>(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 <title>
--        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
      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++
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/rdf.h
index e7a1f946f476bf439e548a496d4d917ead368efa,a98f5a1e474b43354585e2824fd81cae46df07fd..bed01aed09fa2931514237307da1a6a72bd4296b
+++ 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:
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/rect-context.cpp
index 86f0b54a3631a32d0f33fea8f0bd93d3a235dd70,69a9bc2f069a71ce146874be74d35b7dd5180f52..bcb1bf7347e615586a761896448014d229fcdf6d
@@@ -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);
@@@ -110,7 -110,6 +112,7 @@@ static void sp_rect_context_init(SPRect
      event_context->tolerance = 0;
      event_context->within_tolerance = false;
      event_context->item_to_select = NULL;
 +    event_context->tool_url = "/tools/shapes/rect";
  
      rect_context->item = NULL;
  
@@@ -285,7 -284,6 +287,7 @@@ static gint sp_rect_context_root_handle
              SnapManager &m = desktop->namedview->snap_manager;
              m.setup(desktop);
              m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +            m.unSetup();
              rc->center = from_2geom(button_dt);
  
              sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
  
              Geom::Point const motion_w(event->motion.x, event->motion.y);
              Geom::Point motion_dt(desktop->w2d(motion_w));
 +
              m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +            m.unSetup();
          }
          break;
      case GDK_BUTTON_RELEASE:
@@@ -466,16 -462,16 +468,16 @@@ 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);
          Inkscape::GC::release(repr);
-         rc.item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+         rc.item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
          rc.item->updateRepr();
  
          sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
@@@ -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));
  }
  
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/removeoverlap.cpp
index 975b4becb988e0ae7ec29412fa367e5630757bad,a804ceb5f5d857c1fa5c1bc8bd4d2e8e833d870e..b01ae52281c488bb6729e36bc19ded590ac74438
@@@ -4,6 -4,6 +4,7 @@@
  /*
  * Authors:
  *   Tim Dwyer <tgdwyer@gmail.com>
++ *   Abhishek Sharma
  *
  * Copyright (C) 2005 Authors
  *
@@@ -48,7 -48,7 +49,7 @@@ void removeoverlap(GSList const *const 
                ++it)
        {
                using Geom::X; using Geom::Y;
-               Geom::OptRect item_box(sp_item_bbox_desktop(*it));
+               Geom::OptRect item_box((*it)->getBboxDesktop());
                if (item_box) {
                        Geom::Point min(item_box->min() - .5*gap);
                        Geom::Point max(item_box->max() + .5*gap);
index 0a47a585251481f95567b93f37ba10d9994f6355,f7f2bd7da2c718bc49439c7e8117c64ed17a3228..6d8c4d0489b9290aec093ad1d98dfd21285952bf
@@@ -13,7 -13,7 +13,7 @@@ void satisfied_guide_cns(SPDesktop cons
      for (GSList const *l = nv.guides; l != NULL; l = l->next) {
          SPGuide &g = *SP_GUIDE(l->data);
          for (unsigned int i = 0; i < snappoints.size(); ++i) {
-             if (approx_equal( sp_guide_distance_from_pt(&g, snappoints[i].getPoint()), 0) ) {
+             if (approx_equal( g.getDistanceFrom(snappoints[i].getPoint()), 0) ) {
                  cns.push_back(SPGuideConstraint(&g, i));
              }
          }
@@@ -30,4 -30,4 +30,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/selcue.cpp
index 8756524dd6b37c01078f93f0c96ae3d82414057d,0b28a8aef11104145ee178a34a0d5a6cb80bfe1e..171178c4132f2bd7b46e87b98eb6d2da30273c49
@@@ -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
   *
@@@ -84,7 -84,7 +83,7 @@@ void Inkscape::SelCue::_updateItemBboxe
          SPCanvasItem* box = _item_bboxes[bcount ++];
  
          if (box) {
-             Geom::OptRect const b = sp_item_bbox_desktop(item, bbox_type);
+             Geom::OptRect const b = item->getBboxDesktop(bbox_type);
  
              if (b) {
                  sp_canvas_item_show(box);
@@@ -125,7 -125,7 +124,7 @@@ void Inkscape::SelCue::_newItemBboxes(
      for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {
          SPItem *item = (SPItem *) l->data;
  
-         Geom::OptRect const b = sp_item_bbox_desktop(item, bbox_type);
+         Geom::OptRect const b = item->getBboxDesktop(bbox_type);
  
          SPCanvasItem* box = NULL;
  
@@@ -192,7 -192,7 +191,7 @@@ void Inkscape::SelCue::_newTextBaseline
                          NULL);
  
                      sp_canvas_item_show(baseline_point);
-                     SP_CTRL(baseline_point)->moveto((*pt) * sp_item_i2d_affine(item));
+                     SP_CTRL(baseline_point)->moveto((*pt) * item->i2d_affine());
                      sp_canvas_item_move_to_z(baseline_point, 0);
                  }
              }
diff --combined src/select-context.cpp
index 028c8634b62435475a926670ec97082a881c66f7,215436f38099563068b0e91c917e9cacf25dffb0..febcc282d7b2f5a349b1cc893bd1dc948d5000f3
@@@ -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);
                  // 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());
  
                          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();
index 8b917de55ed8201a7da335684856c9962c673fb5,bd2d2768c53d60cb43bc9ddba87e7cb95e5d3a14..d63ee7e83efe6b2452033b132de084a5277b5930
@@@ -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;
  
@@@ -241,7 -241,7 +243,7 @@@ void sp_selection_copy_impl(GSList cons
  
      // Copy item reprs:
      for (GSList *i = (GSList *) sorted_items; i != NULL; i = i->next) {
-         sp_selection_copy_one(SP_OBJECT_REPR(i->data), sp_item_i2doc_affine(SP_ITEM(i->data)), clip, xml_doc);
+         sp_selection_copy_one(SP_OBJECT_REPR(i->data), SP_ITEM(i->data)->i2doc_affine(), clip, xml_doc);
      }
  
      *clip = g_slist_reverse(*clip);
  
  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
          Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
  
          // premultiply the item transform by the accumulated parent transform in the paste layer
-         Geom::Matrix local(sp_item_i2doc_affine(SP_ITEM(parent)));
+         Geom::Matrix local(SP_ITEM(parent)->i2doc_affine());
          if (!local.isIdentity()) {
              gchar const *t_str = copy->attribute("transform");
              Geom::Matrix item_t(Geom::identity());
@@@ -285,9 -285,9 +287,9 @@@ void sp_selection_delete_impl(GSList co
          sp_object_ref((SPObject *)i->data, NULL);
      }
      for (GSList const *i = items; i != NULL; i = i->next) {
 -        SPItem *item = (SPItem *) i->data;
 -        SP_OBJECT(item)->deleteObject(propagate, propagate_descendants);
 -        sp_object_unref((SPObject *)item, NULL);
 +        SPItem *item = reinterpret_cast<SPItem *>(i->data);
 +        item->deleteObject(propagate, propagate_descendants);
 +        sp_object_unref(item, NULL);
      }
  }
  
@@@ -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;
          }
  
       */
      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
                  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);
                          g_free(newref);
                      }
                  }
-                         doc->getObjectById(new_ids[i])->repr->setAttribute("xlink:href", 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])->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);
@@@ -451,18 -442,18 +453,17 @@@ void sp_edit_clear_all(SPDesktop *dt
      GSList *items = sp_item_group_item_list(SP_GROUP(dt->currentLayer()));
  
      while (items) {
 -        SP_OBJECT(items->data)->deleteObject();
 +        reinterpret_cast<SPObject*>(items->data)->deleteObject();
          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()) &&
@@@ -568,7 -559,7 +569,7 @@@ void sp_edit_invert_in_all_layers(SPDes
  }
  
  void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {
 -    
 +
      p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position);
  
      // Remember the position and parent of the topmost object.
              Geom::Matrix item_t(Geom::identity());
              if (t_str)
                  sp_svg_transform_read(t_str, &item_t);
-             item_t *= sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent())));
+             item_t *= SP_ITEM(doc->getObjectByRepr(current->parent()))->i2doc_affine();
              // FIXME: when moving both clone and original from a transformed group (either by
              // grouping into another parent, or by cut/paste) the transform from the original's
              // parent becomes embedded into original itself, and this affects its clones. Fix
  
  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);
  
      }
  
      GSList const *l = (GSList *) selection->reprList();
 -    
 +
      GSList *p = g_slist_copy((GSList *) l);
 -    
 +
      selection->clear();
  
      Inkscape::XML::Node *group = xml_doc->createElement("svg:g");
  
      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 */
@@@ -779,23 -770,23 +781,19 @@@ enclose_items(GSList const *items
  
      Geom::OptRect r;
      for (GSList const *i = items; i; i = i->next) {
-         r = Geom::unify(r, sp_item_bbox_desktop((SPItem *) i->data));
+         r = Geom::unify(r, ((SPItem *) i->data)->getBboxDesktop());
      }
      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
@@@ -830,12 -821,12 +828,12 @@@ sp_selection_raise(SPDesktop *desktop
      // Iterate over all objects in the selection (starting from top).
      if (selected) {
          while (rev) {
 -            SPObject *child = SP_OBJECT(rev->data);
 +            SPObject *child = reinterpret_cast<SPObject*>(rev->data);
              // for each selected object, find the next sibling
              for (SPObject *newref = child->next; newref; newref = newref->next) {
                  // if the sibling is an item AND overlaps our selection,
                  if (SP_IS_ITEM(newref)) {
-                     Geom::OptRect newref_bbox = sp_item_bbox_desktop(SP_ITEM(newref));
+                     Geom::OptRect newref_bbox = SP_ITEM(newref)->getBboxDesktop();
                      if ( newref_bbox && selected->intersects(*newref_bbox) ) {
                          // AND if it's not one of our selected objects,
                          if (!g_slist_find((GSList *) items, newref)) {
          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)
  
      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
@@@ -925,12 -918,12 +923,12 @@@ sp_selection_lower(SPDesktop *desktop
      // Iterate over all objects in the selection (starting from top).
      if (selected) {
          while (rev) {
 -            SPObject *child = SP_OBJECT(rev->data);
 +            SPObject *child = reinterpret_cast<SPObject*>(rev->data);
              // for each selected object, find the prev sibling
              for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) {
                  // if the sibling is an item AND overlaps our selection,
                  if (SP_IS_ITEM(newref)) {
-                     Geom::OptRect ref_bbox = sp_item_bbox_desktop(SP_ITEM(newref));
+                     Geom::OptRect ref_bbox = SP_ITEM(newref)->getBboxDesktop();
                      if ( ref_bbox && selected->intersects(*ref_bbox) ) {
                          // AND if it's not one of our selected objects,
                          if (!g_slist_find((GSList *) items, newref)) {
          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)
          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;
  
      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)
@@@ -1029,16 -1022,16 +1029,16 @@@ SPCSSAttr 
  take_style_from_item(SPItem *item)
  {
      // write the complete cascaded style, context-free
 -    SPCSSAttr *css = sp_css_attr_from_object(SP_OBJECT(item), SP_STYLE_FLAG_ALWAYS);
 +    SPCSSAttr *css = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS);
      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);
      }
  
      // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive
-     double ex = to_2geom(sp_item_i2doc_affine(item)).descrim();
+     double ex = to_2geom(item->i2doc_affine()).descrim();
      if (ex != 1.0) {
          css = sp_css_attr_scale(css, ex);
      }
@@@ -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)
      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;
          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;
          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?
           * 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) {
              // 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;
  
                  if (prefs_parallel) {
                      Geom::Matrix move = result * clone_move * t_inv;
-                     sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &move, compensate);
+                     item->doWriteTransform(SP_OBJECT_REPR(item), move, &move, compensate);
  
                  } else if (prefs_unmoved) {
                      //if (SP_IS_USE(sp_use_get_original(SP_USE(item))))
                      //    clone_move = Geom::identity();
                      Geom::Matrix move = result * clone_move;
-                     sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &t, compensate);
+                     item->doWriteTransform(SP_OBJECT_REPR(item), move, &t, compensate);
                  }
  
              } else {
                  // just apply the result
-                 sp_item_write_transform(item, SP_OBJECT_REPR(item), result, &t, compensate);
+                 item->doWriteTransform(SP_OBJECT_REPR(item), result, &t, compensate);
              }
  
          } else {
              if (set_i2d) {
-                 sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine);
+                 item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine);
              }
-             sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, NULL, compensate);
+             item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, NULL, compensate);
          }
  
          // if we're moving the actual object, not just updating the repr, we can transform the
          // center by the same matrix (only necessary for non-translations)
          if (set_i2d && item->isCenterSet() && !(affine.isTranslation() || affine.isIdentity())) {
              item->setCenter(old_center * affine);
 -            SP_OBJECT(item)->updateRepr();
 +            item->updateRepr();
          }
      }
  }
@@@ -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&#176; CCW") : _("Rotate 90&#176; CW"));
++    DocumentUndo::done(sp_desktop_document(desktop),
++                       ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW,
++                       ccw ? _("Rotate 90&#176; CCW") : _("Rotate 90&#176; 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) {
  
  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;
      }
@@@ -1837,7 -1830,7 +1842,7 @@@ sp_selection_item_prev(SPDesktop *deskt
          root = desktop->currentRoot();
      }
  
-     SPItem *item=next_item_from_list<Reverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
+     SPItem *item=next_item_from_list<ListReverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
  
      if (item) {
          selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer);
@@@ -2000,7 -1993,7 +2005,7 @@@ SPItem *next_item(SPDesktop *desktop, G
  void scroll_to_show_item(SPDesktop *desktop, SPItem *item)
  {
      Geom::Rect dbox = desktop->get_display_area();
-     Geom::OptRect sbox = sp_item_bbox_desktop(item);
+     Geom::OptRect sbox = item->getBboxDesktop();
  
      if ( sbox && dbox.contains(*sbox) == false ) {
          Geom::Point const s_dt = sbox->midpoint();
  }
  
  
--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()) {
          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);
  
@@@ -2101,7 -2096,7 +2106,7 @@@ sp_selection_relink(SPDesktop *desktop
              continue;
  
          SP_OBJECT_REPR(item)->setAttribute("xlink:href", newref);
 -        SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 +        item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
          relinked = true;
      }
  
      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"));
      }
  }
  
@@@ -2139,10 -2134,10 +2144,10 @@@ sp_selection_unlink(SPDesktop *desktop
          SPItem *item = (SPItem *) items->data;
  
          if (SP_IS_TEXT(item)) {
 -            SPObject *tspan = sp_tref_convert_to_tspan(SP_OBJECT(item));
 +            SPObject *tspan = sp_tref_convert_to_tspan(item);
  
              if (tspan) {
 -                SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 +                item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
              }
  
              // Set unlink to true, and fall into the next if which
          SPItem *unlink;
          if (SP_IS_USE(item)) {
              unlink = sp_use_unlink(SP_USE(item));
 +            // Unable to unlink use (external or invalid href?)
 +            if (!unlink) {
 +                new_select = g_slist_prepend(new_select, item);
 +                continue;
 +            }
          } else /*if (SP_IS_TREF(use))*/ {
 -            unlink = SP_ITEM(sp_tref_convert_to_tspan(SP_OBJECT(item)));
 +            unlink = SP_ITEM(sp_tref_convert_to_tspan(item));
          }
  
          unlinked = true;
          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
          Inkscape::Preferences *prefs = Inkscape::Preferences::get();
          bool highlight = prefs->getBool("/options/highlightoriginal/value");
          if (highlight) {
-             Geom::OptRect a = item->getBounds(sp_item_i2d_affine(item));
-             Geom::OptRect b = original->getBounds(sp_item_i2d_affine(original));
+             Geom::OptRect a = item->getBounds(item->i2d_affine());
+             Geom::OptRect b = original->getBounds(original->i2d_affine());
              if ( a && b ) {
                  // draw a flashing line between the objects
                  SPCurve *curve = new SPCurve();
  
  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);
  
          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 ) {
      }
  
      // calculate the transform to be applied to objects to move them to 0,0
-     Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - *c;
+     Geom::Point move_p = Geom::Point(0, doc->getHeight()) - *c;
      move_p[Geom::Y] = -move_p[Geom::Y];
      Geom::Matrix move = Geom::Matrix(Geom::Translate(move_p));
  
      // bottommost object, after sorting
      SPObject *parent = SP_OBJECT_PARENT(items->data);
  
-     Geom::Matrix parent_transform(sp_item_i2doc_affine(SP_ITEM(parent)));
+     Geom::Matrix parent_transform(SP_ITEM(parent)->i2doc_affine());
  
      // remember the position of the first item
      gint pos = SP_OBJECT_REPR(items->data)->position();
      if (apply) {
          // delete objects so that their clones don't get alerted; this object will be restored shortly
          for (GSList *i = items; i != NULL; i = i->next) {
 -            SPObject *item = SP_OBJECT(i->data);
 +            SPObject *item = reinterpret_cast<SPObject*>(i->data);
              item->deleteObject(false);
          }
      }
  
      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) {
              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);
  
          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;
      }
  
      // calculate the transform to be applied to objects to move them to 0,0
-     Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
+     Geom::Point move_p = Geom::Point(0, doc->getHeight()) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y]));
      move_p[Geom::Y] = -move_p[Geom::Y];
      Geom::Matrix move = Geom::Matrix(Geom::Translate(move_p));
  
      // bottommost object, after sorting
      SPObject *parent = SP_OBJECT_PARENT(items->data);
  
-     Geom::Matrix parent_transform(sp_item_i2doc_affine(SP_ITEM(parent)));
+     Geom::Matrix parent_transform(SP_ITEM(parent)->i2doc_affine());
  
      // remember the position of the first item
      gint pos = SP_OBJECT_REPR(items->data)->position();
      if (apply) {
          // delete objects so that their clones don't get alerted; this object will be restored shortly
          for (GSList *i = items; i != NULL; i = i->next) {
 -            SPObject *item = SP_OBJECT(i->data);
 +            SPObject *item = reinterpret_cast<SPObject*>(i->data);
              item->deleteObject(false);
          }
      }
  
      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);
  
  
          SPItem *item = (SPItem *) items->data;
  
 -        SPStyle *style = SP_OBJECT_STYLE(item);
 +        SPStyle *style = item->style;
  
          if (!style || !style->fill.isPaintserver())
              continue;
  
 -        SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
 +        SPPaintServer *server = item->style->getFillPaintServer();
  
          if (!SP_IS_PATTERN(server))
              continue;
          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));
  
             // 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);
          }
      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);
      }
      }
  }
  
--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);
  
  
      // 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();
  
      // 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,
  
      // 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);
      }
  
      // Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects
-     Geom::Matrix eek(sp_item_i2d_affine(SP_ITEM(parent_object)));
+     Geom::Matrix eek(SP_ITEM(parent_object)->i2d_affine());
      Geom::Matrix t;
  
      double shift_x = bbox.x0;
          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();
   * 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);
  
      }
      // /END FIXME
  
-     sp_document_ensure_up_to_date(doc);
 -    doc->ensure_up_to_date();
++    doc->ensureUpToDate();
  
      GSList *items = g_slist_copy((GSList *) selection->itemList());
  
      items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position);
 -    
 +
      // See lp bug #542004
      selection->clear();
  
      GSList *apply_to_items = NULL;
      GSList *items_to_delete = NULL;
      GSList *items_to_select = NULL;
 -    
 +
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
      bool topmost = prefs->getBool("/options/maskobject/topmost", true);
      bool remove_original = prefs->getBool("/options/maskobject/remove", true);
      if (apply_to_layer) {
          // all selected items are used for mask, which is applied to a layer
          apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer());
 -        
 +
          for (GSList *i = items; i != NULL; i = i->next) {
              Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc);
              mask_items = g_slist_prepend(mask_items, dup);
  
 -            SPObject *item = SP_OBJECT(i->data);
 -            if (remove_original) {                
 +            SPObject *item = reinterpret_cast<SPObject*>(i->data);
 +            if (remove_original) {
                  items_to_delete = g_slist_prepend(items_to_delete, item);
              }
              else {
          mask_items = g_slist_prepend(mask_items, dup);
  
          if (remove_original) {
 -            SPObject *item = SP_OBJECT(i->data);
 +            SPObject *item = reinterpret_cast<SPObject*>(i->data);
              items_to_delete = g_slist_prepend(items_to_delete, item);
          }
  
          mask_items = g_slist_prepend(mask_items, dup);
  
          if (remove_original) {
 -            SPObject *item = SP_OBJECT(i->data);
 +            SPObject *item = reinterpret_cast<SPObject*>(i->data);
              items_to_delete = g_slist_prepend(items_to_delete, item);
          }
      }
          reprs_to_group = g_slist_reverse(reprs_to_group);
  
          sp_selection_group_impl(reprs_to_group, group, xml_doc, doc);
 -        
 +
          reprs_to_group = NULL;
  
          // apply clip/mask only to newly created group
  
          gchar const *mask_id = NULL;
          if (apply_clip_path) {
-             mask_id = sp_clippath_create(mask_items_dup, doc, &maskTransform);
+             mask_id = SPClipPath::create(mask_items_dup, doc, &maskTransform);
          } else {
              mask_id = sp_mask_create(mask_items_dup, doc, &maskTransform);
          }
      g_slist_free(apply_to_items);
  
      for (GSList *i = items_to_delete; NULL != i; i = i->next) {
 -        SPObject *item = SP_OBJECT(i->data);
 +        SPObject *item = reinterpret_cast<SPObject*>(i->data);
          item->deleteObject(false);
          items_to_select = g_slist_remove(items_to_select, item);
      }
      g_slist_free(items_to_delete);
 -    
 +
      items_to_select = g_slist_reverse(items_to_select);
 -    
 +
      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
      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;
  
      GSList *items = g_slist_copy((GSList *) selection->itemList());
      selection->clear();
 -    
 +
      GSList *items_to_ungroup = NULL;
      GSList *items_to_select = g_slist_copy(items);
 -    items_to_select = g_slist_reverse(items_to_select);    
 -        
 +    items_to_select = g_slist_reverse(items_to_select);
 +
  
      // SPObject* refers to a group containing the clipped path or mask itself,
      // whereas SPItem* refers to the item being clipped or masked
      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);
              // transform mask, so it is moved the same spot where mask was applied
              Geom::Matrix transform(mask_item->transform);
              transform *= (*it).second->transform;
-             sp_item_write_transform(mask_item, SP_OBJECT_REPR(mask_item), transform);
+             mask_item->doWriteTransform(SP_OBJECT_REPR(mask_item), transform);
          }
  
          g_slist_free(items_to_move);
      }
  
      g_slist_free(items_to_ungroup);
 -    
 +
      // rebuild selection
      items_to_select = g_slist_reverse(items_to_select);
      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"));
      }
  };
  
@@@ -3318,4 -3308,4 +3325,4 @@@ void unhide_all_in_all_layers(SPDeskto
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 1f975975a6abc696f22199aaa9dfdc923b5392d7,48d1a2d162f17b4f1f339e94e7f286caff2e1f8f..65d1ba296a27a17ba0eb99aee6b65a0851220ed0
@@@ -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.
@@@ -17,6 -17,7 +18,7 @@@
   */
  
  #include "forward.h"
+ #include "sp-item.h"
  #include "2geom/forward.h"
  
  namespace Inkscape { class Selection; }
index c9d6871c3ddc953210db6d01496082f0cef9df6b,bd8d8e12e70ffeb9c65c8511f689777d5c6df191..7bc6adf38e454da21c871e2f9f283015919b9d6f
@@@ -4,6 -4,6 +4,7 @@@
   * Authors:
   *   MenTaLguY <mental@rydia.net>
   *   bulia byak <buliabyak@users.sf.net>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2006 Authors
   *
@@@ -39,8 -39,10 +40,8 @@@ const gchar 
  type2term(GType type)
  {
      if (type == SP_TYPE_ANCHOR)
 -        //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
 -      // "Link" means internet link (anchor)
 -        { return Q_("web|Link"); }
 +        //TRANSLATORS: "Link" means internet link (anchor)
 +        { return C_("Web", "Link"); }
      if (type == SP_TYPE_CIRCLE)
          { return _("Circle"); }
      if (type == SP_TYPE_ELLIPSE)
      if (type == SP_TYPE_TEXT)
          { return _("Text"); }
      if (type == SP_TYPE_USE)
 -        // 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
 -        // "Clone" is a noun, type of object
 -        { return Q_("object|Clone"); }
 +        // TRANSLATORS: "Clone" is a noun, type of object
 +        { return C_("Object", "Clone"); }
      if (type == SP_TYPE_ARC)
          { return _("Ellipse"); }
      if (type == SP_TYPE_OFFSET)
@@@ -178,7 -182,7 +179,7 @@@ void SelectionDescriber::_updateMessage
          g_free (parent_name);
  
          if (!items->next) { // one item
-             char *item_desc = sp_item_description(item);
+             char *item_desc = item->description();
              if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) {
                  _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
                                item_desc, in_phrase,
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/selection.cpp
index a4508d9bb2d0458901a76d2abcdb4710fe5eb0b8,acf6a8e6eda1e60632cc998f2040cdb4a002eb49..9cef87076db5dd20c0179fd888ead40d975f9c61
@@@ -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
@@@ -374,7 -374,7 +375,7 @@@ Geom::OptRect Selection::bounds(SPItem:
  
      Geom::OptRect bbox;
      for ( GSList const *i = items ; i != NULL ; i = i->next ) {
-         bbox = unify(bbox, sp_item_bbox_desktop(SP_ITEM(i->data), type));
+         bbox = unify(bbox, SP_ITEM(i->data)->getBboxDesktop(type));
      }
      return bbox;
  }
@@@ -393,8 -393,8 +394,8 @@@ NRRect *Selection::boundsInDocument(NRR
  
      for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) {
          SPItem *item=SP_ITEM(iter->data);
-         Geom::Matrix i2doc(sp_item_i2doc_affine(item));
-         sp_item_invoke_bbox(item, bbox, i2doc, FALSE, type);
+         Geom::Matrix i2doc(item->i2doc_affine());
+         item->invoke_bbox( bbox, i2doc, FALSE, type);
      }
  
      return bbox;
@@@ -406,8 -406,6 +407,8 @@@ Geom::OptRect Selection::boundsInDocume
  }
  
  /** Extract the position of the center from the first selected object */
 +// If we have a selection of multiple items, then the center of the first item
 +// will be returned; this is also the case in SelTrans::centerRequest()
  boost::optional<Geom::Point> Selection::center() const {
      GSList *items = (GSList *) const_cast<Selection *>(this)->itemList();
      Geom::Point center;
@@@ -438,7 -436,7 +439,7 @@@ std::vector<Inkscape::SnapCandidatePoin
      std::vector<Inkscape::SnapCandidatePoint> p;
      for (GSList const *iter = items; iter != NULL; iter = iter->next) {
          SPItem *this_item = SP_ITEM(iter->data);
-         sp_item_snappoints(this_item, p, &snapprefs_dummy);
+         this_item->getSnappoints(p, &snapprefs_dummy);
  
          //Include the transformation origin for snapping
          //For a selection or group only the overall origin is considered
@@@ -460,7 -458,7 +461,7 @@@ std::vector<Inkscape::SnapCandidatePoin
  
      std::vector<Inkscape::SnapCandidatePoint> p;
      for (GSList const *iter = items; iter != NULL; iter = iter->next) {
-         sp_item_snappoints(SP_ITEM(iter->data), p, &snapprefs_dummy);
+         SP_ITEM(iter->data)->getSnappoints(p, &snapprefs_dummy);
      }
  
      std::vector<Inkscape::SnapCandidatePoint> pHull;
@@@ -557,4 -555,4 +558,4 @@@ guint Selection::numberOfParents() 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/seltrans.cpp
index cdfcee7420a3cf84017ca4708553bf43b96ff810,627620a6007e7c0363a41830a29e9c4c4d798ebf..b0e19e60c5d9747835c2a9ea498c8621bded7c74
@@@ -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);
  
@@@ -265,7 -265,7 +267,7 @@@ void Inkscape::SelTrans::grab(Geom::Poi
          SPItem *it = (SPItem *)sp_object_ref(SP_OBJECT(l->data), NULL);
          _items.push_back(it);
          _items_const.push_back(it);
-         _items_affines.push_back(sp_item_i2d_affine(it));
+         _items_affines.push_back(it->i2d_affine());
          _items_centers.push_back(it->getCenter()); // for content-dragging, we need to remember original centers
      }
  
              // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl
              // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole
              for (unsigned i = 0; i < _items.size(); i++) {
-                 getBBoxPoints(sp_item_bbox_desktop(_items[i], _snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp);
+                 getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp);
              }
          } else {
              _bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole
              g_warning("Checking number of snap sources failed; nothing serious, but please report to Diederik");
          }
  
 -        // Optionally, show the snap source
 -        if (!(_state == STATE_ROTATE && x != 0.5 && y != 0.5)) { // but not when we're dragging a rotation handle, because that won't snap
 -            // Now either _bbox_points or _snap_points has a single element, the other one has zero..... or both have zero elements
 -            if ((_snap_points.size() + _bbox_points.size() + _bbox_points_for_translating.size()) > 1) {
 -                g_warning("too many snap sources to display, please fix this");
 -            } else if (m.snapprefs.getSnapEnabledGlobally()) {
 -                if (_bbox_points.size() == 1) {
 -                    _desktop->snapindicator->set_new_snapsource(_bbox_points.at(0));
 -                } else if (_bbox_points_for_translating.size() == 1) {
 -                    _desktop->snapindicator->set_new_snapsource(_bbox_points_for_translating.at(0));
 -                } else if (_snap_points.size() == 1){
 -                    _desktop->snapindicator->set_new_snapsource(_snap_points.at(0));
 -                }
 -            }
 -        }
      }
  
      if ((x != -1) && (y != -1)) {
@@@ -429,7 -444,7 +431,7 @@@ void Inkscape::SelTrans::transform(Geom
          for (unsigned i = 0; i < _items.size(); i++) {
              SPItem &item = *_items[i];
              Geom::Matrix const &prev_transform = _items_affines[i];
-             sp_item_set_i2d_affine(&item, prev_transform * affine);
+             item.set_i2d_affine(prev_transform * affine);
          }
      } else {
          if (_bbox) {
@@@ -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 {
                  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();
@@@ -584,15 -599,15 +586,15 @@@ void Inkscape::SelTrans::stamp(
  
              Geom::Matrix const *new_affine;
              if (_show == SHOW_OUTLINE) {
-                 Geom::Matrix const i2d(sp_item_i2d_affine(original_item));
+                 Geom::Matrix const i2d(original_item->i2d_affine());
                  Geom::Matrix const i2dnew( i2d * _current_relative_affine );
-                 sp_item_set_i2d_affine(copy_item, i2dnew);
+                 copy_item->set_i2d_affine(i2dnew);
                  new_affine = &copy_item->transform;
              } else {
                  new_affine = &original_item->transform;
              }
  
-             sp_item_write_transform(copy_item, copy_repr, *new_affine);
+             copy_item->doWriteTransform(copy_repr, *new_affine);
  
              if ( copy_item->isCenterSet() && _center ) {
                  copy_item->setCenter(*_center * _current_relative_affine);
              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:
@@@ -868,11 -883,7 +870,11 @@@ gboolean Inkscape::SelTrans::handleRequ
      if (handle.request(this, handle, *position, state)) {
          sp_knot_set_position(knot, *position, state);
          SP_CTRL(_grip)->moveto(*position);
 -        SP_CTRL(_norm)->moveto(_origin);
 +        if (&handle == &handle_center) {
 +            SP_CTRL(_norm)->moveto(*position);
 +        } else {
 +            SP_CTRL(_norm)->moveto(_origin);
 +        }
      }
  
      return TRUE;
@@@ -1024,7 -1035,6 +1026,7 @@@ gboolean Inkscape::SelTrans::scaleReque
              geom_scale = Geom::Scale(sn.getTransformation());
              pt = _calcAbsAffineGeom(geom_scale);
          }
 +        m.unSetup();
      }
  
      /* Status text */
@@@ -1120,8 -1130,6 +1122,8 @@@ gboolean Inkscape::SelTrans::stretchReq
              // will have to calculate pt taking the stroke width into account
              pt = _calcAbsAffineGeom(geom_scale);
          }
 +
 +        m.unSetup();
      }
  
      // status text
@@@ -1201,7 -1209,7 +1203,7 @@@ gboolean Inkscape::SelTrans::skewReques
          SnapManager &m = _desktop->namedview->snap_manager;
          m.setup(_desktop, false, _items_const);
  
 -        Inkscape::Snapper::ConstraintLine const constraint(component_vectors[dim_b]);
 +        Inkscape::Snapper::SnapConstraint const constraint(component_vectors[dim_b]);
          // When skewing, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapSkew" for details
          Geom::Point const s(skew[dim_a], scale[dim_a]);
          Inkscape::SnappedPoint sn = m.constrainedSnapSkew(_snap_points, _point, constraint, s, _origin, Geom::Dim2(dim_b));
          } else {
              _desktop->snapindicator->remove_snaptarget();
          }
 +
 +        m.unSetup();
      }
  
      // Update the handle position
@@@ -1270,10 -1276,7 +1272,10 @@@ gboolean Inkscape::SelTrans::rotateRequ
      if (fabs(h2) < 1e-15) return FALSE;
      Geom::Point q2 = d2 / h2; // normalized new vector to handle
  
 -    double radians;
 +    Geom::Rotate r1(q1);
 +    Geom::Rotate r2(q2);
 +
 +    double radians = atan2(Geom::dot(Geom::rot90(d1), d2), Geom::dot(d1, d2));;
      if (state & GDK_CONTROL_MASK) {
          // Snap to defined angle increments
          double cos_t = Geom::dot(q1, q2);
          if (snaps) {
              radians = ( M_PI / snaps ) * floor( radians * snaps / M_PI + .5 );
          }
 -        q1 = Geom::Point(1, 0);
 -        q2 = Geom::Point(cos(radians), sin(radians));
 +        r1 = Geom::Rotate(0); //q1 = Geom::Point(1, 0);
 +        r2 = Geom::Rotate(radians); //q2 = Geom::Point(cos(radians), sin(radians));
      } else {
 -        radians = atan2(Geom::dot(Geom::rot90(d1), d2),
 -                        Geom::dot(d1, d2));
 +        SnapManager &m = _desktop->namedview->snap_manager;
 +        m.setup(_desktop, false, _items_const);
 +        // When rotating, we cannot snap the corners of the bounding box, see the comment in "constrainedSnapRotate" for details
 +        Inkscape::SnappedPoint sn = m.constrainedSnapRotate(_snap_points, _point, radians, _origin);
 +        m.unSetup();
 +
 +        if (sn.getSnapped()) {
 +            _desktop->snapindicator->set_new_snaptarget(sn);
 +            // We snapped something, so change the rotation to reflect it
 +            radians = sn.getTransformation()[0];
 +            r1 = Geom::Rotate(0);
 +            r2 = Geom::Rotate(radians);
 +        } else {
 +            _desktop->snapindicator->remove_snaptarget();
 +        }
 +
      }
  
 -    Geom::Rotate const r1(q1);
 -    Geom::Rotate const r2(q2);
  
      // Calculate the relative affine
      _relative_affine = r2 * r1.inverse();
  // Move the item's transformation center
  gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state)
  {
 +    // When dragging the transformation center while multiple items have been selected, then those
 +    // items will share a single center. While dragging that single center, it should never snap to the
 +    // centers of any of the selected objects. Therefore we will have to pass the list of selected items
 +    // to the snapper, to avoid self-snapping of the rotation center
 +    GSList *items = (GSList *) const_cast<Selection *>(_selection)->itemList();
      SnapManager &m = _desktop->namedview->snap_manager;
      m.setup(_desktop);
 -    m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_OTHER_HANDLE);
 -
 -    if (state & GDK_CONTROL_MASK) {
 -        if ( fabs(_point[Geom::X] - pt[Geom::X]) > fabs(_point[Geom::Y] - pt[Geom::Y]) ) {
 -            pt[Geom::Y] = _point[Geom::Y];
 -        } else {
 -            pt[Geom::X] = _point[Geom::X];
 +    m.setRotationCenterSource(items);
 +
 +    if (state & GDK_CONTROL_MASK) { // with Ctrl, constrain to axes
 +        std::vector<Inkscape::Snapper::SnapConstraint> constraints;
 +        constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(1, 0)));
 +        constraints.push_back(Inkscape::Snapper::SnapConstraint(_point, Geom::Point(0, 1)));
 +        Inkscape::SnappedPoint sp = m.multipleConstrainedSnaps(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER), constraints, state & GDK_SHIFT_MASK);
 +        pt = sp.getPoint();
 +    }
 +    else {
 +        if (!(state & GDK_SHIFT_MASK)) { // Shift disables snapping
 +            m.freeSnapReturnByRef(pt, Inkscape::SNAPSOURCE_ROTATION_CENTER);
          }
      }
  
 -    if ( !(state & GDK_SHIFT_MASK) && _bbox ) {
 -        // screen pixels to snap center to bbox
 -#define SNAP_DIST 5
 -        // FIXME: take from prefs
 -        double snap_dist = SNAP_DIST / _desktop->current_zoom();
 -
 -        for (int i = 0; i < 2; i++) {
 -            if (fabs(pt[i] - _bbox->min()[i]) < snap_dist) {
 -                pt[i] = _bbox->min()[i];
 -            }
 -            if (fabs(pt[i] - _bbox->midpoint()[i]) < snap_dist) {
 -                pt[i] = _bbox->midpoint()[i];
 -            }
 -            if (fabs(pt[i] - _bbox->max()[i]) < snap_dist) {
 -                pt[i] = _bbox->max()[i];
 -            }
 -        }
 -    }
 +    m.unSetup();
  
      // status text
      GString *xs = SP_PX_TO_METRIC_STRING(pt[Geom::X], _desktop->namedview->getDefaultMetric());
@@@ -1432,7 -1430,6 +1434,7 @@@ void Inkscape::SelTrans::moveTo(Geom::P
          }
          m.setup(_desktop, true, _items_const);
          dxy = m.multipleOfGridPitch(dxy, _point);
 +        m.unSetup();
      } else if (shift) {
          if (control) { // shift & control: constrained movement without snapping
              if (fabs(dxy[Geom::X]) > fabs(dxy[Geom::Y])) {
              // the constraint-line once. The constraint lines are parallel, but might not be colinear.
              // Therefore we will have to set the point through which the constraint-line runs
              // individually for each point to be snapped; this will be handled however by _snapTransformed()
 -            s.push_back(m.constrainedSnapTranslation(_bbox_points_for_translating,
 +            s.push_back(m.constrainedSnapTranslate(_bbox_points_for_translating,
                                                       _point,
 -                                                     Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
 +                                                     Inkscape::Snapper::SnapConstraint(component_vectors[dim]),
                                                       dxy));
  
 -            s.push_back(m.constrainedSnapTranslation(_snap_points,
 +            s.push_back(m.constrainedSnapTranslate(_snap_points,
                                                       _point,
 -                                                     Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
 +                                                     Inkscape::Snapper::SnapConstraint(component_vectors[dim]),
                                                       dxy));
          } else { // !control
  
              g_get_current_time(&starttime); */
  
              /* Snap to things with no constraint */
 -            s.push_back(m.freeSnapTranslation(_bbox_points_for_translating, _point, dxy));
 -            s.push_back(m.freeSnapTranslation(_snap_points, _point, dxy));
 +            s.push_back(m.freeSnapTranslate(_bbox_points_for_translating, _point, dxy));
 +            s.push_back(m.freeSnapTranslate(_snap_points, _point, dxy));
  
                /*g_get_current_time(&endtime);
                double elapsed = ((((double)endtime.tv_sec - starttime.tv_sec) * G_USEC_PER_SEC + (endtime.tv_usec - starttime.tv_usec))) / 1000.0;
                std::cout << "Time spent snapping: " << elapsed << std::endl; */
          }
 +        m.unSetup();
  
          /* Pick one */
          Inkscape::SnappedPoint best_snapped_point;
              if (control) {
                  // If we didn't snap, then we should still constrain horizontally or vertically
                  // (When we did snap, then this constraint has already been enforced by
 -                // calling constrainedSnapTranslation() above)
 +                // calling constrainedSnapTranslate() above)
                  if (fabs(dxy[Geom::X]) > fabs(dxy[Geom::Y])) {
                      dxy[Geom::Y] = 0;
                  } else {
@@@ -1645,7 -1641,6 +1647,7 @@@ void Inkscape::SelTrans::_keepClosestPo
          }
      }
  
 +    closest_point.setSourceNum(-1);
      points.clear();
      points.push_back(closest_point);
  }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-anchor.cpp
index aabefdfdb4cfe14d87607bd310b746fcad061e11,9a5e8b1c1c758b453ee9cabe1693c98ef5ae888c..e57ac8a585ea0c9487fd2f5358c56a603fe4ec06
@@@ -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 --combined src/sp-animation.cpp
index 132d0aa0f1b8b9088a1efb96efc0a09e00e85edb,85fa615deca839d6bda218e52d89f785fe041443..f0796b7c61209caeb14fc251ed00663a5d40e050
@@@ -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
@@@ -287,4 -287,4 +286,4 @@@ sp_animate_set(SPObject *object, unsign
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-clippath.cpp
index 856c10b1e3791a157c400a6055d8a76ada4e22b5,d074ef197f248bb3e48b7f74fd1e19c3091aa51e..16368b9c6f64e00c6545119b631d7817363095ae
@@@ -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,60 -37,61 +37,47 @@@ 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) {
          GTypeInfo info = {
              sizeof(SPClipPathClass),
              NULL, NULL,
-             (GClassInitFunc) sp_clippath_class_init,
+             (GClassInitFunc) SPClipPathClass::sp_clippath_class_init,
              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;
      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);
          cp->display = sp_clippath_view_list_remove(cp->display, cp->display);
      }
  
-     if (((SPObjectClass *) (parent_class))->release) {
-         ((SPObjectClass *) parent_class)->release(object);
+     if (((SPObjectClass *) (SPClipPathClass::static_parent_class))->release) {
+         ((SPObjectClass *) SPClipPathClass::static_parent_class)->release(object);
      }
  }
  
- 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) {
              }
              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);
      if (SP_IS_ITEM(ochild)) {
          SPClipPath *cp = SP_CLIPPATH(object);
          for (SPClipPathView *v = cp->display; v != NULL; v = v->next) {
-             NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(ochild),
-                                                   NR_ARENA_ITEM_ARENA(v->arenaitem),
+             NRArenaItem *ac = SP_ITEM(ochild)->invoke_show(                                                  NR_ARENA_ITEM_ARENA(v->arenaitem),
                                                    v->key,
                                                    SP_ITEM_REFERENCE_FLAGS);
              if (ac) {
      }
  }
  
- 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;
  
      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);
      }
      }
  }
  
- 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;
  
      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);
      }
      }
  }
  
- 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);
          }
      }
  
-     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;
          }
      }
      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) ||
      }
  }
  
--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");
  
          if (NULL != applyTransform) {
              Geom::Matrix transform (item->transform);
              transform *= (*applyTransform);
-             sp_item_write_transform(item, SP_OBJECT_REPR(item), transform);
+             item->doWriteTransform(SP_OBJECT_REPR(item), transform);
          }
      }
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-clippath.h
index 02395f3d2e605bd911320182be32a7b623689724,239dca04957045f80df39bee65465630c481c10f..a622df1f6b351401faead55c43ac8c8a59c73cec
@@@ -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.
   * 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;
  
  #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="...">)
       * \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;
              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 --combined src/sp-conn-end-pair.cpp
index 7f019979a7bd65b95fd3589de02aba5310a80d06,21ecf6b43028c24d26d61422b9b411759c951a90..0a5a6d7bdde9e9fb72ae144ba76ab29c7e0355c5
@@@ -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" );
  }
  
  
@@@ -405,7 -405,7 +406,7 @@@ SPConnEndPair::reroutePathFromLibavoid(
  
      recreateCurve( curve, _connRef, _connCurvature );
  
-     Geom::Matrix doc2item = sp_item_i2doc_affine(SP_ITEM(_path)).inverse();
+     Geom::Matrix doc2item = SP_ITEM(_path)->i2doc_affine().inverse();
      curve->transform(doc2item);
  
      return true;
diff --combined src/sp-defs.cpp
index aa0cb0be7643f285f71af3c052fa78cb4596c24e,b523322e136eba709d3878078327a4a4592182a2..2737b3f5c1a2bf8b4c3a333d7b3b9d9ea609df2b
@@@ -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
   *
  #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);
      }
      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;
      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);
      }
          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) {
  
          }
  
          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) {
          }
  
      } 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 *) (parent_class))->write) {
-         (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags);
+     if (((SPObjectClass *) (SPDefsClass::static_parent_class))->write) {
+         (* ((SPObjectClass *) (SPDefsClass::static_parent_class))->write)(object, xml_doc, repr, flags);
      }
  
      return repr;
diff --combined src/sp-defs.h
index 4b6f7a5b712b3c49bd6b059f00f5edf46a733bb0,c88aef81e61cf5ef824aa847eaee7bc0d3f3ea95..83003f4ad631d1cfb3af50c10e17cc5911c3928b
@@@ -6,6 -6,6 +6,7 @@@
   *
   * Authors:
   *   Lauris Kaplinski <lauris@kaplinski.com>
++ *   Abhishek Sharma
   *
   * Copyright (C) 2000-2002 authors
   *
  
  #include "sp-object.h"
  
- #define SP_TYPE_DEFS            (sp_defs_get_type())
+ #define SP_TYPE_DEFS            (SPDefs::sp_defs_get_type())
  #define SP_DEFS(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_DEFS, SPDefs))
  #define SP_DEFS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_DEFS, SPDefsClass))
  #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 --combined src/sp-ellipse.cpp
index d2472c914e87ebb600787d4ec2571502c30084b0,7eb473d0310523f70046e05dac0df40caf4b92b6..ef58e4d6e316b6866ff46efaa3a9dc139270c5fb
@@@ -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)
@@@ -192,7 -190,7 +191,7 @@@ static void sp_genericellipse_set_shape
              // unconditionally read the curve from d, if any, to preserve appearance
              Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
              SPCurve *cold = new SPCurve(pv);
-             sp_shape_set_curve_insync (shape, cold, TRUE);
+             shape->setCurveInsync( cold, TRUE);
              cold->unref();
          }
          return;
  
      /* Reset the shape'scurve to the "original_curve"
       * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
-     sp_shape_set_curve_insync (shape, curve, TRUE);
+     shape->setCurveInsync( curve, TRUE);
      if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
          SPCurve *c_lpe = curve->copy();
          bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
          if (success) {
-             sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+             shape->setCurveInsync( c_lpe, TRUE);
          }
          c_lpe->unref();
      }
@@@ -283,7 -281,7 +282,7 @@@ static void sp_genericellipse_snappoint
  
      SPGenericEllipse *ellipse = SP_GENERICELLIPSE(item);
      sp_genericellipse_normalize(ellipse);
-     Geom::Matrix const i2d = sp_item_i2d_affine(item);
+     Geom::Matrix const i2d = item->i2d_affine();
  
      // figure out if we have a slice, while guarding against rounding errors
      bool slice = false;
@@@ -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" );
  }
  
  /*
@@@ -857,7 -855,7 +856,7 @@@ static voi
  sp_arc_modified(SPObject *object, guint flags)
  {
      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();
      }
  
      if (((SPObjectClass *) arc_parent_class)->modified)
@@@ -925,4 -923,4 +924,4 @@@ Geom::Point sp_arc_get_xy(SPArc *arc, g
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 265c72b14590046eacbde8f8d123ba9fc3bb54ff,4ce0e133d2d63ce233eb519e7a5f4532a8635390..30eda7159e8508987bfc2db46b3f2b3869caf1e6
@@@ -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;
@@@ -292,4 -293,4 +292,4 @@@ void sp_filter_primitive_renderer_commo
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-filter.cpp
index a39cc64372d4ee2c4fa43fbc81bfb63d2a14b12f,e65a7be0552b51ab35f05267fd5f3d75dc00fae1..cfd6253a3e7c0e64b8b9dd023abfad2e95ea0c92
@@@ -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);
              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);
          }
      }
@@@ -583,4 -583,4 +582,4 @@@ bool ltstr::operator()(const char* s1, 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-flowdiv.cpp
index 6d679701fdc098836244aa32d3a4be38644d7c79,41df696092a71024973e6ebbaba11f9ef4f21565..4d07cffd7bc0b3039d79f2b60986fc0a71587445
@@@ -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 --combined src/sp-flowregion.cpp
index 79007cac7735a7494fb43db723ef5395de4f491c,cff7a5db78edc2c90e6cd3f0a4b6ca10a0c8ac57..680589b551e4090e0336703a4ec4f69f6291c1ec
@@@ -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) {
          }
  
      } 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) {
          }
  
      } 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;
  }
  
  
@@@ -520,7 -520,7 +512,7 @@@ static void         GetDest(SPObject* c
                tr_mat = SP_ITEM(u_child)->transform;
        }
        if ( SP_IS_SHAPE (u_child) ) {
-               curve = sp_shape_get_curve (SP_SHAPE (u_child));
+               curve = SP_SHAPE (u_child)->getCurve ();
        } else if ( SP_IS_TEXT (u_child) ) {
        curve = SP_TEXT (u_child)->getNormalizedBpath ();
        }
        }
  }
  
++/*
++  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 --combined src/sp-flowtext.cpp
index b01146d60a3797408a608e4f7f058e717e0aa9fc,4c3cc8a6c5fba18e885cfadc6923db7ed423e2b1..3af12064ff622e7f1b31f7888bd537307ce5a24e
@@@ -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);
      }
      group->rebuildLayout();
  
      NRRect paintbox;
-     sp_item_invoke_bbox(group, &paintbox, Geom::identity(), TRUE);
+     group->invoke_bbox( &paintbox, Geom::identity(), TRUE);
      for (SPItemView *v = group->display; v != NULL; v = v->next) {
          group->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
          nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
      }
  }
  
--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;
      if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
          SPFlowtext *text = SP_FLOWTEXT(object);
          NRRect paintbox;
-         sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE);
+         text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
          for (SPItemView* v = text->display; v != NULL; v = v->next) {
              text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
              nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
          }
      }
  
-     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) {
      }
  }
  
--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);
              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;
  }
@@@ -351,9 -352,9 +355,9 @@@ sp_flowtext_print(SPItem *item, SPPrint
      SPFlowtext *group = SP_FLOWTEXT(item);
  
      NRRect pbox;
-     sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
+     item->invoke_bbox( &pbox, Geom::identity(), TRUE);
      NRRect bbox;
-     Geom::OptRect bbox_maybe = sp_item_bbox_desktop(item);
+     Geom::OptRect bbox_maybe = item->getBboxDesktop();
      if (!bbox_maybe) {
          return;
      }
      NRRect dbox;
      dbox.x0 = 0.0;
      dbox.y0 = 0.0;
-     dbox.x1 = sp_document_width(SP_OBJECT_DOCUMENT(item));
-     dbox.y1 = sp_document_height(SP_OBJECT_DOCUMENT(item));
-     Geom::Matrix const ctm (sp_item_i2d_affine(item));
+     dbox.x1 = SP_OBJECT_DOCUMENT(item)->getWidth();
+     dbox.y1 = SP_OBJECT_DOCUMENT(item)->getHeight();
+     Geom::Matrix const ctm (item->i2d_affine());
  
      group->layout.print(ctx, &pbox, &dbox, &bbox, ctm);
  }
@@@ -392,7 -393,7 +396,7 @@@ static void sp_flowtext_snappoints(SPIt
      if (layout != NULL && layout->outputExists()) {
          boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
          if (pt) {
-             p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
+             p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
          }
      }
  }
@@@ -408,7 -409,7 +412,7 @@@ sp_flowtext_show(SPItem *item, NRArena 
  
      // pass the bbox of the flowtext object as paintbox (used for paintserver fills)
      NRRect paintbox;
-     sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE);
+     item->invoke_bbox( &paintbox, Geom::identity(), TRUE);
      group->layout.show(flowed, &paintbox);
  
      return flowed;
@@@ -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))
                  }
                  *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"));
  
  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));
      Inkscape::GC::release(para_repr);
      Inkscape::GC::release(rect_repr);
  
-     ft_item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+     ft_item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
  
      return ft_item;
  }
diff --combined src/sp-font-face.cpp
index 1912676d42471e8cc171afcbaa685b1f446bf9b6,a5894f83a23cfbaf34aac0fe30f9bf93d99e0cf5..93e2eeac82ea178191b3c006b50d3ed1303640c9
@@@ -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 --combined src/sp-font.cpp
index b2003cf08cd84eebfd25fd4756ad85b8df21349c,a1a2c425f3ce0c3d0b8f0853c3d8971f0bd18f0c..64f7bd481162cfc4930b6c7b7249b71bde341d98
@@@ -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 --combined src/sp-gaussian-blur.cpp
index 6bb1f64e7dc79e563b669d9aa1fd14f4db3db30a,7182e5ce9dd8c7899495cd8cad25038de26c9f59..1c28fb76fdf7513c548ffbfcd16feb3ae36bfe81
@@@ -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) {
@@@ -209,4 -209,4 +208,4 @@@ static void sp_gaussianBlur_build_rende
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-glyph-kerning.cpp
index d62fbb2c295f8a7e7464be7ce725c070e661f7e7,2efdedf7a6de38e69699eb35e039d829fc8371ef..7a9f9b2ff1372307f6227fdb030252e42c5c78cf
@@@ -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 --combined src/sp-glyph.cpp
index 0b3b85d3f73df50bf40ae542eafd740ffed9caac,a2a5c7fcd8fc2f56e6b084cd098d158b0694eb42..6f72381335e323a7a681f1dd4e711b3b7bec4f9c
@@@ -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 --combined src/sp-gradient-test.h
index a664218e0627a4336a59eda6b0c05af2973b2678,62c0ac8c2a8ef377599611e158125bd7e544096e..2a061595eea857747f53549d647ff6f68ea5f06f
@@@ -1,4 -1,4 +1,3 @@@
--
  #ifndef SEEN_SP_GRADIENT_TEST_H
  #define SEEN_SP_GRADIENT_TEST_H
  
@@@ -25,7 -25,7 +24,7 @@@ public
      {
          if ( _doc )
          {
-             sp_document_unref( _doc );
+             _doc->doUnref();
          }
      }
  
          SPGradient *gr = static_cast<SPGradient *>(g_object_new(SP_TYPE_GRADIENT, NULL));
          SP_OBJECT(gr)->document = _doc;
  
-         sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)");
+         SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)");
          TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Matrix(Geom::Translate(5, 8)) );
  
-         sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "");
+         SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "");
          TS_ASSERT_EQUALS( gr->gradientTransform, Geom::identity() );
  
-         sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "rotate(90)");
+         SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "rotate(90)");
          TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Matrix(rotate_degrees(90)) );
  
          g_object_unref(gr);
@@@ -74,7 -74,7 +73,7 @@@
          SPGradient *gr = static_cast<SPGradient *>(g_object_new(SP_TYPE_GRADIENT, NULL));
          SP_OBJECT(gr)->document = _doc;
  
-         sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "matrix(0, 1, -1, 0, 0, 0)");
+         SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "matrix(0, 1, -1, 0, 0, 0)");
          Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_doc);
          Inkscape::XML::Node *repr = xml_doc->createElement("svg:radialGradient");
          SP_OBJECT(gr)->updateRepr(repr, SP_OBJECT_WRITE_ALL);
              sp_gradient_set_gs2d_matrix(gr, funny, larger_rect, gs2d);
              TS_ASSERT( Geom::matrix_equalp(gr->gradientTransform, grXform, 1e-12) );
  
-             sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTUNITS, "userSpaceOnUse");
+             SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTUNITS, "userSpaceOnUse");
              Geom::Matrix const user_g2d(sp_gradient_get_g2d_matrix(gr, funny, larger_rect));
              Geom::Matrix const user_gs2d(sp_gradient_get_gs2d_matrix(gr, funny, larger_rect));
              TS_ASSERT_EQUALS( user_g2d, funny );
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-gradient.cpp
index cd57f40b5ef76fe9ba281a4d07813f94dc634b53,56ddd09d956d23dfb5f1b002c635b31fd35be0e3..1b8f9a11137a0e1e311200c2c00ca7ad97a81145
@@@ -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.
@@@ -45,7 -45,6 +47,7 @@@
  #include "streq.h"
  #include "uri.h"
  #include "xml/repr.h"
 +#include "style.h"
  
  #define SP_MACROS_SILENT
  #include "macros.h"
@@@ -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" );
  }
  
  /**
@@@ -169,15 -168,16 +171,15 @@@ sp_stop_set(SPObject *object, unsigned 
           * stop-color and stop-opacity properties.
           */
              {
-                 gchar const *p = sp_object_get_style_property(object, "stop-color", "black");
+                 gchar const *p = object->getStyleProperty( "stop-color", "black");
                  if (streq(p, "currentColor")) {
                      stop->currentColor = true;
                  } else {
 -                    guint32 const color = sp_svg_read_color(p, 0);
 -                    stop->specified_color.set( color );
 +                    stop->specified_color = SPStop::readStopColor( p );
                  }
              }
              {
-                 gchar const *p = sp_object_get_style_property(object, "stop-opacity", "1");
+                 gchar const *p = object->getStyleProperty( "stop-opacity", "1");
                  gdouble opacity = sp_svg_read_percentage(p, stop->opacity);
                  stop->opacity = opacity;
              }
          }
          case SP_PROP_STOP_COLOR: {
              {
-                 gchar const *p = sp_object_get_style_property(object, "stop-color", "black");
+                 gchar const *p = object->getStyleProperty( "stop-color", "black");
                  if (streq(p, "currentColor")) {
                      stop->currentColor = true;
                  } else {
                      stop->currentColor = false;
 -                    guint32 const color = sp_svg_read_color(p, 0);
 -                    stop->specified_color.set( color );
 +                    stop->specified_color = SPStop::readStopColor( p );
                  }
              }
              object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
          }
          case SP_PROP_STOP_OPACITY: {
              {
-                 gchar const *p = sp_object_get_style_property(object, "stop-opacity", "1");
+                 gchar const *p = object->getStyleProperty( "stop-opacity", "1");
                  gdouble opacity = sp_svg_read_percentage(p, stop->opacity);
                  stop->opacity = opacity;
              }
@@@ -231,12 -232,11 +233,12 @@@ sp_stop_write(SPObject *object, Inkscap
          repr = xml_doc->createElement("svg:stop");
      }
  
 -    guint32 specifiedcolor = stop->specified_color.toRGBA32( 255 );
 +    Glib::ustring colorStr = stop->specified_color.toString();
      gfloat opacity = stop->opacity;
  
 -    if (((SPObjectClass *) stop_parent_class)->write)
 +    if (((SPObjectClass *) stop_parent_class)->write) {
          (* ((SPObjectClass *) stop_parent_class)->write)(object, xml_doc, repr, flags);
 +    }
  
      // Since we do a hackish style setting here (because SPStyle does not support stop-color and
      // stop-opacity), we must do it AFTER calling the parent write method; otherwise
      if (stop->currentColor) {
          os << "currentColor";
      } else {
 -        gchar c[64];
 -        sp_svg_write_color(c, sizeof(c), specifiedcolor);
 -        os << c;
 +        os << colorStr;
      }
      os << ";stop-opacity:" << opacity;
      repr->setAttribute("style", os.str().c_str());
@@@ -286,17 -288,6 +288,17 @@@ SPGradientSpread SPGradient::getSpread(
      return spread;
  }
  
-         sp_object_setAttribute( this, "osb:paint", paintVal, 0 );
 +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;
++        setAttribute( "osb:paint", paintVal, 0 );
 +
 +        requestModified( SP_OBJECT_MODIFIED_FLAG );
 +    }
 +}
 +
  /**
   * Return stop's color as 32bit value.
   */
@@@ -308,7 -299,7 +310,7 @@@ sp_stop_get_rgba32(SPStop const *const 
       * value depends on user agent, and don't give any further restrictions that I can
       * see.) */
      if (stop->currentColor) {
-         char const *str = sp_object_get_style_property(stop, "color", NULL);
+         char const *str = stop->getStyleProperty( "color", NULL);
          if (str) {
              rgb0 = sp_svg_read_color(str, rgb0);
          }
      }
  }
  
 -/**
 - * Return stop's color as SPColor.
 - */
 -static SPColor
 -sp_stop_get_color(SPStop const *const stop)
 -{
 -    if (stop->currentColor) {
 -        char const *str = stop->getStyleProperty( "color", NULL);
 -        guint32 const dfl = 0;
 -        /* 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.) */
 -        guint32 color = dfl;
 -        if (str) {
 -            color = sp_svg_read_color(str, dfl);
 -        }
 -        SPColor ret( color );
 -        return ret;
 -    } else {
 -        return stop->specified_color;
 -    }
 -}
 -
  /*
   * Gradient
   */
@@@ -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;
-                     sp_object_setAttribute( gr, "osb:paint", paintVal.c_str(), 0 );
 +        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 ) {
++                    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;
-             gchar const * attr = gr->repr->attribute("osb:paint");
 +        if ( gr->getStopCount() > 0 ) {
-                 sp_object_setAttribute( gr, "osb:paint", "gradient", 0 );
++            gchar const * attr = gr->getAttribute("osb:paint");
 +            if ( attr && strcmp(attr, "gradient") ) {
++                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;
          }
      }
  
-         gchar const * attr = gr->repr->attribute("osb:paint");
 +    if ( gr->getStopCount() == 0 ) {
-             sp_object_setAttribute( gr, "osb:paint", "solid", 0 );
++        gchar const * attr = gr->getAttribute("osb:paint");
 +        if ( attr && strcmp(attr, "solid") ) {
++            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);
      }
  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);
          }
@@@ -712,17 -684,15 +713,17 @@@ Inkscape::XML::Node *SPGradientImpl::wr
  {
      SPGradient *gr = SP_GRADIENT(object);
  
 -    if (((SPObjectClass *) gradient_parent_class)->write)
 +    if (((SPObjectClass *) gradient_parent_class)->write) {
          (* ((SPObjectClass *) gradient_parent_class)->write)(object, xml_doc, repr, flags);
 +    }
  
      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);
          }
      }
  
 +    if ( (flags & SP_OBJECT_WRITE_EXT) && gr->isSwatch() ) {
 +        if ( gr->isSolid() ) {
 +            repr->setAttribute( "osb:paint", "solid" );
 +        } else {
 +            repr->setAttribute( "osb:paint", "gradient" );
 +        }
 +    } else {
 +        repr->setAttribute( "osb:paint", 0 );
 +    }
 +
      return repr;
  }
  
@@@ -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 */
          sp_repr_set_css_double(child, "offset", gr->vector.stops[i].offset);
          /* strictly speaking, offset an SVG <number> rather than a CSS one, but exponents make no
           * sense for offset proportions. */
 -        gchar c[64];
 -        sp_svg_write_color(c, sizeof(c), gr->vector.stops[i].color.toRGBA32( 0x00 ));
 -        os << "stop-color:" << c << ";stop-opacity:" << gr->vector.stops[i].opacity;
 +        os << "stop-color:" << gr->vector.stops[i].color.toString() << ";stop-opacity:" << gr->vector.stops[i].opacity;
          child->setAttribute("style", os.str().c_str());
          /* Order will be reversed here */
          cl = g_slist_prepend(cl, child);
@@@ -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 ++;
          }
          }
      }
  
-     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);
  
              // down to 100%."
              gstop.offset = CLAMP(gstop.offset, 0, 1);
  
 -            gstop.color = sp_stop_get_color(stop);
 +            gstop.color = stop->getEffectiveColor();
              gstop.opacity = stop->opacity;
  
              vector.stops.push_back(gstop);
@@@ -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" );
  }
  
  /**
@@@ -1999,4 -1961,4 +1996,4 @@@ sp_rg_fill(SPPainter *painter, NRPixBlo
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index e42b2ed322e5c5fa4c66b49a590ceb1c22e843c9,5e3688b888dfbe0877a378e089c1a31e7c47eba2..e5c63d04e03b3cf10d318a06b286254580b0f059
@@@ -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:
@@@ -40,4 -41,4 +40,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-guide.cpp
index f5edf7d97cf3a63baf9820d97bf57822ae640f1b,21b3504860c684b77114c7edae77846e60a35be9..f92d791162e5267677eb10804185d5c4280771a0
@@@ -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");
  
      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));
  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);
      }
  }
  
@@@ -273,7 -274,7 +274,7 @@@ sp_guide_create_guides_around_page(SPDe
      std::list<std::pair<Geom::Point, Geom::Point> > pts;
  
      Geom::Point A(0, 0);
-     Geom::Point C(sp_document_width(doc), sp_document_height(doc));
+     Geom::Point C(doc->getWidth(), doc->getHeight());
      Geom::Point B(C[Geom::X], 0);
      Geom::Point D(0, C[Geom::Y]);
  
  
      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;
          }
      }
      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;
      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 --combined src/sp-guide.h
index 91c181a7046146d9ea21d5f4894a5cb393f96993,b5914e8905400db28694f46710c2293912389baa..4fc4032db44b2b08cff27a78fededf4ffa91553b
@@@ -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;
  
      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:
@@@ -73,4 -81,4 +76,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-image.cpp
index 68bafdeab9345e0c50c9e0bc43d99e4136740124,ae7ac6fa34972652dd67622d8969435797dbd2cb..ad9e79de2ba576a9fec46f9c2538ffdfa44cc722
@@@ -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.
@@@ -569,7 -569,7 +570,7 @@@ sp_image_get_type (void
              (GInstanceInitFunc) sp_image_init,
              NULL,       /* value_table */
          };
-         image_type = g_type_register_static (sp_item_get_type (), "SPImage", &image_info, (GTypeFlags)0);
+         image_type = g_type_register_static (SPItem::getType (), "SPImage", &image_info, (GTypeFlags)0);
      }
      return image_type;
  }
@@@ -585,7 -585,7 +586,7 @@@ sp_image_class_init (SPImageClass * kla
      sp_object_class = (SPObjectClass *) klass;
      item_class = (SPItemClass *) klass;
  
-     parent_class = (SPItemClass*)g_type_class_ref (sp_item_get_type ());
+     parent_class = (SPItemClass*)g_type_class_ref (SPItem::getType ());
  
      sp_object_class->build = sp_image_build;
      sp_object_class->release = sp_image_release;
@@@ -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);
@@@ -1352,7 -1358,7 +1359,7 @@@ static void sp_image_snappoints(SPItem 
          double const y0 = image.y.computed;
          double const x1 = x0 + image.width.computed;
          double const y1 = y0 + image.height.computed;
-         Geom::Matrix const i2d (sp_item_i2d_affine (item));
+         Geom::Matrix const i2d (item->i2d_affine ());
          p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER));
          p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER));
          p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER));
diff --combined src/sp-item-group.cpp
index 5884277521c9a24fcfac82d519363029c005d18d,56b9dbc217cda7d7d312fc5ccb7ba9aa6c15a469..30d08558465b4283ed19be3f9f68eff251da1bbe
@@@ -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);
  
  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);
              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);
++            }
          }
      }
  
          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);
      g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch"));
  
      // this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse
-     sp_item_adjust_paint_recursive (gitem, Geom::identity(), Geom::identity(), false);
+     gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
  
      SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem));
      Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem);
      /* 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)) {
  
              /* Merging of style */
              // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
              // it here _before_ the new transform is set, so as to use the pre-transform bbox
-             sp_item_adjust_paint_recursive (citem, Geom::identity(), Geom::identity(), false);
+             citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
  
              sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem));
              /*
          // fill in the children list if non-null
          SPItem *item = (SPItem *) doc->getObjectByRepr(repr);
  
-         sp_item_write_transform(item, repr, item->transform, NULL, false);
+         item->doWriteTransform(repr, item->transform, NULL, false);
  
          Inkscape::GC::release(repr);
          if (children && SP_IS_ITEM (item))
          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;
  }
  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);
              }
          }
      }
@@@ -604,7 -604,7 +601,7 @@@ void CGroup::onChildAdded(Inkscape::XML
              NRArenaItem *ac;
  
              for (v = _group->display; v != NULL; v = v->next) {
-                 ac = sp_item_invoke_show (SP_ITEM (ochild), NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags);
+                 ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags);
  
                  if (ac) {
                      nr_arena_item_append_child (v->arenaitem, ac);
              }
          }
      } else {    // general case
-         SPObject *ochild = sp_object_get_child_by_repr(_group, child);
+         SPObject *ochild = _group->get_child_by_repr(child);
          if ( ochild && SP_IS_ITEM(ochild) ) {
              /* TODO: this should be moved into SPItem somehow */
              SPItemView *v;
              NRArenaItem *ac;
  
-             unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild));
+             unsigned position = SP_ITEM(ochild)->pos_in_parent();
  
              for (v = _group->display; v != NULL; v = v->next) {
-                 ac = sp_item_invoke_show (SP_ITEM (ochild), NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags);
+                 ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags);
  
                  if (ac) {
                      nr_arena_item_add_child (v->arenaitem, ac, NULL);
@@@ -709,7 -709,7 +706,7 @@@ void CGroup::calculateBBox(NRRect *bbox
          if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) {
              SPItem *child = SP_ITEM(o);
              Geom::Matrix const ct(to_2geom(child->transform) * transform);
-             sp_item_invoke_bbox_full(child, dummy_bbox, ct, flags, FALSE);
+             child->invoke_bbox_full( dummy_bbox, ct, flags, FALSE);
          }
          l = g_slist_remove (l, o);
      }
@@@ -722,7 -722,7 +719,7 @@@ void CGroup::onPrint(SPPrintContext *ct
      while (l) {
          SPObject *o = SP_OBJECT (l->data);
          if (SP_IS_ITEM(o)) {
-             sp_item_invoke_print (SP_ITEM (o), ctx);
+             SP_ITEM(o)->invoke_print (ctx);
          }
          l = g_slist_remove (l, o);
      }
  
  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++;
          }
@@@ -771,7 -771,7 +768,7 @@@ void CGroup::_showChildren (NRArena *ar
          SPObject *o = SP_OBJECT (l->data);
          if (SP_IS_ITEM (o)) {
              child = SP_ITEM (o);
-             ac = sp_item_invoke_show (child, arena, key, flags);
+             ac = child->invoke_show (arena, key, flags);
              if (ac) {
                  nr_arena_item_add_child (ai, ac, ar);
                  ar = ac;
@@@ -789,7 -789,7 +786,7 @@@ void CGroup::hide (unsigned int key) 
          SPObject *o = SP_OBJECT (l->data);
          if (SP_IS_ITEM (o)) {
              child = SP_ITEM (o);
-             sp_item_invoke_hide (child, key);
+             child->invoke_hide (key);
          }
          l = g_slist_remove (l, o);
      }
  
  void CGroup::onOrderChanged (Inkscape::XML::Node *child, Inkscape::XML::Node *, Inkscape::XML::Node *)
  {
-     SPObject *ochild = sp_object_get_child_by_repr(_group, child);
+     SPObject *ochild = _group->get_child_by_repr(child);
      if ( ochild && SP_IS_ITEM(ochild) ) {
          /* TODO: this should be moved into SPItem somehow */
          SPItemView *v;
-         unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild));
+         unsigned position = SP_ITEM(ochild)->pos_in_parent();
          for ( v = SP_ITEM (ochild)->display ; v != NULL ; v = v->next ) {
              nr_arena_item_set_order (v->arenaitem, position);
          }
@@@ -858,12 -858,12 +855,12 @@@ sp_group_perform_patheffect(SPGroup *gr
              if (SP_IS_PATH(subitem)) {
                  c = sp_path_get_original_curve(SP_PATH(subitem));
              } else {
-                 c = sp_shape_get_curve(SP_SHAPE(subitem));
+                 c = SP_SHAPE(subitem)->getCurve();
              }
              // only run LPEs when the shape has a curve defined
              if (c) {
                  sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
-                 sp_shape_set_curve(SP_SHAPE(subitem), c, TRUE);
+                 SP_SHAPE(subitem)->setCurve(c, TRUE);
  
                  if (write) {
                      Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
index 6383a1faecba26b93c6aa99211a4ebbf84d546d2,340aac1acb207a9a81be33ca92aab6a2d4b9d54a..928d6f82f7fa2c8e431a26889f2a838882937c46
@@@ -25,7 -25,7 +25,7 @@@ void sp_item_notify_moveto(SPItem &item
      g_return_if_fail( dir_lensq != 0 );
  
      std::vector<Inkscape::SnapCandidatePoint> snappoints;
-     sp_item_snappoints(&item, snappoints, NULL);
+     item.getSnappoints(snappoints, NULL);
      g_return_if_fail( snappoint_ix < int(snappoints.size()) );
  
      double const pos0 = dot(dir, snappoints[snappoint_ix].getPoint());
@@@ -41,7 -41,7 +41,7 @@@
         s = (position - pos0) / dot(dir, dir). */
      Geom::Translate const tr( ( position - pos0 )
                              * ( dir / dir_lensq ) );
-     sp_item_set_i2d_affine(&item, sp_item_i2d_affine(&item) * tr);
+     item.set_i2d_affine(item.i2d_affine() * tr);
      /// \todo Reget snappoints, check satisfied.
  
      if (commit) {
@@@ -49,7 -49,7 +49,7 @@@
  
          /* Commit repr. */
          {
-             sp_item_write_transform(&item, SP_OBJECT_REPR(&item), item.transform);
+             item.doWriteTransform(SP_OBJECT_REPR(&item), item.transform);
          }
  
          sp_item_rm_unsatisfied_cns(item);
@@@ -73,4 -73,4 +73,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 78628f4a527d5a82acd80102d3d0ca1d95e22680,a7f29fb806d1c4bb72233d9d0df5649e4b6c3a67..de4c7dca1977b67bc20e5b25a46d2ac208a7e79b
@@@ -15,13 -15,13 +15,13 @@@ void sp_item_rm_unsatisfied_cns(SPItem 
          return;
      }
      std::vector<Inkscape::SnapCandidatePoint> snappoints;
-     sp_item_snappoints(&item, snappoints, NULL);
+     item.getSnappoints(snappoints, NULL);
      for (unsigned i = item.constraints.size(); i--;) {
          g_assert( i < item.constraints.size() );
          SPGuideConstraint const &cn = item.constraints[i];
          int const snappoint_ix = cn.snappoint_ix;
          g_assert( snappoint_ix < int(snappoints.size()) );
-         if (!approx_equal( sp_guide_distance_from_pt(cn.g, snappoints[snappoint_ix].getPoint()), 0) ) {
+         if (!approx_equal( cn.g->getDistanceFrom(snappoints[snappoint_ix].getPoint()), 0) ) {
              remove_last(cn.g->attached_items, SPGuideAttachment(&item, cn.snappoint_ix));
              g_assert( i < item.constraints.size() );
              vector<SPGuideConstraint>::iterator const ei(&item.constraints[i]);
@@@ -40,4 -40,4 +40,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index e401f437cfe5d9aa2241357f1fb9b50841914bc6,275d6b0466d53a7f27034f4bccde7a2074f6a26b..81780220cae38fc62becf485ce00f6786de8491e
@@@ -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
   *
@@@ -25,9 -25,9 +24,9 @@@ sp_item_rotate_rel(SPItem *item, Geom::
      Geom::Matrix affine = Geom::Matrix(s).inverse() * Geom::Matrix(rotation) * Geom::Matrix(s);
  
      // Rotate item.
-     sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine);
+     item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine);
      // Use each item's own transform writer, consistent with sp_selection_apply_affine()
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+     item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
  
      // Restore the center position (it's changed because the bbox center changed)
      if (item->isCenterSet()) {
  void
  sp_item_scale_rel (SPItem *item, Geom::Scale const &scale)
  {
-     Geom::OptRect bbox = sp_item_bbox_desktop(item);
+     Geom::OptRect bbox = item->getBboxDesktop();
      if (bbox) {
          Geom::Translate const s(bbox->midpoint()); // use getCenter?
-         sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s);
-         sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+         item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s);
+         item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
      }
  }
  
@@@ -56,8 -56,8 +55,8 @@@ sp_item_skew_rel (SPItem *item, double 
      Geom::Matrix const skew(1, skewY, skewX, 1, 0, 0);
      Geom::Matrix affine = Geom::Matrix(s).inverse() * skew * Geom::Matrix(s);
  
-     sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine);
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+     item->set_i2d_affine(item->i2d_affine() * affine);
+     item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
  
      // Restore the center position (it's changed because the bbox center changed)
      if (item->isCenterSet()) {
@@@ -68,9 -68,9 +67,9 @@@
  
  void sp_item_move_rel(SPItem *item, Geom::Translate const &tr)
  {
-       sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * tr);
+       item->set_i2d_affine(item->i2d_affine() * tr);
  
-       sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+       item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
  }
  
  /*
@@@ -200,4 -200,4 +199,4 @@@ get_visual_bbox (Geom::OptRect const &i
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index c90df01ba83c0fff7be59a0e3bcc3e036e11012d,e1b3989dc580032a046ec12c11a89428c7310b1e..315d0910812c8f007a50489c158158abb303a462
@@@ -10,7 -10,7 +10,7 @@@ using std::vector
  void sp_item_update_cns(SPItem &item, SPDesktop const &desktop)
  {
      std::vector<Inkscape::SnapCandidatePoint> snappoints;
-     sp_item_snappoints(&item, snappoints, NULL);
+     item.getSnappoints(snappoints, NULL);
      /* TODO: Implement the ordering. */
      vector<SPGuideConstraint> found_cns;
      satisfied_guide_cns(desktop, snappoints, found_cns);
@@@ -43,4 -43,4 +43,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-item.cpp
index d213ce2d7414688c0a2787367358a3aea68f99aa,fc605516d51ce3be39976d8788373881434ebb86..755ee0bf40211c2df9cffd0f382776bef83a3a5d
@@@ -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"
  
  #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.
   */
  GType
sp_item_get_type(void)
SPItem::getType(void)
  {
      static GType type = 0;
      if (!type) {
          GTypeInfo info = {
              sizeof(SPItemClass),
              NULL, NULL,
-             (GClassInitFunc) sp_item_class_init,
+             (GClassInitFunc) SPItemClass::sp_item_class_init,
              NULL, NULL,
              sizeof(SPItem),
              16,
  /**
   * SPItem vtable initialization.
   */
static void
- sp_item_class_init(SPItemClass *klass)
+ void
SPItemClass::sp_item_class_init(SPItemClass *klass)
  {
      SPObjectClass *sp_object_class = (SPObjectClass *) klass;
  
-     parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT);
+     static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT);
  
-     sp_object_class->build = sp_item_build;
-     sp_object_class->release = sp_item_release;
-     sp_object_class->set = sp_item_set;
-     sp_object_class->update = sp_item_update;
-     sp_object_class->write = sp_item_write;
+     sp_object_class->build = SPItem::sp_item_build;
+     sp_object_class->release = SPItem::sp_item_release;
+     sp_object_class->set = SPItem::sp_item_set;
+     sp_object_class->update = SPItem::sp_item_update;
+     sp_object_class->write = SPItem::sp_item_write;
  
-     klass->description = sp_item_private_description;
-     klass->snappoints = sp_item_private_snappoints;
+     klass->description = SPItem::sp_item_private_description;
+     klass->snappoints = SPItem::sp_item_private_snappoints;
  }
  
  /**
   * 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 {
@@@ -191,17 -193,16 +175,17 @@@ bool SPItem::isVisibleAndUnlocked(unsig
  }
  
  bool SPItem::isLocked() const {
 -    for (SPObject *o = SP_OBJECT(this); o != NULL; o = SP_OBJECT_PARENT(o)) {
 -        if (SP_IS_ITEM(o) && !(SP_ITEM(o)->sensitive))
 +    for (SPObject const *o = this; o != NULL; o = o->parent) {
 +        if (SP_IS_ITEM(o) && !(SP_ITEM(o)->sensitive)) {
              return true;
 +        }
      }
      return false;
  }
  
  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;
  
      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;
          item->mask_ref = NULL;
      }
  
-     if (((SPObjectClass *) (parent_class))->release) {
-         ((SPObjectClass *) parent_class)->release(object);
+     if (((SPObjectClass *) (SPItemClass::static_parent_class))->release) {
+         ((SPObjectClass *) SPItemClass::static_parent_class)->release(object);
      }
  
      while (item->display) {
      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;
  
          case SP_ATTR_TRANSFORM: {
              Geom::Matrix t;
              if (value && sp_svg_transform_read(value, &t)) {
-                 sp_item_set_item_transform(item, t);
+                 item->set_item_transform(t);
              } else {
-                 sp_item_set_item_transform(item, Geom::identity());
+                 item->set_item_transform(Geom::identity());
              }
              break;
          }
                  sp_style_read_from_object(object->style, object);
                  object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
              } else {
-                 if (((SPObjectClass *) (parent_class))->set) {
-                     (* ((SPObjectClass *) (parent_class))->set)(object, key, value);
+                 if (((SPObjectClass *) (SPItemClass::static_parent_class))->set) {
+                     (* ((SPObjectClass *) (SPItemClass::static_parent_class))->set)(object, key, value);
                  }
              }
              break;
      }
  }
  
- 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 */
      }
      if (SP_IS_MASK(mask)) {
          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_mask_show(SP_MASK(mask),
                                             NR_ARENA_ITEM_ARENA(v->arenaitem),
              nr_arena_item_set_mask(v->arenaitem, ai);
              nr_arena_item_unref(ai);
              sp_mask_set_bbox(SP_MASK(mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
 -            SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 +            mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
          }
      }
  }
  
- 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) {
  
          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) {
      /* Update bounding box data used by filters */
      if (item->style->filter.set && item->display) {
          Geom::OptRect item_bbox;
-         sp_item_invoke_bbox(item, item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX);
+         item->invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX);
  
          SPItemView *itemview = item->display;
          do {
          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);
          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);
              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);
          }
          g_free ((void *) value);
      }
  
-     if (((SPObjectClass *) (parent_class))->write) {
-         ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
+     if (((SPObjectClass *) (SPItemClass::static_parent_class))->write) {
+         ((SPObjectClass *) (SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags);
      }
  
      return repr;
@@@ -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
   * \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();
      }
      temp_bbox.x1 = temp_bbox.y1 = -NR_HUGE;
  
      // call the subclass method
-     if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) {
-         ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &temp_bbox, transform, flags);
+     if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
+         ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &temp_bbox, transform, flags);
      }
  
      // 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;
                  }
  
                  // transform the expansions by the item's transform:
-                 Geom::Matrix i2d(sp_item_i2d_affine (item));
+                 Geom::Matrix i2d(i2d_affine ());
                  dx0 *= i2d.expansionX();
                  dx1 *= i2d.expansionX();
                  dy0 *= i2d.expansionY();
                  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);
          }
      }
   * 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) {
      this_bbox.x1 = this_bbox.y1 = -1e18;
  
      // call the subclass method
-     if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) {
-         ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &this_bbox, transform, flags);
+     if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) {
+         ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &this_bbox, transform, flags);
      }
  
      // 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);
      }
  
      }
  }
  
- 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;
          }
      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;
  }
  
static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const */*snapprefs*/)
void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const */*snapprefs*/)
  {
      /* This will only be called if the derived class doesn't override this.
       * see for example sp_genericellipse_snappoints in sp-ellipse.cpp
       * We don't know what shape we could be dealing with here, so we'll just
       * return the corners of the bounding box */
  
-     Geom::OptRect bbox = item->getBounds(sp_item_i2d_affine(item));
+     Geom::OptRect bbox = item->getBounds(item->i2d_affine());
  
      if (bbox) {
          Geom::Point p1, p2;
  
  }
  
- 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
      if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) {
-         p.push_back(Inkscape::SnapCandidatePoint(item->getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER));
+         p.push_back(Inkscape::SnapCandidatePoint(getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER));
      }
  
      // 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++) {
                  if (SP_IS_ITEM(child)) {
                      std::vector<Inkscape::SnapCandidatePoint> p_clip_or_mask;
                      // Please note the recursive call here!
-                     sp_item_snappoints(SP_ITEM(child), p_clip_or_mask, snapprefs);
+                     SP_ITEM(child)->getSnappoints(p_clip_or_mask, snapprefs);
                      // Take into account the transformation of the item being clipped or masked
                      for (std::vector<Inkscape::SnapCandidatePoint>::const_iterator p_orig = p_clip_or_mask.begin(); p_orig != p_clip_or_mask.end(); p_orig++) {
                          // All snappoints are in desktop coordinates, but the item's transformation is
                          // in document coordinates. Hence the awkward construction below
-                         Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * sp_item_i2d_affine(item);
+                         Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * i2d_affine();
                          p.push_back(Inkscape::SnapCandidatePoint(pt, (*p_orig).getSourceType(), (*p_orig).getTargetType()));
                      }
                  }
      }
  }
  
--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"));
  }
   *
   * 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;
          }
-         if (s && item->mask_ref->getObject()) {
+         if (s && mask_ref->getObject()) {
              gchar *snew = g_strdup_printf (_("%s; <i>masked</i>"), s);
              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 {
   * \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;
  
      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));
  
      NRArenaItem *ai = NULL;
-     if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->show) {
-         ai = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->show(item, arena, key, flags);
+     if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) {
+         ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, arena, key, flags);
      }
  
      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);
  
              // 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;
-     SPItemView *v = item->display;
+     SPItemView *v = display;
      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) {
-                 item->display = v->next;
+                 display = v->next;
              } else {
                  ref->next = v->next;
              }
  
  // 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
               * \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;
  
 -        if (style->stroke_dash.n_dash != 0) {
 -            int i;
 -            for (i = 0; i < style->stroke_dash.n_dash; i++) {
 +        if ( style->stroke_dash.n_dash != 0 ) {
 +            for (int i = 0; i < style->stroke_dash.n_dash; i++) {
                  style->stroke_dash.dash[i] *= ex;
              }
              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)) {
  /**
   * 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);
++            }
++        }
      }
  }
  
@@@ -1329,7 -1328,7 +1250,7 @@@ sp_item_adjust_rects_recursive(SPItem *
          sp_rect_compensate_rxry (SP_RECT(item), advertized_transform);
      }
  
 -    for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
 +    for (SPObject *o = item->children; o != NULL; o = o->next) {
          if (SP_IS_ITEM(o))
              sp_item_adjust_rects_recursive(SP_ITEM(o), advertized_transform);
      }
  /**
   * 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
  // By equating these two expressions we get t_paint_new = t_paint * paint_delta, where:
-     Geom::Matrix t_item = sp_item_transform_repr (item);
+     Geom::Matrix t_item = sp_item_transform_repr (this);
      Geom::Matrix paint_delta = t_item * t_ancestors * advertized_transform * t_ancestors.inverse() * t_item.inverse();
  
  // 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
-                 sp_item_adjust_paint_recursive (SP_ITEM(o), advertized_transform, t_item * t_ancestors, is_pattern);
+                 SP_ITEM(o)->adjust_paint_recursive (advertized_transform, t_item * t_ancestors, is_pattern);
              }
          }
      }
  // 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);
++                }
              }
          }
      }
   * 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
      if (adv != NULL) {
          advertized_transform = *adv;
      } else {
-         advertized_transform = sp_item_transform_repr (item).inverse() * transform;
+         advertized_transform = sp_item_transform_repr (this).inverse() * transform;
      }
  
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
           // recursively compensate for stroke scaling, depending on user preference
          if (!prefs->getBool("/options/transform/stroke", true)) {
              double const expansion = 1. / advertized_transform.descrim();
-             sp_item_adjust_stroke_width_recursive(item, expansion);
+             adjust_stroke_width_recursive(expansion);
          }
  
          // recursively compensate rx/ry of a rect if requested
          if (!prefs->getBool("/options/transform/rectcorners", true)) {
-             sp_item_adjust_rects_recursive(item, advertized_transform);
+             sp_item_adjust_rects_recursive(this, advertized_transform);
          }
  
          // recursively compensate pattern fill if it's not to be transformed
          if (!prefs->getBool("/options/transform/pattern", true)) {
-             sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), Geom::identity(), true);
+             adjust_paint_recursive (advertized_transform.inverse(), Geom::identity(), true);
          }
          /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well
          /// recursively compensate gradient fill if it's not to be transformed
          if (!prefs->getBool("/options/transform/gradient", true)) {
-             sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), Geom::identity(), false);
+             adjust_paint_recursive (advertized_transform.inverse(), Geom::identity(), false);
          } else {
              // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
              // it here _before_ the new transform is set, so as to use the pre-transform bbox
-             sp_item_adjust_paint_recursive (item, Geom::identity(), Geom::identity(), false);
+             adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
          }
  
      } // endif(compensate)
      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;
  }
   * 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);
  }
  
  
@@@ -1537,7 -1536,7 +1439,7 @@@ i2anc_affine(SPObject const *object, SP
          } else {
              ret *= SP_ITEM(object)->transform;
          }
 -        object = SP_OBJECT_PARENT(object);
 +        object = object->parent;
      }
      return ret;
  }
@@@ -1557,66 -1556,66 +1459,56 @@@ Geom::Matrix SPItem::getRelativeTransfo
   * Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
   * \pre (item != NULL) and SP_IS_ITEM(item).
   */
- Geom::Matrix sp_item_i2doc_affine(SPItem const *item)
+ Geom::Matrix SPItem::i2doc_affine() const
  {
-     return i2anc_affine(item, NULL);
+     return i2anc_affine(this, NULL);
  }
  
  /**
   * 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) );
      }
  
      Geom::Matrix const i2p( i2dt * dt2p );
-     sp_item_set_item_transform(item, i2p);
+     set_item_transform(i2p);
  }
  
  
  /**
   * 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;
      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;
   * 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;
          }
      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);
      SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
          SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
  
-     Geom::OptRect bbox = sp_item_bbox_desktop(item, bbox_type);
+     Geom::OptRect bbox = getBboxDesktop(bbox_type);
      if (!bbox) {
          g_warning ("Cannot determine item's bounding box during conversion to guides.\n");
          return;
diff --combined src/sp-item.h
index 7387a63cfa4f94c44543d00e9472798faed2377f,d2c24baf0bac4354ef36d7a41b24aae197357a7d..4ba3dc7a45788a5a2714364c3131566aac9f34f6
@@@ -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;
      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,
      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
      {
  
      mutable bool _is_evaluated;
      mutable EvaluatedStatus _evaluated_status;
 -      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_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 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);
 -      
 -      friend class SPItemClass;
++    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;
  };
  
  /// The SPItem vtable.
- struct SPItemClass {
 -//struct SPItemClass {
+ class SPItemClass {
 -      public:
++public:
      SPObjectClass parent_class;
  
      /** BBox union in given coordinate system */
  
      /** 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
   *
   * \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:
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-line.cpp
index d0ce32397d7ffe801b0447c7c5c8b39a902a42c7,b71616c5b05fa68f35ee92e639bb96a88ae6860f..b8c5a19b74da73b6b5eca1ea2c3f0ae2405f4786
@@@ -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
   *
  #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 --combined src/sp-line.h
index cc6802b7f6d3f1ece91f5ca275a1d3ebefac79cf,114b0ea7c32dc9d82ee874824cd595fc385752c2..8bcb8164552fbf8f4673a4016989923cc4daf14d
@@@ -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
   *
  
  
  
- #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 --combined src/sp-lpe-item.cpp
index 43eb3c52e69cde0684a68001423e15e568e506c3,655c4b27e1653980d7908fd1511446b61c23d841..afd36d2ddef30cf1a68293cd86112984c86cf416
@@@ -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);
@@@ -681,7 -681,7 +680,7 @@@ sp_lpe_item_child_added (SPObject *obje
          (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref);
  
      if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) {
-         SPObject *ochild = sp_object_get_child_by_repr(object, child);
+         SPObject *ochild = object->get_child_by_repr(child);
          if ( ochild && SP_IS_LPE_ITEM(ochild) ) {
              sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(ochild));
          }
@@@ -692,7 -692,7 +691,7 @@@ static voi
  sp_lpe_item_remove_child (SPObject * object, Inkscape::XML::Node * child)
  {
      if (SP_IS_LPE_ITEM(object) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(object))) {
-         SPObject *ochild = sp_object_get_child_by_repr(object, child);
+         SPObject *ochild = object->get_child_by_repr(child);
          if ( ochild && SP_IS_LPE_ITEM(ochild) ) {
              sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(ochild));
          }
@@@ -868,4 -868,4 +867,4 @@@ bool sp_lpe_item_path_effects_enabled(S
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-mask.cpp
index 15be0348f3088be6127f73a7210fa8f54e8a65b3,26ddfa0093884cdc9913587c7e2833e653f90a0d..dde91b0625280d8b1f8afa0643a7c3bd9555c38d
@@@ -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);
@@@ -180,8 -180,7 +180,7 @@@ sp_mask_child_added (SPObject *object, 
        if (SP_IS_ITEM (ochild)) {
                SPMask *cp = SP_MASK (object);
                for (SPMaskView *v = cp->display; v != NULL; v = v->next) {
-                       NRArenaItem *ac = sp_item_invoke_show (SP_ITEM (ochild),
-                                                              NR_ARENA_ITEM_ARENA (v->arenaitem),
+                       NRArenaItem *ac = SP_ITEM (ochild)->invoke_show (                                                              NR_ARENA_ITEM_ARENA (v->arenaitem),
                                                               v->key,
                                                               SP_ITEM_REFERENCE_FLAGS);
                        if (ac) {
        }
  }
  
--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");
      
          if (NULL != applyTransform) {
              Geom::Matrix transform (item->transform);
              transform *= (*applyTransform);
-             sp_item_write_transform(item, SP_OBJECT_REPR(item), transform);
+             item->doWriteTransform(SP_OBJECT_REPR(item), transform);
          }
      }
  
      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);
        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);
        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);
                }
        }
  
@@@ -413,4 -412,4 +408,4 @@@ sp_mask_view_list_remove (SPMaskView *l
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-mask.h
index 0b995f0ce85ded208bd1b6bf6da4d1486ad077e9,ae3b76210fdbc00b1578d62d53cf1ae826e5d97a..d8b6b33ea9b7607e21d6f4879bd6bde90c95ab91
@@@ -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 --combined src/sp-missing-glyph.cpp
index 7d5c42763de6633ea7b782313a0d807ff3acabd6,9833a699593e019ba472fd94408dc2a7daae23d2..9604fe0cac23dbadb7c867d99728f4d93608decd
@@@ -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 --combined src/sp-namedview.cpp
index be2bcd478781ef9d9be4535f15116e4e50131ef4,61685b3217e2b73fc6b93779f35b12b511c52950..59ef4762da6f8433a8d804a942bffb82324e7355
@@@ -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));
          repr->setAttribute("gridempopacity", NULL);
          repr->setAttribute("gridempspacing", NULL);
  
- //        sp_document_done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid from pre0.46 grid settings"));
+ //        SPDocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid from pre0.46 grid settings"));
      }
  }
  
@@@ -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) {
              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;
              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;
              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;
              object->requestModified(SP_OBJECT_MODIFIED_FLAG);
              break;
      }
 +    case SP_ATTR_UNITS: {
 +            SPUnit const *new_unit = NULL;
 +
 +            if (value) {
 +                SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value);
 +                if ( req_unit == NULL ) {
 +                    g_warning("Unrecognized unit `%s'", value);
 +                    /* fixme: Document errors should be reported in the status bar or
 +                     * the like (e.g. as per
 +                     * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log
 +                     * should be only for programmer errors. */
 +                } else if ( req_unit->base == SP_UNIT_ABSOLUTE ||
 +                            req_unit->base == SP_UNIT_DEVICE     ) {
 +                    new_unit = req_unit;
 +                } else {
 +                    g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'",
 +                              value);
 +                    /* fixme: Don't use g_log (see above). */
 +                }
 +            }
 +            nv->units = new_unit;
 +            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 +            break;
 +    }
      default:
              if (((SPObjectClass *) (parent_class))->set) {
                  ((SPObjectClass *) (parent_class))->set(object, key, value);
@@@ -667,10 -642,9 +669,9 @@@ static void sp_namedview_child_added(SP
              g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL);
              if (nv->editable) {
                  for (GSList *l = nv->views; l != NULL; l = l->next) {
-                     sp_guide_show(g, static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event);
+                     g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event);
                      if (static_cast<SPDesktop*>(l->data)->guides_active)
-                         sp_guide_sensitize(g,
-                                            sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
+                         g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
                                             TRUE);
                      sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides);
                  }
@@@ -728,9 -702,9 +729,9 @@@ static Inkscape::XML::Node *sp_namedvie
  void SPNamedView::show(SPDesktop *desktop)
  {
      for (GSList *l = guides; l != NULL; l = l->next) {
-         sp_guide_show(SP_GUIDE(l->data), desktop->guides, (GCallback) sp_dt_guide_event);
+         SP_GUIDE(l->data)->showSPGuide( desktop->guides, (GCallback) sp_dt_guide_event);
          if (desktop->guides_active) {
-             sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(desktop), TRUE);
+             SP_GUIDE(l->data)->sensitize(sp_desktop_canvas(desktop), TRUE);
          }
          sp_namedview_show_single_guide(SP_GUIDE(l->data), showguides);
      }
  
  #define MIN_ONSCREEN_DISTANCE 50
  
 -      g_assert(this->getRepr() != NULL);
 -      Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype));
+ void SPNamedView::writeNewGrid(SPDocument *document,int 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
      }
  }
  
 -      return this->snap_manager.snapprefs.getSnapEnabledGlobally();
+ bool SPNamedView::getSnapGlobal() const
+ {
 -      g_assert(this->getRepr() != NULL);
 -      sp_repr_set_boolean(this->getRepr(), "inkscape:snap-global", v);
++    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);
+ }
  void sp_namedview_update_layers_from_document (SPDesktop *desktop)
  {
      SPObject *layer = NULL;
      }
      // 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);
      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)
      g_assert(g_slist_find(views, desktop));
  
      for (GSList *l = guides; l != NULL; l = l->next) {
-         sp_guide_hide(SP_GUIDE(l->data), sp_desktop_canvas(desktop));
+         SP_GUIDE(l->data)->hideSPGuide(sp_desktop_canvas(desktop));
      }
  
      views = g_slist_remove(views, desktop);
@@@ -880,28 -871,28 +897,28 @@@ void SPNamedView::activateGuides(gpoint
      SPDesktop *dt = static_cast<SPDesktop*>(desktop);
  
      for (GSList *l = guides; l != NULL; l = l->next) {
-         sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(dt), active);
+         SP_GUIDE(l->data)->sensitize( sp_desktop_canvas(dt), active);
      }
  }
  
  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)
          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 */
@@@ -945,7 -936,7 +962,7 @@@ gchar const *SPNamedView::getName() con
  {
      SPException ex;
      SP_EXCEPTION_INIT(&ex);
-     return sp_object_getAttribute(SP_OBJECT(this), "id", &ex);
+     return SP_OBJECT(this)->getAttribute("id", &ex);
  }
  
  guint SPNamedView::getViewCount()
@@@ -1010,6 -1001,48 +1027,47 @@@ SPNamedView *sp_document_namedview(SPDo
      return (SPNamedView *) nv;
  }
  
 -      g_assert(this->getRepr() != NULL);
 -      sp_repr_set_boolean(this->getRepr(), "showguides", v);
 -      sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v);
 -
+ void SPNamedView::setGuides(bool v)
+ {
 -      if(!this->storeAsDouble(key,&value)) {
++    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)) {
+         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.
   */
@@@ -1063,4 -1096,4 +1121,4 @@@ void SPNamedView::scrollAllDesktops(dou
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-namedview.h
index 7a54b2dc56580c6018cce83e0cef8ce8a6a4143b,337a67deb10fd557ff23fa9ff8c25b3071e9b2ce..86b16a5577e2bb63b6e2775340d56a25498a0fca
@@@ -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
@@@ -23,6 -23,8 +24,8 @@@
  #include "sp-object-group.h"
  #include "sp-metric.h"
  #include "snap.h"
+ #include "display/canvas-grid.h"
+ #include "document.h"
  
  namespace Inkscape {
  class CanvasGrid;
@@@ -54,8 -56,7 +57,8 @@@ struct SPNamedView : public SPObjectGro
      bool grids_visible;
  
      SPUnit const *doc_units;
 -
 +    SPUnit const *units;
 +    
      GQuark default_layer_id;
  
      double connector_spacing;
  
      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 {
@@@ -111,4 -120,4 +122,4 @@@ Inkscape::CanvasGrid * sp_namedview_get
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-object-group.cpp
index 1d5c0433974a67fdccfd647864aa3886e2920e07,d0e5c01a7b19ead841016cf8bd021a2d9cd57507..001d7898f0b366ea82a6f94cfc0f0ea9bc6c2a6f
@@@ -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.
  #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 --combined src/sp-object-group.h
index 5d67df6fecea0518c615f1cec8b9c9a156f2ae44,7d35cfc178aebf270ab7401929c1908fd0a79aad..a666a316a6ca4881a50e5be2cedb7eeee441727e
@@@ -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.
  
  #include "sp-object.h"
  
- #define SP_TYPE_OBJECTGROUP (sp_objectgroup_get_type ())
+ #define SP_TYPE_OBJECTGROUP (SPObjectGroup::sp_objectgroup_get_type ())
  #define SP_OBJECTGROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECTGROUP, SPObjectGroup))
  #define SP_OBJECTGROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_OBJECTGROUP, SPObjectGroupClass))
  #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 --combined src/sp-object-repr.cpp
index 17f2706adc4713ebe61311d747d162adec160df6,207d082775ed8b8f3beaf4e810679da58428b8a2..475a57521c3780306c877c6cd5864733803a6150
@@@ -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
   *
@@@ -107,7 -107,7 +106,7 @@@ sp_object_repr_build_tree(SPDocument *d
      g_assert(newobj != NULL);
      SPObject *const object = SP_OBJECT(newobj);
      g_assert(object != NULL);
-     sp_object_invoke_build(object, document, repr, FALSE);
+     object->invoke_build(document, repr, FALSE);
  
      return object;
  }
@@@ -290,4 -290,4 +289,4 @@@ sp_object_type_register(gchar const *na
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-object-repr.h
index 4e85acf5340704d9a519ca8d36c7b7c089b344e0,d1501fe3e9664918822fe59fb1b7e054f548449a..02ad3ea938e68991cdaf835ef2ff8edb40bff69e
@@@ -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
@@@ -13,7 -13,7 +13,7 @@@
   */
  
  #include "forward.h"
+ #include "sp-object.h"
  namespace Inkscape {
  namespace XML {
  class Node;
  }
  
  
- SPObject *sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr);
+ SPObject * sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr);
  
  GType sp_repr_type_lookup (Inkscape::XML::Node *repr);
  
  void sp_object_type_register(gchar const *name, GType type);
  
--#endif
++#endif // SEEN_SP_OBJECT_REPR_H
  
  /*
    Local Variables:
@@@ -38,4 -38,4 +38,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-object.cpp
index 7fe0996997850fb1a462552cd53c38b8f9519415,88d24bffd08753216cf44ca6d762131f084e19d2..17def7f1554f1a13f6b68d5a2fcc8f6cbf7d3993
@@@ -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.
@@@ -38,7 -38,6 +39,7 @@@
  #include "helper/sp-marshal.h"
  #include "xml/node-event-vector.h"
  #include "attributes.h"
 +#include "color-profile-fns.h"
  #include "document.h"
  #include "style.h"
  #include "sp-object-repr.h"
@@@ -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,20 -143,22 +118,19 @@@ 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) {
          GTypeInfo info = {
              sizeof(SPObjectClass),
              NULL, NULL,
-             (GClassInitFunc) sp_object_class_init,
+             (GClassInitFunc) SPObjectClass::sp_object_class_init,
              NULL, NULL,
              sizeof(SPObject),
              16,
  /**
   * 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));
  
      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;
  /**
   * 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;
  
          spobject->_successor = NULL;
      }
  
-     if (((GObjectClass *) (parent_class))->finalize) {
-         (* ((GObjectClass *) (parent_class))->finalize)(object);
+     if (((GObjectClass *) (SPObjectClass::static_parent_class))->finalize) {
+         (* ((GObjectClass *) (SPObjectClass::static_parent_class))->finalize)(object);
      }
  
      spobject->_release_signal.~signal();
@@@ -295,6 -299,15 +268,15 @@@ gchar const* SPObject::getId() const 
      return id;
  }
  
 -      return repr;
+ Inkscape::XML::Node * SPObject::getRepr() {
 -          return repr;
++    return repr;
+ }
+ Inkscape::XML::Node const* SPObject::getRepr() const{
++    return repr;
+ }
  /**
   * Increase reference count of object, with possible debugging.
   *
   * \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);
   * \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);
   * \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);
   * \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);
  /**
   * 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");
  /**
   * 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;
  }
  
  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;
  }
  
  /**
   *    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;
  }
  
  
   * 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);
      }
  /** 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;
  }
  
  /** 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);
  }
  
  
  /** Queues the object for orphan collection */
 -void
 -SPObject::requestOrphanCollection() {
 +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();
      }
   * 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) {
          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);
      }
   * 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));
-     g_return_if_fail(!prev || prev->parent == parent);
+     g_return_if_fail(!prev || prev->parent == this);
      g_return_if_fail(!object->parent);
  
-     sp_object_ref(object, parent);
-     object->parent = parent;
-     parent->_updateTotalHRefCount(object->_total_hrefcount);
+     sp_object_ref(object, this);
+     object->parent = this;
+     this->_updateTotalHRefCount(object->_total_hrefcount);
  
      SPObject *next;
      if (prev) {
          next = prev->next;
          prev->next = object;
      } else {
-         next = parent->children;
-         parent->children = object;
+         next = this->children;
+         this->children = object;
      }
      object->next = next;
      if (!next) {
-         parent->_last_child = object;
+         this->_last_child = object;
      }
      if (!object->xml_space.set)
-         object->xml_space.value = parent->xml_space.value;
+         object->xml_space.value = this->xml_space.value;
  }
  
  /**
   * 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;
      }
  
-     SPObject *next=object->next;
+     SPObject *next=this->next;
      if (old_prev) {
          old_prev->next = next;
      } else {
      }
      if (prev) {
          next = prev->next;
-         prev->next = object;
+         prev->next = this;
      } else {
          next = parent->children;
-         parent->children = object;
+         parent->children = this;
      }
-     object->next = next;
+     this->next = next;
      if (!next) {
-         parent->_last_child = object;
+         parent->_last_child = this;
      }
  }
  
  /**
   * 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();
  
      SPObject *prev=NULL;
-     for ( SPObject *child = parent->children ; child && child != object ;
+     for ( SPObject *child = this->children ; child && child != object ;
            child = child->next )
      {
          prev = child;
      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;
      object->parent = NULL;
  
-     parent->_updateTotalHRefCount(-object->_total_hrefcount);
-     sp_object_unref(object, parent);
+     this->_updateTotalHRefCount(-object->_total_hrefcount);
+     sp_object_unref(object, this);
  }
  
  /**
   * 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);
  }
  
  /**
   * SPRoot destroys the whole document tree.
   * \see sp_object_build()
   */
static void sp_object_release(SPObject *object)
void SPObject::sp_object_release(SPObject *object)
  {
      debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
      while (object->children) {
-         sp_object_detach(object, object->children);
+         object->detach(object->children);
      }
  }
  
   * 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);
++    }
  }
  
  /**
   * Invoked whenever the given mutation event happens in the XML tree.
   * \param old_ref Ignored
   */
static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/,
void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/,
                                      Inkscape::XML::Node *new_ref)
  {
-     SPObject *ochild = sp_object_get_child_by_repr(object, child);
+     SPObject *ochild = object->get_child_by_repr(child);
      g_return_if_fail(ochild != NULL);
-     SPObject *prev = new_ref ? sp_object_get_child_by_repr(object, new_ref) : NULL;
-     sp_object_reorder(ochild, prev);
+     SPObject *prev = new_ref ? object->get_child_by_repr(new_ref) : NULL;
+     ochild->reorder(prev);
      ochild->_position_changed_signal.emit(ochild);
  }
  
   * 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));
  
-     sp_object_read_attr(object, "xml:space");
-     sp_object_read_attr(object, "inkscape:label");
-     sp_object_read_attr(object, "inkscape:collect");
+     object->readAttr("xml:space");
+     object->readAttr("inkscape:label");
+     object->readAttr("inkscape:collect");
  
      for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) {
          GType type = sp_repr_type_lookup(rchild);
              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);
      }
  }
  
- void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned)
+ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned)
  {
-     debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
+     debug("id=%x, typename=%s", this, g_type_name_from_instance((GTypeInstance*)this));
  
-     g_assert(object != NULL);
-     g_assert(SP_IS_OBJECT(object));
+     //g_assert(object != NULL);
+     //g_assert(SP_IS_OBJECT(object));
      g_assert(document != NULL);
      g_assert(repr != NULL);
  
-     g_assert(object->document == NULL);
-     g_assert(object->repr == NULL);
-     g_assert(object->getId() == NULL);
+     g_assert(this->document == NULL);
+     g_assert(this->repr == NULL);
+     g_assert(this->getId() == NULL);
  
      /* 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);
                  }
  
                  /* Redefine ID, if required */
-                 if ((id == NULL) || (strcmp(id, object->getId()) != 0)) {
-                     object->repr->setAttribute("id", object->getId());
+                 if ((id == NULL) || (strcmp(id, this->getId()) != 0)) {
+                     this->repr->setAttribute("id", this->getId());
                  }
              } else if (id) {
                  // bind if id, but no conflict -- otherwise, we can expect
                  // a subsequent setting of the id attribute
-                 if (!object->document->getObjectById(id)) {
-                     object->document->bindObjectToId(id, object);
-                     SPObjectImpl::setId(object, id);
+                 if (!this->document->getObjectById(id)) {
+                     this->document->bindObjectToId(id, this);
+                     SPObjectImpl::setId(this, id);
                  }
              }
          }
      } else {
-         g_assert(object->getId() == NULL);
+         g_assert(this->getId() == NULL);
      }
  
      /* Invoke derived methods, if any */
-     if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->build) {
-         (*((SPObjectClass *) G_OBJECT_GET_CLASS(object))->build)(object, document, repr);
+     if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->build) {
+         (*((SPObjectClass *) G_OBJECT_GET_CLASS(this))->build)(this, document, repr);
      }
  
      /* 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() {
      /* 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);
          }
  }
  
  
--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);
  
   *
   * \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);
  
  /**
   * 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;
  
                          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 {
  /**
   * 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) {
          /* Retrieve the 'key' attribute from the object's XML representation */
-         gchar const *value = object->repr->attribute(key);
+         gchar const *value = getRepr()->attribute(key);
  
-         sp_object_set(object, keyid, value);
+         setKeyValue(keyid, value);
      }
  }
  
  /**
   * 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);
  
-     sp_object_read_attr(object, key);
+     object->readAttr(key);
  
      // manual changes to extension attributes require the normal
      // attributes, which depend on them, to be updated immediately
  /**
   * 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);
          }
              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 ));
  /**
   * 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 {
   *  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;
      }
   * 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 );
  
       * 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();
          }
      }
  }
  /**
   * 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 */
  
      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(...)
      {
   * 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 );
  
       * 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();
          }
      }
  }
   *  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;
      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;
  
  
      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, ':');
   * <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;
                  != 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)
              }
          }
      }
-     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;
      }
-     if (object->parent) {
-         return sp_object_get_style_property(object->parent, key, def);
+     if (this->parent) {
+         return (this->parent)->getStyleProperty(key, def);
      }
  
      return def;
  /**
   * 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)) {
      }
  }
  
--/**
-- * 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:
   * 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");
  }
   * (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);
  }
   * 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");
  }
   * 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);
  }
   * 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;
  }
  
  /**
   * 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,
                      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) {
              if (current_value) {
                  bool different = std::strcmp(current_value, value);
                  g_free(current_value);
--                if (!different) return false;
++                if (!different) {
++                    return false;
++                }
              }
          }
      }
      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();
          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
   * 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;
  }
   * 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("");
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-object.h
index 59cab2328252d99cebe84bf2b760a5620f6360fd,b7b3f9cc48df57dadd0ce5e20a1673baa35b375d..5d3183d9c7245897ad6f2e80930477d2c9bc1b66
@@@ -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.
  
  /* SPObject flags */
  
+ class SPObject;
+ class SPObjectClass;
+ #define SP_TYPE_OBJECT (SPObject::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))
  /* Async modification flags */
  #define SP_OBJECT_MODIFIED_FLAG (1 << 0)
  #define SP_OBJECT_CHILD_MODIFIED_FLAG (1 << 1)
  #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>
@@@ -63,6 -70,7 +68,7 @@@
  #include "forward.h"
  #include "version.h"
  #include "util/forward-pointer-iterator.h"
+ #include "desktop-style.h"
  
  namespace Inkscape {
  namespace XML {
@@@ -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
      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 */
+     Inkscape::XML::Node *repr; /* Our xml representation */
  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
       */
      /* 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);
          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) {
      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(),
      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);
      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
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-offset.cpp
index a43bc873d0084e6376ae1383ddce561f224bed5f,449d7d44d143a72ed332d90d3ad9ba512954917c..51bb1e1ccc190c845e808588b3f47b2a26a99114
@@@ -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" );
      }
  }
  
@@@ -278,7 -283,7 +280,7 @@@ sp_offset_write(SPObject *object, Inksc
  
  
      // Make sure the object has curve
-     SPCurve *curve = sp_shape_get_curve (SP_SHAPE (offset));
+     SPCurve *curve = SP_SHAPE (offset)->getCurve();
      if (curve == NULL) {
          sp_offset_set_shape (SP_SHAPE (offset));
      }
@@@ -405,7 -410,7 +407,7 @@@ sp_offset_update(SPObject *object, SPCt
      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 ();
      }
      offset->isUpdating=false;
  
@@@ -454,12 -459,13 +456,13 @@@ 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);
              g_assert(c != NULL);
-             sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE);
+             ((SPShape *) offset)->setCurveInsync (c, TRUE);
              c->unref();
          }
          return;
          theRes->ConvertToForme (orig, 1, originaux);
  
          SPItem *item = shape;
-         Geom::OptRect bbox = sp_item_bbox_desktop (item);
+         Geom::OptRect bbox = item->getBboxDesktop ();
          if ( bbox ) {
              gdouble size = L2(bbox->dimensions());
              gdouble const exp = item->transform.descrim();
          Geom::PathVector pv = sp_svg_read_pathv(res_d);
          SPCurve *c = new SPCurve(pv);
          g_assert(c != NULL);
-         sp_shape_set_curve_insync ((SPShape *) offset, c, TRUE);
+         ((SPShape *) offset)->setCurveInsync (c, TRUE);
          c->unref();
  
          free (res_d);
@@@ -948,11 -954,11 +951,11 @@@ sp_offset_top_point (SPOffset * offset
          return;
      }
  
-     SPCurve *curve = sp_shape_get_curve (SP_SHAPE (offset));
+     SPCurve *curve = SP_SHAPE (offset)->getCurve();
      if (curve == NULL)
      {
          sp_offset_set_shape (SP_SHAPE (offset));
-         curve = sp_shape_get_curve (SP_SHAPE (offset));
+         curve = SP_SHAPE (offset)->getCurve();
          if (curve == NULL)
              return;
      }
@@@ -1049,7 -1055,7 +1052,7 @@@ sp_offset_move_compensate(Geom::Matrix 
      item->transform *= compensate;
  
      // commit the compensation
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, &advertized_move);
+     item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, &advertized_move);
      SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
@@@ -1076,7 -1082,7 +1079,7 @@@ sp_offset_source_modified (SPObject */*
      SPOffset *offset = SP_OFFSET(item);
      offset->sourceDirty=true;
      refresh_offset_source(offset);
-     sp_shape_set_shape ((SPShape *) offset);
+     ((SPShape *) offset)->setShape ();
  }
  
  static void
@@@ -1094,7 -1100,7 +1097,7 @@@ refresh_offset_source(SPOffset* offset
      SPCurve *curve=NULL;
      if (!SP_IS_SHAPE (item) && !SP_IS_TEXT (item)) return;
      if (SP_IS_SHAPE (item)) {
-         curve = sp_shape_get_curve (SP_SHAPE (item));
+         curve = SP_SHAPE (item)->getCurve ();
          if (curve == NULL)
              return;
      }
          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);
      }
@@@ -1172,4 -1179,4 +1176,4 @@@ sp_offset_get_source (SPOffset *offset
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-path.cpp
index 54d2a201a1480225c438fb778d5ca44d71baa7a1,d98647b11566bcef03682d2e5146329aa31bf2d6..66a70e0f1dc35e78a1f90b9a81f158c57e00a5ba
@@@ -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
@@@ -171,7 -171,7 +170,7 @@@ sp_path_convert_to_guides(SPItem *item
  
      std::list<std::pair<Geom::Point, Geom::Point> > pts;
  
-     Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(path)));
+     Geom::Matrix const i2d (SP_ITEM(path)->i2d_affine());
  
      Geom::PathVector const & pv = curve->get_pathvector();
      for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) {
@@@ -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);
  
          ((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"), "");
      }
  }
  
@@@ -279,11 -279,11 +278,11 @@@ sp_path_set(SPObject *object, unsigned 
                      Geom::PathVector pv = sp_svg_read_pathv(value);
                      SPCurve *curve = new SPCurve(pv);
                      if (curve) {
-                         sp_shape_set_curve((SPShape *) path, curve, TRUE);
+                         ((SPShape *) path)->setCurve(curve, TRUE);
                          curve->unref();
                      }
                  } else {
-                     sp_shape_set_curve((SPShape *) path, NULL, TRUE);
+                     ((SPShape *) path)->setCurve(NULL, TRUE);
                  }
                  object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
              break;
@@@ -392,16 -392,16 +391,16 @@@ sp_path_set_transform(SPItem *item, Geo
      }
  
      // Adjust stroke
-     sp_item_adjust_stroke(item, xform.descrim());
+     item->adjust_stroke(xform.descrim());
  
      // Adjust pattern fill
-     sp_item_adjust_pattern(item, xform);
+     item->adjust_pattern(xform);
  
      // Adjust gradient fill
-     sp_item_adjust_gradient(item, xform);
+     item->adjust_gradient(xform);
  
      // Adjust LPE
-     sp_item_adjust_livepatheffect(item, xform);
+     item->adjust_livepatheffect(xform);
  
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
  
@@@ -425,7 -425,7 +424,7 @@@ g_message("sp_path_update_patheffect")
          SPCurve *curve = path->original_curve->copy();
          /* if a path does not have an lpeitem applied, then reset the curve to the original_curve.
           * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
-         sp_shape_set_curve_insync(shape, curve, TRUE);
+         shape->setCurveInsync(curve, TRUE);
  
          bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve);
          if (success && write) {
@@@ -446,7 -446,7 +445,7 @@@ g_message("sp_path_update_patheffect wr
                  Geom::PathVector pv = sp_svg_read_pathv(value);
                  SPCurve *oldcurve = new SPCurve(pv);
                  if (oldcurve) {
-                     sp_shape_set_curve(shape, oldcurve, TRUE);
+                     shape->setCurve(oldcurve, TRUE);
                      oldcurve->unref();
                  }
              }
@@@ -505,7 -505,7 +504,7 @@@ sp_path_get_curve_for_edit (SPPath *pat
                                  sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) {
          return sp_path_get_original_curve(path);
      } else {
-         return sp_shape_get_curve( (SPShape *) path );
+         return ((SPShape *) path)->getCurve();
      }
  }
  
diff --combined src/sp-pattern.cpp
index a2fc9a6b29b76840eb3c752cf3a0c304522b02d6,779edc3e83d3e7a6788c6f5dd1025700592da231..fbba4cc48caaa56c21939104603deaffebd44288
@@@ -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) {
@@@ -323,16 -323,16 +323,16 @@@ sp_pattern_child_added (SPObject *objec
        if (((SPObjectClass *) (pattern_parent_class))->child_added)
                (* ((SPObjectClass *) (pattern_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 (SP_IS_ITEM (ochild)) {
  
                SPPaintServer *ps = SP_PAINT_SERVER (pat);
-               unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild));
+               unsigned position = SP_ITEM(ochild)->pos_in_parent();
  
                for (SPPainter *p = ps->painters; p != NULL; p = p->next) {
  
                        SPPatPainter *pp = (SPPatPainter *) p;
-                       NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (ochild), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS);
+                       NRArenaItem *ai = SP_ITEM (ochild)->invoke_show (pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS);
  
                        if (ai) {
                                nr_arena_item_add_child (pp->root, ai, NULL);
  
  /* 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");
  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");
                        dup_transform = Geom::identity();
                dup_transform *= move;
  
-               sp_item_write_transform(copy, SP_OBJECT_REPR(copy), dup_transform, NULL, false);
+               copy->doWriteTransform(SP_OBJECT_REPR(copy), dup_transform, NULL, false);
        }
  
        Inkscape::GC::release(repr);
        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;
  }
  
  
@@@ -675,7 -645,7 +671,7 @@@ sp_pattern_painter_release (SPObject *o
      painter->_release_connections->erase(obj);
        }
  
-       sp_item_invoke_hide(SP_ITEM(obj), painter->dkey);
+       SP_ITEM(obj)->invoke_hide(painter->dkey);
  }
  
  /**
@@@ -757,30 -727,30 +753,29 @@@ sp_pattern_painter_new (SPPaintServer *
        /* Create arena */
        pp->arena = NRArena::create();
  
-       pp->dkey = sp_item_display_key_new (1);
+       pp->dkey = SPItem::display_key_new (1);
  
        /* Create group */
        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 --combined src/sp-pattern.h
index cf716b2f8b2cdae57ad154256f1981c5025621e7,be926aabba7b5a96fcefbf82e8c40f9ba98991e7..f50504a76fac0f69972d16bfad5b81a2665f6b39
@@@ -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
   *
@@@ -15,7 -15,7 +16,7 @@@
  #include <gtk/gtktypeutils.h>
  
  #include "forward.h"
+ #include "sp-item.h"
  #define SP_TYPE_PATTERN (sp_pattern_get_type ())
  #define SP_PATTERN(o) (GTK_CHECK_CAST ((o), SP_TYPE_PATTERN, SPPattern))
  #define SP_PATTERN_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_PATTERN, SPPatternClass))
@@@ -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:
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-polygon.cpp
index 014c68c9b75652ba8af992a904325b2c0daca8db,d5e10e10fb0da0494c79acd7c9f82514da708ccc..1067da72e7613ea1a6cab95d24f5a89afd6866d8
@@@ -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" );
  }
  
  
@@@ -116,7 -116,7 +115,7 @@@ static Inkscape::XML::Node *sp_polygon_
      SPShape *shape = SP_SHAPE(object);
      // Tolerable workaround: we need to update the object's curve before we set points=
      // because it's out of sync when e.g. some extension attrs of the polygon or star are changed in XML editor
-     sp_shape_set_shape(shape);
+     shape->setShape();
  
      if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
          repr = xml_doc->createElement("svg:polygon");
@@@ -209,7 -209,7 +208,7 @@@ void sp_polygon_set(SPObject *object, u
                   * a single-point polygon in SPCurve. TODO: add a testcase with only one coordinate pair */
                  curve->closepath();
              }
-             sp_shape_set_curve(SP_SHAPE(polygon), curve, TRUE);
+             (SP_SHAPE(polygon))->setCurve(curve, TRUE);
              curve->unref();
              break;
          }
diff --combined src/sp-polyline.cpp
index 08f446d6124a5685c228de1c09e218ba46f2e33b,5bf40352db8ae194f3bf1c76b46c9fbd072d1093..d0954f2393b2357a72bb351a2f6ace1207454fad
@@@ -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
   *
  #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 --combined src/sp-polyline.h
index 3ee18d6a56283aec16d09cabb0e927a1a76192b1,b7657288c689be55f018863e2814fccd696488ed..277529b49840c085a69b651fe1f8f20e5dfa37ca
@@@ -1,11 -1,11 +1,11 @@@
--#ifndef SP_POLYLINE_H
--#define SP_POLYLINE_H
++#ifndef SEEN_SP_POLYLINE_H
++#define SEEN_SP_POLYLINE_H
  
  #include "sp-shape.h"
  
  
  
- #define SP_TYPE_POLYLINE            (sp_polyline_get_type ())
+ #define SP_TYPE_POLYLINE            (SPPolyLine::sp_polyline_get_type ())
  #define SP_POLYLINE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_POLYLINE, SPPolyLine))
  #define SP_POLYLINE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_POLYLINE, SPPolyLineClass))
  #define SP_IS_POLYLINE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_POLYLINE))
  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 --combined src/sp-rect.cpp
index bdfae7c99905e315c36fd002d4bcc3e934bc3d2f,5b75269dcff0aff8a856dd65e1b527e0b8acf893..94be7551b3a00a5db40c24ada82fdb4ff99be567
@@@ -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
@@@ -185,7 -185,7 +185,7 @@@ sp_rect_update(SPObject *object, SPCtx 
          rect->height.update(em, ex, h);
          rect->rx.update(em, ex, w);
          rect->ry.update(em, ex, h);
-         sp_shape_set_shape((SPShape *) object);
+         ((SPShape *) object)->setShape();
          flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
      }
  
@@@ -231,7 -231,7 +231,7 @@@ sp_rect_set_shape(SPShape *shape
      SPRect *rect = (SPRect *) shape;
  
      if ((rect->height.computed < 1e-18) || (rect->width.computed < 1e-18)) {
-         sp_shape_set_curve_insync(SP_SHAPE(rect), NULL, TRUE);
+         SP_SHAPE(rect)->setCurveInsync( NULL, TRUE);
          return;
      }
  
      }
  
      c->closepath();
-     sp_shape_set_curve_insync(SP_SHAPE(rect), c, TRUE);
+     SP_SHAPE(rect)->setCurveInsync( c, TRUE);
      c->unref();
  }
  
@@@ -379,13 -379,13 +379,13 @@@ sp_rect_set_transform(SPItem *item, Geo
      sp_rect_set_shape(rect);
  
      // Adjust stroke width
-     sp_item_adjust_stroke(item, sqrt(fabs(sw * sh)));
+     item->adjust_stroke(sqrt(fabs(sw * sh)));
  
      // Adjust pattern fill
-     sp_item_adjust_pattern(item, xform * ret.inverse());
+     item->adjust_pattern(xform * ret.inverse());
  
      // Adjust gradient fill
-     sp_item_adjust_gradient(item, xform * ret.inverse());
+     item->adjust_gradient(xform * ret.inverse());
  
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
  
@@@ -570,7 -570,7 +570,7 @@@ static void sp_rect_snappoints(SPItem c
  
      SPRect *rect = SP_RECT(item);
  
-     Geom::Matrix const i2d (sp_item_i2d_affine (item));
+     Geom::Matrix const i2d (item->i2d_affine ());
  
      Geom::Point p0 = Geom::Point(rect->x.computed, rect->y.computed) * i2d;
      Geom::Point p1 = Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d;
@@@ -603,13 -603,13 +603,13 @@@ sp_rect_convert_to_guides(SPItem *item
  
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
      if (!prefs->getBool("/tools/shapes/rect/convertguides", true)) {
-         sp_item_convert_to_guides(SP_ITEM(rect));
+         SP_ITEM(rect)->convert_to_guides();
          return;
      }
  
      std::list<std::pair<Geom::Point, Geom::Point> > pts;
  
-     Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(rect)));
+     Geom::Matrix const i2d (SP_ITEM(rect)->i2d_affine());
  
      Geom::Point A1(Geom::Point(rect->x.computed, rect->y.computed) * i2d);
      Geom::Point A2(Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d);
diff --combined src/sp-rect.h
index 9a97bc2173e025779bd9b6a53bf55905e6e3eff8,9a97bc2173e025779bd9b6a53bf55905e6e3eff8..09d96739b262ed4d6d8e006e55be4c701afc7443
@@@ -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 --combined src/sp-root.cpp
index d5a1e064021d602057e4d3d629bf69f182459844,ad43bb3db1d3f42e52c26a29e45c287176b55066..5f868539b1eab0449e7366d1342fca5f615a751e
@@@ -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;
          }
      }
  
--    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);
      }
  }
  
@@@ -661,4 -662,4 +662,4 @@@ sp_root_print(SPItem *item, SPPrintCont
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-script.cpp
index ad41b8021dc2d2a73eb23ccdea9f58e2e41b0223,6cf120a6578672fa736f916119115f0da356de40..3b6a8796d076dc578a6b845b0ba744da1165d2e4
@@@ -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) {
          }
  
      } 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 --combined src/sp-shape.cpp
index 4bbfbc1e12fcbc728be7c8330d213942a0bcb418,3b3e1108b94be13666afe6cf343ebeb7d27eb871..35364692b29b680a2841d79f42c801c945de3858
@@@ -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
   */
@@@ -24,7 -24,6 +26,7 @@@
  #include <2geom/transforms.h>
  #include <2geom/pathvector.h>
  #include <2geom/path-intersection.h>
 +#include <2geom/exception.h>
  #include "helper/geom.h"
  #include "helper/geom-nodetype.h"
  
  
  #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) {
          GTypeInfo info = {
              sizeof (SPShapeClass),
              NULL, NULL,
-             (GClassInitFunc) sp_shape_class_init,
+             (GClassInitFunc) SPShapeClass::sp_shape_class_init,
              NULL, NULL,
              sizeof (SPShape),
              16,
   * 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);
  
      parent_class = (SPLPEItemClass *)g_type_class_peek_parent (klass);
  
-     gobject_class->finalize = sp_shape_finalize;
+     gobject_class->finalize = SPShape::sp_shape_finalize;
  
-     sp_object_class->build = sp_shape_build;
-     sp_object_class->release = sp_shape_release;
-     sp_object_class->set = sp_shape_set;
-     sp_object_class->update = sp_shape_update;
-     sp_object_class->modified = sp_shape_modified;
-     sp_object_class->write = sp_shape_write;
+     sp_object_class->build = SPShape::sp_shape_build;
+     sp_object_class->release = SPShape::sp_shape_release;
+     sp_object_class->set = SPShape::sp_shape_set;
+     sp_object_class->update = SPShape::sp_shape_update;
+     sp_object_class->modified = SPShape::sp_shape_modified;
+     sp_object_class->write = SPShape::sp_shape_write;
  
-     item_class->bbox = sp_shape_bbox;
+     item_class->bbox = SPShape::sp_shape_bbox;
      item_class->print = sp_shape_print;
-     item_class->show = sp_shape_show;
-     item_class->hide = sp_shape_hide;
-     item_class->snappoints = sp_shape_snappoints;
+     item_class->show = SPShape::sp_shape_show;
+     item_class->hide = SPShape::sp_shape_hide;
+     item_class->snappoints = SPShape::sp_shape_snappoints;
      lpe_item_class->update_patheffect = NULL;
  
      klass->set_shape = NULL;
  /**
   * 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();
      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;
  
          shape->modified_connect[i].~connection();
      }
  
-     if (((GObjectClass *) (parent_class))->finalize) {
-         (* ((GObjectClass *) (parent_class))->finalize)(object);
+     if (((GObjectClass *) (SPShapeClass::parent_class))->finalize) {
+         (* ((GObjectClass *) (SPShapeClass::parent_class))->finalize)(object);
      }
  }
  
   *
   * \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++) {
   *
   * \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;
          shape->curve = shape->curve->unref();
      }
  
-     if (((SPObjectClass *) parent_class)->release) {
-       ((SPObjectClass *) parent_class)->release (object);
+     if (((SPObjectClass *) SPShapeClass::parent_class)->release) {
+       ((SPObjectClass *) SPShapeClass::parent_class)->release (object);
      }
  }
  
  
  
- 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;
   * 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;
  
-     if (((SPObjectClass *) (parent_class))->update) {
-         (* ((SPObjectClass *) (parent_class))->update) (object, ctx, flags);
+     if (((SPObjectClass *) (SPShapeClass::parent_class))->update) {
+         (* ((SPObjectClass *) (SPShapeClass::parent_class))->update) (object, ctx, flags);
      }
  
      /* This stanza checks that an object's marker style agrees with
          }
      }
  
-     if (sp_shape_has_markers (shape)) {
+     if (shape->hasMarkers ()) {
          /* Dimension marker views */
          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 (SP_MARKER_LOC_QTY));
+                 NR_ARENA_ITEM_SET_KEY (v->arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY));
              }
              for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
                  if (shape->marker[i]) {
                      sp_marker_show_dimension ((SPMarker *) shape->marker[i],
                                                NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i,
-                                               sp_shape_number_of_markers (shape, i));
+                                               shape->numberOfMarkers (i));
                  }
              }
          }
   * 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();
  
      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);
  
      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);
   *
   * @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;
  
      // position arguments to sp_marker_show_instance, basically counts the amount of markers.
      int counter[4] = {0};
  
 +    if (!shape->curve) return;
      Geom::PathVector const & pathv = shape->curve->get_pathvector();
 +    if (pathv.empty()) return;
  
      // the first vertex should get a start marker, the last an end marker, and all the others a mid marker
      // see bug 456148
  /**
   * 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);
  
-     if (((SPObjectClass *) (parent_class))->modified) {
-       (* ((SPObjectClass *) (parent_class))->modified) (object, flags);
+     if (((SPObjectClass *) (SPShapeClass::parent_class))->modified) {
+       (* ((SPObjectClass *) (SPShapeClass::parent_class))->modified) (object, flags);
      }
  
      if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
   * Calculates the bounding box for item, storing it into bbox.
   * This also includes the bounding boxes of any markers included in the shape.
   */
static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
  {
      SPShape const *shape = SP_SHAPE (item);
      if (shape->curve) {
                      }
  
                      // 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
  
                                      // get bbox of the marker with that transform
                                      NRRect marker_bbox;
-                                     sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true);
+                                     marker_item->invoke_bbox ( &marker_bbox, from_2geom(tr), true);
                                      // union it with the shape bbox
                                      nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
                                  }
                                      }
                                      tr = marker_item->transform * marker->c2p * tr * transform;
                                      NRRect marker_bbox;
-                                     sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true);
+                                     marker_item->invoke_bbox ( &marker_bbox, from_2geom(tr), true);
                                      nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
                                  }
                                  // MID position
                                              }
                                              tr = marker_item->transform * marker->c2p * tr * transform;
                                              NRRect marker_bbox;
-                                             sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true);
+                                             marker_item->invoke_bbox ( &marker_bbox, from_2geom(tr), true);
                                              nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
                                          }
  
                                      }
                                      tr = marker_item->transform * marker->c2p * tr * transform;
                                      NRRect marker_bbox;
-                                     sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true);
+                                     marker_item->invoke_bbox ( &marker_bbox, tr, true);
                                      nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
                                  }
                              }
  
                                      // get bbox of the marker with that transform
                                      NRRect marker_bbox;
-                                     sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true);
+                                     marker_item->invoke_bbox ( &marker_bbox, tr, true);
                                      // union it with the shape bbox
                                      nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
                                  }
@@@ -752,7 -751,7 +724,7 @@@ sp_shape_print_invoke_marker_printing(S
  
      Geom::Matrix old_tr = marker_item->transform;
      marker_item->transform = tr;
-     sp_item_invoke_print (marker_item, ctx);
+     marker_item->invoke_print (ctx);
      marker_item->transform = old_tr;
  }
  /**
@@@ -770,9 -769,6 +742,9 @@@ sp_shape_print (SPItem *item, SPPrintCo
  
      if (!shape->curve) return;
  
 +    Geom::PathVector const & pathv = shape->curve->get_pathvector();
 +    if (pathv.empty()) return;
 +
          Inkscape::Preferences *prefs = Inkscape::Preferences::get();
          gint add_comments = prefs->getBool("/printing/debug/add-label-comments");
          if (add_comments) {
          }
  
      /* fixme: Think (Lauris) */
-     sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
+     item->invoke_bbox( &pbox, Geom::identity(), TRUE);
      dbox.x0 = 0.0;
      dbox.y0 = 0.0;
-     dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item));
-     dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item));
-     sp_item_bbox_desktop (item, &bbox);
-     Geom::Matrix const i2d(sp_item_i2d_affine(item));
+     dbox.x1 = SP_OBJECT_DOCUMENT (item)->getWidth ();
+     dbox.y1 = SP_OBJECT_DOCUMENT (item)->getHeight ();
+     item->getBboxDesktop (&bbox);
+     Geom::Matrix const i2d(item->i2d_affine());
  
      SPStyle* style = SP_OBJECT_STYLE (item);
  
      if (!style->fill.isNone()) {
 -        sp_print_fill (ctx, shape->curve->get_pathvector(), &i2d, style, &pbox, &dbox, &bbox);
 +        sp_print_fill (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox);
      }
  
      if (!style->stroke.isNone()) {
 -        sp_print_stroke (ctx, shape->curve->get_pathvector(), &i2d, style, &pbox, &dbox, &bbox);
 +        sp_print_stroke (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox);
      }
  
      /** \todo make code prettier */
 -    Geom::PathVector const & pathv = shape->curve->get_pathvector();
      // START marker
      for (int i = 0; i < 2; i++) {  // SP_MARKER_LOC and SP_MARKER_LOC_START    
          if ( shape->marker[i] ) {
  /**
   * 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);
          sp_shape_set_marker (object, i, object->style->marker[i].value);
        }
  
-     if (sp_shape_has_markers (shape)) {
+     if (shape->hasMarkers ()) {
  
          /* provide key and dimension the marker views */
          if (!arenaitem->key) {
-             NR_ARENA_ITEM_SET_KEY (arenaitem, sp_item_display_key_new (SP_MARKER_LOC_QTY));
+             NR_ARENA_ITEM_SET_KEY (arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY));
          }
  
          for (int i = 0; i < SP_MARKER_LOC_QTY; i++) {
              if (shape->marker[i]) {
                  sp_marker_show_dimension ((SPMarker *) shape->marker[i],
                                            NR_ARENA_ITEM_GET_KEY (arenaitem) + i,
-                                           sp_shape_number_of_markers (shape, i));
+                                           shape->numberOfMarkers (i));
              }
          }
  
  /**
   * 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;
        }
      }
  
-     if (((SPItemClass *) parent_class)->hide) {
-       ((SPItemClass *) parent_class)->hide (item, key);
+     if (((SPItemClass *) SPShapeClass::parent_class)->hide) {
+       ((SPItemClass *) SPShapeClass::parent_class)->hide (item, key);
      }
  }
  
  * \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
         specified, then all three should appear. */
  
      return (
-         shape->curve &&
-         (shape->marker[SP_MARKER_LOC] ||
-          shape->marker[SP_MARKER_LOC_START] ||
-          shape->marker[SP_MARKER_LOC_MID] ||
-          shape->marker[SP_MARKER_LOC_END])
+         this->curve &&
+         (this->marker[SP_MARKER_LOC] ||
+          this->marker[SP_MARKER_LOC_START] ||
+          this->marker[SP_MARKER_LOC_MID] ||
+          this->marker[SP_MARKER_LOC_END])
          );
  }
  
  * \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;
      }
      switch(type) {
          case SP_MARKER_LOC:
          {
-             if ( shape->marker[SP_MARKER_LOC] ) {
+             if ( this->marker[SP_MARKER_LOC] ) {
                  guint n = 0;
                  for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
                      n += path_it->size_default() + 1;
          }
          case SP_MARKER_LOC_START:
              // there is only a start marker on the first path of a pathvector
-             return shape->marker[SP_MARKER_LOC_START] ? 1 : 0;
+             return this->marker[SP_MARKER_LOC_START] ? 1 : 0;
  
          case SP_MARKER_LOC_MID:
          {
-             if ( shape->marker[SP_MARKER_LOC_MID] ) {
+             if ( this->marker[SP_MARKER_LOC_MID] ) {
                  guint n = 0;
                  for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
                      n += path_it->size_default() + 1;
          case SP_MARKER_LOC_END:
          {
              // there is only an end marker on the last path of a pathvector
-             return shape->marker[SP_MARKER_LOC_END] ? 1 : 0;
+             return this->marker[SP_MARKER_LOC_END] ? 1 : 0;
          }
  
          default:
@@@ -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);
      }
  }
  
   * 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) {
-             shape->curve = curve->ref();
+             this->curve = curve->ref();
          } else {
-             shape->curve = curve->copy();
+             this->curve = curve->copy();
          }
      }
-         SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+         SP_OBJECT(this)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
  /**
   * 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;
  }
  /**
   * 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) {
-             shape->curve = curve->ref();
+             this->curve = curve->ref();
          } else {
-             shape->curve = curve->copy();
+             this->curve = curve->copy();
          }
      }
  }
  /**
   * Return all nodes in a path that are to be considered for snapping
   */
static void sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
void SPShape::sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
  {
      g_assert(item != NULL);
      g_assert(SP_IS_SHAPE(item));
      if (pathv.empty())
          return;
  
-     Geom::Matrix const i2d (sp_item_i2d_affine (item));
+     Geom::Matrix const i2d (item->i2d_affine ());
  
      if (snapprefs->getSnapObjectMidpoints()) {
-         Geom::OptRect bbox = item->getBounds(sp_item_i2d_affine(item));
+         Geom::OptRect bbox = item->getBounds(item->i2d_affine());
          if (bbox) {
              p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
          }
  
      for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
          if (snapprefs->getSnapToItemNode()) {
 +            // Add the first point of the path
              p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
          }
  
          Geom::Path::const_iterator curve_it1 = path_it->begin();      // incoming curve
          Geom::Path::const_iterator curve_it2 = ++(path_it->begin());  // outgoing curve
 -        while (curve_it2 != path_it->end_closed())
 +        while (curve_it1 != path_it->end_default())
          {
 -            /* Test whether to add the node between curve_it1 and curve_it2.
 -             * Loop to end_closed (so always including closing segment); the last node to be added
 -             * is the node between the closing segment and the segment before that, regardless
 -             * of the path being closed or not. If the path is closed, the final point was already added by
 -             * adding the initial point. */
 -
 -            Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, *curve_it2);
 -
 -            bool c1 = snapprefs->getSnapToItemNode() && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE);
 -            bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM);
 -
 -            if (c1 || c2) {
 -                Inkscape::SnapSourceType sst;
 -                Inkscape::SnapTargetType stt;
 -                switch (nodetype) {
 -                case Geom::NODE_CUSP:
 -                    sst = Inkscape::SNAPSOURCE_NODE_CUSP;
 -                    stt = Inkscape::SNAPTARGET_NODE_CUSP;
 -                    break;
 -                case Geom::NODE_SMOOTH:
 -                case Geom::NODE_SYMM:
 -                    sst = Inkscape::SNAPSOURCE_NODE_SMOOTH;
 -                    stt = Inkscape::SNAPTARGET_NODE_SMOOTH;
 -                    break;
 -                default:
 -                    sst = Inkscape::SNAPSOURCE_UNDEFINED;
 -                    stt = Inkscape::SNAPTARGET_UNDEFINED;
 -                    break;
 +            // For each path: consider midpoints of line segments for snapping
 +            if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping)
 +                if (Geom::LineSegment const* line_segment = dynamic_cast<Geom::LineSegment const*>(&(*curve_it1))) {
 +                    p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2d, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT));
                  }
 -                p.push_back(Inkscape::SnapCandidatePoint(curve_it1->finalPoint() * i2d, sst, stt));
              }
  
 -            // Consider midpoints of line segments for snapping
 -            if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforce strict snapping)
 -                if (Geom::LineSegment const* line_segment = dynamic_cast<Geom::LineSegment const*>(&(*curve_it1))) {
 -                    p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2d, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT));
 +            if (curve_it2 == path_it->end_default()) { // Test will only pass for the last iteration of the while loop
 +                if (snapprefs->getSnapToItemNode() && !path_it->closed()) {
 +                    // Add the last point of the path, but only for open paths
 +                    // (for closed paths the first and last point will coincide)
 +                    p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
 +                }
 +            } else {
 +                /* Test whether to add the node between curve_it1 and curve_it2.
 +                 * Loop to end_default (so only iterating through the stroked part); */
 +
 +                Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, *curve_it2);
 +
 +                bool c1 = snapprefs->getSnapToItemNode() && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE);
 +                bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM);
 +
 +                if (c1 || c2) {
 +                    Inkscape::SnapSourceType sst;
 +                    Inkscape::SnapTargetType stt;
 +                    switch (nodetype) {
 +                    case Geom::NODE_CUSP:
 +                        sst = Inkscape::SNAPSOURCE_NODE_CUSP;
 +                        stt = Inkscape::SNAPTARGET_NODE_CUSP;
 +                        break;
 +                    case Geom::NODE_SMOOTH:
 +                    case Geom::NODE_SYMM:
 +                        sst = Inkscape::SNAPSOURCE_NODE_SMOOTH;
 +                        stt = Inkscape::SNAPTARGET_NODE_SMOOTH;
 +                        break;
 +                    default:
 +                        sst = Inkscape::SNAPSOURCE_UNDEFINED;
 +                        stt = Inkscape::SNAPTARGET_UNDEFINED;
 +                        break;
 +                    }
 +                    p.push_back(Inkscape::SnapCandidatePoint(curve_it1->finalPoint() * i2d, sst, stt));
                  }
              }
  
          // (using "Method 1" as described in Inkscape::ObjectSnapper::_collectNodes())
          if (snapprefs->getSnapIntersectionCS()) {
              Geom::Crossings cs;
 -            cs = self_crossings(*path_it);
 -            if (cs.size() > 0) { // There might be multiple intersections...
 -                for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) {
 -                    Geom::Point p_ix = (*path_it).pointAt((*i).ta);
 -                    p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2d, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION));
 +            try {
 +                cs = self_crossings(*path_it);
 +                if (cs.size() > 0) { // There might be multiple intersections...
 +                    for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) {
 +                        Geom::Point p_ix = (*path_it).pointAt((*i).ta);
 +                        p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2d, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION));
 +                    }
                  }
 +            } catch (Geom::RangeError &e) {
 +                // do nothing
 +                // The exception could be Geom::InfiniteSolutions: then no snappoints should be added
              }
 +
          }
      }
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-shape.h
index 4b1ded23649394f2066412c1d4be334d62b72817,0a3b3e37f6308dea5fdd6f7107998bb4a209051f..78855c1c7d32606f98b0801045964801d736f3e8
@@@ -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.
@@@ -21,7 -21,7 +23,7 @@@
  
  #include <sigc++/connection.h>
  
- #define SP_TYPE_SHAPE (sp_shape_get_type ())
+ #define SP_TYPE_SHAPE (SPShape::getType ())
  #define SP_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SHAPE, SPShape))
  #define SP_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SHAPE, SPShapeClass))
  #define SP_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SHAPE))
  
  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 --combined src/sp-skeleton.cpp
index 329df8eb64d199e963a39014be66db1ee9dbcbe6,f67341826f54262f7e221cd188ea3fe058e33154..42fc5289f7e70bf6d9cc5e0f5b7de88b40a0ff1c
@@@ -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" );
      */
  }
  
@@@ -212,4 -212,4 +211,4 @@@ sp_skeleton_write(SPObject *object, Ink
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-spiral.cpp
index c309c60ccfd8059ec75e516beb342b88e670cd20,499500c44ecf24a5e307d3c5e849132005c1ee72..cfe02947a26af5276f16532be2bea8f2aafb06df
@@@ -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" );
  }
  
  /**
@@@ -287,7 -287,7 +286,7 @@@ static voi
  sp_spiral_update (SPObject *object, SPCtx *ctx, guint flags)
  {
      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 ();
      }
  
      if (((SPObjectClass *) parent_class)->update)
@@@ -427,7 -427,7 +426,7 @@@ sp_spiral_set_shape (SPShape *shape
              // unconditionally read the curve from d, if any, to preserve appearance
              Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
              SPCurve *cold = new SPCurve(pv);
-             sp_shape_set_curve_insync (shape, cold, TRUE);
+             shape->setCurveInsync( cold, TRUE);
              cold->unref();
          }
          return;
  
      /* Reset the shape'scurve to the "original_curve"
       * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
-     sp_shape_set_curve_insync (shape, c, TRUE);
+     shape->setCurveInsync( c, TRUE);
      if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
          SPCurve *c_lpe = c->copy();
          bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
          if (success) {
-             sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+             shape->setCurveInsync( c_lpe, TRUE);
          }
          c_lpe->unref();
      }
@@@ -533,7 -533,7 +532,7 @@@ static void sp_spiral_snappoints(SPIte
      }
  
      if (snapprefs->getSnapObjectMidpoints()) {
-         Geom::Matrix const i2d (sp_item_i2d_affine (item));
+         Geom::Matrix const i2d (item->i2d_affine ());
          SPSpiral *spiral = SP_SPIRAL(item);
          p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(spiral->cx, spiral->cy) * i2d, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
          // This point is the start-point of the spiral, which is also returned when _snap_to_itemnode has been set
@@@ -679,4 -679,4 +678,4 @@@ sp_spiral_is_invalid (SPSpiral const *s
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-star.cpp
index 3694a7cd1025904042fa2c013de8d295fc88be3a,b956019d44b487976f793cff7ca2558db31177ee..b94e2dbc4b38d1f122eeb8295ec6789522ad3ab9
@@@ -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 *
@@@ -270,7 -270,7 +269,7 @@@ sp_star_update (SPObject *object, SPCt
      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 ();
      }
  
      if (((SPObjectClass *) parent_class)->update)
@@@ -439,7 -439,7 +438,7 @@@ sp_star_set_shape (SPShape *shape
              // unconditionally read the curve from d, if any, to preserve appearance
              Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
              SPCurve *cold = new SPCurve(pv);
-             sp_shape_set_curve_insync (shape, cold, TRUE);
+             shape->setCurveInsync( cold, TRUE);
              cold->unref();
          }
          return;
  
      /* Reset the shape'scurve to the "original_curve"
       * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
-     sp_shape_set_curve_insync (shape, c, TRUE);
+     shape->setCurveInsync( c, TRUE);
      if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
          SPCurve *c_lpe = c->copy();
          bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
          if (success) {
-             sp_shape_set_curve_insync (shape, c_lpe, TRUE);
+             shape->setCurveInsync( c_lpe, TRUE);
          } 
          c_lpe->unref();
      }
@@@ -560,7 -560,7 +559,7 @@@ static void sp_star_snappoints(SPItem c
      }
  
      if (snapprefs->getSnapObjectMidpoints()) {
-         Geom::Matrix const i2d (sp_item_i2d_affine (item));
+         Geom::Matrix const i2d (item->i2d_affine ());
          p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2d,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
      }
  }
@@@ -610,4 -610,4 +609,4 @@@ sp_star_get_xy (SPStar *star, SPStarPoi
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-stop.cpp
index 15fc93e2f116b90684016d865f3f38fee0c8a0cb,740cfef7853e49dc0eedf63a13ea247ccb08d388..0c0a3b03aa19f3c9fbf981227e634ef47ddca7a6
@@@ -15,7 -15,7 +15,7 @@@
  
  
  #include "sp-stop.h"
 -
 +#include "style.h"
  
  // A stop might have some non-stop siblings
  SPStop* SPStop::getNextStop()
@@@ -52,34 -52,6 +52,34 @@@ SPStop* SPStop::getPrevStop(
      return result;
  }
  
-         char const *str = sp_object_get_style_property(this, "color", NULL);
 +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 = 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;
 +}
 +
  
  
  /*
@@@ -91,4 -63,4 +91,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-string.cpp
index b424ac3d8c318ee10e14af386b7c4b1f97fa886f,8cf8d3291c089ede5e3876c03201b53ceda15f79..c116e8dd854b3f2f1dcd6d59eaf8b074cdb20d1a
@@@ -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;
          }
      }
          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);
  }
@@@ -166,4 -168,4 +175,4 @@@ sp_string_update(SPObject *object, SPCt
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-style-elem-test.h
index 0c01136f6af47df3d97b86a4efc73af5215210db,9b096c86100851aed3031880927651d2759240ec..53362d3e374096a3ad1e8bef63757a7135a26810
@@@ -1,4 -1,4 +1,3 @@@
--
  #ifndef SEEN_SP_STYLE_ELEM_TEST_H
  #define SEEN_SP_STYLE_ELEM_TEST_H
  
@@@ -23,7 -23,7 +22,7 @@@ public
      {
          if ( _doc )
          {
-             sp_document_unref( _doc );
+             _doc->doUnref();
          }
      }
  
          SPStyleElem *style_elem = static_cast<SPStyleElem *>(g_object_new(SP_TYPE_STYLE_ELEM, NULL));
          SP_OBJECT(style_elem)->document = _doc;
  
-         sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "something unrecognized");
+         SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "something unrecognized");
          TS_ASSERT( !style_elem->is_css );
  
-         sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/css");
+         SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css");
          TS_ASSERT( style_elem->is_css );
  
-         sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "atext/css");
+         SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "atext/css");
          TS_ASSERT( !style_elem->is_css );
  
-         sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/cssx");
+         SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/cssx");
          TS_ASSERT( !style_elem->is_css );
  
          g_object_unref(style_elem);
@@@ -82,7 -82,7 +81,7 @@@
          SPStyleElem *style_elem = SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL));
          SP_OBJECT(style_elem)->document = _doc;
  
-         sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/css");
+         SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css");
          Inkscape::XML::Node *repr = sp_document_repr_doc(_doc)->createElement("svg:style");
          SP_OBJECT(style_elem)->updateRepr(sp_document_repr_doc(_doc), repr, SP_OBJECT_WRITE_ALL);
          {
          SPStyleElem &style_elem = *SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL));
          Inkscape::XML::Node *const repr = sp_document_repr_doc(_doc)->createElement("svg:style");
          repr->setAttribute("type", "text/css");
-         sp_object_invoke_build(&style_elem, _doc, repr, false);
+         (&style_elem)->invoke_build( _doc, repr, false);
          TS_ASSERT( style_elem.is_css );
          TS_ASSERT( style_elem.media.print );
          TS_ASSERT( style_elem.media.screen );
          repr->setAttribute("type", "text/css");
          Inkscape::XML::Node *const content_repr = sp_document_repr_doc(_doc)->createTextNode(".myclass { }");
          repr->addChild(content_repr, NULL);
-         sp_object_invoke_build(&style_elem, _doc, repr, false);
+         (&style_elem)->invoke_build(_doc, repr, false);
          TS_ASSERT( style_elem.is_css );
          TS_ASSERT( _doc->style_cascade );
          CRStyleSheet const *const stylesheet = cr_cascade_get_sheet(_doc->style_cascade, ORIGIN_AUTHOR);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-style-elem.cpp
index 5a57d548b83e9e0d772e5f17c6d8be5f355fe720,68d8e88703900acb0b922ef31cfffd50c5546703..02ed80445346aedd73f1e6fe39bcb6e59221760e
@@@ -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
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-switch.cpp
index 37be6f75eef0b384e418c3ade98eec793fb86b89,2d67b8637533a0607bdb4f1f86aa46cbf93cbd24..19c014b9b50e76c46168158a2f3eda7b8bcf34ce
@@@ -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) {
@@@ -168,7 -168,7 +170,7 @@@ void CSwitch::_showChildren (NRArena *a
          if (SP_IS_ITEM (o)) {
              child = SP_ITEM (o);
              child->setEvaluated(o == evaluated_child);
-             ac = sp_item_invoke_show (child, arena, key, flags);
+             ac = child->invoke_show (arena, key, flags);
              if (ac) {
                  nr_arena_item_add_child (ai, ac, ar);
                  ar = ac;
          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 --combined src/sp-symbol.cpp
index 41004db6e37154db0e98ae5ae6f687d2dc2af5ae,262cfa6a062caed964319b38baffdb2cda7c269e..6c8d3cd82a7433e64b6f2d70f52f0ec237b62e27
@@@ -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 --combined src/sp-text.cpp
index 4b896db9cd980ad8d90d8f6a4408bb1e2165b618,dcf9160ff134af85f67a111d193c4783a33261e1..80eb786f28754cbfed3928c5b7cc6d5c62de92af
@@@ -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);
  
      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);
      }
          text->rebuildLayout();
  
          NRRect paintbox;
-         sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE);
+         text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
          for (SPItemView* v = text->display; v != NULL; v = v->next) {
              text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
              nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
      }
  }
  
--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
      if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
          SPText *text = SP_TEXT (object);
          NRRect paintbox;
-         sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE);
+         text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
          for (SPItemView* v = text->display; v != NULL; v = v->next) {
              text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
              nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
          }
      }
  
--    /* 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);
      }
  }
  
--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);
              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 {
          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;
  }
@@@ -387,7 -387,7 +396,7 @@@ sp_text_show(SPItem *item, NRArena *are
  
      // pass the bbox of the text object as paintbox (used for paintserver fills)
      NRRect paintbox;
-     sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE);
+     item->invoke_bbox( &paintbox, Geom::identity(), TRUE);
      group->layout.show(flowed, &paintbox);
  
      return flowed;
@@@ -442,7 -442,7 +451,7 @@@ static void sp_text_snappoints(SPItem c
      if (layout != NULL && layout->outputExists()) {
          boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
          if (pt) {
-             p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
+             p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE));
          }
      }
  }
@@@ -483,13 -483,13 +492,13 @@@ sp_text_set_transform (SPItem *item, Ge
      text->_adjustFontsizeRecursive (item, ex);
  
      // Adjust stroke width
-     sp_item_adjust_stroke_width_recursive (item, ex);
+     item->adjust_stroke_width_recursive (ex);
  
      // Adjust pattern fill
-     sp_item_adjust_pattern(item, xform * ret.inverse());
+     item->adjust_pattern(xform * ret.inverse());
  
      // Adjust gradient fill
-     sp_item_adjust_gradient(item, xform * ret.inverse());
+     item->adjust_gradient(xform * ret.inverse());
  
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
  
@@@ -502,13 -502,13 +511,13 @@@ sp_text_print (SPItem *item, SPPrintCon
      NRRect     pbox, dbox, bbox;
      SPText *group = SP_TEXT (item);
  
-     sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
-     sp_item_bbox_desktop (item, &bbox);
+     item->invoke_bbox( &pbox, Geom::identity(), TRUE);
+     item->getBboxDesktop (&bbox);
      dbox.x0 = 0.0;
      dbox.y0 = 0.0;
-     dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item));
-     dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item));
-     Geom::Matrix const ctm (sp_item_i2d_affine(item));
+     dbox.x1 = SP_OBJECT_DOCUMENT (item)->getWidth ();
+     dbox.y1 = SP_OBJECT_DOCUMENT (item)->getHeight ();
+     Geom::Matrix const ctm (item->i2d_affine());
  
      group->layout.print(ctx,&pbox,&dbox,&bbox,ctm);
  }
@@@ -528,7 -528,7 +537,7 @@@ unsigned SPText::_buildLayoutInput(SPOb
      }
      else if (SP_IS_TSPAN(root)) {
          SPTSpan *tspan = SP_TSPAN(root);
 -        // x, y attributes are stripped from some tspans as we do our own line layout
 +        // x, y attributes are stripped from some tspans marked with role="line" as we do our own line layout.
          // This should be checked carefully, as it can undo line layout in imported SVG files.
          bool use_xy = !in_textpath && (tspan->role == SP_TSPAN_ROLE_UNSPECIFIED || !tspan->attributes.singleXYCoordinates());
          tspan->attributes.mergeInto(&optional_attrs, parent_optional_attrs, parent_attrs_offset, use_xy, true);
      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
              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);
              length += string.length();
-         } else if (!sp_repr_is_meta_element(child->repr)) {
+         } /*XML Tree being directly used here while it shouldn't be.*/ else if (!sp_repr_is_meta_element(child->getRepr())) {
              length += _buildLayoutInput(child, optional_attrs, child_attrs_offset + length, in_textpath);
          }
      }
@@@ -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) {
      //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);
++            }
++        }
      }
  }
  
@@@ -1039,4 -1039,4 +1052,4 @@@ void TextTagAttributes::setRotate(unsig
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-textpath.h
index 76d236cc9bfa91c584086b6f2f299e3028a268a8,6642587d2776b4ad0f597628c2d0b6b7de8e1cd8..2f30f6023b7df9f916ae10fc0c5f88e47cd4dba5
@@@ -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);
@@@ -48,4 -48,4 +48,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-tref-reference.h
index 37a5e21cee3456852da5ddf20045862c4698a44c,f3c64594249d142ff57411aa902ce34ba5c2bfcb..c2264f83e85516f37246e5b27f4d4aacbc572fa6
@@@ -7,11 -7,12 +7,13 @@@
   * 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.
   */
  
  #include <forward.h>
+ #include "sp-item.h"
  #include <uri-references.h>
  #include <sigc++/sigc++.h>
  
diff --combined src/sp-tref.cpp
index 66a8c1e7920f6ef75b5a0170d53669334eed6808,ef9c8948609bdb3686638c50fa4a85614fbbff2b..eddcd270c482a79be553201b5d7a21f5d9840833
@@@ -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" );
  }
  
  /**
@@@ -359,7 -359,7 +359,7 @@@ sp_tref_description(SPItem *item
          char *child_desc;
  
          if (SP_IS_ITEM(referred)) {
-             child_desc = sp_item_description(SP_ITEM(referred));
+             child_desc = SP_ITEM(referred)->description();
          } else {
              child_desc = g_strdup("");
          }
@@@ -388,7 -388,7 +388,7 @@@ sp_tref_href_changed(SPObject */*old_re
          tref->_delete_connection.disconnect();
  
          if (tref->stringChild) {
-             sp_object_detach(SP_OBJECT(tref), tref->stringChild);
+             SP_OBJECT(tref)->detach(tref->stringChild);
              tref->stringChild = NULL;
          }
  
@@@ -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
          build_string_from_root(SP_OBJECT_REPR(tref->getObjectReferredTo()), &charData);
  
          if (tref->stringChild) {
-             sp_object_detach(SP_OBJECT(tref), tref->stringChild);
+             SP_OBJECT(tref)->detach(tref->stringChild);
              tref->stringChild = NULL;
          }
  
          // 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));
  
          // Add this SPString as a child of the tref
-         sp_object_attach(SP_OBJECT(tref), tref->stringChild, tref->lastChild());
+         SP_OBJECT(tref)->attach(tref->stringChild, tref->lastChild());
          sp_object_unref(tref->stringChild, NULL);
-         sp_object_invoke_build(tref->stringChild, SP_OBJECT(tref)->document, newStringRepr, TRUE);
+         (tref->stringChild)->invoke_build(SP_OBJECT(tref)->document, newStringRepr, TRUE);
  
          Inkscape::GC::release(newStringRepr);
      }
@@@ -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");
  
      ////////////////////
      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);
          }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-tspan.cpp
index 056436ed3abf6cf785e950f1b428740bf8d1d578,8cddc6e5e36837d2e04fddd8181a02069ef4826d..2afd75e75992d303453514f2e9a76c9d06402057
@@@ -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);
              } 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);
              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) ) {
          }
      }
        
--    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);
              } 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);
              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) ) {
          }
      }
        
--    if (((SPObjectClass *) textpath_parent_class)->write)
++    if (((SPObjectClass *) textpath_parent_class)->write) {
          ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags);
++    }
        
      return repr;
  }
@@@ -578,7 -578,7 +590,7 @@@ sp_textpath_to_text(SPObject *tp
      SPObject *text = SP_OBJECT_PARENT(tp);
  
      NRRect bbox;
-     sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE);
+     SP_ITEM(text)->invoke_bbox( &bbox, SP_ITEM(text)->i2doc_affine(), TRUE);
      Geom::Point xy(bbox.x0, bbox.y0);
  
      // make a list of textpath children
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/sp-use.cpp
index ecb7eb788b137c69537c43312d9950e96ce06518,075c7f8044d52f9a0c09ab4bd9248f1624caabb4..505c64fd225b326e448dca557ad9e1fb31b4c525
@@@ -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.
@@@ -140,7 -140,7 +140,7 @@@ sp_use_finalize(GObject *obj
      SPUse *use = (SPUse *) obj;
  
      if (use->child) {
-         sp_object_detach(SP_OBJECT(obj), use->child);
+         SP_OBJECT(obj)->detach(use->child);
          use->child = NULL;
      }
  
@@@ -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,
@@@ -177,7 -177,7 +177,7 @@@ sp_use_release(SPObject *object
      SPUse *use = SP_USE(object);
  
      if (use->child) {
-         sp_object_detach(object, use->child);
+         object->detach(use->child);
          use->child = NULL;
      }
  
@@@ -289,7 -289,7 +289,7 @@@ sp_use_bbox(SPItem const *item, NRRect 
                                                 use->y.computed)
                               * transform );
          Geom::OptRect optbbox;
-         sp_item_invoke_bbox_full(child, optbbox, ct, flags, FALSE);
+         child->invoke_bbox_full( optbbox, ct, flags, FALSE);
          if (optbbox) {
              bbox->x0 = (*optbbox)[0][0];
              bbox->y0 = (*optbbox)[1][0];
@@@ -312,7 -312,7 +312,7 @@@ sp_use_print(SPItem *item, SPPrintConte
      }
  
      if (use->child && SP_IS_ITEM(use->child)) {
-         sp_item_invoke_print(SP_ITEM(use->child), ctx);
+         SP_ITEM(use->child)->invoke_print(ctx);
      }
  
      if (translated) {
@@@ -336,7 -336,7 +336,7 @@@ sp_use_description(SPItem *item
               * a <use>, and giving its description. */
          }
          ++recursion_depth;
-         char *child_desc = sp_item_description(SP_ITEM(use->child));
+         char *child_desc = SP_ITEM(use->child)->description();
          --recursion_depth;
  
          ret = g_strdup_printf(_("<b>Clone</b> of: %s"), child_desc);
@@@ -357,7 -357,7 +357,7 @@@ sp_use_show(SPItem *item, NRArena *aren
      nr_arena_group_set_style(NR_ARENA_GROUP(ai), SP_OBJECT_STYLE(item));
  
      if (use->child) {
-         NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(use->child), arena, key, flags);
+         NRArenaItem *ac = SP_ITEM(use->child)->invoke_show(arena, key, flags);
          if (ac) {
              nr_arena_item_add_child(ai, ac, NULL);
          }
@@@ -375,7 -375,7 +375,7 @@@ sp_use_hide(SPItem *item, unsigned key
      SPUse *use = SP_USE(item);
  
      if (use->child) {
-         sp_item_invoke_hide(SP_ITEM(use->child), key);
+         SP_ITEM(use->child)->invoke_hide(key);
      }
  
      if (((SPItemClass *) parent_class)->hide) {
@@@ -492,7 -492,7 +492,7 @@@ sp_use_move_compensate(Geom::Matrix con
          return;
  
      // restore item->transform field from the repr, in case it was changed by seltrans
-     sp_object_read_attr (SP_OBJECT (self), "transform");
+     SP_OBJECT (self)->readAttr ("transform");
  
      Geom::Matrix t = sp_use_get_parent_transform(self);
      Geom::Matrix clone_move = t.inverse() * m * t;
      // commit the compensation
      SPItem *item = SP_ITEM(self);
      item->transform *= clone_move;
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, &advertized_move);
+     item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, &advertized_move);
      SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
@@@ -525,7 -525,7 +525,7 @@@ sp_use_href_changed(SPObject */*old_ref
      use->_transformed_connection.disconnect();
  
      if (use->child) {
-         sp_object_detach(SP_OBJECT(use), use->child);
+         SP_OBJECT(use)->detach(use->child);
          use->child = NULL;
      }
  
              g_return_if_fail(type > G_TYPE_NONE);
              if (g_type_is_a(type, SP_TYPE_ITEM)) {
                  use->child = (SPObject*) g_object_new(type, 0);
-                 sp_object_attach(SP_OBJECT(use), use->child, use->lastChild());
+                 SP_OBJECT(use)->attach(use->child, use->lastChild());
                  sp_object_unref(use->child, SP_OBJECT(use));
-                 sp_object_invoke_build(use->child, SP_OBJECT(use)->document, childrepr, TRUE);
+                 (use->child)->invoke_build(SP_OBJECT(use)->document, childrepr, TRUE);
  
                  for (SPItemView *v = item->display; v != NULL; v = v->next) {
                      NRArenaItem *ai;
-                     ai = sp_item_invoke_show(SP_ITEM(use->child), NR_ARENA_ITEM_ARENA(v->arenaitem), v->key, v->flags);
+                     ai = SP_ITEM(use->child)->invoke_show(NR_ARENA_ITEM_ARENA(v->arenaitem), v->key, v->flags);
                      if (ai) {
                          nr_arena_item_add_child(v->arenaitem, ai, NULL);
                      }
@@@ -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);
      {
          Geom::Matrix nomove(Geom::identity());
          // Advertise ourselves as not moving.
-         sp_item_write_transform(item, SP_OBJECT_REPR(item), t, &nomove);
+         item->doWriteTransform(SP_OBJECT_REPR(item), t, &nomove);
      }
      return item;
  }
diff --combined src/spiral-context.cpp
index 6730ab63b77a7fc1b6db06975aa855a3235cf61b,13407b80b3002e1e538a1783c6c13a321fd5e812..75488519273826d5040bac4f35714e9e042aed0b
@@@ -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);
@@@ -242,7 -242,7 +244,7 @@@ sp_spiral_context_root_handler(SPEventC
                  SnapManager &m = desktop->namedview->snap_manager;
                  m.setup(desktop);
                  m.freeSnapReturnByRef(sc->center, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -
 +                m.unSetup();
                  sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                      ( GDK_KEY_PRESS_MASK |
                                        GDK_BUTTON_RELEASE_MASK |
                  SnapManager &m = desktop->namedview->snap_manager;
                  m.setup(desktop, true, sc->item);
                  m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +                m.unSetup();
                  sp_spiral_drag(sc, from_2geom(motion_dt), event->motion.state);
  
                  gobble_motion_events(GDK_BUTTON1_MASK);
              } else if (!sp_event_context_knot_mouseover(sc)) {
                  SnapManager &m = desktop->namedview->snap_manager;
                  m.setup(desktop);
 -
                  Geom::Point const motion_w(event->motion.x, event->motion.y);
                  Geom::Point motion_dt(desktop->w2d(motion_w));
                  m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +                m.unSetup();
              }
              break;
          case GDK_BUTTON_RELEASE:
      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;
  
              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);
          Inkscape::GC::release(repr);
-         sc->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+         sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
          sc->item->updateRepr();
  
          sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
      m.setup(desktop, true, sc->item);
      Geom::Point pt2g = to_2geom(p);
      m.freeSnapReturnByRef(pt2g, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -
 +    m.unSetup();
      Geom::Point const p0 = desktop->dt2doc(sc->center);
      Geom::Point const p1 = desktop->dt2doc(pt2g);
  
@@@ -475,14 -474,14 +476,14 @@@ sp_spiral_finish(SPSpiralContext *sc
  
        SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
  
-         sp_shape_set_shape(SP_SHAPE(spiral));
+         SP_SHAPE(spiral)->setShape();
          SP_OBJECT(spiral)->updateRepr(SP_OBJECT_WRITE_EXT);
  
          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));
  }
  
  /*
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/splivarot.cpp
index e7787813d3830383700e0e69f9b70ce5937c7b5d,b2fe45e19b7668cd4c6d1aeef1428ccb6e65eabd..5f32e591ef906ab4b90c1dfd43a5060f6ef3e594
@@@ -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;
      // adjust style properties that depend on a possible transform in the source object in order
      // to get a correct style attribute for the new path
      SPItem* item_source = SP_ITEM(source);
-     Geom::Matrix i2doc(sp_item_i2doc_affine(item_source));
-     sp_item_adjust_stroke(item_source, i2doc.descrim());
-     sp_item_adjust_pattern(item_source, i2doc);
-     sp_item_adjust_gradient(item_source, i2doc);
-     sp_item_adjust_livepatheffect(item_source, i2doc);
+     Geom::Matrix i2doc(item_source->i2doc_affine());
+     item_source->adjust_stroke(i2doc.descrim());
+     item_source->adjust_pattern(i2doc);
+     item_source->adjust_gradient(i2doc);
+     item_source->adjust_livepatheffect(i2doc);
  
      Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source);
  
  
      // premultiply by the inverse of parent's repr
      SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent));
-     Geom::Matrix local (sp_item_i2doc_affine(parent_item));
+     Geom::Matrix local (parent_item->i2doc_affine());
      gchar *transform = sp_svg_transform_write(local.inverse());
  
      // now that we have the result, add it on the canvas
          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)
      } 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);
  
      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;
@@@ -620,13 -620,14 +621,13 @@@ void sp_selected_path_outline_add_marke
          Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate(xml_doc);
          g_repr->appendChild(m_repr);
          SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr);
-         sp_item_write_transform(marker_item, m_repr, tr);
+         marker_item->doWriteTransform(m_repr, tr);
      }
  }
  
  static
  void item_outline_add_marker( SPObject const *marker_object, Geom::Matrix marker_transform,
 -                              Geom::Scale stroke_scale, Geom::Matrix transform,
 -                              Geom::PathVector* pathv_in )
 +                              Geom::Scale stroke_scale, Geom::PathVector* pathv_in )
  {
      SPMarker* marker = SP_MARKER (marker_object);
      SPItem* marker_item = sp_item_first_item_child(SP_OBJECT(marker_object));
          tr = stroke_scale * tr;
      }
      // total marker transform
 -    tr = marker_item->transform * marker->c2p * tr * transform;
 +    tr = marker_item->transform * marker->c2p * tr;
  
      Geom::PathVector* marker_pathv = item_outline(marker_item);
      
@@@ -666,7 -667,7 +667,7 @@@ Geom::PathVector* item_outline(SPItem c
  
      SPCurve *curve = NULL;
      if (SP_IS_SHAPE(item)) {
-         curve = sp_shape_get_curve(SP_SHAPE(item));
+         curve = SP_SHAPE(item)->getCurve();
      } else if (SP_IS_TEXT(item)) {
          curve = SP_TEXT(item)->getNormalizedBpath();
      }
          return ret_pathv;
      }
  
 +    if (curve->get_pathvector().empty()) {
 +        return ret_pathv;
 +    }
 +
      // remember old stroke style, to be set on fill
      SPStyle *i_style = SP_OBJECT_STYLE(item);
  
      if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether
          ret_pathv = orig->MakePathVector();
  
-         if (SP_IS_SHAPE(item) && sp_shape_has_markers (SP_SHAPE(item))) {
+         if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers ()) {
              SPShape *shape = SP_SHAPE(item);
  
              Geom::PathVector const & pathv = curve->get_pathvector();
                  if ( SPObject *marker_obj = shape->marker[i] ) {
                      Geom::Matrix const m (sp_shape_marker_get_transform_at_start(pathv.front().front()));
                      item_outline_add_marker( marker_obj, m,
 -                                             Geom::Scale(i_style->stroke_width.computed), transform,
 +                                             Geom::Scale(i_style->stroke_width.computed),
                                               ret_pathv );
                  }
              }
                      {
                          Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front()));
                          item_outline_add_marker( midmarker_obj, m,
 -                                                 Geom::Scale(i_style->stroke_width.computed), transform,
 +                                                 Geom::Scale(i_style->stroke_width.computed),
                                                   ret_pathv );
                      }
                      // MID position
                               */
                              Geom::Matrix const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2));
                              item_outline_add_marker( midmarker_obj, m,
 -                                                     Geom::Scale(i_style->stroke_width.computed), transform,
 +                                                     Geom::Scale(i_style->stroke_width.computed),
                                                       ret_pathv);
  
                              ++curve_it1;
                          Geom::Curve const &lastcurve = path_it->back_default();
                          Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve);
                          item_outline_add_marker( midmarker_obj, m,
 -                                                 Geom::Scale(i_style->stroke_width.computed), transform,
 +                                                 Geom::Scale(i_style->stroke_width.computed),
                                                   ret_pathv );
                      }
                  }
  
                      Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve);
                      item_outline_add_marker( marker_obj, m,
 -                                             Geom::Scale(i_style->stroke_width.computed), transform,
 +                                             Geom::Scale(i_style->stroke_width.computed),
                                               ret_pathv );
                  }
              }
@@@ -894,7 -891,7 +895,7 @@@ sp_selected_path_outline(SPDesktop *des
  
          SPCurve *curve = NULL;
          if (SP_IS_SHAPE(item)) {
-             curve = sp_shape_get_curve(SP_SHAPE(item));
+             curve = SP_SHAPE(item)->getCurve();
              if (curve == NULL)
                  continue;
          }
                  continue;
          }
  
 +        if (curve->get_pathvector().empty()) {
 +            continue;
 +        }
 +
          // pas de stroke pas de chocolat
          if (!SP_OBJECT_STYLE(item) || SP_OBJECT_STYLE(item)->stroke.noneSet) {
              curve->unref();
          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
              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
                  // restore title, description, id, transform
                  repr->setAttribute("id", id);
                  SPItem *newitem = (SPItem *) doc->getObjectByRepr(repr);
-                 sp_item_write_transform(newitem, repr, transform);
+                 newitem->doWriteTransform(repr, transform);
                  if (title) {
                        newitem->setTitle(title);
                  }
                  repr->setAttribute("id", id);
  
                  SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
-                 sp_item_write_transform(newitem, repr, transform);
+                 newitem->doWriteTransform(repr, transform);
                  if (title) {
                        newitem->setTitle(title);
                  }
      }
  
      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."));
@@@ -1315,7 -1308,7 +1316,7 @@@ sp_selected_path_create_offset_object(S
      }
      if (SP_IS_SHAPE(item))
      {
-         curve = sp_shape_get_curve(SP_SHAPE(item));
+         curve = SP_SHAPE(item)->getCurve();
          if (curve == NULL)
              return;
      }
  
      Geom::Matrix const transform(item->transform);
  
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
+     item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity());
  
-     style = g_strdup(SP_OBJECT(item)->repr->attribute("style"));
+       //XML Tree being used directly here while it shouldn't be...
+     style = g_strdup(SP_OBJECT(item)->getRepr()->attribute("style"));
  
      // remember the position of the item
      gint pos = SP_OBJECT_REPR(item)->position();
      {
          // 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;
  
          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
          g_free(str);
  
          if ( updating ) {
-             char const *id = SP_OBJECT(item)->repr->attribute("id");
+                       //XML Tree being used directly here while it shouldn't be
+             char const *id = SP_OBJECT(item)->getRepr()->attribute("id");
              char const *uri = g_strdup_printf("#%s", id);
              repr->setAttribute("xlink:href", uri);
              g_free((void *) uri);
          if ( updating ) {
              // on conserve l'original
              // we reapply the transform to the original (offset will feel it)
-             sp_item_write_transform(item, SP_OBJECT_REPR(item), transform);
+             item->doWriteTransform(SP_OBJECT_REPR(item), transform);
          } else {
              // delete original, apply the transform to the offset
              SP_OBJECT(item)->deleteObject(false);
-             sp_item_write_transform(nitem, repr, transform);
+             nitem->doWriteTransform(repr, transform);
          }
  
          // The object just created from a temporary repr is only a seed.
          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;
@@@ -1541,7 -1537,7 +1545,7 @@@ sp_selected_path_do_offset(SPDesktop *d
  
          SPCurve *curve = NULL;
          if (SP_IS_SHAPE(item)) {
-             curve = sp_shape_get_curve(SP_SHAPE(item));
+             curve = SP_SHAPE(item)->getCurve();
              if (curve == NULL)
                  continue;
          }
  
          Geom::Matrix const transform(item->transform);
  
-         sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
+         item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity());
  
          gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style"));
  
  
              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);
              SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
  
              // reapply the transform
-             sp_item_write_transform(newitem, repr, transform);
+             newitem->doWriteTransform(repr, transform);
  
              repr->setAttribute("id", id);
  
      }
  
      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;
@@@ -1783,7 -1779,7 +1787,7 @@@ sp_selected_path_simplify_item(SPDeskto
      SPCurve *curve = NULL;
  
      if (SP_IS_SHAPE(item)) {
-         curve = sp_shape_get_curve(SP_SHAPE(item));
+         curve = SP_SHAPE(item)->getCurve();
          if (!curve)
              return false;
      }
      }
  
      // correct virtual size by full transform (bug #166937)
-     size /= sp_item_i2doc_affine(item).descrim();
+     size /= item->i2doc_affine().descrim();
  
      // save the transform, to re-apply it after simplification
      Geom::Matrix const transform(item->transform);
         this is necessary so that the item is transformed twice back and forth,
         allowing all compensations to cancel out regardless of the preferences
      */
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
+     item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity());
  
      gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style"));
      gchar *mask = g_strdup(SP_OBJECT_REPR(item)->attribute("mask"));
          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
      SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
  
      // reapply the transform
-     sp_item_write_transform(newitem, repr, transform);
+     newitem->doWriteTransform(repr, transform);
  
      // restore title & description
      if (title) {
@@@ -1950,7 -1946,7 +1954,7 @@@ sp_selected_path_simplify_items(SPDeskt
            continue;
  
          if (simplifyIndividualPaths) {
-             Geom::OptRect itemBbox = item->getBounds(sp_item_i2d_affine(item));
+             Geom::OptRect itemBbox = item->getBounds(item->i2d_affine());
              if (itemBbox) {
                  simplifySize      = L2(itemBbox->dimensions());
              } else {
@@@ -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."));
  
@@@ -2095,7 -2091,7 +2099,7 @@@ pathvector_for_curve(SPItem *item, SPCu
      
      if (doTransformation) {
          if (transformFull) {
-             *dest *= extraPreAffine * sp_item_i2doc_affine(item) * extraPostAffine;
+             *dest *= extraPreAffine * item->i2doc_affine() * extraPostAffine;
          } else {
              *dest *= extraPreAffine * (Geom::Matrix)item->transform * extraPostAffine;
          }
@@@ -2116,7 -2112,7 +2120,7 @@@ SPCurve* curve_for_item(SPItem *item
          if (SP_IS_PATH(item)) {
              curve = sp_path_get_curve_for_edit(SP_PATH(item));
          } else {
-             curve = sp_shape_get_curve(SP_SHAPE(item));
+             curve = SP_SHAPE(item)->getCurve();
          }
      }
      else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
@@@ -2155,4 -2151,4 +2159,4 @@@ Geom::Point get_point_on_Path(Path *pat
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/spray-context.cpp
index e7172acd4febc29ecf51ce3de7fce7a6af4f3ade,ebdf56673a062fecc0f775c6271c20f3b107e771..0cf74f59b97d5e617f8a841dbab2333bc478d278
@@@ -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;
  
  
@@@ -151,9 -151,9 +153,9 @@@ void sp_spray_rotate_rel(Geom::Point c,
      Geom::Translate const s(c);
      Geom::Matrix affine = Geom::Matrix(s).inverse() * Geom::Matrix(rotation) * Geom::Matrix(s);
      // Rotate item.
-     sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine);
+     item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine);
      // Use each item's own transform writer, consistent with sp_selection_apply_affine()
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+     item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
      // Restore the center position (it's changed because the bbox center changed)
      if (item->isCenterSet()) {
          item->setCenter(c);
  void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale  const &scale)
  {
      Geom::Translate const s(c);
-     sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s  );
-     sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform);
+     item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s  );
+     item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
  }
  
  static void sp_spray_context_init(SPSprayContext *tc)
@@@ -479,14 -479,14 +481,14 @@@ bool sp_spray_recursive(SPDesktop *desk
      dr=dr*radius;
  
      if (mode == SPRAY_MODE_COPY) {
-         Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect a = item->getBounds(item->i2doc_affine());
          if (a) {
              SPItem *item_copied;
              if(_fid<=population)
              {
                  // 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);
              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();
  
-         Geom::OptRect a = father->getBounds(sp_item_i2doc_affine(father));
+         Geom::OptRect a = father->getBounds(father->i2doc_affine());
          if (a) {
              if (i==2) {
                  Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc);
              }
          }
      } else if (mode == SPRAY_MODE_CLONE) {
-         Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect a = item->getBounds(item->i2doc_affine());
          if (a) {
              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;
              }
          }
@@@ -1051,5 -1051,5 +1053,5 @@@ break
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  
diff --combined src/star-context.cpp
index 910c048b6f67e26ab58b4a9377d09ca8f6ff0120,61646ceee7cc79d0fe47eac6496685e2514712ed..0fb20a2ab0a044ac928e5acc24ce919d162c7e6b
@@@ -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);
@@@ -111,7 -111,6 +113,7 @@@ sp_star_context_init (SPStarContext * s
      event_context->tolerance = 0;
      event_context->within_tolerance = false;
      event_context->item_to_select = NULL;
 +    event_context->tool_url = "/tools/shapes/star";
  
      star_context->item = NULL;
  
@@@ -261,7 -260,7 +263,7 @@@ static gint sp_star_context_root_handle
              SnapManager &m = desktop->namedview->snap_manager;
              m.setup(desktop, true);
              m.freeSnapReturnByRef(sc->center, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -
 +            m.unSetup();
              sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                  GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                                  GDK_POINTER_MOTION_MASK |
  
              Geom::Point const motion_w(event->motion.x, event->motion.y);
              Geom::Point motion_dt(desktop->w2d(motion_w));
 +
              m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +            m.unSetup();
          }
          break;
      case GDK_BUTTON_RELEASE:
@@@ -425,17 -422,17 +427,17 @@@ 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));
          Inkscape::GC::release(repr);
-         sc->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+         sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
          sc->item->updateRepr();
  
          sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
      m.setup(desktop, true, sc->item);
      Geom::Point pt2g = to_2geom(p);
      m.freeSnapReturnByRef(pt2g, Inkscape::SNAPSOURCE_NODE_HANDLE);
 -
 +    m.unSetup();
      Geom::Point const p0 = desktop->dt2doc(sc->center);
      Geom::Point const p1 = desktop->dt2doc(pt2g);
  
@@@ -495,15 -492,15 +497,15 @@@ sp_star_finish (SPStarContext * sc
          SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
          SPObject *object = SP_OBJECT(sc->item);
  
-         sp_shape_set_shape(SP_SHAPE(sc->item));
+         (SP_SHAPE(sc->item))->setShape();
  
          object->updateRepr(SP_OBJECT_WRITE_EXT);
  
          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));
  }
  
  /*
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/style-test.h
index 67a4d70141b2d70005ea4a509a8d3f38e9fb8148,0bc47906c6f39cc25032d120078068132a3134d4..064773d1d97a64e81bcd52539c8d9aadbf2a3ac2
@@@ -1,4 -1,4 +1,3 @@@
--
  #ifndef SEEN_STYLE_TEST_H
  #define SEEN_STYLE_TEST_H
  
@@@ -22,7 -22,7 +21,7 @@@ public
      {
          if ( _doc )
          {
-             sp_document_unref( _doc );
+             _doc->doUnref();
              _doc = 0;
          }
      }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/style.cpp
index 551dd658516b594ea794405040c0aa6427b0d73b,13967ec0c0041f5169ba07ce822d680817aff995..d254ab6f484fc8bceff099b5f3cef80722de62c8
@@@ -1,3 -1,5 +1,3 @@@
 -#define __SP_STYLE_C__
 -
  /** @file
   * @brief SVG stylesheets implementation.
   */
@@@ -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.
@@@ -26,6 -28,7 +27,6 @@@
  #include "svg/svg.h"
  #include "svg/svg-color.h"
  #include "svg/svg-icc-color.h"
 -#include "svg/svg-device-color.h"
  
  #include "display/canvas-bpath.h"
  #include "attributes.h"
@@@ -83,6 -86,7 +84,6 @@@ static void sp_style_read_ilength(SPILe
  static void sp_style_read_ilengthornormal(SPILengthOrNormal *val, gchar const *str);
  static void sp_style_read_itextdecoration(SPITextDecoration *val, gchar const *str);
  static void sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document);
 -static void sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document);
  static void sp_style_read_ifontsize(SPIFontSize *val, gchar const *str);
  static void sp_style_read_ibaselineshift(SPIBaselineShift *val, gchar const *str);
  static void sp_style_read_ifilter(gchar const *str, SPStyle *style, SPDocument *document);
@@@ -485,11 -489,11 +486,11 @@@ sp_style_new_from_object(SPObject *obje
      g_return_val_if_fail(object != NULL, NULL);
      g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
  
 -    SPStyle *style = sp_style_new(SP_OBJECT_DOCUMENT(object));
 +    SPStyle *style = sp_style_new( object->document );
      style->object = object;
      style->release_connection = object->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_style_object_release), style));
  
 -    if (object && SP_OBJECT_IS_CLONED(object)) {
 +    if (object && object->cloned) {
          style->cloned = true;
      }
  
@@@ -571,7 -575,7 +572,7 @@@ sp_style_read(SPStyle *style, SPObject 
  
      sp_style_clear(style);
  
 -    if (object && SP_OBJECT_IS_CLONED(object)) {
 +    if (object && object->cloned) {
          style->cloned = true;
      }
  
      if (!style->fill.set) {
          val = repr->attribute("fill");
          if (val) {
 -            sp_style_read_ipaint(&style->fill, val, style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL);
 +            style->fill.read( val, *style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL );
          }
      }
      /* fill-opacity */
      if (!style->stroke.set) {
          val = repr->attribute("stroke");
          if (val) {
 -            sp_style_read_ipaint(&style->stroke, val, style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL);
 +            style->stroke.read( val, *style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL );
          }
      }
      SPS_READ_PLENGTH_IF_UNSET(&style->stroke_width, repr, "stroke-width");
@@@ -1015,7 -1019,9 +1016,9 @@@ sp_style_merge_property(SPStyle *style
               * Fixes Bug #324849
               */
              g_warning("attribute 'clip-path' given as CSS");
-             style->object->repr->setAttribute("clip-path", val);
+                       //XML Tree being directly used here.
+             style->object->getRepr()->setAttribute("clip-path", val);
              break;
          case SP_PROP_CLIP_RULE:
              g_warning("Unimplemented style property SP_PROP_CLIP_RULE: value: %s", val);
               * See comment for SP_PROP_CLIP_PATH
               */
              g_warning("attribute 'mask' given as CSS");
-             style->object->repr->setAttribute("mask", val);
+                       
+                       //XML Tree being directly used here.
+             style->object->getRepr()->setAttribute("mask", val);
              break;
          case SP_PROP_OPACITY:
              if (!style->opacity.set) {
          }
          case SP_PROP_FILL:
              if (!style->fill.set) {
 -                sp_style_read_ipaint(&style->fill, val, style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL);
 +                style->fill.read( val, *style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL );
              }
              break;
          case SP_PROP_FILL_OPACITY:
  
          case SP_PROP_STROKE:
              if (!style->stroke.set) {
 -                sp_style_read_ipaint(&style->stroke, val, style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL);
 +                style->stroke.read( val, *style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL );
              }
              break;
          case SP_PROP_STROKE_WIDTH:
@@@ -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.
@@@ -3197,17 -3207,18 +3204,17 @@@ sp_style_read_icolor(SPIPaint *paint, g
   *
   * \pre paint == \&style.fill || paint == \&style.stroke.
   */
 -static void
 -sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document)
 +void SPIPaint::read( gchar const *str, SPStyle &style, SPDocument *document )
  {
      while (g_ascii_isspace(*str)) {
          ++str;
      }
  
 -    paint->clear();
 +    clear();
  
      if (streq(str, "inherit")) {
 -        paint->set = TRUE;
 -        paint->inherit = TRUE;
 +        set = TRUE;
 +        inherit = TRUE;
      } else {
          if ( strneq(str, "url", 3) ) {
              gchar *uri = extract_uri( str, &str );
                  ++str;
              }
              // TODO check on and comment the comparrison "paint != &style->color".
 -            if ( uri && *uri && (paint != &style->color) ) {
 -                paint->set = TRUE;
 +            if ( uri && *uri && (this != &style.color) ) {
 +                set = TRUE;
  
                  // it may be that this style's SPIPaint has not yet created its URIReference;
                  // now that we have a document, we can create it here
 -                if (!paint->value.href && document) {
 -                    paint->value.href = new SPPaintServerReference(document);
 -                    paint->value.href->changedSignal().connect(sigc::bind(sigc::ptr_fun((paint == &style->fill)? sp_style_fill_paint_server_ref_changed : sp_style_stroke_paint_server_ref_changed), style));
 +                if (!value.href && document) {
 +                    value.href = new SPPaintServerReference(document);
 +                    value.href->changedSignal().connect(sigc::bind(sigc::ptr_fun((this == &style.fill)? sp_style_fill_paint_server_ref_changed : sp_style_stroke_paint_server_ref_changed), &style));
                  }
  
                  // TODO check what this does in light of move away from union
 -                sp_style_set_ipaint_to_uri_string (style, paint, uri);
 +                sp_style_set_ipaint_to_uri_string (&style, this, uri);
              }
              g_free( uri );
          }
  
 -        if (streq(str, "currentColor") && paint != &style->color) {
 -            paint->set = TRUE;
 -            paint->currentcolor = TRUE;
 -        } else if (streq(str, "none") && paint != &style->color) {
 -            paint->set = TRUE;
 -            paint->noneSet = TRUE;
 +        if (streq(str, "currentColor") && (this != &style.color)) {
 +            set = TRUE;
 +            currentcolor = TRUE;
 +        } else if (streq(str, "none") && (this != &style.color)) {
 +            set = TRUE;
 +            noneSet = TRUE;
          } else {
              guint32 const rgb0 = sp_svg_read_color(str, &str, 0xff);
              if (rgb0 != 0xff) {
 -                paint->setColor( rgb0 );
 -                paint->set = TRUE;
 +                setColor( rgb0 );
 +                set = TRUE;
  
                  while (g_ascii_isspace(*str)) {
                      ++str;
                          delete tmp;
                          tmp = 0;
                      }
 -                    paint->value.color.icc = tmp;
 -                }
 -                if (strneq(str, "device-gray(", 12) ||
 -                    strneq(str, "device-rgb(", 11) ||
 -                    strneq(str, "device-cmyk(", 12) ||
 -                    strneq(str, "device-nchannel(", 16)) {
 -                    SVGDeviceColor* tmp = new SVGDeviceColor();
 -                    if ( ! sp_svg_read_device_color( str, &str, tmp ) ) {
 -                        delete tmp;
 -                        tmp = 0;
 -                    }
 -                    paint->value.color.device = tmp;
 +                    value.color.icc = tmp;
                  }
              }
          }
@@@ -4021,17 -4043,6 +4028,17 @@@ sp_style_write_ifilter(gchar *p, gint c
      return 0;
  }
  
 +SPIPaint::SPIPaint() :
 +    set(0),
 +    inherit(0),
 +    currentcolor(0),
 +    colorSet(0),
 +    noneSet(0),
 +    value()
 +{
 +    value.color.set( 0 );
 +    value.href = 0;
 +}
  
  void SPIPaint::clear()
  {
@@@ -4436,4 -4447,4 +4443,4 @@@ css2_escape_quote(gchar const *val) 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/svg-view-widget.cpp
index 10d9976566f04a3fed2b3b6f720a35e7e8504939,a60c93f0bd70cb5ec201a6a81840c6e721c1d8c4..d2a31966afab6916bffb915ed373459e80094b6e
@@@ -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.
@@@ -149,8 -149,8 +148,8 @@@ sp_svg_view_widget_size_request (GtkWid
                gdouble width, height;
  
                svgv = static_cast<SPSVGView*> (v);
-               width = sp_document_width (v->doc()) * svgv->_hscale;
-               height = sp_document_height (v->doc()) * svgv->_vscale;
+               width = (v->doc())->getWidth () * svgv->_hscale;
+               height = (v->doc())->getHeight () * svgv->_vscale;
  
                if (width <= vw->maxwidth) {
                        hpol = GTK_POLICY_NEVER;
diff --combined src/svg-view.cpp
index bd46dd17a6c86645eec790878106b47d4ce9ca28,6d989a8f5188e6ba0f3f64a651ceecf231bcb1e6..ef87b38efecbf8dd5fac4887b7252091d6c81661
@@@ -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;
      }
  }
@@@ -84,12 -84,12 +84,12 @@@ voi
  SPSVGView::doRescale (bool event)
  {
      if (!doc()) return;
-     if (sp_document_width (doc()) < 1e-9) return;
-     if (sp_document_height (doc()) < 1e-9) return;
+     if (doc()->getWidth () < 1e-9) return;
+     if (doc()->getHeight () < 1e-9) return;
  
      if (_rescale) {
-         _hscale = _width / sp_document_width (doc());
-         _vscale = _height / sp_document_height (doc());
+         _hscale = _width / doc()->getWidth ();
+         _vscale = _height / doc()->getHeight ();
          if (_keepaspect) {
              if (_hscale > _vscale) {
                  _hscale = _vscale;
      }
  
      if (event) {
-         emitResized (sp_document_width (doc()) * _hscale,
-                 sp_document_height (doc()) * _vscale);
+         emitResized (doc()->getWidth () * _hscale,
+                 doc()->getHeight () * _vscale);
      }
  }
  
@@@ -152,7 -152,7 +152,7 @@@ arena_handler (SPCanvasArena */*arena*/
                                spev.type = SP_EVENT_ACTIVATE;
                                  if ( spitem != 0 )
                                {
-                                 sp_item_event (spitem, &spev);
+                                 spitem->emitEvent (spev);
                                  }
                                }
                }
                spev.data = svgview;
                  if ( spitem != 0 )
                {
-                 sp_item_event (spitem, &spev);
+                 spitem->emitEvent (spev);
                  }
                break;
        case GDK_LEAVE_NOTIFY:
                spev.data = svgview;
                  if ( spitem != 0 )
                {
-                 sp_item_event (spitem, &spev);
+                 spitem->emitEvent (spev);
                  }
                break;
        default:
@@@ -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) {
      }
  
      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 --combined src/test-helpers.h
index 19dacd9c8cf56b9fa6e3652b84a1564677f20e46,280935900e0f19d6c3b61f7aea26050a537f0bfa..e1b8521621b6fc9c14bf55de0e0c47d653a80c2c
@@@ -1,4 -1,4 +1,3 @@@
--
  #ifndef SEEN_TEST_HELPERS_H
  #define SEEN_TEST_HELPERS_H
  
@@@ -32,7 -32,7 +31,7 @@@ T* createSuiteAndDocument( void (*fun)(
          static_cast<void>(g_object_new(inkscape_get_type(), NULL));
      }
  
-     SPDocument* tmp = sp_document_new( NULL, TRUE, true );
+     SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true );
      if ( tmp ) {
          fun( suite );
          if ( suite )
@@@ -41,7 -41,7 +40,7 @@@
          }
          else
          {
-             sp_document_unref( tmp );
+             tmp->doUnref();
          }
      }
  
@@@ -61,4 -61,4 +60,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/text-chemistry.cpp
index cc02c656e350b397dad443592c222ca25c606945,9d4c23b258d66ea5f1c468acae1c14f7f3f7d24d..f2ea4367b9acd5ee27de6f2893d27e34d4dd3b56
@@@ -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."));
          parent->appendChild(repr);
  
          SPItem *new_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
-         sp_item_write_transform(new_item, repr, text->transform);
+         new_item->doWriteTransform(repr, text->transform);
          SP_OBJECT(new_item)->updateRepr();
  
          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();
  
      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;
  
      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);
  
  
      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);
  
          rtext->setAttribute("style", SP_OBJECT_REPR(flowtext)->attribute("style")); // fixme: transfer style attrs too; and from descendants
  
          NRRect bbox;
-         sp_item_invoke_bbox(SP_ITEM(flowtext), &bbox, sp_item_i2doc_affine(SP_ITEM(flowtext)), TRUE);
+         SP_ITEM(flowtext)->invoke_bbox( &bbox, SP_ITEM(flowtext)->i2doc_affine(), TRUE);
          Geom::Point xy(bbox.x0, bbox.y0);
          if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) {
              sp_repr_set_svg_double(rtext, "x", xy[Geom::X]);
      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
@@@ -518,7 -518,7 +519,7 @@@ flowtext_to_text(
          parent->addChild(repr, SP_OBJECT_REPR(item));
  
          SPItem *new_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr);
-         sp_item_write_transform(new_item, repr, item->transform);
+         new_item->doWriteTransform(repr, item->transform);
          SP_OBJECT(new_item)->updateRepr();
      
          Inkscape::GC::release(repr);
      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)->
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/text-context.cpp
index 9d94e0e78ac11e500cb95d66ba9f7b353a22d313,cfde60a0da1910fdce64f1bfcdf59a036facc3fe..66e5f9450a97f9335e54be7918a35805c0819874
@@@ -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) {
                  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);
                  } else {
                      SP_CTRLRECT(tc->indicator)->setColor(0x0000ff7f, false, 0);
                  }
-                 Geom::OptRect ibbox = sp_item_bbox_desktop(item_ungrouped);
+                 Geom::OptRect ibbox = item_ungrouped->getBboxDesktop();
                  if (ibbox) {
                      SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox);
                  }
@@@ -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
  
      /* 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"));
      }
  }
  
@@@ -610,14 -610,7 +611,14 @@@ sp_text_context_root_handler(SPEventCon
                  event_context->within_tolerance = true;
  
                  Geom::Point const button_pt(event->button.x, event->button.y);
 -                tc->p0 = desktop->w2d(button_pt);
 +                Geom::Point button_dt(desktop->w2d(button_pt));
 +
 +                SnapManager &m = desktop->namedview->snap_manager;
 +                m.setup(desktop);
 +                m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +                m.unSetup();
 +
 +                tc->p0 = button_dt;
                  Inkscape::Rubberband::get(desktop)->start(desktop, tc->p0);
                  sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                      GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
                  event_context->within_tolerance = false;
  
                  Geom::Point const motion_pt(event->motion.x, event->motion.y);
 -                Geom::Point const p = desktop->w2d(motion_pt);
 +                Geom::Point p = desktop->w2d(motion_pt);
 +
 +                SnapManager &m = desktop->namedview->snap_manager;
 +                m.setup(desktop);
 +                m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +                m.unSetup();
  
                  Inkscape::Rubberband::get(desktop)->move(p);
                  gobble_motion_events(GDK_BUTTON1_MASK);
                  g_string_free(xs, FALSE);
                  g_string_free(ys, FALSE);
  
 +            } else if (!sp_event_context_knot_mouseover(event_context)) {
 +                SnapManager &m = desktop->namedview->snap_manager;
 +                m.setup(desktop);
 +
 +                Geom::Point const motion_w(event->motion.x, event->motion.y);
 +                Geom::Point motion_dt(desktop->w2d(motion_w));
 +                m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
 +                m.unSetup();
              }
              break;
          case GDK_BUTTON_RELEASE:
              if (event->button.button == 1 && !event_context->space_panning) {
 +                sp_event_context_discard_delayed_snap_event(event_context);
 +
 +                Geom::Point p1 = desktop->w2d(Geom::Point(event->button.x, event->button.y));
 +
 +                SnapManager &m = desktop->namedview->snap_manager;
 +                m.setup(desktop);
 +                m.freeSnapReturnByRef(p1, Inkscape::SNAPSOURCE_NODE_HANDLE);
 +                m.unSetup();
  
                  if (tc->grabbed) {
                      sp_canvas_item_ungrab(tc->grabbed, GDK_CURRENT_TIME);
                  if (tc->creating && event_context->within_tolerance) {
                      /* Button 1, set X & Y & new item */
                      sp_desktop_selection(desktop)->clear();
 -                    Geom::Point dtp = desktop->w2d(Geom::Point(event->button.x, event->button.y));
 -                    tc->pdoc = desktop->dt2doc(dtp);
 -
 +                    tc->pdoc = desktop->dt2doc(p1);
                      tc->show = TRUE;
                      tc->phase = 1;
                      tc->nascent_object = 1; // new object was just created
                      /* Cursor */
                      sp_canvas_item_show(tc->cursor);
                      // Cursor height is defined by the new text object's font size; it needs to be set
 -                    // articifically here, for the text object does not exist yet:
 +                    // artificially here, for the text object does not exist yet:
                      double cursor_height = sp_desktop_get_font_size_tool(desktop);
 -                    sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), dtp, dtp + Geom::Point(0, cursor_height));
 +                    sp_ctrlline_set_coords(SP_CTRLLINE(tc->cursor), p1, p1 + Geom::Point(0, cursor_height));
                      event_context->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Type text; <b>Enter</b> to start new line.")); // FIXME:: this is a copy of a string from _update_cursor below, do not desync
  
                      event_context->within_tolerance = false;
                  } else if (tc->creating) {
 -                    Geom::Point const button_pt(event->button.x, event->button.y);
 -                    Geom::Point p1 = desktop->w2d(button_pt);
                      double cursor_height = sp_desktop_get_font_size_tool(desktop);
                      if (fabs(p1[Geom::Y] - tc->p0[Geom::Y]) > cursor_height) {
                          // otherwise even one line won't fit; most probably a slip of hand (even if bigger than tolerance)
                          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."));
                      }
                                      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;
                                          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;
                                          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;
  
                                  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:
  
                                      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:
  
                                      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:
                                              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();
                                              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();
                                              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();
                                              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();
                                          } 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;
                                          } 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;
                                                  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);
                                                  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);
  
@@@ -1594,8 -1570,8 +1589,8 @@@ sp_text_context_update_cursor(SPTextCon
      if (tc->text) {
          Geom::Point p0, p1;
          sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1);
-         Geom::Point const d0 = p0 * sp_item_i2d_affine(SP_ITEM(tc->text));
-         Geom::Point const d1 = p1 * sp_item_i2d_affine(SP_ITEM(tc->text));
+         Geom::Point const d0 = p0 * SP_ITEM(tc->text)->i2d_affine();
+         Geom::Point const d1 = p1 * SP_ITEM(tc->text)->i2d_affine();
  
          // scroll to show cursor
          if (scroll_to_see) {
                      SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0);
                  }
                  sp_canvas_item_show(tc->frame);
-                 Geom::OptRect frame_bbox = sp_item_bbox_desktop(frame);
+                 Geom::OptRect frame_bbox = frame->getBboxDesktop();
                  if (frame_bbox) {
                      SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox);
                  }
@@@ -1676,7 -1652,7 +1671,7 @@@ static void sp_text_context_update_text
  
      std::vector<Geom::Point> quads;
      if (tc->text != NULL)
-         quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, sp_item_i2d_affine(tc->text));
+         quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, (tc->text)->i2d_affine());
      for (unsigned i = 0 ; i < quads.size() ; i += 4) {
          SPCanvasItem *quad_canvasitem;
          quad_canvasitem = sp_canvas_item_new(sp_desktop_controls(tc->desktop), SP_TYPE_CTRLQUADR, NULL);
@@@ -1728,7 -1704,7 +1723,7 @@@ sp_text_context_forget_text(SPTextConte
          // the XML editor
          if ( text_repr && sp_repr_parent(text_repr) ) {
              sp_repr_unparent(text_repr);
-             sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT,
+             SPDocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT,
                       _("Remove empty text"));
          }
      }
@@@ -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
@@@ -1798,4 -1774,4 +1793,4 @@@ Inkscape::Text::Layout::iterator *sp_te
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/text-editing.cpp
index 5bad33d290b28510900ec2dc98cd4b5ef779c2d6,a307e5e279eeee6b1add8fb2b59c2ed001b1c8a0..2e6e2f9fa9b454fe5ae9579dec40a4531af86773
@@@ -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,31 -57,30 +59,35 @@@ 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
  sp_te_get_position_by_coords (SPItem const *item, Geom::Point const &i_p)
  {
-     Geom::Matrix im (sp_item_i2d_affine (item));
+     Geom::Matrix im (item->i2d_affine ());
      im = im.inverse();
  
      Geom::Point p = i_p * im;
@@@ -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;
      }
      
      // 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);
      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)) {
                  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;
  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);
      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;
      }
  
@@@ -957,7 -956,7 +979,7 @@@ sp_te_adjust_kerning_screen (SPItem *it
      // divide increment by zoom
      // divide increment by matrix expansion
      gdouble factor = 1 / desktop->current_zoom();
-     Geom::Matrix t (sp_item_i2doc_affine(item));
+     Geom::Matrix t (item->i2doc_affine());
      factor = factor / t.descrim();
      by = factor * by;
  
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
 -void
 -sp_te_adjust_dx (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, double delta)
 +void sp_te_adjust_dx(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop * /*desktop*/, double delta)
  {
 -    unsigned char_index;
 +    unsigned char_index = 0;
      TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index);
 -    if (attributes) attributes->addToDx(char_index, delta);
 +    if (attributes) {
 +        attributes->addToDx(char_index, delta);
 +    }
      if (start != end) {
          attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index);
 -        if (attributes) attributes->addToDx(char_index, -delta);
 +        if (attributes) {
 +            attributes->addToDx(char_index, -delta);
 +        }
      }
  
      item->updateRepr();
      item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
 -void
 -sp_te_adjust_dy (SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop *desktop, double delta)
 +void sp_te_adjust_dy(SPItem *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop * /*desktop*/, double delta)
  {
 -    unsigned char_index;
 +    unsigned char_index = 0;
      TextTagAttributes *attributes = text_tag_attributes_at_position(item, std::min(start, end), &char_index);
 -    if (attributes) attributes->addToDy(char_index, delta);
 +    if (attributes) {
 +        attributes->addToDy(char_index, delta);
 +    }
      if (start != end) {
          attributes = text_tag_attributes_at_position(item, std::max(start, end), &char_index);
 -        if (attributes) attributes->addToDy(char_index, -delta);
 +        if (attributes) {
 +            attributes->addToDy(char_index, -delta);
 +        }
      }
  
      item->updateRepr();
@@@ -1015,7 -1008,7 +1037,7 @@@ sp_te_adjust_rotation_screen(SPItem *te
      // divide increment by zoom
      // divide increment by matrix expansion
      gdouble factor = 1 / desktop->current_zoom();
-     Geom::Matrix t (sp_item_i2doc_affine(text));
+     Geom::Matrix t (text->i2doc_affine());
      factor = factor / t.descrim();
      Inkscape::Text::Layout const *layout = te_get_layout(text);
      if (layout == NULL) return;
@@@ -1048,25 -1041,23 +1070,25 @@@ sp_te_adjust_rotation(SPItem *text, Ink
      text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
  }
  
 -void
 -sp_te_set_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop */*desktop*/, gdouble degrees)
 +void sp_te_set_rotation(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPDesktop */*desktop*/, gdouble degrees)
  {
 -    unsigned char_index;
 +    unsigned char_index = 0;
      TextTagAttributes *attributes = text_tag_attributes_at_position(text, std::min(start, end), &char_index);
 -    if (attributes == NULL) return;
 -
 -    if (start != end) {
 -        for (Inkscape::Text::Layout::iterator it = std::min(start, end) ; it != std::max(start, end) ; it.nextCharacter()) {
 -            attributes = text_tag_attributes_at_position(text, it, &char_index);
 -            if (attributes) attributes->setRotate(char_index, degrees);
 +    if (attributes != NULL) {
 +        if (start != end) {
 +            for (Inkscape::Text::Layout::iterator it = std::min(start, end) ; it != std::max(start, end) ; it.nextCharacter()) {
 +                attributes = text_tag_attributes_at_position(text, it, &char_index);
 +                if (attributes) {
 +                    attributes->setRotate(char_index, degrees);
 +                }
 +            }
 +        } else {
 +            attributes->setRotate(char_index, degrees);
          }
 -    } else
 -        attributes->setRotate(char_index, degrees);
  
 -    text->updateRepr();
 -    text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 +        text->updateRepr();
 +        text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 +    }
  }
  
  void
@@@ -1121,7 -1112,7 +1143,7 @@@ sp_te_adjust_tspan_letterspacing_screen
      gdouble const zoom = desktop->current_zoom();
      gdouble const zby = (by
                           / (zoom * (nb_let > 1 ? nb_let - 1 : 1))
-                          / to_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj))).descrim());
+                          / to_2geom(SP_ITEM(source_obj)->i2doc_affine()).descrim());
      val += zby;
  
      if (start == end) {
@@@ -1193,7 -1184,7 +1215,7 @@@ sp_te_adjust_linespacing_screen (SPIte
      gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count));
  
      // divide increment by matrix expansion
-     Geom::Matrix t (sp_item_i2doc_affine (SP_ITEM(text)));
+     Geom::Matrix t (SP_ITEM(text)->i2doc_affine ());
      zby = zby / t.descrim();
  
      switch (style->line_height.unit) {
@@@ -1292,17 -1283,16 +1314,17 @@@ static bool objects_have_equal_style(SP
      parent_style = sp_style_write_string(parent_spstyle, SP_STYLE_FLAG_ALWAYS);
      sp_style_unref(parent_spstyle);
  
 -    Glib::ustring child_style_construction(parent_style);
 +    Glib::ustring child_style_construction;
      while (child != parent) {
          // FIXME: this assumes that child's style is only in style= whereas it can also be in css attributes!
          char const *style_text = SP_OBJECT_REPR(child)->attribute("style");
          if (style_text && *style_text) {
 -            child_style_construction += ';';
 -            child_style_construction += style_text;
 +            child_style_construction.insert(0, style_text);
 +            child_style_construction.insert(0, 1, ';');
          }
          child = SP_OBJECT_PARENT(child);
      }
 +    child_style_construction.insert(0, parent_style);
      SPStyle *child_spstyle = sp_style_new(SP_OBJECT_DOCUMENT(parent));
      sp_style_merge_from_style_string(child_spstyle, child_style_construction.c_str());
      gchar *child_style = sp_style_write_string(child_spstyle, SP_STYLE_FLAG_ALWAYS);
@@@ -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)) {
  
                  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) {
                          child_span->appendChild(text_in_span);
                          Inkscape::GC::release(text_in_span);
                          child->deleteObject();
-                         child = sp_object_get_child_by_repr(common_ancestor, child_span);
+                         child = common_ancestor->get_child_by_repr(child_span);
  
                      } else
                          surround_entire_string = true;
                      SP_OBJECT_REPR(common_ancestor)->removeChild(child_repr);
                      child_span->appendChild(child_repr);
                      Inkscape::GC::release(child_repr);
-                     child = sp_object_get_child_by_repr(common_ancestor, child_span);
+                     child = common_ancestor->get_child_by_repr(child_span);
                  }
                  Inkscape::GC::release(child_span);
  
@@@ -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
  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);
          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;
  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);
@@@ -1656,15 -1647,15 +1686,15 @@@ static bool redundant_semi_nesting_proc
  
      SPCSSAttr *css_child_and_item = sp_repr_css_attr_new();
      SPCSSAttr *css_child_only = sp_repr_css_attr_new();
 +    gchar const *item_style = SP_OBJECT_REPR(*item)->attribute("style");
 +    if (item_style && *item_style) {
 +        sp_repr_css_attr_add_from_string(css_child_and_item, item_style);
 +    }
      gchar const *child_style = SP_OBJECT_REPR(child)->attribute("style");
      if (child_style && *child_style) {
          sp_repr_css_attr_add_from_string(css_child_and_item, child_style);
          sp_repr_css_attr_add_from_string(css_child_only, child_style);
      }
 -    gchar const *item_style = SP_OBJECT_REPR(*item)->attribute("style");
 -    if (item_style && *item_style) {
 -        sp_repr_css_attr_add_from_string(css_child_and_item, item_style);
 -    }
      bool equal = css_attrs_are_equal(css_child_only, css_child_and_item);
      sp_repr_css_attr_unref(css_child_and_item);
      sp_repr_css_attr_unref(css_child_only);
      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;
              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;
      }
      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++) {
                  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
      SPCSSAttr *css_set = sp_repr_css_attr_new();
      sp_repr_css_merge(css_set, (SPCSSAttr*) css);
      {
-         Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(common_ancestor)));
+         Geom::Matrix const local(SP_ITEM(common_ancestor)->i2doc_affine());
          double const ex(local.descrim());
          if ( ( ex != 0. )
               && ( ex != 1. ) ) {
@@@ -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;
  }
  
  /*
    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 --combined src/text-editing.h
index 038458ff7af4eecaf12dda0ecb68b3b3f24cd78d,038458ff7af4eecaf12dda0ecb68b3b3f24cd78d..3d5efbbecb0e508edfc48a2c54e64fc8cdf9741f
@@@ -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 --combined src/trace/trace.cpp
index e2bd0e9f583581cc9dba0a9fc01c36f06644789a,cff464e9f1fba1c57e71fd953c17eced7f9a59f5..48d25d0c45c9add015b360b28398094c486c5669
@@@ -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
   *
@@@ -246,7 -246,7 +248,7 @@@ Tracer::sioxProcessImage(SPImage *img
          return Glib::RefPtr<Gdk::Pixbuf>(NULL);
          }
  
-     NRArenaItem *aImg = sp_item_get_arenaitem(img, desktop->dkey);
+     NRArenaItem *aImg = img->get_arenaitem(desktop->dkey);
      //g_message("img: %d %d %d %d\n", aImg->bbox.x0, aImg->bbox.y0,
      //                                aImg->bbox.x1, aImg->bbox.y1);
  
      for (iter = sioxShapes.begin() ; iter!=sioxShapes.end() ; iter++)
          {
          SPItem *item = *iter;
-         NRArenaItem *aItem = sp_item_get_arenaitem(item, desktop->dkey);
+         NRArenaItem *aItem = item->get_arenaitem(desktop->dkey);
          arenaItems.push_back(aItem);
          }
  
@@@ -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();
          }
  
      //### 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()
  
      //#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
          if (reprobj)
              {
              SPItem *newItem = SP_ITEM(reprobj);
-             sp_item_write_transform(newItem, pathRepr, tf, NULL);
+             newItem->doWriteTransform(pathRepr, tf, NULL);
              }
          if (nrPaths == 1)
              {
          }
  
      //## 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 --combined src/tweak-context.cpp
index 29289e053adbb5ce3eabc63719f61e98e6a47ee1,775e7aec35c76ddc5b7ec4fd52c7855cf30af1eb..1d0c004a4a40fc448a9cc87da6f729ab8734701c
@@@ -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);
              }
      } else {
          if (mode == TWEAK_MODE_MOVE) {
  
-             Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect a = item->getBounds(item->i2doc_affine());
              if (a) {
                  double x = Geom::L2(a->midpoint() - p)/radius;
                  if (a->contains(p)) x = 0;
  
          } else if (mode == TWEAK_MODE_MOVE_IN_OUT) {
  
-             Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect a = item->getBounds(item->i2doc_affine());
              if (a) {
                  double x = Geom::L2(a->midpoint() - p)/radius;
                  if (a->contains(p)) x = 0;
  
          } else if (mode == TWEAK_MODE_MOVE_JITTER) {
  
-             Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect a = item->getBounds(item->i2doc_affine());
              if (a) {
                  double dp = g_random_double_range(0, M_PI*2);
                  double dr = g_random_double_range(0, radius);
  
          } else if (mode == TWEAK_MODE_SCALE) {
  
-             Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect a = item->getBounds(item->i2doc_affine());
              if (a) {
                  double x = Geom::L2(a->midpoint() - p)/radius;
                  if (a->contains(p)) x = 0;
  
          } else if (mode == TWEAK_MODE_ROTATE) {
  
-             Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect a = item->getBounds(item->i2doc_affine());
              if (a) {
                  double x = Geom::L2(a->midpoint() - p)/radius;
                  if (a->contains(p)) x = 0;
  
          } else if (mode == TWEAK_MODE_MORELESS) {
  
-             Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect a = item->getBounds(item->i2doc_affine());
              if (a) {
                  double x = Geom::L2(a->midpoint() - p)/radius;
                  if (a->contains(p)) x = 0;
                              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();
  
  
          // skip those paths whose bboxes are entirely out of reach with our radius
-         Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect bbox = item->getBounds(item->i2doc_affine());
          if (bbox) {
              bbox->expandBy(radius);
              if (!bbox->contains(p)) {
  
          Shape *theShape = new Shape;
          Shape *theRes = new Shape;
-         Geom::Matrix i2doc(sp_item_i2doc_affine(item));
+         Geom::Matrix i2doc(item->i2doc_affine());
  
          orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059
          orig->Fill(theShape, 0);
@@@ -801,7 -801,7 +803,7 @@@ tweak_colors_in_gradient (SPItem *item
      if (!gradient || !SP_IS_GRADIENT(gradient))
          return;
  
-     Geom::Matrix i2d (sp_item_i2doc_affine (item));
+     Geom::Matrix i2d (item->i2doc_affine ());
      Geom::Point p = p_w * i2d.inverse();
      p *= (gradient->gradientTransform).inverse();
      // now p is in gradient's original coordinates
      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,
          if (!style) {
              return false;
          }
-         Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item),
+         Geom::OptRect bbox = item->getBounds(item->i2doc_affine(),
                                                          SPItem::GEOMETRIC_BBOX);
          if (!bbox) {
              return false;
          if (this_force > 0.002) {
  
              if (do_blur) {
-                 Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item),
+                 Geom::OptRect bbox = item->getBounds(item->i2doc_affine(),
                                                          SPItem::GEOMETRIC_BBOX);
                  if (!bbox) {
                      return did;
                  }
  
                  double blur_now = 0;
-                 Geom::Matrix i2d = sp_item_i2d_affine (item);
+                 Geom::Matrix i2d = item->i2d_affine ();
                  if (style->filter.set && style->getFilter()) {
                      //cycle through filter primitives
                      SPObject *primitive_obj = style->getFilter()->children;
@@@ -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;
              }
          }
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/clipboard.cpp
index 90a9ba0f548e3a80f9a96b421a199a6017e4a790,e050d69b4b81bc311080c46dfca05d70899aab8a..d405afb8f6ec9b33ce237247f37e1c82e9fa7924
@@@ -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
@@@ -335,7 -335,7 +336,7 @@@ bool ClipboardManagerImpl::paste(SPDesk
      }
  
      _pasteDocument(desktop, tempdoc, in_place);
-     sp_document_unref(tempdoc);
+     tempdoc->doUnref();
  
      return true;
  }
@@@ -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;
  
          _userWarn(desktop, _("No style on the clipboard."));
      }
  
-     sp_document_unref(tempdoc);
+     tempdoc->doUnref();
      return pasted;
  }
  
@@@ -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) {
          if (separately) {
              for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) {
                  SPItem *item = SP_ITEM(i->data);
-                 Geom::OptRect obj_size = sp_item_bbox_desktop(item);
+                 Geom::OptRect obj_size = item->getBboxDesktop();
                  if ( !obj_size ) {
                      continue;
                  }
          }
          pasted = true;
      }
-     sp_document_unref(tempdoc);
+     tempdoc->doUnref();
      return pasted;
  }
  
@@@ -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 ) {
  
      if ( repr == NULL ) {
          _userWarn(desktop, _("Clipboard does not contain a path."));
-         sp_document_unref(tempdoc);
+         tempdoc->doUnref();
          return "";
      }
      gchar const *svgd = repr->attribute("id");
@@@ -615,7 -615,7 +613,7 @@@ void ClipboardManagerImpl::_copySelecti
          // write the complete accumulated transform passed to us
          // (we're dealing with unattached representations, so we write to their attributes
          // instead of using sp_item_set_transform)
-         gchar *transform_str = sp_svg_transform_write(sp_item_i2doc_affine(SP_ITEM(i->data)));
+         gchar *transform_str = sp_svg_transform_write(SP_ITEM(i->data)->i2doc_affine());
          obj_copy->setAttribute("transform", transform_str);
          g_free(transform_str);
      }
  void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
  {
      // copy fill and stroke styles (patterns and gradients)
 -    SPStyle *style = SP_OBJECT_STYLE(item);
 +    SPStyle *style = item->style;
  
      if (style && (style->fill.isPaintserver())) {
 -        SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
 -        if (SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server)) {
 +        SPPaintServer *server = item->style->getFillPaintServer();
 +        if ( SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server) ) {
              _copyGradient(SP_GRADIENT(server));
          }
 -        if (SP_IS_PATTERN(server)) {
 +        if ( SP_IS_PATTERN(server) ) {
              _copyPattern(SP_PATTERN(server));
          }
      }
      if (style && (style->stroke.isPaintserver())) {
 -        SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
 -        if (SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server)) {
 +        SPPaintServer *server = item->style->getStrokePaintServer();
 +        if ( SP_IS_LINEARGRADIENT(server) || SP_IS_RADIALGRADIENT(server) ) {
              _copyGradient(SP_GRADIENT(server));
          }
 -        if (SP_IS_PATTERN(server)) {
 +        if ( SP_IS_PATTERN(server) ) {
              _copyPattern(SP_PATTERN(server));
          }
      }
      }
      // 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);
      selection->setReprList(pasted_objects);
  
      // invers apply parent transform
-     Geom::Matrix doc2parent = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
+     Geom::Matrix doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
      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();
              // get offset from mouse pointer to bbox center, snap to grid if enabled
              Geom::Point mouse_offset = desktop->point() - sel_bbox->midpoint();
              offset = m.multipleOfGridPitch(mouse_offset - offset, sel_bbox->midpoint() + offset) + offset;
 +            m.unSetup();
          }
  
          sp_selection_move_relative(selection, offset);
@@@ -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);
  
@@@ -1201,7 -1200,7 +1197,7 @@@ void ClipboardManagerImpl::_onGet(Gtk::
              guint32 bgcolor = 0x00000000;
  
              Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed);
-             Geom::Rect area = Geom::Rect(origin, origin + sp_document_dimensions(_clipboardSPDoc));
+             Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions());
  
              unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5);
              unsigned long int height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5);
@@@ -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);
  void ClipboardManagerImpl::_discardInternalClipboard()
  {
      if ( _clipboardSPDoc != NULL ) {
-         sp_document_unref(_clipboardSPDoc);
+         _clipboardSPDoc->doUnref();
          _clipboardSPDoc = NULL;
          _defs = NULL;
          _doc = NULL;
@@@ -1534,4 -1533,4 +1530,4 @@@ ClipboardManager *ClipboardManager::get
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/context-menu.cpp
index 262fdcf32de710975a884b55186c7c1ab02a7dc8,1ffbf1fd09f095dc3e33a4a62e482f776c8cc895..c544d1999491ad4b599803618baca6d241e9d11a
@@@ -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 */
@@@ -46,7 -46,6 +48,7 @@@ sp_object_menu(SPObject *object, SPDesk
  
  #include "sp-anchor.h"
  #include "sp-image.h"
 +#include "sp-text.h"
  
  #include "document.h"
  #include "desktop-handles.h"
@@@ -54,8 -53,6 +56,8 @@@
  #include "selection-chemistry.h"
  #include "dialogs/item-properties.h"
  #include "dialogs/object-attributes.h"
 +#include "dialogs/text-edit.h"
 +#include "dialogs/spellcheck.h"
  
  #include "sp-path.h"
  #include "sp-clippath.h"
@@@ -67,7 -64,6 +69,7 @@@ static void sp_group_menu(SPObject *obj
  static void sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu);
  static void sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu);
  static void sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu);
 +static void sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu);
  
  static void
  sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu)
@@@ -81,7 -77,6 +83,7 @@@
          g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_ANCHOR), (void*)sp_anchor_menu);
          g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_IMAGE), (void*)sp_image_menu);
          g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_SHAPE), (void*)sp_shape_menu);
 +        g_hash_table_insert(t2m, GUINT_TO_POINTER(SP_TYPE_TEXT), (void*)sp_text_menu);
      }
      handler = (void (*)(SPObject*, SPDesktop*, GtkMenu*))g_hash_table_lookup(t2m, GUINT_TO_POINTER(type));
      if (handler) handler(object, desktop, menu);
@@@ -107,7 -102,7 +109,7 @@@ sp_item_menu(SPObject *object, SPDeskto
      item = (SPItem *) object;
  
      /* Item dialog */
 -    w = gtk_menu_item_new_with_mnemonic(_("Object _Properties"));
 +    w = gtk_menu_item_new_with_mnemonic(_("_Object Properties..."));
      gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
      gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_properties), item);
      gtk_widget_show(w);
      gtk_widget_show(w);
      gtk_menu_append(GTK_MENU(m), w);
      /* Set Clip */
 -    w = gtk_menu_item_new_with_mnemonic(_("Set Clip"));
 +    w = gtk_menu_item_new_with_mnemonic(_("Set _Clip"));
      gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
      gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_clip), item);
      if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) {
      gtk_widget_show(w);
      gtk_menu_append(GTK_MENU(m), w);
      /* Release Clip */
 -    w = gtk_menu_item_new_with_mnemonic(_("Release Clip"));
 +    w = gtk_menu_item_new_with_mnemonic(_("Release C_lip"));
      gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
      gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_clip), item);
      if (item && item->clip_ref && item->clip_ref->getObject()) {
@@@ -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);
      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");
  
@@@ -348,7 -343,7 +350,7 @@@ sp_anchor_menu(SPObject *object, SPDesk
      item = (SPItem *) object;
  
      /* Link dialog */
 -    w = gtk_menu_item_new_with_mnemonic(_("Link _Properties"));
 +    w = gtk_menu_item_new_with_mnemonic(_("Link _Properties..."));
      gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
      gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_properties), item);
      gtk_widget_show(w);
@@@ -407,7 -402,7 +409,7 @@@ sp_image_menu(SPObject *object, SPDeskt
      GtkWidget *w;
  
      /* Link dialog */
 -    w = gtk_menu_item_new_with_mnemonic(_("Image _Properties"));
 +    w = gtk_menu_item_new_with_mnemonic(_("Image _Properties..."));
      gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
      gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_properties), item);
      gtk_widget_show(w);
@@@ -478,10 -473,10 +480,10 @@@ static void sp_image_image_edit(GtkMenu
      g_free(editorBin);
  }
  
 -/* SPShape */
 +/* Fill and Stroke entry */
  
  static void
 -sp_shape_fill_settings(GtkMenuItem *menuitem, SPItem *item)
 +sp_fill_settings(GtkMenuItem *menuitem, SPItem *item)
  {
      SPDesktop *desktop;
  
      desktop->_dlg_mgr->showDialog("FillAndStroke");
  }
  
 +/* SPShape */
 +
  static void
  sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
  {
      item = (SPItem *) object;
  
      /* Item dialog */
 -    w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke"));
 +    w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke..."));
      gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
 -    gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_shape_fill_settings), item);
 +    gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item);
      gtk_widget_show(w);
      gtk_menu_append(GTK_MENU(m), w);
  }
  
 +/* Edit Text entry */
 +
 +static void
 +sp_text_settings(GtkMenuItem *menuitem, SPItem *item)
 +{
 +    SPDesktop *desktop;
 +
 +    g_assert(SP_IS_ITEM(item));
 +
 +    desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
 +    g_return_if_fail(desktop != NULL);
 +
 +    if (sp_desktop_selection(desktop)->isEmpty()) {
 +        sp_desktop_selection(desktop)->set(item);
 +    }
 +
 +    sp_text_edit_dialog();
 +}
 +
 +/* Spellcheck entry */
  
 +static void
 +sp_spellcheck_settings(GtkMenuItem *menuitem, SPItem *item)
 +{
 +    SPDesktop *desktop;
 +
 +    g_assert(SP_IS_ITEM(item));
 +
 +    desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
 +    g_return_if_fail(desktop != NULL);
 +
 +    if (sp_desktop_selection(desktop)->isEmpty()) {
 +        sp_desktop_selection(desktop)->set(item);
 +    }
 +
 +    sp_spellcheck_dialog();
 +}
 +
 +/* SPText */
 +
 +static void
 +sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
 +{
 +    SPItem *item;
 +    GtkWidget *w;
 +
 +    item = (SPItem *) object;
 +
 +    /* Fill and Stroke dialog */
 +    w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke..."));
 +    gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
 +    gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item);
 +    gtk_widget_show(w);
 +    gtk_menu_append(GTK_MENU(m), w);
 +    
 +    /* Edit Text dialog */
 +    w = gtk_menu_item_new_with_mnemonic(_("_Text and Font..."));
 +    gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
 +    gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_text_settings), item);
 +    gtk_widget_show(w);
 +    gtk_menu_append(GTK_MENU(m), w);
 +
 +    /* Spellcheck dialog */
 +    w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g..."));
 +    gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
 +    gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_spellcheck_settings), item);
 +    gtk_widget_show(w);
 +    gtk_menu_append(GTK_MENU(m), w);
 +}
  /*
    Local Variables:
    mode:c++
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/context-menu.h
index c66cd4e965aae06a312a5d88f94ab8ea7198d42f,46a1e8941ce19eed97f9fca8978e0bc17e8fc4ce..36846edc3c4ad928c1d1c4d7f3b92754aae86377
@@@ -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
   */
@@@ -13,7 -13,7 +14,7 @@@
  #include <gtk/gtkmenu.h>
  
  #include "forward.h"
+ #include "sp-object.h"
  /* Append object-specific part to context menu */
  
  void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu);
@@@ -29,4 -29,4 +30,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 8d467d53f331164f701d1a8d2ab68509a1dacbfe,8c102b57f443d8b1fa99d4c3c725840ad15d4fa1..8db5e7c0b1bef4e1bf70f7a427ba43df23be5c5e
@@@ -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
@@@ -147,7 -147,7 +148,7 @@@ Gtk::Widget *build_splash_widget() 
      // should be in UTF-*8..
  
      char *about=g_build_filename(INKSCAPE_SCREENSDIR, _("about.svg"), NULL);
-     SPDocument *doc=sp_document_new (about, TRUE);
+     SPDocument *doc=SPDocument::createNewDoc (about, TRUE);
      g_free(about);
      g_return_val_if_fail(doc != NULL, NULL);
  
      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);
  
-     double width=sp_document_width(doc);
-     double height=sp_document_height(doc);
+     double width=doc->getWidth();
+     double height=doc->getHeight();
      
-     sp_document_unref(doc);
+     doc->doUnref();
  
      sp_svg_view_widget_set_resize(SP_SVG_VIEW_WIDGET(v), FALSE, (int)width, (int)height);
  
index ba8cc939b5b5e3a7c328a1cc86559cc7fb0da58f,af1671b04e5ffac9ef6f0a44d5f7f2b5a3deed9d..48f0fbf22ee3eaf0a6f7b59e47da5f8ee4463113
@@@ -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
   *
@@@ -152,7 -152,7 +154,7 @@@ private 
                  selected.erase(master);
              /*}*/
              //Compute the anchor point
-             Geom::OptRect b = sp_item_bbox_desktop (thing);
+             Geom::OptRect b = thing->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]);
          }
  
          case AlignAndDistribute::PAGE:
-             mp = Geom::Point(a.mx1 * sp_document_width(sp_desktop_document(desktop)),
-                            a.my1 * sp_document_height(sp_desktop_document(desktop)));
+             mp = Geom::Point(a.mx1 * sp_desktop_document(desktop)->getWidth(),
+                            a.my1 * sp_desktop_document(desktop)->getHeight());
              break;
  
          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]);
               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]);
          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"));
          }
  
  
@@@ -322,7 -321,7 +323,7 @@@ private 
              it != selected.end();
              ++it)
          {
-             Geom::OptRect bbox = sp_item_bbox_desktop(*it);
+             Geom::OptRect bbox = (*it)->getBboxDesktop();
              if (bbox) {
                  sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd));
              }
          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;
@@@ -465,8 -464,10 +466,8 @@@ public
          removeOverlapXGap.set_value(0);
          dialog.tooltips().set_tip(removeOverlapXGap,
                                    _("Minimum horizontal gap (in px units) between bounding boxes"));
 -        //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
 -        // "H:" stands for horizontal gap
 -        removeOverlapXGapLabel.set_label(Q_("gap|H:"));
 +        //TRANSLATORS: "H:" stands for horizontal gap
 +        removeOverlapXGapLabel.set_label(C_("Gap", "H:"));
  
          removeOverlapYGap.set_digits(1);
          removeOverlapYGap.set_size_request(60, -1);
          dialog.tooltips().set_tip(removeOverlapYGap,
                                    _("Minimum vertical gap (in px units) between bounding boxes"));
          /* TRANSLATORS: Vertical gap */
 -        removeOverlapYGapLabel.set_label(_("V:"));
 +        removeOverlapYGapLabel.set_label(C_("Gap", "V:"));
  
          dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL);
          dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL);
@@@ -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"));
      }
  };
  
@@@ -516,8 -517,8 +517,8 @@@ public
                           guint row,
                           guint column,
                           AlignAndDistribute &dialog) :
 -        Action(id, tiptext, row, column + 4,
 -               dialog.graphLayout_table(), dialog.tooltips(), dialog)
 +        Action(id, tiptext, row, column,
 +               dialog.rearrange_table(), dialog.tooltips(), dialog)
      {}
  
  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,
                 guint column,
                 AlignAndDistribute &dialog):
          Action(id, tiptext, row, column,
 -               dialog.distribute_table(), dialog.tooltips(), dialog)
 +               dialog.rearrange_table(), dialog.tooltips(), dialog)
      {}
  
  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"));
      }
  };
  
@@@ -674,7 -580,7 +676,7 @@@ public 
                 guint column,
                 AlignAndDistribute &dialog):
          Action(id, tiptext, row, column,
 -               dialog.distribute_table(), dialog.tooltips(), dialog)
 +               dialog.rearrange_table(), dialog.tooltips(), dialog)
      {}
  
  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 +
          // 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"));
      }
  };
  
@@@ -801,7 -707,7 +803,7 @@@ private 
                  Inkscape::Text::Layout const *layout = te_get_layout(*it);
                  boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
                  if (pt) {
-                     Geom::Point base = *pt * sp_item_i2d_affine(*it);
+                     Geom::Point base = *pt * (*it)->i2d_affine();
                      if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
                      if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
                      if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
              }
  
              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 {
                      Inkscape::Text::Layout const *layout = te_get_layout(*it);
                      boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
                      if (pt) {
-                         Geom::Point base = *pt * sp_item_i2d_affine(*it);
+                         Geom::Point base = *pt * (*it)->i2d_affine();
                          Geom::Point t(0.0, 0.0);
                          t[_orientation] = b_min[_orientation] - base[_orientation];
                          sp_item_move_rel(*it, Geom::Translate(t));
              }
  
              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"));
              }
          }
      }
@@@ -885,13 -791,13 +887,13 @@@ AlignAndDistribute::AlignAndDistribute(
        randomize_bbox(),
        _alignFrame(_("Align")),
        _distributeFrame(_("Distribute")),
 +      _rearrangeFrame(_("Rearrange")),
        _removeOverlapFrame(_("Remove overlaps")),
 -      _graphLayoutFrame(_("Connector network layout")),
        _nodesFrame(_("Nodes")),
        _alignTable(2, 6, true),
 -      _distributeTable(3, 6, true),
 +      _distributeTable(2, 6, true),
 +      _rearrangeTable(1, 5, false),
        _removeOverlapTable(1, 5, false),
 -      _graphLayoutTable(1, 5, false),
        _nodesTable(1, 4, true),
        _anchorLabel(_("Relative to: ")),
        _selgrpLabel(_("Treat selection as group: "))
                     _("Distribute baselines of texts vertically"),
                       1, 5, this->distribute_table(), Geom::Y, true);
  
 +    // Rearrange
 +    //Graph Layout
 +    addGraphLayoutButton(INKSCAPE_ICON_DISTRIBUTE_GRAPH,
 +                            _("Nicely arrange selected connector network"),
 +                            0, 0);
 +    addExchangePositionsButton(INKSCAPE_ICON_EXCHANGE_POSITIONS,
 +                            _("Exchange positions of selected objects - selection order"),
 +                            0, 1);
 +    addExchangePositionsByZOrderButton(INKSCAPE_ICON_EXCHANGE_POSITIONS_ZORDER,
 +                            _("Exchange positions of selected objects - stacking order"),
 +                            0, 2);
 +    addExchangePositionsClockwiseButton(INKSCAPE_ICON_EXCHANGE_POSITIONS_CLOCKWISE,
 +                            _("Exchange positions of selected objects - clockwise rotate"),
 +                            0, 3);
 +                          
      //Randomize & Unclump
      addRandomizeButton(INKSCAPE_ICON_DISTRIBUTE_RANDOMIZE,
                          _("Randomize centers in both dimensions"),
 -                        2, 2);
 +                        0, 4);
      addUnclumpButton(INKSCAPE_ICON_DISTRIBUTE_UNCLUMP,
                          _("Unclump objects: try to equalize edge-to-edge distances"),
 -                        2, 4);
 +                        0, 5);
  
      //Remove overlaps
      addRemoveOverlapsButton(INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS,
                              _("Move objects as little as possible so that their bounding boxes do not overlap"),
                              0, 0);
 -    //Graph Layout
 -    addGraphLayoutButton(INKSCAPE_ICON_DISTRIBUTE_GRAPH,
 -                            _("Nicely arrange selected connector network"),
 -                            0, 0);
  
      //Node Mode buttons
      // NOTE: "align nodes vertically" means "move nodes vertically until they align on a common
  
      _alignFrame.add(_alignBox);
      _distributeFrame.add(_distributeTable);
 +    _rearrangeFrame.add(_rearrangeTable);
      _removeOverlapFrame.add(_removeOverlapTable);
 -    _graphLayoutFrame.add(_graphLayoutTable);
      _nodesFrame.add(_nodesTable);
  
      Gtk::Box *contents = _getContents();
  
      contents->pack_start(_alignFrame, true, true);
      contents->pack_start(_distributeFrame, true, true);
 +    contents->pack_start(_rearrangeFrame, true, true);
      contents->pack_start(_removeOverlapFrame, true, true);
 -    contents->pack_start(_graphLayoutFrame, true, true);
      contents->pack_start(_nodesFrame, true, true);
  
      //Connect to the global tool change signal
@@@ -1114,8 -1009,8 +1116,8 @@@ void AlignAndDistribute::setMode(bool n
  
      ((_alignFrame).*(mSel))();
      ((_distributeFrame).*(mSel))();
 +    ((_rearrangeFrame).*(mSel))();
      ((_removeOverlapFrame).*(mSel))();
 -    ((_graphLayoutFrame).*(mSel))();
      ((_nodesFrame).*(mNode))();
  
  }
@@@ -1167,33 -1062,6 +1169,33 @@@ void AlignAndDistribute::addGraphLayout
          );
  }
  
 +void AlignAndDistribute::addExchangePositionsButton(const Glib::ustring &id, const Glib::ustring tiptext,
 +                                      guint row, guint col)
 +{
 +    _actionList.push_back(
 +        new ActionExchangePositions(
 +            id, tiptext, row, col, *this)
 +        );
 +}
 +
 +void AlignAndDistribute::addExchangePositionsByZOrderButton(const Glib::ustring &id, const Glib::ustring tiptext,
 +                                      guint row, guint col)
 +{
 +    _actionList.push_back(
 +        new ActionExchangePositions(
 +            id, tiptext, row, col, *this, ActionExchangePositions::ZOrder)
 +        );
 +}
 +
 +void AlignAndDistribute::addExchangePositionsClockwiseButton(const Glib::ustring &id, const Glib::ustring tiptext,
 +                                      guint row, guint col)
 +{
 +    _actionList.push_back(
 +        new ActionExchangePositions(
 +            id, tiptext, row, col, *this, ActionExchangePositions::Clockwise)
 +        );
 +}
 +
  void AlignAndDistribute::addUnclumpButton(const Glib::ustring &id, const Glib::ustring tiptext,
                                        guint row, guint col)
  {
@@@ -1239,7 -1107,7 +1241,7 @@@ std::list<SPItem *>::iterator AlignAndD
      {
          gdouble max = -1e18;
          for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
-             Geom::OptRect b = sp_item_bbox_desktop (*it);
+             Geom::OptRect b = (*it)->getBboxDesktop ();
              if (b) {
                  gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent();
                  if (dim > max) {
      {
          gdouble max = 1e18;
          for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
-             Geom::OptRect b = sp_item_bbox_desktop (*it);
+             Geom::OptRect b = (*it)->getBboxDesktop ();
              if (b) {
                  gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent();
                  if (dim < max) {
@@@ -1296,4 -1164,4 +1298,4 @@@ AlignAndDistribute::AlignTarget AlignAn
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 97603a8a2a1786666f7fe39d7e209a6d410f1e24,a8445c66c35cb79f0b321d064c0f8ae9986e5fcd..9f163c00c495eee5dfb3bc1c18463b86bfb06ef0
@@@ -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
                      str = 0;
  
                      if ( bruteForce( document, rroot, paletteName, def.getR(), def.getG(), def.getB() ) ) {
-                         sp_document_done( document , SP_VERB_DIALOG_SWATCHES,
+                         SPDocumentUndo::done( document , SP_VERB_DIALOG_SWATCHES,
                                            _("Change color definition"));
                      }
                  }
@@@ -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() );
      }
  }
  
@@@ -834,4 -834,4 +835,4 @@@ void ColorItem::_linkTone( ColorItem& o
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index f22509496ec8685cc96c32241da718e55b660524,4e1ddda2e7b2d95dfa4c54205d3ec8f38182d7d4..16212bef7fb830a3830ddfdacf39aa755348226a
@@@ -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
@@@ -103,8 -103,11 +105,8 @@@ DocumentProperties::DocumentProperties(
        _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr),
      //---------------------------------------------------------------
        _grids_label_crea("", Gtk::ALIGN_LEFT),
 -      //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
 -      // "New" refers to grid
 -      _grids_button_new(Q_("Grid|_New"), _("Create new grid.")),
 -      _grids_button_remove(_("_Remove"), _("Remove selected grid.")),
 +      _grids_button_new(C_("Grid", "_New"), _("Create new grid.")),
 +      _grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")),
        _grids_label_def("", Gtk::ALIGN_LEFT)
      //---------------------------------------------------------------
  {
@@@ -333,28 -336,49 +335,28 @@@ DocumentProperties::populate_available_
          delete(*it2);
      }
  
 -    std::list<Glib::ustring> sources = ColorProfile::getProfileDirs();
 -
 -    // Use this loop to iterate through a list of possible document locations.
 -    for ( std::list<Glib::ustring>::const_iterator it = sources.begin(); it != sources.end(); ++it ) {
 -        if ( Inkscape::IO::file_test( it->c_str(), G_FILE_TEST_EXISTS )
 -             && Inkscape::IO::file_test( it->c_str(), G_FILE_TEST_IS_DIR )) {
 -            GError *err = 0;
 -            GDir *directory = g_dir_open(it->c_str(), 0, &err);
 -            if (!directory) {
 -                gchar *safeDir = Inkscape::IO::sanitizeString(it->c_str());
 -                g_warning(_("Color profiles directory (%s) is unavailable."), safeDir);
 -                g_free(safeDir);
 -            } else {
 -                gchar *filename = 0;
 -                while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
 -                    gchar* full = g_build_filename(it->c_str(), filename, NULL);
 -                    if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) {
 -                        cmsErrorAction( LCMS_ERROR_SHOW );
 -                        cmsHPROFILE hProfile = cmsOpenProfileFromFile(full, "r");
 -                        if (hProfile != NULL){
 -                            const gchar* name;
 -                            lcms_profile_get_name(hProfile, &name);
 -                            Gtk::MenuItem* mi = manage(new Gtk::MenuItem());
 -                            mi->set_data("filepath", g_strdup(full));
 -                            mi->set_data("name", g_strdup(name));
 -                            Gtk::HBox *hbox = manage(new Gtk::HBox());
 -                            hbox->show();
 -                            Gtk::Label* lbl = manage(new Gtk::Label(name));
 -                            lbl->show();
 -                            hbox->pack_start(*lbl, true, true, 0);
 -                            mi->add(*hbox);
 -                            mi->show_all();
 -                            _menu.append(*mi);
 -        //                    g_free((void*)name);
 -                            cmsCloseProfile(hProfile);
 -                        }
 -                    }
 -                    g_free(full);
 -                }
 -                g_dir_close(directory);
 -            }
 +    std::list<Glib::ustring> files = ColorProfile::getProfileFiles();
 +    for ( std::list<Glib::ustring>::const_iterator it = files.begin(); it != files.end(); ++it ) {
 +        cmsHPROFILE hProfile = cmsOpenProfileFromFile(it->c_str(), "r");
 +        if ( hProfile ){
 +            const gchar* name = 0;
 +            lcms_profile_get_name(hProfile, &name);
 +            Gtk::MenuItem* mi = manage(new Gtk::MenuItem());
 +            mi->set_data("filepath", g_strdup(it->c_str()));
 +            mi->set_data("name", g_strdup(name));
 +            Gtk::HBox *hbox = manage(new Gtk::HBox());
 +            hbox->show();
 +            Gtk::Label* lbl = manage(new Gtk::Label(name));
 +            lbl->show();
 +            hbox->pack_start(*lbl, true, true, 0);
 +            mi->add(*hbox);
 +            mi->show_all();
 +            _menu.append(*mi);
 +//            g_free((void*)name);
 +            cmsCloseProfile(hProfile);
          }
      }
 +
      _menu.show_all();
  }
  
@@@ -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
          //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("");
          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);
      }
  
  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);
@@@ -798,8 -826,8 +804,8 @@@ DocumentProperties::update(
      if (nv->doc_units)
          _rum_deflt.setUnit (nv->doc_units);
  
-     double const doc_w_px = sp_document_width(sp_desktop_document(dt));
-     double const doc_h_px = sp_document_height(sp_desktop_document(dt));
+     double const doc_w_px = sp_desktop_document(dt)->getWidth();
+     double const doc_h_px = sp_desktop_document(dt)->getHeight();
      _page_sizer.setDim (doc_w_px, doc_h_px);
      _page_sizer.updateFitMarginsUI(SP_OBJECT_REPR(nv));
  
@@@ -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"));
      }
  }
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index fbfdc4a9b5fca13c9b63a69de84e0a898dfc207a,5a9f37bf02aa7e06abedee97b094ceb10196fc13..855d5a223c6f71dcb58a57c07a13468dcf6d7696
@@@ -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>
@@@ -123,9 -123,9 +124,9 @@@ findExpanderWidgets(Gtk::Container *par
  bool SVGPreview::setDocument(SPDocument *doc)
  {
      if (document)
-         sp_document_unref(document);
+         document->doUnref();
  
-     sp_document_ref(doc);
+     doc->doRef();
      document = doc;
  
      //This should remove it from the box, and free resources
@@@ -151,7 -151,7 +152,7 @@@ bool SVGPreview::setFileName(Glib::ustr
       * I don't know why passing false to keepalive is bad.  But it
       * prevents the display of an svg with a non-ascii filename
       */
-     SPDocument *doc = sp_document_new (fileName.c_str(), true);
+     SPDocument *doc = SPDocument::createNewDoc (fileName.c_str(), true);
      if (!doc) {
          g_warning("SVGView: error loading document '%s'\n", fileName.c_str());
          return false;
  
      setDocument(doc);
  
-     sp_document_unref(doc);
+     doc->doUnref();
  
      return true;
  }
@@@ -172,7 -172,7 +173,7 @@@ bool SVGPreview::setFromMem(char const 
          return false;
  
      gint len = (gint)strlen(xmlBuffer);
-     SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0);
+     SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0);
      if (!doc) {
          g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer);
          return false;
  
      setDocument(doc);
  
-     sp_document_unref(doc);
+     doc->doUnref();
  
      Inkscape::GC::request_early_collection();
  
@@@ -1625,4 -1625,4 +1626,4 @@@ FileExportDialogImpl::getFilename(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index e2bf47db928b1652a20990518374ee2231ff8a5f,aabb3c2dff60d3af900cdd5670ebeb122e4e4a71..65bb49f1376bca4febbe1a342b7fd64278aae886
@@@ -4,6 -4,6 +4,7 @@@
  /* Authors:
   *   Joel Holdsworth
   *   The Inkscape Organization
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004-2008 The Inkscape Organization
   *
@@@ -59,11 -59,7 +60,11 @@@ namespace U
  namespace Dialog
  {
  
 -const int PreviewWidening = 150;
 +const int PREVIEW_WIDENING = 150;
 +const int WINDOW_WIDTH_MINIMUM = 32;
 +const int WINDOW_WIDTH_FALLBACK = 450;
 +const int WINDOW_HEIGHT_MINIMUM = 32;
 +const int WINDOW_HEIGHT_FALLBACK = 360;
  const char PreviewWindowClassName[] = "PreviewWnd";
  const unsigned long MaxPreviewFileSize = 10240; // kB
  
@@@ -95,21 -91,6 +96,21 @@@ ustring utf16_to_ustring(const wchar_t 
      return result;
  }
  
 +namespace {
 +
 +int sanitizeWindowSizeParam( int size, int delta, int minimum, int fallback )
 +{
 +    int result = size;
 +    if ( size < minimum ) {
 +        g_warning( "Window size %d is less than cutoff.", size );
 +        result = fallback - delta;
 +    }
 +    result += delta;
 +    return result;
 +}
 +
 +} // namespace
 +
  /*#########################################################################
  ### F I L E     D I A L O G    B A S E    C L A S S
  #########################################################################*/
@@@ -462,9 -443,9 +463,9 @@@ UINT_PTR CALLBACK FileOpenDialogImplWin
              RECT rcRect;
              GetWindowRect(hParentWnd, &rcRect);
              MoveWindow(hParentWnd, rcRect.left, rcRect.top,
 -                rcRect.right - rcRect.left + PreviewWidening,
 -                rcRect.bottom - rcRect.top,
 -                FALSE);
 +                       rcRect.right - rcRect.left + PREVIEW_WIDENING,
 +                       rcRect.bottom - rcRect.top,
 +                       FALSE);
  
              // Set the pointer to the object
              OPENFILENAMEW *ofn = (OPENFILENAMEW*)lParam;
@@@ -906,20 -887,20 +907,20 @@@ bool FileOpenDialogImplWin32::set_svg_p
  
      gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string,
          _MAX_PATH, NULL, NULL, NULL);
-     SPDocument *svgDoc = sp_document_new (utf8string, true);
+     SPDocument *svgDoc = SPDocument::createNewDoc (utf8string, true);
      g_free(utf8string);
  
      // Check the document loaded properly
      if(svgDoc == NULL) return false;
      if(svgDoc->root == NULL)
      {
-         sp_document_unref(svgDoc);
+         svgDoc->doUnref();
          return false;
      }
  
      // Get the size of the document
-     const double svgWidth = sp_document_width(svgDoc);
-     const double svgHeight = sp_document_height(svgDoc);
+     const double svgWidth = svgDoc->getWidth();
+     const double svgHeight = svgDoc->getHeight();
  
      // Find the minimum scale to fit the image inside the preview area
      const double scaleFactorX =    PreviewSize / svgWidth;
  
      // 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();
  
      // Fail if the pixblock failed to allocate
      if(pixBlock.data.px == NULL)
      {
-         sp_document_unref(svgDoc);
+         svgDoc->doUnref();
          return false;
      }
  
      nr_arena_item_invoke_render(NULL, root, &bbox, &pixBlock, /*0*/NR_ARENA_ITEM_RENDER_NO_CACHE);
  
      // Tidy up
-     sp_document_unref(svgDoc);
+     svgDoc->doUnref();
      sp_item_invoke_hide((SPItem*)(svgDoc->root), key);
      nr_object_unref((NRObject *) arena);
  
@@@ -1705,19 -1686,12 +1706,19 @@@ UINT_PTR CALLBACK FileSaveDialogImplWin
              GetWindowRect(GetDlgItem(hParentWnd, stc2), &rST);
              GetWindowRect(hdlg, &rROOT);
              int ydelta = rCB1.top - rEDT1.top;
 +            if ( ydelta < 0 ) {
 +                g_warning("Negative dialog ydelta");
 +                ydelta = 0;
 +            }
  
              // Make the window a bit longer
 +            // Note: we have a width delta of 1 because there is a suspicion that MoveWindow() to the same size causes zero-width results.
              RECT rcRect;
              GetWindowRect(hParentWnd, &rcRect);
 -            MoveWindow(hParentWnd, rcRect.left, rcRect.top, rcRect.right - rcRect.left,
 -                       rcRect.bottom - rcRect.top + ydelta, FALSE);
 +            MoveWindow(hParentWnd, rcRect.left, rcRect.top,
 +                       sanitizeWindowSizeParam( rcRect.right - rcRect.left, 1, WINDOW_WIDTH_MINIMUM, WINDOW_WIDTH_FALLBACK ),
 +                       sanitizeWindowSizeParam( rcRect.bottom - rcRect.top, ydelta, WINDOW_HEIGHT_MINIMUM, WINDOW_HEIGHT_FALLBACK ),
 +                       FALSE);
  
              // It is not necessary to delete stock objects by calling DeleteObject
              HGDIOBJ dlgFont = GetStockObject(DEFAULT_GUI_FONT);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index bee6b7c9da7e73badd35517a9f3e9d26bd390ad3,07b8a4159459f7f369b4e692cc4f191ab8601215..ed7103be3c801a91fc4628d271e403d0e13c38b1
@@@ -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
   *
@@@ -27,6 -27,8 +29,6 @@@
  #include <gtkmm/tooltips.h>
  #include <glibmm/i18n.h>
  
 -#include "application/application.h"
 -#include "application/editor.h"
  #include "desktop.h"
  #include "desktop-handles.h"
  #include "dialog-manager.h"
@@@ -174,7 -176,7 +176,7 @@@ public
          if (tip_text) {
              _tt.set_tip(*this, tip_text);
          }
 -        combo = new ComboBoxEnum<T>(default_value, c, a);
 +        combo = new ComboBoxEnum<T>(default_value, c, a, false);
          add(*combo);
          show_all();
      }
@@@ -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()
  
      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
                  }
                  // 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.
@@@ -2175,14 -2187,13 +2187,14 @@@ void FilterEffectsDialog::init_settings
  
      _settings->type(NR_FILTER_COMPONENTTRANSFER);
      _settings->add_notimplemented();
 +    /*
      //TRANSLATORS: for info on "Slope" and "Intercept", see http://id.mind.net/~zona/mmts/functionInstitute/linearFunctions/lsif.html
 -    /*_settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter);
 -    _ct_slope = _settings->add_spinslider(SP_ATTR_SLOPE, _("Slope"), -100, 100, 1, 0.01, 1);
 -    _ct_intercept = _settings->add_spinslider(SP_ATTR_INTERCEPT, _("Intercept"), -100, 100, 1, 0.01, 1);
 -    _ct_amplitude = _settings->add_spinslider(SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 100, 1, 0.01, 1);
 -    _ct_exponent = _settings->add_spinslider(SP_ATTR_EXPONENT, _("Exponent"), 0, 100, 1, 0.01, 1);
 -    _ct_offset = _settings->add_spinslider(SP_ATTR_OFFSET, _("Offset"), -100, 100, 1, 0.01, 1);*/
 +    _settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter);
 +    _ct_slope = _settings->add_spinslider(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2);
 +    _ct_intercept = _settings->add_spinslider(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2);
 +    _ct_amplitude = _settings->add_spinslider(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2);
 +    _ct_exponent = _settings->add_spinslider(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2);
 +    _ct_offset = _settings->add_spinslider(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/
  
      _settings->type(NR_FILTER_COMPOSITE);
      _settings->add_combo(COMPOSITE_OVER, SP_ATTR_OPERATOR, _("Operator:"), CompositeOperatorConverter);
  
      _settings->type(NR_FILTER_DIFFUSELIGHTING);
      _settings->add_color(/*default: white*/ 0xffffffff, SP_PROP_LIGHTING_COLOR, _("Diffuse Color:"), _("Defines the color of the light source"));
 -    _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -1000, 1000, 1, 0.01, 1, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
 -    _settings->add_spinslider(1, SP_ATTR_DIFFUSECONSTANT, _("Constant:"), 0, 100, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
 +    _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.01, 0.001, 3, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
 +    _settings->add_spinslider(1, SP_ATTR_DIFFUSECONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
      _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1);
      _settings->add_lightsource();
  
  
      _settings->type(NR_FILTER_SPECULARLIGHTING);
      _settings->add_color(/*default: white*/ 0xffffffff, SP_PROP_LIGHTING_COLOR, _("Specular Color:"), _("Defines the color of the light source"));
 -    _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -1000, 1000, 1, 0.01, 1, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
 -    _settings->add_spinslider(1, SP_ATTR_SPECULARCONSTANT, _("Constant:"), 0, 100, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
 -    _settings->add_spinslider(1, SP_ATTR_SPECULAREXPONENT, _("Exponent:"), 1, 128, 1, 0.01, 1, _("Exponent for specular term, larger is more \"shiny\"."));
 +    _settings->add_spinslider(1, SP_ATTR_SURFACESCALE, _("Surface Scale:"), -5, 5, 0.1, 0.01, 2, _("This value amplifies the heights of the bump map defined by the input alpha channel"));
 +    _settings->add_spinslider(1, SP_ATTR_SPECULARCONSTANT, _("Constant:"), 0, 5, 0.1, 0.01, 2, _("This constant affects the Phong lighting model."));
 +    _settings->add_spinslider(1, SP_ATTR_SPECULAREXPONENT, _("Exponent:"), 1, 50, 1, 0.01, 1, _("Exponent for specular term, larger is more \"shiny\"."));
      _settings->add_dualspinslider(SP_ATTR_KERNELUNITLENGTH, _("Kernel Unit Length:"), 0.01, 10, 1, 0.01, 1);
      _settings->add_lightsource();
  
@@@ -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();
      }
  
@@@ -2530,4 -2543,4 +2544,4 @@@ void FilterEffectsDialog::update_color_
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/dialog/find.cpp
index 7fad00f56d32eea7afc716e75d2e6c4a433d8fed,5068e3bf4c91874eb6f08d85c73d1be4aaa613a7..b6d6a0319cd122d7fe855be03ce5f47b1a086c78
@@@ -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
   *
@@@ -57,10 -57,10 +59,10 @@@ namespace Dialog 
  
  Find::Find()
      : UI::Widget::Panel("", "/dialogs/find", SP_VERB_DIALOG_FIND),
 -      _entry_text(_("_Text: "), _("Find objects by their text content (exact or partial match)")),
 -      _entry_id(_("_ID: "), _("Find objects by the value of the id attribute (exact or partial match)")),
 -      _entry_style(_("_Style: "), _("Find objects by the value of the style attribute (exact or partial match)")),
 -      _entry_attribute(_("_Attribute: "), _("Find objects by the name of an attribute (exact or partial match)")),
 +      _entry_text(_("_Text:"), _("Find objects by their text content (exact or partial match)")),
 +      _entry_id(_("_ID:"), _("Find objects by the value of the id attribute (exact or partial match)")),
 +      _entry_style(_("_Style:"), _("Find objects by the value of the style attribute (exact or partial match)")),
 +      _entry_attribute(_("_Attribute:"), _("Find objects by the name of an attribute (exact or partial match)")),
        _check_search_selection(_("Search in s_election"), _("Limit search to the current selection")),
        _check_search_layer(_("Search in current _layer"), _("Limit search to the current layer")),
        _check_include_hidden(_("Include _hidden"), _("Include hidden objects in search")),
        _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 --combined src/ui/dialog/glyphs.cpp
index 5e66ca9b8960edbca6150278f5381d29ab9389db,8193b43845ba573f932008aacd9969b7c62108fd..f3d7ed9711a54219f545d9230685714e4c995872
@@@ -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
@@@ -28,7 -28,7 +29,7 @@@
  #include "glyphs.h"
  
  #include "desktop.h"
- #include "document.h" // for sp_document_done()
+ #include "document.h" // for SPDocumentUndo::done()
  #include "libnrtype/font-instance.h"
  #include "sp-flowtext.h"
  #include "sp-text.h"
@@@ -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"));
          }
      }
  }
@@@ -746,4 -746,4 +747,4 @@@ void GlyphsPanel::rebuild(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/dialog/guides.cpp
index aac6024b9341c8ded3c8f1c2ada827fb49ee9b31,9c3422167facc854e6b4821e9d8cd434b2173b02..1ab0d51bc6f1a86bdfe3c95c264901c8883c65d8
@@@ -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] ) );
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 07e1ff43052a02bec77f857367a7bdd70b672e2e,e74e47ca3797dbc5da70332290855d58803f4285..b507d9f9af4f05911483935289211c44d8764a9b
@@@ -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
@@@ -41,8 -41,6 +42,8 @@@ sp_icon_doc_icon( SPDocument *doc, NRAr
                    const gchar *name, unsigned int psize );
  }
  
 +#define noICON_VERBOSE 1
 +
  namespace Inkscape {
  namespace UI {
  namespace Dialog {
@@@ -87,10 -85,7 +88,10 @@@ IconPreviewPanel::IconPreviewPanel() 
      desktop(0),
      document(0),
      timer(0),
 +    renderTimer(0),
      pending(false),
 +    minDelay(0.1),
 +    targetId(),
      hot(1),
      selectionButton(0),
      desktopChangeConn(),
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
      numEntries = 0;
  
 +    bool pack = prefs->getBool("/iconpreview/pack", true);
 +
      std::vector<Glib::ustring> pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default");
      std::vector<int> rawSizes;
  
          Glib::ustring label(*labels[i]);
          buttons[i] = new Gtk::ToggleToolButton(label);
          buttons[i]->set_active( i == hot );
 -        Gtk::Frame *frame = new Gtk::Frame();
 -        frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
 -        frame->add(*images[i]);
 -        buttons[i]->set_icon_widget(*Gtk::manage(frame));
 +        if ( prefs->getBool("/iconpreview/showFrames", true) ) {
 +            Gtk::Frame *frame = new Gtk::Frame();
 +            frame->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
 +            frame->add(*images[i]);
 +            buttons[i]->set_icon_widget(*Gtk::manage(frame));
 +        } else {
 +            buttons[i]->set_icon_widget(*images[i]);
 +        }
  
          tips.set_tip((*buttons[i]), label);
  
          align->add(*buttons[i]);
  
          int pad = 12;
 -        if ((avail == 0) && (previous == 0)) {
 +        if ( !pack || ( (avail == 0) && (previous == 0) ) ) {
              verts->pack_end(*align, Gtk::PACK_SHRINK);
              previous = sizes[i];
              avail = sizes[i];
      splitter.pack2( *actuals, false, false );
  
  
 -    selectionButton = new Gtk::CheckButton(_("Selection")); // , GTK_RESPONSE_APPLY
 +    selectionButton = new Gtk::CheckButton(C_("Icon preview window", "Sele_ction"), true);//selectionButton = (Gtk::ToggleButton*) gtk_check_button_new_with_mnemonic(_("_Selection")); // , GTK_RESPONSE_APPLY
      magBox->pack_start( *selectionButton, Gtk::PACK_SHRINK );
      tips.set_tip((*selectionButton), _("Selection only or whole document"));
      selectionButton->signal_clicked().connect( sigc::mem_fun(*this, &IconPreviewPanel::modeToggled) );
@@@ -253,11 -242,6 +254,11 @@@ IconPreviewPanel::~IconPreviewPanel(
          delete timer;
          timer = 0;
      }
 +    if ( renderTimer ) {
 +        renderTimer->stop();
 +        delete renderTimer;
 +        renderTimer = 0;
 +    }
  
      selChangedConn.disconnect();
      docModConn.disconnect();
  //#########################################################################
  
  
 +#if ICON_VERBOSE
 +static Glib::ustring getTimestr()
 +{
 +    Glib::ustring str;
 +    GTimeVal now = {0, 0};
 +    g_get_current_time(&now);
 +    glong secs = now.tv_sec % 60;
 +    glong mins = (now.tv_sec / 60) % 60;
 +    gchar *ptr = g_strdup_printf(":%02ld:%02ld.%06ld", mins, secs, now.tv_usec);
 +    str = ptr;
 +    g_free(ptr);
 +    ptr = 0;
 +    return str;
 +}
 +#endif // ICON_VERBOSE
 +
  void IconPreviewPanel::setDesktop( SPDesktop* desktop )
  {
      Panel::setDesktop(desktop);
          this->desktop = Panel::getDesktop();
          if ( this->desktop ) {
              docReplacedConn = this->desktop->connectDocumentReplaced(sigc::hide<0>(sigc::mem_fun(this, &IconPreviewPanel::setDocument)));
 -            if (this->desktop->selection) {
 +            if ( this->desktop->selection && Inkscape::Preferences::get()->getBool("/iconpreview/autoRefresh", true) ) {
                  selChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(this, &IconPreviewPanel::queueRefresh)));
              }
          }
@@@ -316,9 -284,7 +317,9 @@@ void IconPreviewPanel::setDocument( SPD
  
          this->document = document;
          if (this->document) {
 -            docModConn = this->document->connectModified(sigc::hide(sigc::mem_fun(this, &IconPreviewPanel::queueRefresh)));
 +            if ( Inkscape::Preferences::get()->getBool("/iconpreview/autoRefresh", true) ) {
 +                docModConn = this->document->connectModified(sigc::hide(sigc::mem_fun(this, &IconPreviewPanel::queueRefresh)));
 +            }
              queueRefresh();
          }
      }
@@@ -330,50 -296,38 +331,50 @@@ void IconPreviewPanel::refreshPreview(
      if (!timer) {
          timer = new Glib::Timer();
      }
 -    if (timer->elapsed() < 0.1) {
 +    if (timer->elapsed() < minDelay) {
 +#if ICON_VERBOSE
 +        g_message( "%s Deferring refresh as too soon. calling queueRefresh()", getTimestr().c_str() );
 +#endif //ICON_VERBOSE
          // Do not refresh too quickly
          queueRefresh();
      } else if ( desktop ) {
 +#if ICON_VERBOSE
 +        g_message( "%s Refreshing preview.", getTimestr().c_str() );
 +#endif // ICON_VERBOSE
 +        bool hold = Inkscape::Preferences::get()->getBool("/iconpreview/selectionHold", true);
 +        SPObject *target = 0;
          if ( selectionButton && selectionButton->get_active() )
          {
 -            Inkscape::Selection * sel = sp_desktop_selection(desktop);
 -            if ( sel ) {
 -                //g_message("found a selection to play with");
 -
 -                GSList const *items = sel->itemList();
 -                SPObject *target = 0;
 -                while ( items && !target ) {
 -                    SPItem* item = SP_ITEM( items->data );
 -                    SPObject * obj = SP_OBJECT(item);
 -                    gchar const *id = obj->getId();
 -                    if ( id ) {
 -                        target = obj;
 +            target = (hold && !targetId.empty()) ? desktop->doc()->getObjectById( targetId.c_str() ) : 0;
 +            if ( !target ) {
 +                targetId.clear();
 +                Inkscape::Selection * sel = sp_desktop_selection(desktop);
 +                if ( sel ) {
 +                    //g_message("found a selection to play with");
 +
 +                    GSList const *items = sel->itemList();
 +                    while ( items && !target ) {
 +                        SPItem* item = SP_ITEM( items->data );
 +                        SPObject * obj = SP_OBJECT(item);
 +                        gchar const *id = obj->getId();
 +                        if ( id ) {
 +                            targetId = id;
 +                            target = obj;
 +                        }
 +
 +                        items = g_slist_next(items);
                      }
 -
 -                    items = g_slist_next(items);
 -                }
 -                if ( target ) {
 -                    renderPreview(target);
                  }
              }
          } else {
 -            SPObject *target = desktop->currentRoot();
 -            if ( target ) {
 -                renderPreview(target);
 -            }
 +            target = desktop->currentRoot();
          }
 +        if ( target ) {
 +            renderPreview(target);
 +        }
 +#if ICON_VERBOSE
 +        g_message( "%s  resetting timer", getTimestr().c_str() );
 +#endif // ICON_VERBOSE
          timer->reset();
      }
  }
@@@ -384,15 -338,9 +385,15 @@@ bool IconPreviewPanel::refreshCB(
      if (!timer) {
          timer = new Glib::Timer();
      }
 -    if ( timer->elapsed() > 0.1 ) {
 +    if ( timer->elapsed() > minDelay ) {
 +#if ICON_VERBOSE
 +        g_message( "%s refreshCB() timer has progressed", getTimestr().c_str() );
 +#endif // ICON_VERBOSE
          callAgain = false;
          refreshPreview();
 +#if ICON_VERBOSE
 +        g_message( "%s refreshCB() setting pending false", getTimestr().c_str() );
 +#endif // ICON_VERBOSE
          pending = false;
      }
      return callAgain;
@@@ -402,9 -350,6 +403,9 @@@ void IconPreviewPanel::queueRefresh(
  {
      if (!pending) {
          pending = true;
 +#if ICON_VERBOSE
 +        g_message( "%s queueRefresh() Setting pending true", getTimestr().c_str() );
 +#endif // ICON_VERBOSE
          if (!timer) {
              timer = new Glib::Timer();
          }
  void IconPreviewPanel::modeToggled()
  {
      Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 -    prefs->setBool("/iconpreview/selectionOnly", (selectionButton && selectionButton->get_active()));
 +    bool selectionOnly = (selectionButton && selectionButton->get_active());
 +    prefs->setBool("/iconpreview/selectionOnly", selectionOnly);
 +    if ( !selectionOnly ) {
 +        targetId.clear();
 +    }
  
      refreshPreview();
  }
@@@ -428,14 -369,8 +429,14 @@@ void IconPreviewPanel::renderPreview( S
  {
      SPDocument * doc = SP_OBJECT_DOCUMENT(obj);
      gchar const * id = obj->getId();
 +    if ( !renderTimer ) {
 +        renderTimer = new Glib::Timer();
 +    }
 +    renderTimer->reset();
  
 -//    g_message(" setting up to render '%s' as the icon", id );
 +#if ICON_VERBOSE
 +    g_message("%s setting up to render '%s' as the icon", getTimestr().c_str(), id );
 +#endif // ICON_VERBOSE
  
      NRArenaItem *root = NULL;
  
      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] );
      }
      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()
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 1728ff3a6d95c9723d6fbf7140abae87b6812483,80c943e39baa865f128822d6a605e102138bd28a..bf15bcd76af9103ff5828142c87d971a83895a40
@@@ -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"));
  }
@@@ -259,4 -259,4 +260,4 @@@ void LayerPropertiesDialog::_setLayer(S
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/dialog/layers.cpp
index c3c0ae3c5b946bcfb6e15f2690e12433946f2cfc,962d78df8d354e2fbbf9bb5ad37a0bdaa43444b9..0eca5bbca2435947c64d62dbc47a9630a99d85c6
@@@ -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;
  
                  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;
          }
@@@ -631,30 -631,32 +632,30 @@@ LayersPanel::LayersPanel() 
      _buttonsRow.set_child_min_width( 16 );
  
      Gtk::Button* btn = manage( new Gtk::Button() );
 -    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, GTK_STOCK_ADD, _("New") );
 +    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, GTK_STOCK_ADD, C_("Layers", "New") );
      btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) );
      _buttonsRow.add( *btn );
  
      btn = manage( new Gtk::Button() );
 -    //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
 -    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, Q_("layers|Top") );
 +    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, C_("Layers", "Top") );
      btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
      _watchingNonTop.push_back( btn );
      _buttonsRow.add( *btn );
  
      btn = manage( new Gtk::Button() );
 -    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, _("Up") );
 +    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, C_("Layers", "Up") );
      btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
      _watchingNonTop.push_back( btn );
      _buttonsRow.add( *btn );
  
      btn = manage( new Gtk::Button() );
 -    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, _("Dn") );
 +    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, C_("Layers", "Dn") );
      btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
      _watchingNonBottom.push_back( btn );
      _buttonsRow.add( *btn );
  
      btn = manage( new Gtk::Button() );
 -    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, _("Bot") );
 +    _styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") );
      btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
      _watchingNonBottom.push_back( btn );
      _buttonsRow.add( *btn );
@@@ -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);
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 706a84733932685d29ad568bec02459fe8b2dc29,d05790b3e66b291b999de709a67fc254695719f9..bf60fe059471b7d465bdc839426dc09b4758a4d4
@@@ -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.
@@@ -299,10 -299,6 +300,10 @@@ LivePathEffectEditor::effect_list_reloa
      PathEffectList::iterator it;
      for( it = effectlist.begin() ; it!=effectlist.end(); it++ )
      {
 +        if ( !(*it)->lpeobject ) {
 +            continue;
 +        }
 +
          if ((*it)->lpeobject->get_lpe()) {
              Gtk::TreeModel::Row row = *(effectlist_store->append());
              row[columns.col_name] = (*it)->lpeobject->get_lpe()->getName();
@@@ -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"));
      }
  }
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/dialog/print.cpp
index 2456e10daa69931b9728436b7120af8b6e304b0d,80838617167fc998ae34831a527df9b5bbbfc19e..a56cbfd9d65dd6066d4126c9cd5df143ba52f9dc
@@@ -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.
@@@ -46,8 -46,8 +47,8 @@@ static void draw_page
  
      if (junk->_tab->as_bitmap()) {
          // Render as exported PNG
-         gdouble width = sp_document_width(junk->_doc);
-         gdouble height = sp_document_height(junk->_doc);
+         gdouble width = (junk->_doc)->getWidth();
+         gdouble height = (junk->_doc)->getHeight();
          gdouble dpi = junk->_tab->bitmap_dpi();
          std::string tmp_png;
          std::string tmp_base = "inkscape-print-png-XXXXXX";
@@@ -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;
      // set up paper size to match the document size
      gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS);
      GtkPageSetup *page_setup = gtk_page_setup_new();
-     gdouble doc_width = sp_document_width(_doc) * PT_PER_PX;
-     gdouble doc_height = sp_document_height(_doc) * PT_PER_PX;
+     gdouble doc_width = _doc->getWidth() * PT_PER_PX;
+     gdouble doc_height = _doc->getHeight() * PT_PER_PX;
      GtkPaperSize *paper_size;
      if (doc_width > doc_height) {
          gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
@@@ -240,4 -240,4 +241,4 @@@ Gtk::PrintOperationResult Print::run(Gt
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 51b206a85b7cb72110dbebd6fefcf089aa7bccb6,01560733f5a7b1eb40f7655fd359b11271d0fe65..d8ff8ca56efac3466e6e0c9c6abb636777eb3ebb
@@@ -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
@@@ -171,7 -171,7 +172,7 @@@ SessionPlaybackDialogImpl::_respCallbac
                        switch (result) {
                                case Gtk::RESPONSE_OK:
                                        this->_sm->clearDocument();
-                                       sp_document_done(sp_desktop_document(this->_desktop), SP_VERB_NONE, 
+                                       SPDocumentUndo::done(sp_desktop_document(this->_desktop), SP_VERB_NONE, 
                                                         /* TODO: annotate */ "session-player.cpp:186");
                                        this->_sm->loadSessionFile(sessionfiledlg.get_filename());
                                        this->_openfile.set_text(this->_sfp->filename());
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 1f11a412e9fb0ecb2b6ddd4ad5df4652a19d385c,9f9f91bd1d83c0a92ec8737af675d5ccc8832e86..042acb6e1b3e16a4e22620d16115998f2b164d20
@@@ -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"));
      }
  
  }
@@@ -163,15 -163,17 +165,17 @@@ void SvgFontsDialog::on_kerning_value_c
      if (!this->kerning_pair) return;
      SPDocument* document = sp_desktop_document(this->getDesktop());
  
-     //TODO: I am unsure whether this is the correct way of calling sp_document_maybe_done
+     //TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done
      Glib::ustring undokey = "svgfonts:hkern:k:";
      undokey += this->kerning_pair->u1->attribute_string();
      undokey += ":";
      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());
      // 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(){
      create_kerning_pairs_popup_menu(_KerningPairsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_kerning_pair));
  
  //Kerning Setup:
 -    kerning_vbox.add(*Gtk::manage(new Gtk::Label(_("Kerning Setup:"))));
 +    kerning_vbox.add(*Gtk::manage(new Gtk::Label(_("Kerning Setup"))));
      Gtk::HBox* kerning_selector = Gtk::manage(new Gtk::HBox());
      kerning_selector->add(*Gtk::manage(new Gtk::Label(_("1st Glyph:"))));
      kerning_selector->add(first_glyph);
@@@ -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(){
      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()
@@@ -911,4 -925,4 +926,4 @@@ SvgFontsDialog::~SvgFontsDialog(){
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 4c8a018fa5c2a8ae131dc022fb4eda3015482b3f,6cef5bedd2ee6ec0502b5dc7b2e2859f2ab14dc0..b2b1b26da5372ffa90117f8302a27e68f6588f9f
@@@ -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
@@@ -14,7 -14,6 +15,7 @@@
  
  #include <errno.h>
  #include <map>
 +#include <algorithm>
  
  #include <gtk/gtkdialog.h> //for GTK_RESPONSE* types
  #include <gtk/gtkdnd.h>
@@@ -50,7 -49,7 +51,7 @@@
  #include "widgets/eek-preview.h"
  #include "display/nr-plain-stuff.h"
  #include "sp-gradient-reference.h"
 -
 +#include "dialog-manager.h"
  
  namespace Inkscape {
  namespace UI {
@@@ -73,8 -72,7 +74,8 @@@ static std::map<SwatchesPanel*, SPDocum
  class SwatchesPanelHook : public SwatchesPanel
  {
  public:
 -    static void convertGradient( GtkMenuItem * menuitem, gpointer userData );
 +    static void convertGradient( GtkMenuItem *menuitem, gpointer userData );
 +    static void deleteGradient( GtkMenuItem *menuitem, gpointer userData );
  };
  
  static void handleClick( GtkWidget* /*widget*/, gpointer callback_data ) {
@@@ -113,37 -111,11 +114,37 @@@ static void redirSecondaryClick( GtkMen
      }
  }
  
 -static void editGradientImpl( SPGradient* gr )
 +static void editGradientImpl( SPDesktop* desktop, SPGradient* gr )
  {
      if ( gr ) {
 -        GtkWidget *dialog = sp_gradient_vector_editor_new( gr );
 -        gtk_widget_show( dialog );
 +        bool shown = false;
 +        if ( desktop && desktop->doc() ) {
 +            Inkscape::Selection *selection = sp_desktop_selection( desktop );
 +            GSList const *items = selection->itemList();
 +            if (items) {
 +                SPStyle *query = sp_style_new( desktop->doc() );
 +                int result = objects_query_fillstroke(const_cast<GSList *>(items), query, true);
 +                if ( (result == QUERY_STYLE_MULTIPLE_SAME) || (result == QUERY_STYLE_SINGLE) ) {
 +                    // could be pertinent
 +                    if (query->fill.isPaintserver()) {
 +                        SPPaintServer* server = query->getFillPaintServer();
 +                        if ( SP_IS_GRADIENT(server) ) {
 +                            SPGradient* grad = SP_GRADIENT(server);
 +                            if ( grad->isSwatch() && grad->getId() == gr->getId()) {
 +                                desktop->_dlg_mgr->showDialog("FillAndStroke");
 +                                shown = true;
 +                            }
 +                        }
 +                    }
 +                }
 +                sp_style_unref(query);
 +            }
 +        }
 +
 +        if (!shown) {
 +            GtkWidget *dialog = sp_gradient_vector_editor_new( gr );
 +            gtk_widget_show( dialog );
 +        }
      }
  }
  
@@@ -155,11 -127,11 +156,11 @@@ 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() ) {
 -                    editGradientImpl( grad );
 +                    editGradientImpl( desktop, grad );
                      break;
                  }
              }
      }
  }
  
 -static void addNewGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
 +void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer userData )
  {
      if ( bounceTarget ) {
          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;
 +                }
 +            }
          }
      }
  }
  
 -void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer userData )
 +void SwatchesPanelHook::deleteGradient( GtkMenuItem */*menuitem*/, gpointer /*userData*/ )
  {
      if ( bounceTarget ) {
          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;
                  }
              }
@@@ -268,13 -251,17 +269,13 @@@ gboolean colorItemHandleButtonPress( Gt
              gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
              popupExtras.push_back(child);
  
 -            child = gtk_menu_item_new_with_label(_("Add"));
 +            child = gtk_menu_item_new_with_label(_("Delete"));
              g_signal_connect( G_OBJECT(child),
                                "activate",
 -                              G_CALLBACK(addNewGradient),
 +                              G_CALLBACK(SwatchesPanelHook::deleteGradient),
                                user_data );
              gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
              popupExtras.push_back(child);
 -
 -            child = gtk_menu_item_new_with_label(_("Delete"));
 -            gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
 -            //popupExtras.push_back(child);
              gtk_widget_set_sensitive( child, FALSE );
  
              child = gtk_menu_item_new_with_label(_("Edit..."));
                      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);
@@@ -436,7 -423,7 +437,7 @@@ void _loadPaletteFile( gchar const *fil
                                      if ( !hasErr && *ptr ) {
                                          char* n = trim(ptr);
                                          if (n != NULL) {
 -                                            name = n;
 +                                            name = g_dpgettext2(NULL, "Palette", n);
                                          }
                                      }
                                      if ( !hasErr ) {
@@@ -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() ) {
      }
  
      if ( !newList.empty() ) {
 +        std::reverse(newList.begin(), newList.end());
          for ( std::vector<SPGradient*>::iterator it = newList.begin(); it != newList.end(); ++it )
          {
              SPGradient* grad = *it;
@@@ -902,25 -888,21 +903,25 @@@ void SwatchesPanel::handleDefsModified(
          std::map<ColorItem*, SPGradient*> tmpGrads;
          recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads);
  
 -        int cap = std::min(docPalette->_colors.size(), tmpColors.size());
 -        for (int i = 0; i < cap; i++) {
 -            ColorItem* newColor = tmpColors[i];
 -            ColorItem* oldColor = docPalette->_colors[i];
 -            if ( (newColor->def.getType() != oldColor->def.getType()) ||
 -                 (newColor->def.getR() != oldColor->def.getR()) ||
 -                 (newColor->def.getG() != oldColor->def.getG()) ||
 -                 (newColor->def.getB() != oldColor->def.getB()) ) {
 -                oldColor->def.setRGB(newColor->def.getR(), newColor->def.getG(), newColor->def.getB());
 -            }
 -            if (tmpGrads.find(newColor) != tmpGrads.end()) {
 -                oldColor->setGradient(tmpGrads[newColor]);
 -            }
 -            if ( tmpPrevs.find(newColor) != tmpPrevs.end() ) {
 -                oldColor->setPixData(tmpPrevs[newColor], PREVIEW_PIXBUF_WIDTH, VBLOCK);
 +        if ( tmpColors.size() != docPalette->_colors.size() ) {
 +            handleGradientsChange(document);
 +        } else {
 +            int cap = std::min(docPalette->_colors.size(), tmpColors.size());
 +            for (int i = 0; i < cap; i++) {
 +                ColorItem* newColor = tmpColors[i];
 +                ColorItem* oldColor = docPalette->_colors[i];
 +                if ( (newColor->def.getType() != oldColor->def.getType()) ||
 +                     (newColor->def.getR() != oldColor->def.getR()) ||
 +                     (newColor->def.getG() != oldColor->def.getG()) ||
 +                     (newColor->def.getB() != oldColor->def.getB()) ) {
 +                    oldColor->def.setRGB(newColor->def.getR(), newColor->def.getG(), newColor->def.getB());
 +                }
 +                if (tmpGrads.find(newColor) != tmpGrads.end()) {
 +                    oldColor->setGradient(tmpGrads[newColor]);
 +                }
 +                if ( tmpPrevs.find(newColor) != tmpPrevs.end() ) {
 +                    oldColor->setPixData(tmpPrevs[newColor], PREVIEW_PIXBUF_WIDTH, VBLOCK);
 +                }
              }
          }
      }
@@@ -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;
                              }
                              }
                          }
                          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;
                              }
@@@ -1075,4 -1060,4 +1078,4 @@@ void SwatchesPanel::_rebuild(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/dialog/tile.cpp
index b506109383cc8d2f7080ea9b0c94a9c8fca76da6,cf29ed77fd50423b2a97674c4346244b49256e17..fccf5c105bbcb01c1210e6fc147c169f857ad7f6
@@@ -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
@@@ -46,8 -46,8 +47,8 @@@ sp_compare_x_position(SPItem *first, SP
      using Geom::X;
      using Geom::Y;
  
-     Geom::OptRect a = first->getBounds(sp_item_i2doc_affine(first));
-     Geom::OptRect b = second->getBounds(sp_item_i2doc_affine(second));
+     Geom::OptRect a = first->getBounds(first->i2doc_affine());
+     Geom::OptRect b = second->getBounds(second->i2doc_affine());
  
      if ( !a || !b ) {
          // FIXME?
@@@ -86,8 -86,8 +87,8 @@@
  int
  sp_compare_y_position(SPItem *first, SPItem *second)
  {
-     Geom::OptRect a = first->getBounds(sp_item_i2doc_affine(first));
-     Geom::OptRect b = second->getBounds(sp_item_i2doc_affine(second));
+     Geom::OptRect a = first->getBounds(first->i2doc_affine());
+     Geom::OptRect b = second->getBounds(second->i2doc_affine());
  
      if ( !a || !b ) {
          // FIXME?
@@@ -159,14 -159,14 +160,14 @@@ 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;
      cnt=0;
      for (; items != NULL; items = items->next) {
          SPItem *item = SP_ITEM(items->data);
-         Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item));
+         Geom::OptRect b = item->getBounds(item->i2doc_affine());
          if (!b) {
              continue;
          }
          const GSList *sizes = sorted;
          for (; sizes != NULL; sizes = sizes->next) {
              SPItem *item = SP_ITEM(sizes->data);
-             Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item));
+             Geom::OptRect b = item->getBounds(item->i2doc_affine());
              if (b) {
                  width = b->dimensions()[Geom::X];
                  height = b->dimensions()[Geom::Y];
@@@ -316,7 -316,7 +317,7 @@@ g_print("\n row = %f     col = %f selec
               for (; current_row != NULL; current_row = current_row->next) {
                   SPItem *item=SP_ITEM(current_row->data);
                   Inkscape::XML::Node *repr = SP_OBJECT_REPR(item);
-                  Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item));
+                  Geom::OptRect b = item->getBounds(item->i2doc_affine());
                   Geom::Point min;
                   if (b) {
                       width = b->dimensions()[Geom::X];
                   // signs are inverted between x and y due to y inversion
                   Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y);
                   Geom::Matrix const affine = Geom::Matrix(Geom::Translate(move));
-                  sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine);
-                  sp_item_write_transform(item, repr, item->transform,  NULL);
+                  item->set_i2d_affine(item->i2d_affine() * affine);
+                  item->doWriteTransform(repr, item->transform,  NULL);
                   SP_OBJECT (current_row->data)->updateRepr();
                   cnt +=1;
               }
               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"));
  
  }
  
@@@ -885,4 -885,4 +886,4 @@@ TileDialog::TileDialog(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 ::
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 338e11d38bfca6896321f74798db7ad438ed7dd8,62f0f38aa18720df3956a40755ed690af2c179c8..c895f0be9d3650e92a745e7a19496a6bcd032b92
@@@ -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.
@@@ -26,7 -26,6 +27,7 @@@
  #include "selection-chemistry.h"
  #include "verbs.h"
  #include "preferences.h"
 +#include "sp-namedview.h"
  #include "sp-item-transform.h"
  #include "macros.h"
  #include "sp-item.h"
@@@ -80,27 -79,27 +81,27 @@@ Transformation::Transformation(
        _page_rotate            (4, 2),
        _page_skew              (4, 2),
        _page_transform         (3, 3),
 -      _scalar_move_horizontal (_("_Horizontal"), _("Horizontal displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
 +      _scalar_move_horizontal (_("_Horizontal:"), _("Horizontal displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
                                 "", "transform-move-horizontal", &_units_move),
 -      _scalar_move_vertical   (_("_Vertical"),  _("Vertical displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
 +      _scalar_move_vertical   (_("_Vertical:"),  _("Vertical displacement (relative) or position (absolute)"), UNIT_TYPE_LINEAR,
                                 "", "transform-move-vertical", &_units_move),
 -      _scalar_scale_horizontal(_("_Width"), _("Horizontal size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
 +      _scalar_scale_horizontal(_("_Width:"), _("Horizontal size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
                                 "", "transform-scale-horizontal", &_units_scale),
 -      _scalar_scale_vertical  (_("_Height"),  _("Vertical size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
 +      _scalar_scale_vertical  (_("_Height:"),  _("Vertical size (absolute or percentage of current)"), UNIT_TYPE_DIMENSIONLESS,
                                 "", "transform-scale-vertical", &_units_scale),
 -      _scalar_rotate          (_("A_ngle"), _("Rotation angle (positive = counterclockwise)"), UNIT_TYPE_RADIAL,
 +      _scalar_rotate          (_("A_ngle:"), _("Rotation angle (positive = counterclockwise)"), UNIT_TYPE_RADIAL,
                                 "", "transform-rotate", &_units_rotate),
 -      _scalar_skew_horizontal (_("_Horizontal"), _("Horizontal skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"), UNIT_TYPE_LINEAR,
 +      _scalar_skew_horizontal (_("_Horizontal:"), _("Horizontal skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"), UNIT_TYPE_LINEAR,
                                 "", "transform-skew-horizontal", &_units_skew),
 -      _scalar_skew_vertical   (_("_Vertical"),  _("Vertical skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"),  UNIT_TYPE_LINEAR,
 +      _scalar_skew_vertical   (_("_Vertical:"),  _("Vertical skew angle (positive = counterclockwise), or absolute displacement, or percentage displacement"),  UNIT_TYPE_LINEAR,
                                 "", "transform-skew-vertical", &_units_skew),
  
 -      _scalar_transform_a     ("_A", _("Transformation matrix element A")),
 -      _scalar_transform_b     ("_B", _("Transformation matrix element B")),
 -      _scalar_transform_c     ("_C", _("Transformation matrix element C")),
 -      _scalar_transform_d     ("_D", _("Transformation matrix element D")),
 -      _scalar_transform_e     ("_E", _("Transformation matrix element E")),
 -      _scalar_transform_f     ("_F", _("Transformation matrix element F")),
 +      _scalar_transform_a     ("_A:", _("Transformation matrix element A")),
 +      _scalar_transform_b     ("_B:", _("Transformation matrix element B")),
 +      _scalar_transform_c     ("_C:", _("Transformation matrix element C")),
 +      _scalar_transform_d     ("_D:", _("Transformation matrix element D")),
 +      _scalar_transform_e     ("_E:", _("Transformation matrix element E")),
 +      _scalar_transform_f     ("_F:", _("Transformation matrix element F")),
  
        _check_move_relative    (_("Rela_tive move"), _("Add the specified relative displacement to the current position; otherwise, edit the current absolute position directly")),
        _check_scale_proportional (_("Scale proportionally"), _("Preserve the width/height ratio of the scaled objects")),
@@@ -199,14 -198,6 +200,14 @@@ voi
  Transformation::layoutPageMove()
  {
      _units_move.setUnitType(UNIT_TYPE_LINEAR);
 +    
 +    // Setting default unit to document unit
 +    SPDesktop *dt = getDesktop();
 +    SPNamedView *nv = sp_desktop_namedview(dt);
 +    if (nv->doc_units) {
 +        _units_move.setUnit(nv->doc_units->abbr);
 +    }
 +    
      _scalar_move_horizontal.initScalar(-1e6, 1e6);
      _scalar_move_horizontal.setDigits(3);
      _scalar_move_horizontal.setIncrements(0.1, 1.0);
@@@ -471,9 -462,8 +472,9 @@@ Transformation::updatePageMove(Inkscape
                  double x = bbox->min()[Geom::X];
                  double y = bbox->min()[Geom::Y];
  
 -                _scalar_move_horizontal.setValue(x, "px");
 -                _scalar_move_vertical.setValue(y, "px");
 +                double conversion = _units_move.getConversion("px");
 +                _scalar_move_horizontal.setValue(x / conversion);
 +                _scalar_move_vertical.setValue(y / conversion);
              }
          } else {
              // do nothing, so you can apply the same relative move to many objects in turn
@@@ -636,7 -626,7 +637,7 @@@ Transformation::applyPageMove(Inkscape:
                       it != selected.end();
                       ++it)
                  {
-                     Geom::OptRect bbox = sp_item_bbox_desktop(*it);
+                     Geom::OptRect bbox = (*it)->getBboxDesktop();
                      if (bbox) {
                          sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.));
                      }
                       it != selected.end();
                       ++it)
                  {
-                     Geom::OptRect bbox = sp_item_bbox_desktop(*it);
+                     Geom::OptRect bbox = (*it)->getBboxDesktop();
                      if (bbox) {
                          sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.));
                      }
          }
      }
  
-     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
@@@ -704,7 -694,7 +705,7 @@@ Transformation::applyPageScale(Inkscape
              Geom::Scale scale (0,0);
              // the values are increments!
              if (_units_scale.isAbsolute()) {
-                 Geom::OptRect bbox(sp_item_bbox_desktop(item));
+                 Geom::OptRect bbox(item->getBboxDesktop());
                  if (bbox) {
                      double new_width = scaleX;
                      if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object
          }
      }
  
-     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
@@@ -791,7 -781,7 +792,7 @@@ Transformation::applyPageSkew(Inkscape:
              } else { // absolute displacement
                  double skewX = _scalar_skew_horizontal.getValue("px");
                  double skewY = _scalar_skew_vertical.getValue("px");
-                 Geom::OptRect bbox(sp_item_bbox_desktop(item));
+                 Geom::OptRect bbox(item->getBboxDesktop());
                  if (bbox) {
                      double width = bbox->dimensions()[Geom::X];
                      double height = bbox->dimensions()[Geom::Y];
          }
      }
  
-     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"));
  }
  
  
@@@ -845,15 -835,15 +846,15 @@@ Transformation::applyPageTransform(Inks
      if (_check_replace_matrix.get_active()) {
          for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
              SPItem *item = SP_ITEM(l->data);
-             sp_item_set_item_transform(item, displayed);
+             item->set_item_transform(displayed);
              SP_OBJECT(item)->updateRepr();
          }
      } else {
          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"));
  }
  
  
@@@ -881,8 -871,6 +882,8 @@@ Transformation::onMoveRelativeToggled(
      double x = _scalar_move_horizontal.getValue("px");
      double y = _scalar_move_vertical.getValue("px");
  
 +    double conversion = _units_move.getConversion("px");
 +
      //g_message("onMoveRelativeToggled: %f, %f px\n", x, y);
  
      Geom::OptRect bbox = selection->bounds();
      if (bbox) {
          if (_check_move_relative.get_active()) {
              // From absolute to relative
 -            _scalar_move_horizontal.setValue(x - bbox->min()[Geom::X], "px");
 -            _scalar_move_vertical.setValue(  y - bbox->min()[Geom::Y], "px");
 +            _scalar_move_horizontal.setValue((x - bbox->min()[Geom::X]) / conversion);
 +            _scalar_move_vertical.setValue((  y - bbox->min()[Geom::Y]) / conversion);
          } else {
              // From relative to absolute
 -            _scalar_move_horizontal.setValue(bbox->min()[Geom::X] + x, "px");
 -            _scalar_move_vertical.setValue(  bbox->min()[Geom::Y] + y, "px");
 +            _scalar_move_horizontal.setValue((bbox->min()[Geom::X] + x) / conversion);
 +            _scalar_move_vertical.setValue((  bbox->min()[Geom::Y] + y) / conversion);
          }
      }
  
@@@ -1080,4 -1068,4 +1081,4 @@@ Transformation::onApplySeparatelyToggle
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 111dc014d5841462475d78a7b6375a1349c76a38,9e092207211579e2a8fc694d24208046f71eaab9..17d0327581634fe5791dac201d220c6006922d4c
@@@ -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);
  
  
              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() )
  
              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);
  
@@@ -345,4 -345,4 +346,4 @@@ const CellRendererInt::Filter& UndoHist
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 82446b7b438247675bfc0b44117f4d551458851e,a455567e834ca2378f587ab7c1fc6966115bfd15..ef1c764bbb35c0f35161a42093fa59e2c0c1dad8
@@@ -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
@@@ -220,29 -220,11 +221,29 @@@ void MultiPathManipulator::invertSelect
  void MultiPathManipulator::setNodeType(NodeType type)
  {
      if (_selection.empty()) return;
 +
 +    // When all selected nodes are already cusp, retract their handles
 +    bool retract_handles = (type == NODE_CUSP);
 +
      for (ControlPointSelection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
          Node *node = dynamic_cast<Node*>(*i);
 -        if (node) node->setType(type);
 +        if (node) {
 +            retract_handles &= (node->type() == NODE_CUSP);
 +            node->setType(type);
 +        }
 +    }
 +
 +    if (retract_handles) {
 +        for (ControlPointSelection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
 +            Node *node = dynamic_cast<Node*>(*i);
 +            if (node) {
 +                node->front()->retract();
 +                node->back()->retract();
 +            }
 +        }
      }
 -    _done(_("Change node type"));
 +
 +    _done(retract_handles ? _("Retract handles") : _("Change node type"));
  }
  
  void MultiPathManipulator::setSegmentType(SegmentType type)
@@@ -262,12 -244,6 +263,12 @@@ void MultiPathManipulator::insertNodes(
      _done(_("Add nodes"));
  }
  
 +void MultiPathManipulator::duplicateNodes()
 +{
 +    invokeForAll(&PathManipulator::duplicateNodes);
 +    _done(_("Duplicate nodes"));
 +}
 +
  void MultiPathManipulator::joinNodes()
  {
      invokeForAll(&PathManipulator::hideDragPoint);
@@@ -537,12 -513,6 +538,12 @@@ bool MultiPathManipulator::event(GdkEve
                  return true;
              }
              break;
 +        case GDK_d:
 +        case GDK_D:
 +            if (held_only_shift(event->key)) {
 +                duplicateNodes();
 +                return true;
 +            }
          case GDK_j:
          case GDK_J:
              if (held_only_shift(event->key)) {
                  return true;
              }
              break;
 +        case GDK_l:
 +        case GDK_L:
 +            if (held_only_shift(event->key)) {
 +                // Shift+L - make segments linear
 +                setSegmentType(SEGMENT_STRAIGHT);
 +                return true;
 +            }
 +        case GDK_u:
 +        case GDK_U:
 +            if (held_only_shift(event->key)) {
 +                // Shift+L - make segments curves
 +                setSegmentType(SEGMENT_CUBIC_BEZIER);
 +                return true;
 +            }
          default:
              break;
          }
@@@ -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();
  }
  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();
  }
  
@@@ -758,4 -714,4 +759,4 @@@ guint32 MultiPathManipulator::_getOutli
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index e046fb57338b67f5ce9a28878c9ebbe91379113b,0b6d2168f6a600d0016c85b60d02ceb3629b32bd..8661e79465dbf13ef75c43501da10230c1d3eb5c
@@@ -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
@@@ -25,7 -25,6 +26,7 @@@
  #include "sp-mask.h"
  #include "sp-object-group.h"
  #include "sp-path.h"
 +#include "sp-text.h"
  #include "ui/tool/node-tool.h"
  #include "ui/tool/control-point-selection.h"
  #include "ui/tool/curve-drag-point.h"
   *   is to eventually use a common class for object and control point transforms.
   * - SelectableControlPoint: base for any type of selectable point. It can belong to only one
   *   selection.
 - * 
 + *
 + * @par Functionality that resides in weird places
 + * @par
 + *
 + * This list is probably incomplete.
 + * - Curve dragging: CurveDragPoint, controlled by PathManipulator
 + * - Single handle shortcuts: MultiPathManipulator::event(), ModifierTracker
 + * - Linear and spatial grow: Node, spatial grow routed to ControlPointSelection
 + * - Committing handle actions performed with the mouse: PathManipulator
 + * - Sculpting: ControlPointSelection
 + *
   * @par Plans for the future
   * @par
   * - MultiPathManipulator should become a generic shape editor that manages all active manipulator,
@@@ -175,7 -164,6 +176,7 @@@ void ink_node_tool_init(InkNodeTool *nt
      new (&nt->_multipath) MultiPathPtr();
      new (&nt->_selector) SelectorPtr();
      new (&nt->_path_data) PathSharedDataPtr();
 +    new (&nt->_shape_editors) ShapeEditors();
  }
  
  void ink_node_tool_dispose(GObject *object)
      nt->_multipath.~MultiPathPtr();
      nt->_selected_nodes.~CSelPtr();
      nt->_selector.~SelectorPtr();
 +    nt->_shape_editors.~ShapeEditors();
      
      Inkscape::UI::PathSharedData &data = *nt->_path_data;
      destroy_group(data.node_data.node_group);
      if (nt->_node_message_context) {
          delete nt->_node_message_context;
      }
 -    if (nt->shape_editor) {
 -        nt->shape_editor->unset_item(SH_KNOTHOLDER);
 -        delete nt->shape_editor;
 -    }
  
      G_OBJECT_CLASS(g_type_class_peek(g_type_parent(INK_TYPE_NODE_TOOL)))->dispose(object);
  }
@@@ -290,6 -281,9 +291,6 @@@ void ink_node_tool_setup(SPEventContex
      nt->flash_tempitem = NULL;
      nt->flashed_item = NULL;
      nt->_last_over = NULL;
 -    // TODO long term, fold ShapeEditor into MultiPathManipulator and rename MPM
 -    // to something better
 -    nt->shape_editor = new ShapeEditor(nt->desktop);
  
      // read prefs before adding items to selection to prevent momentarily showing the outline
      sp_event_context_read(nt, "show_handles");
@@@ -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?
          ShapeRecord r;
          r.item = item;
          // TODO add support for objectBoundingBox
-         r.edit_transform = base ? sp_item_i2doc_affine(base) : Geom::identity();
+         r.edit_transform = base ? base->i2doc_affine() : Geom::identity();
          r.role = role;
          if (s.insert(r).second) {
              // this item was encountered the first time
@@@ -409,30 -404,24 +411,30 @@@ void ink_node_tool_selection_changed(In
          }
      }
  
 -    // ugly hack: set the first editable non-path item for knotholder
 -    // maybe use multiple ShapeEditors for now, to allow editing many shapes at once?
 -    bool something_set = false;
 +    // use multiple ShapeEditors for now, to allow editing many shapes at once
 +    // needs to be rethought
 +    for (ShapeEditors::iterator i = nt->_shape_editors.begin();
 +         i != nt->_shape_editors.end(); )
 +    {
 +        ShapeRecord s;
 +        s.item = i->first;
 +        if (shapes.find(s) == shapes.end()) {
 +            nt->_shape_editors.erase(i++);
 +        } else {
 +            ++i;
 +        }
 +    }
 +
      for (std::set<ShapeRecord>::iterator i = shapes.begin(); i != shapes.end(); ++i) {
          ShapeRecord const &r = *i;
 -
 -              //XML Tree being used directly here while it shouldn't be.
 -        if (SP_IS_SHAPE(r.item) ||
 -            (SP_IS_PATH(r.item) && r.item->getRepr()->attribute("inkscape:original-d") != NULL))
 +        if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item)) &&
 +            nt->_shape_editors.find(r.item) == nt->_shape_editors.end())
          {
 -            nt->shape_editor->set_item(r.item, SH_KNOTHOLDER);
 -            something_set = true;
 -            break;
 +            ShapeEditor *si = new ShapeEditor(nt->desktop);
 +            si->set_item(r.item, SH_KNOTHOLDER);
 +            nt->_shape_editors.insert(const_cast<SPItem*&>(r.item), si);
          }
      }
 -    if (!something_set) {
 -        nt->shape_editor->unset_item(SH_KNOTHOLDER);
 -    }
  
      nt->_multipath->setItems(shapes);
      ink_node_tool_update_tip(nt, NULL);
@@@ -481,7 -470,7 +483,7 @@@ gint ink_node_tool_root_handler(SPEvent
  
              nt->flashed_item = over_item;
              SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(over_item));
-             c->transform(sp_item_i2d_affine(over_item));
+             c->transform(over_item->i2d_affine());
              SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c);
              sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash),
                  prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0,
@@@ -560,24 -549,19 +562,24 @@@ void ink_node_tool_update_tip(InkNodeTo
      unsigned sz = nt->_selected_nodes->size();
      unsigned total = nt->_selected_nodes->allPoints().size();
      if (sz != 0) {
 +        char *nodestring = g_strdup_printf(
 +            ngettext("<b>%u of %u</b> node selected.", "<b>%u of %u</b> nodes selected.", total),
 +            sz, total);
          if (nt->_last_over) {
 +            // TRANSLATORS: The %s below is where the "%u of %u nodes selected" sentence gets put
              char *dyntip = g_strdup_printf(C_("Node tool tip",
 -                "<b>%u of %u nodes</b> selected. "
 -                "Drag to select nodes, click to edit only this object (more: Shift)"), sz, total);
 +                "%s Drag to select nodes, click to edit only this object (more: Shift)"),
 +                nodestring);
              nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip);
              g_free(dyntip);
          } else {
              char *dyntip = g_strdup_printf(C_("Node tool tip",
 -                "<b>%u of %u nodes</b> selected. "
 -                "Drag to select nodes, click clear the selection"), sz, total);
 +                "%s Drag to select nodes, click clear the selection"),
 +                nodestring);
              nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip);
              g_free(dyntip);
          }
 +        g_free(nodestring);
      } else if (!nt->_multipath->empty()) {
          if (nt->_last_over) {
              nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip",
@@@ -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 {
@@@ -634,14 -617,8 +635,14 @@@ void ink_node_tool_select_point(InkNode
  
      if (item_clicked == NULL) { // nothing under cursor
          // if no Shift, deselect
 -        if (!(event->state & GDK_SHIFT_MASK)) {
 -            selection->clear();
 +        // if there are nodes selected, the first click should deselect the nodes
 +        // and the second should deselect the items
 +        if (!state_held_shift(event->state)) {
 +            if (nt->_selected_nodes->empty()) {
 +                selection->clear();
 +            } else {
 +                nt->_selected_nodes->clear();
 +            }
          }
      } else {
          if (held_shift(*event)) {
@@@ -683,4 -660,4 +684,4 @@@ void ink_node_tool_mouseover_changed(In
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index bb8ce0fb50722c41dfca5e658fb20ac5ac7e6e05,f102be1f73c34e93e2684439529dcf7032badc59..5ae9c4137255c7ab9cc1db66f7cb700045190448
@@@ -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
@@@ -108,7 -108,7 +109,7 @@@ PathManipulator::PathManipulator(MultiP
      , _path(path)
      , _spcurve(new SPCurve())
      , _dragpoint(new CurveDragPoint(*this))
-     , _observer(new PathManipulatorObserver(this, SP_OBJECT(path)->repr))
+     , /* XML Tree being used here directly while it shouldn't be*/_observer(new PathManipulatorObserver(this, SP_OBJECT(path)->getRepr()))
      , _edit_transform(et)
      , _num_selected(0)
      , _show_handles(true)
      , _lpe_key(lpe_key)
  {
      if (_lpe_key.empty()) {
-         _i2d_transform = sp_item_i2d_affine(SP_ITEM(path));
+         _i2d_transform = SP_ITEM(path)->i2d_affine();
      } else {
          _i2d_transform = Geom::identity();
      }
@@@ -319,39 -319,6 +320,39 @@@ void PathManipulator::insertNodes(
      }
  }
  
 +/** Insert new nodes exactly at the positions of selected nodes while preserving shape.
 + * This is equivalent to breaking, except that it doesn't split into subpaths. */
 +void PathManipulator::duplicateNodes()
 +{
 +    if (_num_selected == 0) return;
 +
 +    for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) {
 +        for (NodeList::iterator j = (*i)->begin(); j != (*i)->end(); ++j) {
 +            if (j->selected()) {
 +                NodeList::iterator k = j.next();
 +                Node *n = new Node(_multi_path_manipulator._path_data.node_data, *j);
 +
 +                // Move the new node to the bottom of the Z-order. This way you can drag all
 +                // nodes that were selected before this operation without deselecting
 +                // everything because there is a new node above.
 +                n->sink();
 +
 +                n->front()->setPosition(*j->front());
 +                j->front()->retract();
 +                j->setType(NODE_CUSP, false);
 +                (*i)->insert(k, n);
 +
 +                // We need to manually call the selection change callback to refresh
 +                // the handle display correctly.
 +                // This call changes num_selected, but we call this once for a selected node
 +                // and once for an unselected node, so in the end the number stays correct.
 +                _selectionChanged(j.ptr(), true);
 +                _selectionChanged(n, false);
 +            }
 +        }
 +    }
 +}
 +
  /** Replace contiguous selections of nodes in each subpath with one node. */
  void PathManipulator::weldNodes(NodeList::iterator preserve_pos)
  {
@@@ -992,8 -959,6 +993,8 @@@ NodeList::iterator PathManipulator::ext
  /** Called by the XML observer when something else than us modifies the path. */
  void PathManipulator::_externalChange(unsigned type)
  {
 +    hideDragPoint();
 +
      switch (type) {
      case PATH_CHANGE_D: {
          _getGeometry();
          } break;
      case PATH_CHANGE_TRANSFORM: {
          Geom::Matrix i2d_change = _d2i_transform;
-         _i2d_transform = sp_item_i2d_affine(SP_ITEM(_path));
+         _i2d_transform = SP_ITEM(_path)->i2d_affine();
          _d2i_transform = _i2d_transform.inverse();
          i2d_change *= _i2d_transform;
          for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) {
@@@ -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)
          return true;
      } else if (held_control(*event)) {
          // Ctrl+click: cycle between node types
 -        if (n->isEndNode()) {
 -            if (n->type() == NODE_CUSP) {
 -                n->setType(NODE_SMOOTH);
 -            } else {
 -                n->setType(NODE_CUSP);
 -            }
 -        } else {
 +        if (!n->isEndNode()) {
              n->setType(static_cast<NodeType>((n->type() + 1) % NODE_LAST_REAL_TYPE));
 +            update();
 +            _commit(_("Cycle node type"));
          }
 -        update();
 -        _commit(_("Cycle node type"));
          return true;
      }
      return false;
@@@ -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
@@@ -1443,10 -1419,7 +1449,10 @@@ void PathManipulator::_updateDragPoint(
      NodeList::iterator first = (*spi)->before(pvp->t, &fracpart);
      
      double stroke_tolerance = _getStrokeTolerance();
 -    if (Geom::distance(evp, nearest_point) < stroke_tolerance) {
 +    if (first && first.next() &&
 +        fracpart != 0.0 &&
 +        Geom::distance(evp, nearest_point) < stroke_tolerance)
 +    {
          _dragpoint->setVisible(true);
          _dragpoint->setPosition(_desktop->w2d(nearest_point));
          _dragpoint->setSize(2 * stroke_tolerance);
@@@ -1491,4 -1464,4 +1497,4 @@@ double PathManipulator::_getStrokeToler
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/ui/view/view.cpp
index 1b498a846ec018112149d37bbeb6dd1ce5ded556,1b498a846ec018112149d37bbeb6dd1ce5ded556..f05e024d19fd871971114fafe61deb5d10972782
@@@ -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() );
  }
  
  }}}
index b7a67b74419184b7879619c3f23fc466f879e297,48dd596858d7941ad9539b362dbd47631f110276..650ed10f6897dc8bb87991f6ffa4bdd5590780bf
@@@ -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;
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 968e35b6c053b3e1f7c584c55d279fb070781185,cc38de24fb495e93f3573755c4b9331fbdc42a6d..e191a93605cd82c582dbad1f415138b83378d37e
@@@ -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"
  
@@@ -56,7 -56,7 +59,7 @@@ EntityEntry::create (rdf_work_entity_t
  }
  
  EntityEntry::EntityEntry (rdf_work_entity_t* ent, Gtk::Tooltips& tt, Registry& wr)
 -: _label(Glib::ustring(_(ent->title))+":", 1.0, 0.5), _packable(0), 
 +: _label(Glib::ustring(_(ent->title)), 1.0, 0.5), _packable(0), 
    _entity(ent), _tt(&tt), _wr(&wr)
  {
  }
@@@ -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);
  }
  
index 71ba4428c5b6440466c5d718217cec3f52a9d595,f5dd3e9fafdd740f91edb520b375e364b0bb0e7f..c60e94ab724bc84fcf114dafbccc19b570b8133f
@@@ -4,6 -4,6 +4,7 @@@
   * Authors:
   *   Bob Jamison
   *   Other dudes from The Inkscape Organization
++ *   Abhishek Sharma
   *
   * Copyright (C) 2004 The Inkscape Organization
   *
@@@ -76,7 -76,7 +77,7 @@@ ImageIcon::ImageIcon(const ImageIcon &o
  ImageIcon::~ImageIcon()
  {
      if (document)
-         sp_document_unref(document);
+         document->doUnref();
  }
  
  
@@@ -98,11 -98,11 +99,11 @@@ bool ImageIcon::showSvgDocument(const S
  {
  
      if (document)
-         sp_document_unref(document);
+         document->doUnref();
  
      SPDocument *doc = (SPDocument *)docArg;
  
-     sp_document_ref(doc);
+     doc->doRef();
      document = doc;
  
      //This should remove it from the box, and free resources
@@@ -127,7 -127,7 +128,7 @@@ bool ImageIcon::showSvgFile(const Glib:
  
      fileName = Glib::filename_to_utf8(fileName);
  
-     SPDocument *doc = sp_document_new (fileName.c_str(), 0);
+     SPDocument *doc = SPDocument::createNewDoc (fileName.c_str(), 0);
      if (!doc) {
          g_warning("SVGView: error loading document '%s'\n", fileName.c_str());
          return false;
  
      showSvgDocument(doc);
  
-     sp_document_unref(doc);
+     doc->doUnref();
  
      return true;
  }
@@@ -148,7 -148,7 +149,7 @@@ bool ImageIcon::showSvgFromMemory(cons
          return false;
  
      gint len = (gint)strlen(xmlBuffer);
-     SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0);
+     SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0);
      if (!doc) {
          g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer);
          return false;
  
      showSvgDocument(doc);
  
-     sp_document_unref(doc);
+     doc->doUnref();
  
      return true;
  }
index 5fb8089b4a3b69fd4bd33ff528f40879c67a29df,da096f25d628de2e6981b57e7df092a881e891b1..6d1da0af09f660561e005a4c16beffc5533890e2
@@@ -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"));
      }
  }
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index a5f1d89be02b6ab48a6965c650270bef7e4dfd4e,a4a789840e710430d3bcb08cbc4ec81b8cc963bb..c9550bb27604c31167a344dcdb463f218c4ebdf1
@@@ -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();
index a9b4fe83e32f8954c8f50840a70c1f4d64ea4611,f5e4657b13e719a23a6dd444737cb9013d284a47..1de425da376b97856680a119645773f65f6017ea
@@@ -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
   *
@@@ -59,7 -59,7 +60,7 @@@ ObjectCompositeSettings::ObjectComposit
    _opacity_tag(Glib::ustring(history_prefix) + ":opacity"),
    _opacity_vbox(false, 0),
    _opacity_label_box(false, 0),
 -  _opacity_label(_("Opacity, %"), 0.0, 1.0, true),
 +  _opacity_label(_("Opacity (%):"), 0.0, 1.0, true),
    _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0),
    _opacity_hscale(_opacity_adjustment),
    _opacity_spin_button(_opacity_adjustment, 0.01, 1),
@@@ -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
@@@ -305,4 -305,4 +306,4 @@@ ObjectCompositeSettings::_subjectChange
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 724848ca5f17bc39f819c295410c2d7d6210c2f4,33adc85d0c5cb008d194057f27b23ef47873fbf0..f7cb6f145ea2518d2a46eaf218030ec824675676
@@@ -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
   *
@@@ -297,15 -297,6 +298,15 @@@ PageSizer::PageSizer(Registry & _wr
      _portraitButton.set_group (group);
      _portraitButton.set_active (true);
  
 +    // Setting default custom unit to document unit
 +    SPDesktop *dt = SP_ACTIVE_DESKTOP;
 +    SPNamedView *nv = sp_desktop_namedview(dt);
 +    if (nv->units) {
 +        _dimensionUnits.setUnit(nv->units);
 +    } else if (nv->doc_units) {
 +        _dimensionUnits.setUnit(nv->doc_units);
 +    }
 +    
      //## Set up custom size frame
      _customFrame.set_label(_("Custom size"));
      pack_start (_customFrame, false, false, 0);
@@@ -415,14 -406,14 +416,14 @@@ PageSizer::setDim (double w, double h, 
  
      if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) {
          SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP);
-         double const old_height = sp_document_height(doc);
-         sp_document_set_width (doc, w, &_px_unit);
-         sp_document_set_height (doc, h, &_px_unit);
+         double const old_height = doc->getHeight();
+         doc->setWidth (w, &_px_unit);
+         doc->setHeight (h, &_px_unit);
          // The origin for the user is in the lower left corner; this point should remain stationary when
          // 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 ) {
index db31d08d340288573c82cf06bf0ddb0251919dee,16422f1b2e1557e3acfc477f53c09875ab3ebdb4..04bd272856b2704feb2676071ad0fd97b5d8bcd7
@@@ -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);
  }
index 7aefbb90e4005d4cf343050ef12104ef837b0f0c,dec8cd111f30e17ba51f927ad84da32ca6abea16..efb5eb70edb3f1865ffaa3945f4a4ab945416d53
@@@ -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 --combined src/ui/widget/ruler.cpp
index 7f260680bb6b817a111b2c40050f4a408d5654d1,9fac481456d979702924d4e5d9e829df9bb1207b..107f4e8c6ef248088299a21f9094b280f5b2dee1
@@@ -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);
      }
@@@ -197,4 -197,4 +199,4 @@@ VRuler::~VRuler(
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 8e11c8308f10573b0c997b3f816a4548a3994d30,9a94113eb461311e488ec732cc817e445dec3b05..e7d8ac5a36bacd1188a2742c6ae02d05fb586290
@@@ -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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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() {
      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
@@@ -1030,8 -1030,8 +1031,8 @@@ SelectedStyle::update(
      case QUERY_STYLE_SINGLE:
      case QUERY_STYLE_MULTIPLE_AVERAGED:
      case QUERY_STYLE_MULTIPLE_SAME:
 -        _tooltips.set_tip(_opacity_place, _("Opacity, %"));
 -        _tooltips.set_tip(_opacity_sb, _("Opacity, %"));
 +        _tooltips.set_tip(_opacity_place, _("Opacity (%)"));
 +        _tooltips.set_tip(_opacity_sb, _("Opacity (%)"));
          if (_opacity_blocked) break;
          _opacity_blocked = true;
          _opacity_sb.set_sensitive(true);
@@@ -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")));
      }
  
index 09001a993223428bea45ebe19cc278e92ef13186,ab21ecf328d8752b8170c52d780ebca619073cd8..f4780896b239cbfc2e1426a4e58851f44b6a99d0
@@@ -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.
   */
@@@ -146,7 -146,7 +147,7 @@@ StyleSubject::iterator StyleSubject::Cu
  Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) {
      SPObject *layer = _getLayer();
      if (layer && SP_IS_ITEM(layer)) {
-         return sp_item_bbox_desktop(SP_ITEM(layer), type);
+         return SP_ITEM(layer)->getBboxDesktop(type);
      } else {
          return Geom::OptRect();
      }
@@@ -191,4 -191,4 +192,4 @@@ void StyleSubject::CurrentLayer::_after
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 3a36127f4d74bd733e271621fd91642bf2a9b2be,84c6a0de2be868e572afd25ab220aa70d7f11bb3..cc179ddbca55b37d8ef2039060906076e67d3866
@@@ -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 --combined src/unclump.cpp
index 3226160dc8bacfcacbd9a52f0a87a44bbb77c5fe,1d051bc6253709c670a7567b5cfeef8d4b9e33cb..1039351a334b6f780b6d8d222fa18da2f963cb1b
@@@ -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
@@@ -31,7 -31,7 +33,7 @@@ unclump_center (SPItem *item
          return i->second;
      }
  
-     Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item));
+     Geom::OptRect r = item->getBounds(item->i2d_affine());
      if (r) {
          Geom::Point const c = r->midpoint();
          c_cache[item->getId()] = c;
@@@ -50,7 -50,7 +52,7 @@@ unclump_wh (SPItem *item
      if ( i != wh_cache.end() ) {
          wh = i->second;
      } else {
-         Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item));
+         Geom::OptRect r = item->getBounds(item->i2d_affine());
          if (r) {
              wh = r->dimensions();
              wh_cache[item->getId()] = wh;
@@@ -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
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/uri-references.h
index a98c84153bf382603295d212b2f69444a4a2690d,e6399bfd97fa8c5a2f9d452ee70f01a62f4b940b..c0f9190b1967a6e84be76c2487b4321714921f27
@@@ -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.
@@@ -18,6 -18,7 +19,7 @@@
  
  #include "bad-uri-exception.h"
  #include "forward.h"
+ #include "sp-object.h"
  
  namespace Inkscape {
  
diff --combined src/vanishing-point.cpp
index d8e27debd009161902a462a1148e3a518aa6e3de,80f15fc5a7ab1ef0afd17c0818de17cfe79fb212..f8e991623ded868fcd43c373feff2f8311bd04b2
@@@ -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
   *
  #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
@@@ -78,7 -76,7 +79,7 @@@ have_VPs_of_same_perspective (VPDragge
  }
  
  static void
 -vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint state, gpointer data)
 +vp_knot_moved_handler (SPKnot *knot, Geom::Point const *ppointer, guint state, gpointer data)
  {
      VPDragger *dragger = (VPDragger *) data;
      VPDrag *drag = dragger->parent;
              }
              // 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;
          }
      }
                  //       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;
              }
          }
 -    }
  
 +        // We didn't snap to another dragger, so we'll try a regular snap
 +        SPDesktop *desktop = inkscape_active_desktop();
 +        SnapManager &m = desktop->namedview->snap_manager;
 +        m.setup(desktop);
 +        Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE));
 +        m.unSetup();
 +        if (s.getSnapped()) {
 +            p = s.getPoint();
 +            sp_knot_moveto(knot, p);
 +        }
 +    }
  
 -    dragger->point = p; // FIXME: Brauchen wir dragger->point Ã¼berhaupt?
 +    dragger->point = p; // FIXME: Is dragger->point being used at all?
  
      dragger->updateVPs(p);
      dragger->updateBoxDisplays();
@@@ -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;
@@@ -787,4 -775,4 +788,4 @@@ VPDrag::addLine (Geom::Point p1, Geom::
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/verbs.cpp
index 8b5ec9b3bc8d57a7ca0fd23d1e563d96467f4f2f,5c35c1e51900c9919d3c31bdc427021392e16af0..a218e85dbf7d5359083ebcbbf56e717898bf93ca
@@@ -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
@@@ -63,7 -63,6 +63,7 @@@
  #include "selection-chemistry.h"
  #include "seltrans.h"
  #include "shape-editor.h"
 +#include "shortcuts.h"
  #include "sp-flowtext.h"
  #include "sp-guide.h"
  #include "splivarot.h"
@@@ -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
@@@ -335,15 -334,7 +337,15 @@@ Verb::VerbIDTable Verb::_verb_ids
      in the \c _verbs hashtable which is indexed by the \c code.
  */
  Verb::Verb(gchar const *id, gchar const *name, gchar const *tip, gchar const *image) :
 -    _actions(NULL), _id(id), _name(name), _tip(tip), _image(image)
 +    _actions(0),
 +    _id(id),
 +    _name(name),
 +    _tip(tip),
 +    _full_tip(0),
 +    _shortcut(0),
 +    _image(image),
 +    _code(0),
 +    _default_sensitive(false)
  {
      static int count = SP_VERB_LAST;
  
      _code = count;
      _verbs.insert(VerbTable::value_type(count, this));
      _verb_ids.insert(VerbIDTable::value_type(_id, this));
 -
 -    return;
  }
  
  /** \brief  Destroy a verb.
@@@ -365,10 -358,7 +367,10 @@@ Verb::~Verb(void
          delete _actions;
      }
  
 -    return;
 +    if (_full_tip) {
 +        g_free(_full_tip);
 +        _full_tip = 0;
 +    }
  }
  
  /** \brief  Verbs are no good without actions.  This is a place holder
@@@ -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."));
              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."));
              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:
                      break;
              }
  
--            if ( SP_OBJECT_NEXT(layer) != old_pos ) {
++            if ( layer->getNext() != old_pos ) {
                  char const *message = NULL;
                  Glib::ustring description = "";
                  switch (verb) {
                          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);
                  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);
                      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."));
                      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."));
                  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);
@@@ -1712,9 -1683,9 +1715,9 @@@ ZoomVerb::perform(SPAction *action, voi
          case SP_VERB_VIEW_MODE_OUTLINE:
              dt->setDisplayModeOutline();
              break;
 -        case SP_VERB_VIEW_MODE_PRINT_COLORS_PREVIEW:
 -            dt->setDisplayModePrintColorsPreview();
 -            break;
 +//        case SP_VERB_VIEW_MODE_PRINT_COLORS_PREVIEW:
 +//            dt->setDisplayModePrintColorsPreview();
 +//            break;
          case SP_VERB_VIEW_MODE_TOGGLE:
              dt->displayModeToggle();
              break;
@@@ -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;
@@@ -2326,8 -2297,8 +2329,8 @@@ Verb *Verb::_base_verbs[] = 
                   N_("Deselect any selected objects or nodes"), INKSCAPE_ICON_EDIT_SELECT_NONE),
      new EditVerb(SP_VERB_EDIT_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("_Guides Around Page"),
                   N_("Create four guides aligned with the page borders"), NULL),
 -    new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next Path Effect Parameter"),
 -                 N_("Show next Path Effect parameter for editing"), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT),
 +    new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"),
 +                 N_("Show next editable path effect parameter"), INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT),
  
      /* Selection */
      new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"),
      new ZoomVerb(SP_VERB_TOGGLE_SCROLLBARS, "ToggleScrollbars", N_("Scroll_bars"), N_("Show or hide the canvas scrollbars"), NULL),
      new ZoomVerb(SP_VERB_TOGGLE_GRID, "ToggleGrid", N_("_Grid"), N_("Show or hide the grid"), INKSCAPE_ICON_SHOW_GRID),
      new ZoomVerb(SP_VERB_TOGGLE_GUIDES, "ToggleGuides", N_("G_uides"), N_("Show or hide guides (drag from a ruler to create a guide)"), INKSCAPE_ICON_SHOW_GUIDES),
 -    new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Toggle snapping on or off"), INKSCAPE_ICON_SNAP),
 +    new ZoomVerb(SP_VERB_TOGGLE_SNAPPING, "ToggleSnapGlobal", N_("Snap"), N_("Enable snapping"), INKSCAPE_ICON_SNAP),
      new ZoomVerb(SP_VERB_ZOOM_NEXT, "ZoomNext", N_("Nex_t Zoom"), N_("Next zoom (from the history of zooms)"),
                   INKSCAPE_ICON_ZOOM_NEXT),
      new ZoomVerb(SP_VERB_ZOOM_PREV, "ZoomPrev", N_("Pre_vious Zoom"), N_("Previous zoom (from the history of zooms)"),
                   N_("Switch to normal display without filters"), NULL),
      new ZoomVerb(SP_VERB_VIEW_MODE_OUTLINE, "ViewModeOutline", N_("_Outline"),
                   N_("Switch to outline (wireframe) display mode"), NULL),
 -    new ZoomVerb(SP_VERB_VIEW_MODE_PRINT_COLORS_PREVIEW, "ViewModePrintColorsPreview", N_("_Print Colors Preview"),
 -                 N_("Switch to print colors preview mode"), NULL),
 +//    new ZoomVerb(SP_VERB_VIEW_MODE_PRINT_COLORS_PREVIEW, "ViewModePrintColorsPreview", N_("_Print Colors Preview"),
 +//                 N_("Switch to print colors preview mode"), NULL),
      new ZoomVerb(SP_VERB_VIEW_MODE_TOGGLE, "ViewModeToggle", N_("_Toggle"),
                   N_("Toggle between normal and outline display modes"), NULL),
  
      new DialogVerb(SP_VERB_DIALOG_METADATA, "DialogMetadata", N_("Document _Metadata..."),
                     N_("Edit document metadata (to be saved with the document)"), INKSCAPE_ICON_DOCUMENT_METADATA ),
      new DialogVerb(SP_VERB_DIALOG_FILL_STROKE, "DialogFillStroke", N_("_Fill and Stroke..."),
 -                   N_("Edit objects' colors, gradients, stroke width, arrowheads, dash patterns..."), INKSCAPE_ICON_DIALOG_FILL_AND_STROKE),
 +                   N_("Edit objects' colors, gradients, arrowheads, and other fill and stroke properties..."), INKSCAPE_ICON_DIALOG_FILL_AND_STROKE),
      new DialogVerb(SP_VERB_DIALOG_GLYPHS, "DialogGlyphs", N_("Glyphs..."),
                     N_("Select characters from a glyphs palette"), GTK_STOCK_SELECT_FONT),
      // TRANSLATORS: "Swatches" means: color samples
@@@ -2768,4 -2739,4 +2771,4 @@@ Verb::list (void) 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index d447abf2e1872a4a1010e9887df9cf1fc186c006,591ea62531ed0add2689ab3aa119bf080f2c7059..7a3e337ded52557484b94d5f626b51bbe21ae2f3
@@@ -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
@@@ -41,7 -41,6 +41,7 @@@
  #include <extension/db.h>
  #include "file.h"
  #include "helper/units.h"
 +#include "helper/unit-tracker.h"
  #include "inkscape-private.h"
  #include "interface.h"
  #include "macros.h"
@@@ -70,7 -69,7 +70,7 @@@
  using Inkscape::round;
  #endif
  
 -
 +using Inkscape::UnitTracker;
  using Inkscape::UI::UXManager;
  using Inkscape::UI::ToolboxFactory;
  
@@@ -326,7 -325,7 +326,7 @@@ void SPDesktopWidget::init( SPDesktopWi
      dtw->hbox = gtk_hbox_new(FALSE, 0);
      gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 );
      gtk_widget_show(dtw->hbox);
 -
 + 
      dtw->aux_toolbox = ToolboxFactory::createAuxToolbox();
      gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0);
  
@@@ -709,8 -708,8 +709,8 @@@ sp_desktop_widget_realize (GtkWidget *w
      NRRect d;
      d.x0 = 0.0;
      d.y0 = 0.0;
-     d.x1 = sp_document_width (dtw->desktop->doc());
-     d.y1 = sp_document_height (dtw->desktop->doc());
+     d.x1 = (dtw->desktop->doc())->getWidth ();
+     d.y1 = (dtw->desktop->doc())->getHeight ();
  
      if ((fabs (d.x1 - d.x0) < 1.0) || (fabs (d.y1 - d.y0) < 1.0)) return;
  
@@@ -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);
  
              {
                  Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
  
-                 sp_document_ref(doc);
+                 doc->doRef();
                  sp_namedview_document_from_window(desktop);
                  if (sp_file_save_document(*window, doc)) {
-                     sp_document_unref(doc);
+                     doc->doUnref();
                  } else { // save dialog cancelled or save failed
-                     sp_document_unref(doc);
+                     doc->doUnref();
                      return TRUE;
                  }
  
          }
          /* 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
                  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);
              switch (response) {
              case GTK_RESPONSE_YES:
              {
-                 sp_document_ref(doc);
+                 doc->doRef();
  
                  Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
  
                  if (sp_file_save_dialog(*window, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG)) {
-                     sp_document_unref(doc);
+                     doc->doUnref();
                  } else { // save dialog cancelled or save failed
-                     sp_document_unref(doc);
+                     doc->doUnref();
                      return TRUE;
                  }
  
@@@ -1511,40 -1510,6 +1511,40 @@@ void SPDesktopWidget::namedviewModified
          sp_ruler_set_metric(GTK_RULER (this->vruler), nv->getDefaultMetric());
          sp_ruler_set_metric(GTK_RULER (this->hruler), nv->getDefaultMetric());
  
 +        /* This loops through all the grandchildren of aux toolbox,
 +         * and for each that it finds, it performs an sp_search_by_data_recursive(),
 +         * looking for widgets that hold some "tracker" data (this is used by
 +         * all toolboxes to refer to the unit selector). The default document units 
 +         * is then selected within these unit selectors.
 +         *
 +         * Of course it would be nice to be able to refer to the toolbox and the
 +         * unit selector directly by name, but I don't yet see a way to do that.
 +         * 
 +         * This should solve: https://bugs.launchpad.net/inkscape/+bug/362995
 +         */
 +        if (GTK_IS_CONTAINER(aux_toolbox)) {
 +            GList *ch = gtk_container_get_children (GTK_CONTAINER(aux_toolbox));
 +            for (GList *i = ch; i != NULL; i = i->next) {
 +                if (GTK_IS_CONTAINER(i->data)) {
 +                    GList *grch = gtk_container_get_children (GTK_CONTAINER(i->data));
 +                    for (GList *j = grch; j != NULL; j = j->next) {                        
 +                        if (!GTK_IS_WIDGET(j->data)) // wasn't a widget
 +                            continue;
 +
 +                        gpointer t = sp_search_by_data_recursive(GTK_WIDGET(j->data), (gpointer) "tracker");
 +                        if (t == NULL) // didn't find any tracker data
 +                            continue;
 +
 +                        UnitTracker *tracker = reinterpret_cast<UnitTracker*>( t );
 +                        if (tracker == NULL) // it's null when inkscape is first opened
 +                            continue;
 +
 +                        tracker->setActiveUnit( nv->doc_units );
 +                    } // grandchildren
 +                } // if child is a container
 +            } // children
 +        } // if aux_toolbox is a container
 +
          gtk_tooltips_set_tip(this->tt, this->hruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL);
          gtk_tooltips_set_tip(this->tt, this->vruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL);
  
@@@ -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 );
@@@ -1837,11 -1802,11 +1837,11 @@@ sp_desktop_widget_update_scrollbars (SP
  
      /* The desktop region we always show unconditionally */
      SPDocument *doc = dtw->desktop->doc();
-     Geom::Rect darea ( Geom::Point(-sp_document_width(doc), -sp_document_height(doc)),
-                      Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc))  );
+     Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()),
+                      Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight())  );
      SPObject* root = doc->root;
      SPItem* item = SP_ITEM(root);
-     Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
+     Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop());
  
      /* Canvas region we always show unconditionally */
      Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),
index 33f2a6ae717586c686b1f95efb8cb689ef365ed2,6aa2a1ed5e038fb62db7e67cf51285ec24a38568..4edd434afc503bcd73b357af47f93480b0cfa318
@@@ -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
   */
  
@@@ -17,6 -17,7 +18,7 @@@
  #include "display/display-forward.h"
  #include "libnr/nr-point.h"
  #include "forward.h"
+ #include "sp-object.h"
  #include "message.h"
  #include "ui/view/view-widget.h"
  #include "ui/view/edit-widget-interface.h"
index b70c8f47d8e6da161fe824571ab5c175470963ec,e4db09c90c244e775d8ec0f4a23c0ef34092753a..b4272a3a47227afdff671ac880d22641c0d759fb
@@@ -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;
          }
  
              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
                  SPGradientType const gradient_type = ( psel->mode != SPPaintSelector::MODE_GRADIENT_RADIAL
                                                         ? SP_GRADIENT_TYPE_LINEAR
                                                         : SP_GRADIENT_TYPE_RADIAL );
 +                bool createSwatch = (psel->mode == SPPaintSelector::MODE_SWATCH);
  
                  SPCSSAttr *css = 0;
                  if (kind == FILL) {
  
                      SPStyle *query = sp_style_new(desktop->doc());
                      int result = objects_query_fillstroke(const_cast<GSList *>(items), query, kind == FILL);
 -                    SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
 -                    guint32 common_rgb = 0;
                      if (result == QUERY_STYLE_MULTIPLE_SAME) {
 +                        SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
 +                        SPColor common;
                          if (!targPaint.isColor()) {
 -                            common_rgb = sp_desktop_get_color(desktop, kind == FILL);
 +                            common = sp_desktop_get_color(desktop, kind == FILL);
                          } else {
 -                            common_rgb = targPaint.value.color.toRGBA32( 0xff );
 +                            common = targPaint.value.color;
 +                        }
 +                        vector = sp_document_default_gradient_vector( document, common, createSwatch );
 +                        if ( vector && createSwatch ) {
 +                            vector->setSwatch();
                          }
 -                        vector = sp_document_default_gradient_vector(document, common_rgb);
                      }
                      sp_style_unref(query);
  
                      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) {
 +                            SPGradient *gr = sp_gradient_vector_for_object( document, desktop, reinterpret_cast<SPObject*>(i->data), kind == FILL, createSwatch );
 +                            if ( gr && createSwatch ) {
 +                                gr->setSwatch();
 +                            }
                              sp_item_set_gradient(SP_ITEM(i->data),
 -                                                 sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), kind == FILL),
 +                                                 gr,
                                                   gradient_type, kind == FILL);
                          } else {
                              sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL);
                      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);
                      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;
  
                       */
  
                  } 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);
                      // 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;
                          }
 -                        SPObject *selobj = SP_OBJECT(i->data);
 +                        SPObject *selobj = reinterpret_cast<SPObject*>(i->data);
  
 -                        SPStyle *style = SP_OBJECT_STYLE(selobj);
 +                        SPStyle *style = selobj->style;
                          if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) {
 -                            SPObject *server = (kind == FILL) ?
 -                                SP_OBJECT_STYLE_FILL_SERVER(selobj) :
 -                                SP_OBJECT_STYLE_STROKE_SERVER(selobj);
 +                            SPPaintServer *server = (kind == FILL) ?
 +                                selobj->style->getFillPaintServer() :
 +                                selobj->style->getStrokePaintServer();
                              if (SP_IS_PATTERN(server) && pattern_getroot(SP_PATTERN(server)) == pattern)
                                  // only if this object's pattern is not rooted in our selected pattern, apply
                                  continue;
  
                  } // 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;
                  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;
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 5b663c49302a284fbd02ce79d98ba2d1cad94930,77defa5c9d4290b483924e648ea13189c85dd771..49549de1c51d49e19a7b26122e1b671757774f93
@@@ -117,10 -117,10 +117,10 @@@ sp_gradient_selector_class_init (SPGrad
      object_class->destroy = sp_gradient_selector_destroy;
  }
  
 -static void
 -sp_gradient_selector_init (SPGradientSelector *sel)
 +static void sp_gradient_selector_init(SPGradientSelector *sel)
  {
 -    GtkWidget *hb, *m, *mi;
 +    sel->safelyInit = true;
 +    new (&sel->nonsolid) std::vector<GtkWidget*>();
  
      sel->mode = SPGradientSelector::MODE_LINEAR;
  
      g_signal_connect (G_OBJECT (sel->vectors), "vector_set", G_CALLBACK (sp_gradient_selector_vector_set), sel);
  
      /* Create box for buttons */
 -    hb = gtk_hbox_new (FALSE, 0);
 -    gtk_box_pack_start (GTK_BOX (sel), hb, FALSE, FALSE, 0);
 +    GtkWidget *hb = gtk_hbox_new( FALSE, 0 );
 +    sel->nonsolid.push_back(hb);
 +    gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 );
      GtkTooltips *ttips = gtk_tooltips_new ();
  
      sel->add = gtk_button_new_with_label (_("Duplicate"));
 +    sel->nonsolid.push_back(sel->add);
      gtk_box_pack_start (GTK_BOX (hb), sel->add, TRUE, TRUE, 0);
      g_signal_connect (G_OBJECT (sel->add), "clicked", G_CALLBACK (sp_gradient_selector_add_vector_clicked), sel);
      gtk_widget_set_sensitive (sel->add, FALSE);
  
      sel->edit = gtk_button_new_with_label (_("Edit..."));
 +    sel->nonsolid.push_back(sel->edit);
      gtk_box_pack_start (GTK_BOX (hb), sel->edit, TRUE, TRUE, 0);
      g_signal_connect (G_OBJECT (sel->edit), "clicked", G_CALLBACK (sp_gradient_selector_edit_vector_clicked), sel);
      gtk_widget_set_sensitive (sel->edit, FALSE);
  
 -    gtk_widget_show_all (hb);
 +    gtk_widget_show_all(hb);
  
      /* Spread selector */
 -    hb = gtk_hbox_new (FALSE, 0);
 -    gtk_widget_show (hb);
 -    gtk_box_pack_start (GTK_BOX (sel), hb, FALSE, FALSE, 0);
 -
 -    sel->spread = gtk_option_menu_new ();
 -    gtk_widget_show (sel->spread);
 -    gtk_box_pack_end (GTK_BOX (hb), sel->spread, FALSE, FALSE, 0);
 -    gtk_tooltips_set_tip (ttips, sel->spread,
 +    hb = gtk_hbox_new( FALSE, 0 );
 +    sel->nonsolid.push_back(hb);
 +    gtk_widget_show(hb);
 +    gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 );
 +
 +    sel->spread = gtk_option_menu_new();
 +    sel->nonsolid.push_back(sel->spread);
 +    gtk_widget_show(sel->spread);
 +    gtk_box_pack_end( GTK_BOX(hb), sel->spread, FALSE, FALSE, 0 );
 +    gtk_tooltips_set_tip( ttips, sel->spread,
                            // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute
                            _("Whether to fill with flat color beyond the ends of the gradient vector "
                              "(spreadMethod=\"pad\"), or repeat the gradient in the same direction "
                              "(spreadMethod=\"repeat\"), or repeat the gradient in alternating opposite "
                              "directions (spreadMethod=\"reflect\")"), NULL);
  
 -    m = gtk_menu_new ();
 -    mi = gtk_menu_item_new_with_label (_("none"));
 +    GtkWidget *m = gtk_menu_new();
 +    GtkWidget *mi = gtk_menu_item_new_with_label(_("none"));
      gtk_menu_append (GTK_MENU (m), mi);
      g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_PAD));
      g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel);
      gtk_menu_append (GTK_MENU (m), mi);
      gtk_widget_show_all (m);
  
 -    gtk_option_menu_set_menu (GTK_OPTION_MENU (sel->spread), m);
 +    gtk_option_menu_set_menu( GTK_OPTION_MENU(sel->spread), m );
  
 -    sel->spreadLbl = gtk_label_new (_("Repeat:"));
 -    gtk_widget_show(sel->spreadLbl);
 -    gtk_box_pack_end(GTK_BOX(hb), sel->spreadLbl, FALSE, FALSE, 4);
 +    sel->spreadLbl = gtk_label_new( _("Repeat:") );
 +    sel->nonsolid.push_back(sel->spreadLbl);
 +    gtk_widget_show( sel->spreadLbl );
 +    gtk_box_pack_end( GTK_BOX(hb), sel->spreadLbl, FALSE, FALSE, 4 );
  }
  
 -static void
 -sp_gradient_selector_destroy (GtkObject *object)
 +static void sp_gradient_selector_destroy(GtkObject *object)
  {
 -    SPGradientSelector *sel;
 +    SPGradientSelector *sel = SP_GRADIENT_SELECTOR( object );
  
 -    sel = SP_GRADIENT_SELECTOR (object);
 +    if ( sel->safelyInit ) {
 +        sel->safelyInit = false;
 +        using std::vector;
 +        sel->nonsolid.~vector<GtkWidget*>();
 +    }
  
 -    if (((GtkObjectClass *) (parent_class))->destroy)
 +    if (((GtkObjectClass *) (parent_class))->destroy) {
          (* ((GtkObjectClass *) (parent_class))->destroy) (object);
 +    }
  }
  
  GtkWidget *
@@@ -218,15 -208,26 +218,15 @@@ sp_gradient_selector_new (void
      return (GtkWidget *) sel;
  }
  
 -static void removeWidget( GtkWidget *& widget )
 -{
 -    if (widget) {
 -        GtkWidget *parent = gtk_widget_get_parent(widget);
 -        if (parent) {
 -            gtk_container_remove(GTK_CONTAINER(parent), widget);
 -            widget = 0;
 -        }
 -    }
 -}
 -
  void SPGradientSelector::setMode(SelectorMode mode)
  {
      if (mode != this->mode) {
          this->mode = mode;
          if (mode == MODE_SWATCH) {
 -            removeWidget(add);
 -            removeWidget(edit);
 -            removeWidget(spread);
 -            removeWidget(spreadLbl);
 +            for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
 +            {
 +                gtk_widget_hide(*it);
 +            }
  
              SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors);
              vs->setSwatched();
@@@ -268,20 -269,6 +268,20 @@@ void SPGradientSelector::setVector(SPDo
      sp_gradient_vector_selector_set_gradient(SP_GRADIENT_VECTOR_SELECTOR(vectors), doc, vector);
  
      if (vector) {
 +        if ( (mode == MODE_SWATCH) && vector->isSwatch() ) {
 +            if ( vector->isSolid() ) {
 +                for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
 +                {
 +                    gtk_widget_hide(*it);
 +                }
 +            } else {
 +                for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
 +                {
 +                    gtk_widget_show_all(*it);
 +                }
 +            }
 +        }
 +
          if (edit) {
              gtk_widget_set_sensitive(edit, TRUE);
          }
@@@ -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;
  
index ce5f5fb8f5e90fadc0607dc22aae14920b740f33,a5543990838de8d2030758b5ff8ac6f29e80b836..e7596ead42e5c99c2057b43e263b24ff616a877f
@@@ -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     ##
@@@ -73,17 -73,18 +75,17 @@@ static void gr_toggle_fillstroke (GtkWi
      }
  }
  
 -void
 -gr_apply_gradient_to_item (SPItem *item, SPGradient *gr, SPGradientType new_type, guint new_fill, bool do_fill, bool do_stroke)
 +void gr_apply_gradient_to_item( SPItem *item, SPGradient *gr, SPGradientType new_type, guint new_fill, bool do_fill, bool do_stroke )
  {
 -    SPStyle *style = SP_OBJECT_STYLE (item);
 +    SPStyle *style = item->style;
  
      if (do_fill) {
          if (style && (style->fill.isPaintserver()) &&
 -            SP_IS_GRADIENT (SP_OBJECT_STYLE_FILL_SERVER (item))) {
 -            SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
 -            if (SP_IS_LINEARGRADIENT (server)) {
 +            SP_IS_GRADIENT( item->style->getFillPaintServer() )) {
 +            SPPaintServer *server = item->style->getFillPaintServer();
 +            if ( SP_IS_LINEARGRADIENT(server) ) {
                  sp_item_set_gradient(item, gr, SP_GRADIENT_TYPE_LINEAR, true);
 -            } else if (SP_IS_RADIALGRADIENT (server)) {
 +            } else if ( SP_IS_RADIALGRADIENT(server) ) {
                  sp_item_set_gradient(item, gr, SP_GRADIENT_TYPE_RADIAL, true);
              }
          } else if (new_fill) {
  
      if (do_stroke) {
          if (style && (style->stroke.isPaintserver()) &&
 -            SP_IS_GRADIENT (SP_OBJECT_STYLE_STROKE_SERVER (item))) {
 -            SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
 -            if (SP_IS_LINEARGRADIENT (server)) {
 +            SP_IS_GRADIENT( item->style->getStrokePaintServer() )) {
 +            SPPaintServer *server = item->style->getStrokePaintServer();
 +            if ( SP_IS_LINEARGRADIENT(server) ) {
                  sp_item_set_gradient(item, gr, SP_GRADIENT_TYPE_LINEAR, false);
 -            } else if (SP_IS_RADIALGRADIENT (server)) {
 +            } else if ( SP_IS_RADIALGRADIENT(server) ) {
                  sp_item_set_gradient(item, gr, SP_GRADIENT_TYPE_RADIAL, false);
              }
          } else if (!new_fill) {
@@@ -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() ) {
  
              GtkWidget *hb = gtk_hbox_new (FALSE, 4);
              GtkWidget *l = gtk_label_new ("");
 -            gchar *label = gr_prepare_label (SP_OBJECT(gradient));
 +            gchar *label = gr_prepare_label(gradient);
              gtk_label_set_markup (GTK_LABEL(l), label);
              g_free (label);
              gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
@@@ -309,11 -310,11 +311,11 @@@ void gr_read_selection( Inkscape::Selec
     // If no selected dragger, read desktop selection
     for (GSList const* i = selection->itemList(); i; i = i->next) {
          SPItem *item = SP_ITEM(i->data);
 -        SPStyle *style = SP_OBJECT_STYLE (item);
 +        SPStyle *style = item->style;
  
          if (style && (style->fill.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
 -            if (SP_IS_GRADIENT(server)) {
 +            SPPaintServer *server = item->style->getFillPaintServer();
 +            if ( SP_IS_GRADIENT(server) ) {
                  SPGradient *gradient = SP_GRADIENT(server)->getVector();
                  SPGradientSpread spread = SP_GRADIENT(server)->fetchSpread();
  
              }
          }
          if (style && (style->stroke.isPaintserver())) {
 -            SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
 -            if (SP_IS_GRADIENT(server)) {
 +            SPPaintServer *server = item->style->getStrokePaintServer();
 +            if ( SP_IS_GRADIENT(server) ) {
                  SPGradient *gradient = SP_GRADIENT(server)->getVector();
                  SPGradientSpread spread = SP_GRADIENT(server)->fetchSpread();
  
                  if (gradient && gradient->isSolid()) {
                      gradient = 0;
 -
                  }
  
                  if (gradient && (gradient != gr_selected)) {
index 76bb9b8e1c9b63fa3473d092b723836a18d4e1bc,ffa5b12dd11392c6d56f827e348359fac0d5e56c..1be0aae8e658e5f7f0acf4d8303b5a55e4338b56
@@@ -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
@@@ -174,10 -174,6 +177,10 @@@ GtkWidget *sp_gradient_vector_selector_
  
  void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr)
  {
 +//     g_message("sp_gradient_vector_selector_set_gradient(%p, %p, %p) [%s] %d %d", gvs, doc, gr,
 +//               (gr ? gr->getId():"N/A"),
 +//               (gr ? gr->isSwatch() : -1),
 +//               (gr ? gr->isSolid() : -1));
      static gboolean suppress = FALSE;
  
      g_return_if_fail(gvs != NULL);
@@@ -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);
      }
          /* 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);
      xml_doc = SP_OBJECT_REPR(gradient)->document();
  
      if (i < 1) {
 -        gchar c[64];
 -        sp_svg_write_color(c, sizeof(c), 0x00000000);
 -
          Inkscape::CSSOStringStream os;
 -        os << "stop-color:" << c << ";stop-opacity:" << 1.0 << ";";
 +        os << "stop-color: #000000;stop-opacity:" << 1.0 << ";";
  
          Inkscape::XML::Node *child;
  
  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);
              }
      } else {
  
          for (; sl != NULL; sl = sl->next){
 -            SPStop *stop;
 -            GtkWidget *i;
              if (SP_IS_STOP(sl->data)){
 -                stop = SP_STOP(sl->data);
 -                i = gtk_menu_item_new();
 +                SPStop *stop = SP_STOP(sl->data);
 +                GtkWidget *i = gtk_menu_item_new();
                  gtk_widget_show(i);
                  g_object_set_data(G_OBJECT(i), "stop", stop);
                  GtkWidget *hb = gtk_hbox_new(FALSE, 4);
@@@ -600,8 -600,11 +603,8 @@@ static void sp_grad_edit_select(GtkOpti
      blocked = TRUE;
  
      SPColorSelector *csel = (SPColorSelector*)g_object_get_data(G_OBJECT(tbl), "cselector");
 -    guint32 const c = sp_stop_get_rgba32(stop);
 -    csel->base->setAlpha(SP_RGBA32_A_F(c));
 -    SPColor color( SP_RGBA32_R_F(c), SP_RGBA32_G_F(c), SP_RGBA32_B_F(c) );
      // set its color, from the stored array
 -    csel->base->setColor( color );
 +    csel->base->setColorAlpha( stop->getEffectiveColor(), stop->opacity );
      GtkWidget *offspin = GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "offspn"));
      GtkWidget *offslide =GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "offslide"));
  
  
  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)
          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"));
      }
  
  }
@@@ -1015,11 -1021,15 +1018,11 @@@ static void sp_gradient_vector_widget_l
  
          GtkOptionMenu *mnu = static_cast<GtkOptionMenu *>(g_object_get_data(G_OBJECT(widget), "stopmenu"));
          SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop"));
 -        guint32 const c = sp_stop_get_rgba32(stop);
  
 -        /// get the color selector
 +        // get the color selector
          SPColorSelector *csel = SP_COLOR_SELECTOR(g_object_get_data(G_OBJECT(widget), "cselector"));
 -        // set alpha
 -        csel->base->setAlpha(SP_RGBA32_A_F(c));
 -        SPColor color( SP_RGBA32_R_F(c), SP_RGBA32_G_F(c), SP_RGBA32_B_F(c) );
 -        // set color
 -        csel->base->setColor( color );
 +
 +        csel->base->setColorAlpha( stop->getEffectiveColor(), stop->opacity );
  
          /* Fill preview */
          GtkWidget *w = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(widget), "preview"));
          // 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);
@@@ -1144,6 -1154,10 +1147,6 @@@ static void sp_gradient_vector_color_dr
  
  static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *object)
  {
 -    SPColor color;
 -    float alpha;
 -    guint32 rgb;
 -
      if (blocked) {
          return;
      }
      SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop"));
  
      csel = static_cast<SPColorSelector*>(g_object_get_data(G_OBJECT(object), "cselector"));
 +    SPColor color;
 +    float alpha = 0;
      csel->base->getColorAlpha( color, alpha );
 -    rgb = color.toRGBA32( 0x00 );
  
      sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset);
      Inkscape::CSSOStringStream os;
 -    gchar c[64];
 -    sp_svg_write_color(c, sizeof(c), rgb);
 -    os << "stop-color:" << c << ";stop-opacity:" << static_cast<gdouble>(alpha) <<";";
 +    os << "stop-color:" << color.toString() << ";stop-opacity:" << static_cast<gdouble>(alpha) <<";";
      SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str());
      // 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;
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/widgets/icon.cpp
index c25e6aac2f88ed5786b89a239e5d7ad47513f346,570502253cc7601e241cd4883b7847d8123223ec..15900d340c1e27969a35cb6d1dba2f2abc78710e
@@@ -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
   *
@@@ -219,7 -219,7 +220,7 @@@ void sp_icon_fetch_pixbuf( SPIcon *ico
      }
  }
  
 -static GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) {
 +GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) {
      GtkIconTheme *theme = gtk_icon_theme_get_default();
  
      GdkPixbuf *pb = 0;
@@@ -918,13 -918,13 +919,13 @@@ sp_icon_doc_icon( SPDocument *doc, NRAr
          SPObject *object = doc->getObjectById(name);
          if (object && SP_IS_ITEM(object)) {
              /* Find bbox in document */
-             Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object)));
+             Geom::Matrix const i2doc(SP_ITEM(object)->i2doc_affine());
              Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc);
  
              if ( SP_OBJECT_PARENT(object) == NULL )
              {
                  dbox = Geom::Rect(Geom::Point(0, 0),
-                                 Geom::Point(sp_document_width(doc), sp_document_height(doc)));
+                                 Geom::Point(doc->getWidth(), doc->getHeight()));
              }
  
              /* This is in document coordinates, i.e. pixels */
@@@ -1105,15 -1105,15 +1106,15 @@@ static guchar *load_svg_pixels(gchar co
          /* Try to load from document. */
          if (!info &&
              Inkscape::IO::file_test( doc_filename, G_FILE_TEST_IS_REGULAR ) &&
-             (doc = sp_document_new( doc_filename, FALSE )) ) {
+             (doc = SPDocument::createNewDoc( doc_filename, FALSE )) ) {
  
              //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 */
-             unsigned visionkey = sp_item_display_key_new(1);
+             unsigned visionkey = SPItem::display_key_new(1);
              /* fixme: Memory manage root if needed (Lauris) */
              // This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days
              // because shapes are being rendered which are not being freed
              ==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;
@@@ -1184,8 -1183,7 +1184,8 @@@ void Inkscape::queueIconPrerender( Glib
  {
      GtkStockItem stock;
      gboolean stockFound = gtk_stock_lookup( name.c_str(), &stock );
 -    if (!stockFound && !gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name.c_str()) ) {
 +    gboolean themedFound = gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name.c_str());
 +    if (!stockFound && !themedFound ) {
          gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
          if ( !sizeMapDone ) {
              injectCustomSize();
@@@ -1350,9 -1348,7 +1350,9 @@@ static void addPreRender( GtkIconSize l
  }
  
  gboolean icon_prerender_task(gpointer /*data*/) {
 -    if (!pendingRenders.empty()) {
 +    if ( inkscapeIsCrashing() ) {
 +        // stop
 +    } else if (!pendingRenders.empty()) {
          bool workDone = false;
          do {
              preRenderItem single = pendingRenders.front();
          } while (!pendingRenders.empty() && !workDone);
      }
  
 -    if (!pendingRenders.empty()) {
 +    if (!inkscapeIsCrashing() && !pendingRenders.empty()) {
          return TRUE;
      } else {
          callbackHooked = false;
@@@ -1443,4 -1439,4 +1443,4 @@@ static void imageMapNamedCB(GtkWidget* 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index a7bed9e94c6461a294bedb0fe0f57b18daebe8e0,aadda9e2005d2071f9c22e9f569f61846c28b1d4..1d8acb40a63b426c9c86f426d7838e86a8a438a4
@@@ -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);
@@@ -875,7 -875,7 +876,7 @@@ ink_pattern_menu_populate_menu(GtkWidge
      if (patterns_doc == NULL) {
          char *patterns_source = g_build_filename(INKSCAPE_PATTERNSDIR, "patterns.svg", NULL);
          if (Inkscape::IO::file_test(patterns_source, G_FILE_TEST_IS_REGULAR)) {
-             patterns_doc = sp_document_new(patterns_source, FALSE);
+             patterns_doc = SPDocument::createNewDoc(patterns_source, FALSE);
          }
          g_free(patterns_source);
      }
  
      // 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 );
      }
  
@@@ -1082,10 -1082,11 +1083,10 @@@ static void sp_paint_selector_set_mode_
      SwatchSelector *swatchsel = 0;
  
      if (psel->mode == SPPaintSelector::MODE_SWATCH){
 -        /* Already have pattern menu */
          swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector"));
      } else {
          sp_paint_selector_clear_frame(psel);
 -        /* Create new gradient selector */
 +        // Create new gradient selector
          SwatchSelector *swatchsel = new SwatchSelector();
          swatchsel->show();
  
  
          gtk_frame_set_label(GTK_FRAME(psel->frame), _("Swatch fill"));
      }
 +
  #ifdef SP_PS_VERBOSE
      g_print("Swatch req\n");
  #endif
@@@ -1186,4 -1186,4 +1187,4 @@@ SPPaintSelector::Mode SPPaintSelector::
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index ed54857f8159c3e691e0d2ce4931be847a55dafc,a5bf818210daa155aa02ba024972c35282097754..a0ec248ca5395ea313459d84852b72e8817e5d93
@@@ -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)?
          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
@@@ -455,19 -455,25 +457,19 @@@ void sp_select_toolbox_prep(SPDesktop *
  
      // four spinbuttons
  
 -    //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
 -    eact = create_adjustment_action( "XAction", _("select toolbar|X position"), _("select toolbar|X"), "X",
 +    eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X",
                                       -1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
                                       _("Horizontal coordinate of selection"), TRUE );
      gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
      contextActions->push_back( GTK_ACTION(eact) );
  
 -    //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
 -    eact = create_adjustment_action( "YAction", _("select toolbar|Y position"), _("select toolbar|Y"), "Y",
 +    eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y",
                                       -1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
                                       _("Vertical coordinate of selection"), FALSE );
      gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
      contextActions->push_back( GTK_ACTION(eact) );
  
 -    //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
 -    eact = create_adjustment_action( "WidthAction", _("select toolbar|Width"), _("select toolbar|W"), "width",
 +    eact = create_adjustment_action( "WidthAction", C_("Select toolbar", "Width"), C_("Select toolbar", "W:"), "width",
                                       1e-3, GTK_WIDGET(desktop->canvas), tracker, spw,
                                       _("Width of selection"), FALSE );
      gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
      gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
      }
  
 -    //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
 -    eact = create_adjustment_action( "HeightAction", _("select toolbar|Height"), _("select toolbar|H"), "height",
 +    eact = create_adjustment_action( "HeightAction", C_("Select toolbar", "Height"), C_("Select toolbar", "H:"), "height",
                                       1e-3, GTK_WIDGET(desktop->canvas), tracker, spw,
                                       _("Height of selection"), FALSE );
      gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
index 3473d8f31c8fbac07673a169a77808525f08f27c,8a46001b1a3b5da064c5ae6adde590340f2fbcdd..0c31c2f74a562eb46266332c6b1f88afd3c288b8
@@@ -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) {
  
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 4b565d1a31b38b9464eb99e027069de495007aac,17324967ecb642bb35d38e2d81e88e2fed086f56..12467041c4f4fb7189a8190d91378d3f5c4d2944
@@@ -217,12 -217,12 +217,12 @@@ void getThings( DWORD space, gchar cons
          //
          {"_Y", "C_b", "C_r", "", "", ""},
          {"_Y", "_x", "y", "", "", ""},
 -        {_("_R"), _("_G"), _("_B"), "", "", ""},
 -        {_("_G"), "", "", "", "", ""},
 -        {_("_H"), _("_S"), "_V", "", "", ""},
 -        {_("_H"), _("_L"), _("_S"), "", "", ""},
 -        {_("_C"), _("_M"), _("_Y"), _("_K"), "", ""},
 -        {_("_C"), _("_M"), _("_Y"), "", "", ""},
 +        {_("_R:"), _("_G:"), _("_B:"), "", "", ""},
 +        {_("_G:"), "", "", "", "", ""},
 +        {_("_H:"), _("_S:"), "_V:", "", "", ""},
 +        {_("_H:"), _("_L:"), _("_S:"), "", "", ""},
 +        {_("_C:"), _("_M:"), _("_Y:"), _("_K:"), "", ""},
 +        {_("_C:"), _("_M:"), _("_Y:"), "", "", ""},
      };
  
      static gchar const *tips[][6] = {
@@@ -377,7 -377,7 +377,7 @@@ void ColorICCSelector::init(
      }
  
      /* Label */
 -    _label = gtk_label_new_with_mnemonic (_("_A"));
 +    _label = gtk_label_new_with_mnemonic (_("_A:"));
      gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5);
      gtk_widget_show (_label);
      gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD);
@@@ -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);
@@@ -933,4 -933,4 +933,4 @@@ void ColorICCSelector::_sliderChanged( 
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 7150b07fd4b6fa244120073c52d0d04f27aa117e,239f6e6e1f4a294cb865be6d43a33a85cad43806..75d68d25c58ff351b35ee745833004ba11bc2b9a
@@@ -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"));
      }
  }
index 2c5506273d05080d5742c5dbeb67695eedb0bada,65732d4885312572df5746297d0194c0ddeb3fe3..ffcbe48f88ed1e5b43579919bedba5816358c091
@@@ -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");
  
  
  // 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?
  
      // Find object's bbox in document
-     Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object)));
+     Geom::Matrix const i2doc(SP_ITEM(object)->i2doc_affine());
      Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc);
  
      if (!dbox) {
      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);
          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);
  }
  
@@@ -342,7 -342,7 +344,7 @@@ gchar const *buffer = "<svg xmlns=\"htt
  
  "</svg>";
  
-     return sp_document_new_from_mem (buffer, strlen(buffer), FALSE);
+     return SPDocument::createNewDocFromMem (buffer, strlen(buffer), FALSE);
  }
  
  static void
@@@ -373,7 -373,7 +375,7 @@@ ink_marker_menu_create_menu(Gtk::Menu *
      if (markers_doc == NULL) {
          char *markers_source = g_build_filename(INKSCAPE_MARKERSDIR, "markers.svg", NULL);
          if (Inkscape::IO::file_test(markers_source, G_FILE_TEST_IS_REGULAR)) {
-             markers_doc = sp_document_new(markers_source, FALSE);
+             markers_doc = SPDocument::createNewDoc(markers_source, FALSE);
          }
          g_free(markers_source);
      }
  
      // 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"));
  
  };
  
@@@ -671,7 -671,10 +673,7 @@@ sp_stroke_style_line_widget_new(void
  
      gint i = 0;
  
 -    //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
 -    /* Stroke width */
 -    spw_label(t, Q_("StrokeWidth|Width:"), 0, i);
 +    spw_label(t, C_("Stroke width", "Width:"), 0, i);
  
      hb = spw_hbox(t, 3, 1, i);
  
@@@ -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"));
      }
  }
  
@@@ -1471,4 -1474,4 +1473,4 @@@ ink_extract_marker_name(gchar const *n
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 3c209a45d455555c0a19f942e563a91f7ffbe80a,b1329b92a438aed2b9012232c764f3c2b0e9ca2f..935282a3a606a60a5a5db38513aff05dc89ea86c
@@@ -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"));
              }
          }
      }
@@@ -169,9 -169,10 +169,9 @@@ void SwatchSelector::connectchangedHand
  void SwatchSelector::setVector(SPDocument */*doc*/, SPGradient *vector)
  {
      //GtkVBox * box = gobj();
 -
      _gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
  
 -    if (vector) {
 +    if ( vector && vector->isSolid() ) {
          SPStop* stop = vector->getFirstStop();
  
          guint32 const colorVal = sp_stop_get_rgba32(stop);
          SPColor color( SP_RGBA32_R_F(colorVal), SP_RGBA32_G_F(colorVal), SP_RGBA32_B_F(colorVal) );
          // set its color, from the stored array
          _csel->base->setColor( color );
 +        gtk_widget_show_all( GTK_WIDGET(_csel) );
 +    } else {
 +        gtk_widget_hide( GTK_WIDGET(_csel) );
      }
  
  /*
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/widgets/toolbox.cpp
index ce71a097ea4211e868d3754f8cfe3782e1e39e29,6da23a69635e1fb4510481b2082a1ec8eaf719c6..8a616d0024d5f7b314b52793440144dac33d6c48
@@@ -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
  
  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);
@@@ -303,7 -303,7 +305,7 @@@ static gchar const * ui_descr 
          "    <separator />"
          "    <toolitem action='ObjectEditClipPathAction' />"
          "    <toolitem action='ObjectEditMaskPathAction' />"
 -        "    <toolitem action='EditNextLPEParameterAction' />"
 +        "    <toolitem action='EditNextPathEffectParameter' />"
          "    <separator />"
          "    <toolitem action='NodesShowTransformHandlesAction' />"
          "    <toolitem action='NodesShowHandlesAction' />"
@@@ -827,14 -827,14 +829,14 @@@ GtkWidget * sp_toolbox_button_new_from_
  
  
      unsigned int shortcut = sp_shortcut_get_primary(verb);
 -    if (shortcut) {
 -        gchar key[256];
 -        sp_ui_shortcut_string(shortcut, key);
 +    if (shortcut != GDK_VoidSymbol) {
 +        gchar *key = sp_shortcut_get_label(shortcut);
          gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key);
          if ( t ) {
              gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, tip, 0 );
          }
          g_free(tip);
 +        g_free(key);
      } else {
          if ( t ) {
              gtk_toolbar_append_widget( GTK_TOOLBAR(t), b, action->tip, 0 );
@@@ -992,8 -992,7 +994,8 @@@ static GtkWidget* toolboxNewCommon( Gtk
      gtk_widget_set_sensitive(tb, FALSE);
  
      GtkWidget *hb = 0;
 -    if ( UXManager::getInstance()->isFloatWindowProblem() ) {
 +    gboolean forceFloatAllowed = Inkscape::Preferences::get()->getBool("/options/workarounds/floatallowed", false);
 +    if ( UXManager::getInstance()->isFloatWindowProblem() && !forceFloatAllowed ) {
          hb = gtk_event_box_new(); // A simple, neutral container.
      } else {
          hb = gtk_handle_box_new();
@@@ -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));
      }
@@@ -1500,10 -1499,9 +1502,10 @@@ static void sp_node_toolbox_prep(SPDesk
      }
  
      {
 -        InkAction* inky = ink_action_new( "EditNextLPEParameterAction",
 -                                          _("Next path effect parameter"),
 -                                          _("Show next editable path effect parameter"),
 +        Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER);
 +        InkAction* inky = ink_action_new( verb->get_id(),
 +                                          verb->get_name(),
 +                                          verb->get_tip(),
                                            INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT,
                                            secondarySize );
          g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop );
@@@ -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"));
      // 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)
      Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
  
      {
 -        InkToggleAction* act = ink_toggle_action_new("ToggleSnapGlobal",
 -                                                     _("Snap"), _("Enable snapping"), INKSCAPE_ICON_SNAP, secondarySize,
 +        // TODO: This is a cludge. On the one hand we have verbs+actions,
 +        //       on the other we have all these explicit callbacks specified here.
 +        //       We should really unify these (should save some lines of code as well).
 +        //       For example, this action could be based on the verb(+action) + PrefsPusher.
 +        Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_TOGGLE_SNAPPING);
 +        InkToggleAction* act = ink_toggle_action_new(verb->get_id(),
 +                                                     verb->get_name(), verb->get_tip(), INKSCAPE_ICON_SNAP, secondarySize,
                                                       SP_ATTR_INKSCAPE_SNAP_GLOBAL);
  
          gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
@@@ -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();
          }
      }
      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);
      }
  
      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);
      }
      }
  
      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);
      }
          }
      }
      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);
      }
          }
      }
      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));
      }
      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);
      }
      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);
      }
      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);
      }
      }
  
      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);
@@@ -6867,7 -6860,7 +6869,7 @@@ static void sp_text_wordspacing_value_c
      // Set css word-spacing
      SPCSSAttr *css = sp_repr_css_attr_new ();
      Inkscape::CSSOStringStream osfs;
 -    osfs << adj->value;
 +    osfs << adj->value << "px"; // For now always use px
      sp_repr_css_set_property (css, "word-spacing", osfs.str().c_str());
  
      // Apply word-spacing to selected objects.
      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);
@@@ -6906,7 -6899,7 +6908,7 @@@ static void sp_text_letterspacing_value
      // Set css letter-spacing
      SPCSSAttr *css = sp_repr_css_attr_new ();
      Inkscape::CSSOStringStream osfs;
 -    osfs << adj->value;
 +    osfs << adj->value << "px";  // For now always use px
      sp_repr_css_set_property (css, "letter-spacing", osfs.str().c_str());
  
      // Apply letter-spacing to selected objects.
      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);
      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;
      }
  
          SPItem *item = (SPItem *) l->data;
  
          if (cc_item_is_connector(item)) {
-             sp_object_setAttribute(item, "inkscape:connector-type",
+             item->setAttribute( "inkscape:connector-type",
                      value, false);
              item->avoidRef->handleSettingChange();
              modmade = true;
          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;
      }
  
          SPItem *item = (SPItem *) l->data;
  
          if (cc_item_is_connector(item)) {
-             sp_object_setAttribute(item, "inkscape:connector-curvature",
+             item->setAttribute( "inkscape:connector-curvature",
                      value, false);
              item->avoidRef->handleSettingChange();
              modmade = true;
          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;
      }
  
          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*/ )
@@@ -8060,17 -8053,21 +8062,17 @@@ static void connector_tb_event_attr_cha
  {
      GtkWidget *tbl = GTK_WIDGET(data);
  
 -    if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
 -        return;
 -    }
 -    if (strcmp(name, "inkscape:connector-spacing") == 0)
 -    {
 -        GtkAdjustment *adj = (GtkAdjustment*)
 -                gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
 +    if ( !g_object_get_data(G_OBJECT(tbl), "freeze")
 +         && (strcmp(name, "inkscape:connector-spacing") == 0) ) {
 +        GtkAdjustment *adj = static_cast<GtkAdjustment*>(gtk_object_get_data(GTK_OBJECT(tbl), "spacing"));
          gdouble spacing = defaultConnSpacing;
          sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);
  
          gtk_adjustment_set_value(adj, spacing);
          gtk_adjustment_value_changed(adj);
 -    }
  
 -    spinbutton_defocus(GTK_OBJECT(tbl));
 +        spinbutton_defocus(GTK_OBJECT(tbl));
 +    }
  }
  
  static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl)
@@@ -8463,4 -8460,4 +8465,4 @@@ static void sp_paintbucket_toolbox_prep
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
index 620a88d8c2c500c21c2a3229a5128ebd734d81f0,976a8a7ec000e21a7f8f67826923708798d52d7a..ce902ba75699e95bae30db68a67094fd8811d47b
@@@ -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 --combined src/xml/node-iterators.h
index 3d09dfd1baa52715ee1842602493c71eaae25d80,0868fb2ab8fd493cb458e62d7e4c78e3d53a43bf..389d70be0eb1191885c8b5592266cb789e5a63ef
@@@ -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 );
@@@ -58,4 -58,4 +59,4 @@@ typedef Inkscape::Util::ForwardPointerI
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/xml/rebase-hrefs.cpp
index c3876725d3849c657add39369178cc10fc4f27f5,33978420c61b3afa0044995bcf9ff8d62576e46f..0655171606f213c6e90592b0ce2945c653d6f9a9
@@@ -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:
       *
       * 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 --combined src/xml/repr-io.cpp
index b1320a4a399d9eb54fc06671da6cb5b779d6e431,fa5e9b6ed3bc8f78aac7061eede1511d61ce3af8..5f7654ba8e7966467077f4d3735582381c65f733
@@@ -1,5 -1,5 +1,3 @@@
--#define __SP_REPR_IO_C__
--
  /*
   * Dirty DOM-like  tree
   *
@@@ -20,8 -20,6 +18,8 @@@
  #include <string>
  #include <stdexcept>
  
 +#include <libxml/parser.h>
 +
  #include "xml/repr.h"
  #include "xml/attribute-record.h"
  #include "xml/rebase-hrefs.h"
@@@ -296,7 -294,7 +294,7 @@@ sp_repr_read_file (const gchar * filena
                               &src,
                               localFilename,
                               src.getEncoding(),
 -                             XML_PARSE_NOENT );
 +                             XML_PARSE_NOENT | XML_PARSE_HUGE);
          }
      }
  
@@@ -990,4 -988,4 +988,4 @@@ sp_repr_write_stream_element (Node * re
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/xml/repr-sorting.cpp
index df1d2cbb8bd5fed5a754d8a612b7cb9522ed2d4a,27293d3c24b6878b7055298f777cde2f55811cf2..056236d333379665909bf6a89251a344661eb11f
@@@ -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 ) {
      }
  }
  
--/**
-- * 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:
@@@ -50,4 -50,4 +56,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/xml/repr-sorting.h
index 7d5542f67dcd224be80378d92b217dea63656a58,37f719622a0f291d2f73e6304708de2f7eb72713..d560dfa26b6dc5fe8824f6b7a4cdf38b97737931
  #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
@@@ -22,4 -22,4 +32,4 @@@
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/xml/repr-util.cpp
index d310639ba2a15fe63a6924e19dfe22484f57b43f,d78f6a927772f547d90809a61a423f3d3499fc23..07a25ca6daeab0fa1fcb996e7d2025279c1d612c
@@@ -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)) {
             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.
   */
@@@ -659,4 -659,4 +652,4 @@@ sp_repr_get_point(Inkscape::XML::Node *
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --combined src/xml/repr.cpp
index 4494d3fe6dc44aa2cd6249a375bac72254157db1,4494d3fe6dc44aa2cd6249a375bac72254157db1..0a384c9c1d707e5a3c489a93c9c7de30660e0f52
@@@ -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 --combined src/xml/repr.h
index 3b8d532fd8a0a4755f0ad38df04352f4ca386a56,549822e4e1a4c82e7509d51eb2ec805ee3ffe965..bde3e533f07b6b458bc8e6eb80d0d5f0f9220342
@@@ -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++
    fill-column:99
    End:
  */
 -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
 +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :