Code

GSoC C++-ificiation merge and cleanup.
authorJon A. Cruz <jon@joncruz.org>
Sun, 12 Dec 2010 09:05:21 +0000 (01:05 -0800)
committerJon A. Cruz <jon@joncruz.org>
Sun, 12 Dec 2010 09:05:21 +0000 (01:05 -0800)
302 files changed:
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 [new file with mode: 0644]
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-conn-end.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-reference.cpp
src/sp-use-reference.h
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

index b485dd1835c2d3446f4a7d058ff74f9bdad29cb3..1c480ecbc6efaeb971230fc2bce45977edf624a8 100644 (file)
@@ -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 +46,8 @@
 
 #include "arc-context.h"
 
+using Inkscape::DocumentUndo;
+
 static void sp_arc_context_class_init(SPArcContextClass *klass);
 static void sp_arc_context_init(SPArcContext *arc_context);
 static void sp_arc_context_dispose(GObject *object);
@@ -410,17 +413,17 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state)
             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);
@@ -444,7 +447,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state)
         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 +506,7 @@ static void sp_arc_finish(SPArcContext *ac)
         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,
+               DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
                          _("Create ellipse"));
 
         ac->item = NULL;
@@ -529,7 +532,7 @@ static void sp_arc_cancel(SPArcContext *ac)
 
     sp_canvas_end_forced_full_redraws(desktop->canvas);
 
-    sp_document_cancel(sp_desktop_document(desktop));
+    DocumentUndo::cancel(sp_desktop_document(desktop));
 }
 
 
index 14f4470bc1241b9fe240d565846c0fbac8235565..f23e4d8836b182eac748e9fdfe972d7b23e5b1b3 100644 (file)
@@ -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,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 +190,10 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g
  * 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->firstChild(); child; child = child->getNext() ) {
         if (SP_IS_PERSP3D(child)) {
             has_persp = true;
             break;
@@ -436,42 +438,42 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
 
         case GDK_bracketright:
             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, -180/snaps, MOD__ALT);
-            sp_document_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,
+            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,
+            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,
+            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,
+            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,
+            DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
                              _("Change perspective (angle of PLs)"));
             ret = true;
             break;
@@ -573,7 +575,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
 
 static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
 {
-    SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
+    SPDesktop *desktop = bc.desktop;
 
     if (!bc.item) {
 
@@ -581,25 +583,19 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
             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");
+        // 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;
         // 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));
-
+            Box3DSide *side = Box3DSide::createBox3DSide(box3d);
+            
             guint desc = Box3D::int_to_face(i);
 
             Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
@@ -608,10 +604,27 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
             side->dir2 = Box3D::extract_second_axis_direction(plane);
             side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
 
-            /* Set style */
-            box3d_side_apply_style(side);
+            // 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);    
+    
+            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);
+            }
 
-            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 +680,7 @@ static void sp_box3d_finish(Box3DContext *bc)
         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,
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
                          _("Create 3D box"));
 
         bc->item = NULL;
index 057d8f7dfcd6e2c9bac68a937a8fad3bb9868ee1..72a479ca4ab0957ead622c60404acbdfd15e131b 100644 (file)
@@ -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 +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" );
 }
 
 static Inkscape::XML::Node *
@@ -117,7 +116,7 @@ box3d_side_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
         sp_repr_set_int(repr, "inkscape:box3dsidetype", side->dir1 ^ side->dir2 ^ side->front_or_rear);
     }
 
-    sp_shape_set_shape ((SPShape *) object);
+    static_cast<SPShape *>(object)->setShape();
 
     /* Duplicate the path */
     SPCurve const *curve = ((SPShape *) object)->curve;
@@ -179,13 +178,33 @@ box3d_side_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);
+        static_cast<SPShape *>(object)->setShape ();
     }
 
     if (((SPObjectClass *) parent_class)->update)
         ((SPObjectClass *) parent_class)->update (object, ctx, flags);
 }
 
+/* Create a new Box3DSide and append it to the parent box */
+Box3DSide * Box3DSide::createBox3DSide(SPBox3D *box)
+{
+       Box3DSide *box3d_side = 0;
+       Inkscape::XML::Document *xml_doc = box->document->rdoc;
+       Inkscape::XML::Node *repr_side = xml_doc->createElement("svg:path");
+       repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
+       box3d_side = 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 +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
-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 */
-        repr_face->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));
-        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 +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", side->getAttribute("d"));
+    repr->setAttribute("style", side->getAttribute("style"));
 
     return repr;
 }
index 18c81507312652658ba87dd41eb10a3e14b68fa8..a8d692b01d6d70e55155fb4e0d2f863c03fc8394 100644 (file)
@@ -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 +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);
 };
 
 struct Box3DSideClass {
@@ -40,13 +43,15 @@ 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);
+
 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:
index aa2dc55e36cad3b833b26d9c1a17108f68d68c13..d51df9df3a1e18e3895e3d6a82c2517489317e7a 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_BOX3D_C__
-
 /*
  * SVG <box3d> implementation
  *
@@ -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 +131,9 @@ box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
 
     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" );
 }
 
 /**
@@ -227,7 +226,7 @@ box3d_set(SPObject *object, unsigned int key, const gchar *value)
                 box3d_position_set(box);
             }
             break;
-       default:
+        default:
             if (((SPObjectClass *) (parent_class))->set) {
                 ((SPObjectClass *) (parent_class))->set(object, key, value);
             }
@@ -268,7 +267,7 @@ box3d_update(SPObject *object, SPCtx *ctx, guint flags)
 }
 
 
-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);
 
@@ -290,11 +289,9 @@ static Inkscape::XML::Node *box3d_write(SPObject *object, Inkscape::XML::Documen
                 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);
+                Glib::ustring href = "#";
+                href += doc->getCurrentPersp3D()->getId();
+                repr->setAttribute("inkscape:perspectiveID", href.c_str());
             }
         }
 
@@ -327,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) ) {
-        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 +347,21 @@ box3d_set_transform(SPItem *item, Geom::Matrix const &xform)
     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->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 +390,7 @@ box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) {
     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 +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 +506,16 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta
     return box3d_get_perspective(box)->perspective_impl->tmat.preimage (result, z_coord, Proj::Z);
 }
 
+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 = 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 +679,15 @@ box3d_half_line_crosses_joining_line (Geom::Point const &A, Geom::Point const &B
     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 +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->firstChild(); side; side = side->getNext() ) {
+        if (SP_IS_BOX3D_SIDE(side)){
+            Box3DSide *bside = SP_BOX3D_SIDE(side);
+            sides[Box3D::face_to_int(bside->getFaceId())] = bside;
+        }
     }
     sides.erase(-1);
     return sides;
@@ -1288,12 +1296,11 @@ box3d_check_for_swapped_coords(SPBox3D *box) {
     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->firstChild(); child; child = child->getNext() ) {
             box3d_extract_boxes_rec(child, boxes);
         }
     }
@@ -1328,35 +1335,33 @@ box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp,
     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);
+    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 = 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");
+    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 = 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.");
@@ -1365,7 +1370,7 @@ box3d_convert_to_group(SPBox3D *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 +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));
+        box->convert_to_guides();
         return;
     }
 
index 8273e35420324c6f2ace6011dfd98763f19dcc73..5dbf0cf5e4912aeea30a82ae10cfe35a171a5425 100644 (file)
@@ -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,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 +30,8 @@ class Box3DSide;
 class Persp3D;
 class Persp3DReference;
 
-struct SPBox3D : public SPGroup {
+class SPBox3D : public SPGroup {
+public:
     gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom)
 
     gchar *persp_href;
@@ -44,9 +46,15 @@ struct SPBox3D : public SPGroup {
     Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging
 
     gint my_counter; // for debugging only
+
+    /**
+     * Create a SPBox3D and append it to the parent.
+     */
+    static SPBox3D * createBox3D(SPItem * parent);
 };
 
-struct SPBox3DClass {
+class SPBox3DClass {
+public:
     SPGroupClass parent_class;
 };
 
@@ -78,7 +86,7 @@ void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_pe
 SPGroup *box3d_convert_to_group(SPBox3D *box);
 
 
-#endif /* __SP_BOX3D_H__ */
+#endif // SEEN_SP_BOX3D_H
 
 /*
   Local Variables:
index 42893039a070b5e82274334964920a41b8b9f066..4b679e5b7e1eeff0dea1d1c035e49e9550085d97 100644 (file)
@@ -25,7 +25,7 @@ public:
     {
         if ( _doc )
         {
-            sp_document_unref( _doc );
+            _doc->doUnref();
         }
     }
 
@@ -80,7 +80,7 @@ public:
 
         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 );
         }
 
@@ -99,13 +99,13 @@ public:
         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);
@@ -123,13 +123,13 @@ public:
         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);
index 4c71fd72b47d356f5383abcea339797150da1ba0..e08a416d3b829a9ac84379956186d5c5166ffb6a 100644 (file)
@@ -180,9 +180,8 @@ void ColorProfile::init( ColorProfile *cprof )
 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));
+    if ( object->document ) {
+        object->document->removeResource("iccprofile", object);
     }
 
     ColorProfile *cprof = COLORPROFILE(object);
@@ -249,14 +248,14 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML:
     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->addResource( "iccprofile", object );
     }
 }
 
@@ -290,7 +289,7 @@ void ColorProfile::set( SPObject *object, unsigned key, gchar const *value )
                         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 +476,7 @@ static int getLcmsIntent( guint svgIntent )
 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->getResourceList("iccprofile");
     while ( current && !result ) {
         if ( IS_COLORPROFILE(current->data) ) {
             ColorProfile* prof = COLORPROFILE(current->data);
index 8d1770d6abc7f26fa135b315c5bddcf4e2189060..d35f18cf1f66391e942ce2ef2422ec77c9de0ca6 100644 (file)
@@ -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 +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);
-    
-    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;
+    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 ( 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'))
index fe25fa418f5ad29b1f9179ee1eda0fa5ab35af9c..21ef2deab53c14bd87502c68c47648ea9c14d249 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Authors:
  *   Michael Wybrow <mjwybrow@users.sourceforge.net>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2005 Michael Wybrow
  *
@@ -38,7 +39,7 @@
 #include "inkscape.h"
 #include <glibmm/i18n.h>
 
-
+using Inkscape::DocumentUndo;
 
 using Avoid::Router;
 
@@ -195,10 +196,10 @@ void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar
 {
     SPDocument* doc = SP_OBJECT_DOCUMENT(item);
 
-    sp_object_setAttribute( SP_OBJECT(item), "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->ensureUpToDate();
+    DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, action);
 }
 
 void SPAvoidRef::addConnectionPoint(ConnectionPoint &cp)
@@ -295,7 +296,7 @@ void SPAvoidRef::handleSettingChange(void)
         // isn't the same as the document that this item is part of.  This
         // case can happen if a new document is loaded from the file chooser
         // or via the recent file menu.  In this case, we can end up here
-        // as a rersult of a sp_document_ensure_up_to_date performed on a
+        // as a rersult of a ensureUpToDate performed on a
         // document not yet attached to the active desktop.
         return;
     }
@@ -315,7 +316,7 @@ void SPAvoidRef::handleSettingChange(void)
             _transformed_connection = item->connectTransformed(
                     sigc::ptr_fun(&avoid_item_move));
 
-            const char *id = SP_OBJECT_REPR(item)->attribute("id");
+            char const *id = item->getAttribute("id");
             g_assert(id != NULL);
 
             // Get a unique ID for the item.
@@ -389,12 +390,12 @@ Geom::Point SPAvoidRef::getConnectionPointPos(const int type, const int id)
 {
     g_assert(item);
     Geom::Point pos;
-    const Geom::Matrix& transform = sp_item_i2doc_affine(item);
+    const Geom::Matrix& transform = item->i2doc_affine();
 
     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
@@ -491,7 +492,7 @@ static std::vector<Geom::Point> approxItemWithPoints(SPItem const *item, const G
     }
     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 +512,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item)
     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);
 
@@ -557,8 +558,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item)
 GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop,
         bool initialised)
 {
-    for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ;
-            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 +596,8 @@ void init_avoided_shape_geometry(SPDesktop *desktop)
     // 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 = DocumentUndo::getUndoSensitive(document);
+    DocumentUndo::setUndoSensitive(document, false);
 
     bool initialised = false;
     GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop,
@@ -611,7 +611,7 @@ void init_avoided_shape_geometry(SPDesktop *desktop)
     if (items) {
         g_slist_free(items);
     }
-    sp_document_set_undo_sensitive(document, saved);
+    DocumentUndo::setUndoSensitive(document, saved);
 }
 
 
index adc54a1ae228b68e08b129030f19b17415caec16..b1061c1247a47452fb5b6d2aa5d30d4504ed5808 100644 (file)
@@ -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);
@@ -971,7 +974,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons
                 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;
@@ -1075,7 +1078,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
                     m.unSetup();
                     cc_connector_rerouting_finish(cc, &p);
 
-                    sp_document_ensure_up_to_date(doc);
+                    doc->ensureUpToDate();
                     cc->state = SP_CONNECTOR_CONTEXT_IDLE;
                     return TRUE;
                     break;
@@ -1101,7 +1104,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
                         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);
                     }
 
@@ -1119,11 +1122,11 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
 
                     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->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 +1170,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
 
                     cc_connector_rerouting_finish(cc, NULL);
 
-                    sp_document_undo(doc);
+                    DocumentUndo::undo(doc);
 
                     cc->state = SP_CONNECTOR_CONTEXT_IDLE;
                     desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE,
@@ -1197,7 +1200,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
                     // 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,
@@ -1219,7 +1222,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
                         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);
                     }
 
@@ -1249,11 +1252,11 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
 
                     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->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 +1303,12 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p
 
         if (found) {
             if (cc->clickedhandle == cc->endpt_handle[0]) {
-                sp_object_setAttribute(cc->clickeditem,
-                        "inkscape:connection-start", shape_label, false);
-                sp_object_setAttribute(cc->clickeditem,
-                        "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,
-                        "inkscape:connection-end", shape_label, false);
-                sp_object_setAttribute(cc->clickeditem,
-                        "inkscape:connection-end-point", cpid, false);
+                cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, false);
+                cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, false);
             }
             g_free(shape_label);
         }
@@ -1317,7 +1316,7 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p
     cc->clickeditem->setHidden(false);
     sp_conn_reroute_path_immediate(SP_PATH(cc->clickeditem));
     cc->clickeditem->updateRepr();
-    sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
+    DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
                      _("Reroute connector"));
     cc_set_active_conn(cc, cc->clickeditem);
 }
@@ -1429,7 +1428,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
 
     SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     if ( c && !c->is_empty() ) {
         /* We actually have something to write */
@@ -1445,35 +1444,33 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
 
         /* 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->isOrthogonal ? "orthogonal" : "polyline", false);
-        sp_object_setAttribute(cc->newconn, "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->shref, false);
-            if (cc->scpid)
-                sp_object_setAttribute(cc->newconn, "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->ehref, false);
-            if (cc->ecpid)
-                sp_object_setAttribute(cc->newconn, "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->ensureUpToDate();
 
         if (connection) {
             // Adjust endpoints to shape edge.
@@ -1491,7 +1488,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
 
     c->unref();
 
-    sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector"));
+    DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector"));
 }
 
 
@@ -1607,7 +1604,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc)
 
                 // 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 +1704,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item)
 
         // Ensure the item's connection_points map
         // has been updated
-        sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item));
+        item->document->ensureUpToDate();
 
         std::set<int> seen;
         for  ( ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end() ;)
@@ -1766,7 +1763,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item)
     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)
     {
@@ -1950,8 +1947,7 @@ void cc_selection_set_avoid(bool const set_avoid)
         char const *value = (set_avoid) ? "true" : NULL;
 
         if (cc_item_is_shape(item)) {
-            sp_object_setAttribute(item, "inkscape:connector-avoid",
-                    value, false);
+            item->setAttribute("inkscape:connector-avoid", value, false);
             item->avoidRef->handleSettingChange();
             changes++;
         }
@@ -1968,7 +1964,7 @@ void cc_selection_set_avoid(bool const set_avoid)
     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);
+    DocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc);
 }
 
 
index 18782c1638279172303d9511b43a4f97674a16e9..2cbac74f891f8a51b58e96a50d80e7eb9422e437 100644 (file)
@@ -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 +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);
 }
 
 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);
 }
 
 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);
 }
 
 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);
 }
 
 }
index f7d1c7d291fbe3c789b6e7efba60998a7aba711d..b5c08a8b54aa151ef301136ce398e7fd26f4dba4 100644 (file)
@@ -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 +32,7 @@ public:
 };
 }
 
-#endif
+#endif // SEEN_INKSCAPE_CONSOLE_OUTPUT_UNDO_OBSERVER_H
 
 /*
   Local Variables:
index f7697a6c06d4ebe93dc7ffa5ae5897986c876566..71c865879cba626876eb012fb6513d01e4c86e4c 100644 (file)
@@ -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 +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 +78,6 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
     int wx, wy;
 
     SPDesktop *desktop = dtw->desktop;
-    Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
 
     gdk_window_get_pointer(GTK_WIDGET(dtw->canvas)->window, &wx, &wy, NULL);
     Geom::Point const event_win(wx, wy);
@@ -92,8 +94,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
                 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);
+                desktop->namedview->setGuides(true);
 
                 // calculate the normal of the guidelines when dragged from the edges of rulers.
                 Geom::Point normal_bl_to_tr(-1.,1.); //bottomleft to topright
@@ -181,13 +182,13 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
                 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);
+                    desktop->namedview->appendChild(repr);
                     Inkscape::GC::release(repr);
-                    sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE,
+                    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
                                      _("Create guide"));
                 }
                 desktop->set_coordinate_status(from_2geom(event_dt));
@@ -400,14 +401,14 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
                                 g_assert_not_reached();
                                 break;
                         }
-                        sp_document_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,
+                        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
                                      _("Delete guide"));
                     }
                     moved = false;
@@ -454,7 +455,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
                 {
                     SPDocument *doc = SP_OBJECT_DOCUMENT(guide);
                     sp_guide_remove(guide);
-                    sp_document_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;
index 5615a8ea96d1cca3b259d2999b0cff14ac2dbe62..c580d6767636a641c2036e2dd62600fe1b081af9 100644 (file)
@@ -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
  *
@@ -103,7 +103,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
               || SP_IS_FLOWDIV(o)
               || SP_IS_FLOWPARA(o)
               || SP_IS_TEXTPATH(o))
-          && !SP_OBJECT_REPR(o)->attribute("style"))
+          &&  !o->getAttribute("style"))
         &&
         !(SP_IS_FLOWREGION(o) ||
           SP_IS_FLOWREGIONEXCLUDE(o) ||
@@ -121,7 +121,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
 
         // 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. ) ) {
@@ -129,7 +129,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
             }
         }
 
-        sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style");
+        o->changeCSS(css_set,"style");
 
         sp_repr_css_attr_unref(css_set);
     }
@@ -138,7 +138,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
     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 = o->firstChild() ; child ; child = child->getNext() ) {
         if (sp_repr_css_property(css, "opacity", NULL) != NULL) {
             // Unset properties which are accumulating and thus should not be set recursively.
             // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group.
@@ -420,7 +420,7 @@ stroke_average_width (GSList const *objects)
         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();
 
         SPObject *object = SP_OBJECT(l->data);
 
@@ -702,11 +702,11 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res)
         if (!style) continue;
 
         if ( style->stroke.isNone() && !(
-                               style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should
-                               style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width
-                               style->marker[SP_MARKER_LOC_MID].set ||
-                               style->marker[SP_MARKER_LOC_END].set))
-               {
+                 style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should
+                 style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width
+                 style->marker[SP_MARKER_LOC_MID].set ||
+                 style->marker[SP_MARKER_LOC_END].set))
+        {
             continue;
         }
 
@@ -714,7 +714,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res)
 
         noneSet &= style->stroke.isNone();
 
-        Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
+        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 +932,7 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res)
         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 +1180,12 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res)
     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 +1235,12 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res)
     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 +1380,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res)
         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();
 
         items ++;
 
@@ -1483,7 +1485,7 @@ sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
 
     // 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;
index 83a6f40219717352957ad0f7659cd591290da120..0b17fb385aead21accff281c1d3cc646cdf92955 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_DESKTOP_C__
-
 /** \file
  * Editable view implementation
  *
@@ -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 @@
 #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 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
 
     SPDocument *document = SP_OBJECT_DOCUMENT (namedview);
     /* Kill flicker */
-    sp_document_ensure_up_to_date (document);
+    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);
 
     /* Connect document */
     setDocument (document);
@@ -255,7 +256,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
     // 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);
@@ -272,12 +273,12 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
 
 
     /* Connect event for page resize */
-    _doc2dt[5] = sp_document_height (document);
+    _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(document->getRoot())->invoke_show(
             SP_CANVAS_ARENA (drawing)->arena,
             dkey,
             SP_ITEM_SHOW_DISPLAY);
@@ -394,7 +395,7 @@ void SPDesktop::destroy()
     }
 
     if (drawing) {
-        sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), dkey);
+        SP_ITEM(doc()->getRoot())->invoke_hide(dkey);
         drawing = NULL;
     }
 
@@ -450,7 +451,7 @@ void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) {
     canvas->rendermode = mode;
     _display_mode = mode;
     sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw
-    _widget->setTitle(SP_DOCUMENT_NAME(sp_desktop_document(this)));
+    _widget->setTitle( sp_desktop_document(this)->getName() );
 }
 
 void SPDesktop::displayModeToggle() {
@@ -494,7 +495,7 @@ SPObject *SPDesktop::currentLayer() const
 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 @@ bool SPDesktop::isLayer(SPObject *object) const {
 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 {
@@ -684,33 +685,30 @@ SPDesktop::set_coordinate_status (Geom::Point p) {
 }
 
 /**
- * \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::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()->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()->getGroupAtPoint(dkey, p);
 }
 
 /**
@@ -966,6 +964,26 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py,
                      0.0);
 }
 
+/**
+  * Apply the desktop's current style or the tool style to the object.
+  */
+void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text)
+{
+    SPCSSAttr *css_current = sp_desktop_get_style(this, with_text);
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+    if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
+        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 @@ void
 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 @@ 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);
 }
@@ -1078,10 +1096,10 @@ void
 SPDesktop::zoom_drawing()
 {
     g_return_if_fail (doc() != NULL);
-    SPItem *docitem = SP_ITEM (sp_document_root (doc()));
+    SPItem *docitem = SP_ITEM(doc()->getRoot());
     g_return_if_fail (docitem != NULL);
 
-    Geom::OptRect d = sp_item_bbox_desktop(docitem);
+    Geom::OptRect d = docitem->getBboxDesktop();
 
     /* Note that the second condition here indicates that
     ** there are no items in the drawing.
@@ -1416,8 +1434,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);
+        namedview->writeNewGrid(sp_desktop_document(this), Inkscape::GRID_RECTANGULAR);
         showGrids(true);
     }
 }
@@ -1435,9 +1452,8 @@ void SPDesktop::showGrids(bool show, bool dirty_document)
 
 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->getSnapGlobal();
+    namedview->setSnapGlobal(!v);
 }
 
 //----------------------------------------------------------------------
@@ -1480,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(this->doc()->getRoot())->invoke_hide(dkey);
     }
 
     if (_layer_hierarchy) {
@@ -1491,7 +1507,7 @@ SPDesktop::setDocument (SPDocument *doc)
     _layer_hierarchy->connectAdded(sigc::bind(sigc::ptr_fun(_layer_activated), this));
     _layer_hierarchy->connectRemoved(sigc::bind(sigc::ptr_fun(_layer_deactivated), this));
     _layer_hierarchy->connectChanged(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this));
-    _layer_hierarchy->setTop(SP_DOCUMENT_ROOT(doc));
+    _layer_hierarchy->setTop(doc->getRoot());
 
     /* setup EventLog */
     event_log = new Inkscape::EventLog(doc);
@@ -1511,7 +1527,7 @@ SPDesktop::setDocument (SPDocument *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(doc->getRoot())->invoke_show(
                 SP_CANVAS_ARENA (drawing)->arena,
                 dkey,
                 SP_ITEM_SHOW_DISPLAY);
index af2473bafaa729759e18de38bb564f9989b4a2e2..957c3b342509629fe39367dfd64d75f7723185ca 100644 (file)
@@ -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 +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:
     Inkscape::UI::Dialog::DialogManager *_dlg_mgr;
     SPNamedView               *namedview;
     SPCanvas                  *canvas;
@@ -229,9 +232,9 @@ struct SPDesktop : public Inkscape::UI::View::View
     void push_event_context (GtkType type, const gchar *config, unsigned int key);
 
     void set_coordinate_status (Geom::Point p);
-    SPItem *item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const;
-    SPItem *item_at_point (Geom::Point const p, bool into_groups, SPItem *upto = NULL) const;
-    SPItem *group_at_point (Geom::Point const p) const;
+    SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const;
+    SPItem *getItemAtPoint(Geom::Point const p, bool into_groups, SPItem *upto = NULL) const;
+    SPItem *getGroupAtPoint(Geom::Point const p) const;
     Geom::Point point() const;
 
     Geom::Rect get_display_area() const;
@@ -255,8 +258,9 @@ struct SPDesktop : public Inkscape::UI::View::View
     void prev_zoom();
     void next_zoom();
     void zoom_quick(bool enable = true);
-       /** \brief  Returns whether the desktop is in quick zoom mode or not */
-       bool quick_zoomed(void) { return _quick_zoom_enabled; }
+
+    /** \brief  Returns whether the desktop is in quick zoom mode or not */
+    bool quick_zoomed(void) { return _quick_zoom_enabled; }
 
     bool scroll_to_point (Geom::Point const &s_dt, gdouble autoscrollspeed = 0);
     void scroll_world (double dx, double dy, bool is_scrolling = false);
@@ -324,6 +328,8 @@ struct SPDesktop : public Inkscape::UI::View::View
     virtual bool onDeleteUI (GdkEventAny*);
     virtual bool onWindowStateEvent (GdkEventWindowState* event);
 
+    void applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text);
+
 private:
     Inkscape::UI::View::EditWidgetInterface       *_widget;
     Inkscape::Application     *_inkscape;
index 864cf8927e884029e2f63c303e075f76fe1e2591..8045675b4022ac097f522747e6523d2f60774551 100644 (file)
@@ -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
@@ -45,6 +47,8 @@
 #include "widgets/icon.h"
 #include "xml/repr.h"
 
+using Inkscape::DocumentUndo;
+
 #define MIN_ONSCREEN_DISTANCE 50
 
 static GtkWidget *dlg = NULL;
@@ -110,11 +114,6 @@ clonetiler_dialog_delete (GtkObject */*object*/, GdkEvent * /*event*/, gpointer
 
 }
 
-static void on_delete()
-{
-    (void)clonetiler_dialog_delete (0, 0, NULL);
-}
-
 static void
 on_picker_color_changed (guint rgba)
 {
@@ -839,9 +838,9 @@ clonetiler_trace_hide_tiled_clones_recursively (SPObject *from)
     if (!trace_arena)
         return;
 
-    for (SPObject *o = sp_object_first_child(from); 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 +850,16 @@ clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original)
 {
     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(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(trace_doc->getRoot()));
 
-    sp_document_root (trace_doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
-    sp_document_ensure_up_to_date(trace_doc);
+    trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+    trace_doc->ensureUpToDate();
 
     trace_zoom = zoom;
 }
@@ -944,7 +942,7 @@ static void
 clonetiler_trace_finish ()
 {
     if (trace_doc) {
-        sp_item_invoke_hide(SP_ITEM(sp_document_root(trace_doc)), trace_visionkey);
+        SP_ITEM(trace_doc->getRoot())->invoke_hide(trace_visionkey);
     }
     if (trace_arena) {
         ((NRObject *) trace_arena)->unreference();
@@ -972,20 +970,20 @@ clonetiler_unclump( GtkWidget */*widget*/, void * )
 
     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->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)->ensureUpToDate();
 
     unclump (to_unclump);
 
     g_slist_free (to_unclump);
 
-    sp_document_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 +993,7 @@ clonetiler_number_of_clones (SPObject *obj)
 
     guint n = 0;
 
-    for (SPObject *child = sp_object_first_child(parent); 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 +1022,7 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 
 // 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->firstChild(); child != NULL; child = child->next) {
         if (clonetiler_is_a_clone_of (child, obj)) {
             to_delete = g_slist_prepend (to_delete, child);
         }
@@ -1036,9 +1034,10 @@ clonetiler_remove( GtkWidget */*widget*/, void *, bool do_undo = true )
 
     clonetiler_change_selection (NULL, selection, dlg);
 
-    if (do_undo)
-        sp_document_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 +1221,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
         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];
@@ -1471,7 +1470,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
                 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)->ensureUpToDate();
                 // it's hard to figure out exact width/height of the tile without having an object
                 // that we can take bbox of; however here we only need a lower bound so that blur
                 // margins are not too small, and the perimeter should work
@@ -1501,8 +1500,8 @@ clonetiler_apply( GtkWidget */*widget*/, void * )
 
     desktop->clearWaitingCursor();
 
-    sp_document_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 *
index 82e2d45e1b18df482aa835864742b66c161027f2..7e99c2496efb96fb12b2de617fe2ca73db65cc7f 100644 (file)
@@ -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 +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 +366,9 @@ gchar* create_filepath_from_id (const gchar *id, const gchar *file_entry_text) {
 
     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 +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 +784,7 @@ sp_export_selection_modified ( Inkscape::Application */*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(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX);
                 if (bbox) {
                     sp_export_set_area (base, bbox->min()[Geom::X],
                                               bbox->min()[Geom::Y],
@@ -861,7 +865,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
                 /** \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(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) {
@@ -871,7 +875,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
                 }
             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 +1068,8 @@ gchar *absolutize_path_from_document_location (SPDocument *doc, const gchar *fil
 {
     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 +1109,10 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
         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);
@@ -1117,7 +1121,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
             }
 
             // retrieve export dpi hints
-            const gchar *dpi_hint = SP_OBJECT_REPR(item)->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now
+            const gchar *dpi_hint = item->getRepr()->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now
             gdouble dpi = 0.0;
             if (dpi_hint) {
                 dpi = atof(dpi_hint);
@@ -1127,7 +1131,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
             }
 
             Geom::OptRect area;
-            sp_item_invoke_bbox(item, area, sp_item_i2d_affine((SPItem *) item), TRUE);
+            item->invoke_bbox( area, item->i2d_affine(), TRUE );
             if (area) {
                 gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5);
                 gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5);
@@ -1239,14 +1243,13 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
         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 = DocumentUndo::getUndoSensitive(doc);
+            DocumentUndo::setUndoSensitive(doc, false);
 
-            temp_string = repr->attribute("inkscape:export-filename");
+            gchar const *temp_string = repr->attribute("inkscape:export-filename");
             if (temp_string == NULL || strcmp(temp_string, filename_ext)) {
                 repr->setAttribute("inkscape:export-filename", filename_ext);
                 modified = true;
@@ -1261,7 +1264,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
                 sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
                 modified = true;
             }
-            sp_document_set_undo_sensitive(doc, saved);
+            DocumentUndo::setUndoSensitive(doc, saved);
 
             if (modified) {
                 doc->setModifiedSinceSave();
@@ -1273,8 +1276,8 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
             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 = DocumentUndo::getUndoSensitive(doc);
+            DocumentUndo::setUndoSensitive(doc, false);
             reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList();
 
             for(; reprlst != NULL; reprlst = reprlst->next) {
@@ -1283,8 +1286,8 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
 
                 if (repr->attribute("id") == NULL ||
                         !(g_strrstr(filename_ext, repr->attribute("id")) != NULL &&
-                          (!SP_DOCUMENT_URI(SP_ACTIVE_DOCUMENT) ||
-                            strcmp(g_dirname(filename), g_dirname(SP_DOCUMENT_URI(SP_ACTIVE_DOCUMENT))) == 0))) {
+                          ( !SP_ACTIVE_DOCUMENT->getURI() ||
+                            strcmp(g_dirname(filename), g_dirname(SP_ACTIVE_DOCUMENT->getURI())) == 0))) {
                     temp_string = repr->attribute("inkscape:export-filename");
                     if (temp_string == NULL || strcmp(temp_string, filename_ext)) {
                         repr->setAttribute("inkscape:export-filename", filename_ext);
@@ -1302,7 +1305,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
                     modified = true;
                 }
             }
-            sp_document_set_undo_sensitive(doc, saved);
+            DocumentUndo::setUndoSensitive(doc, saved);
 
             if (modified) {
                 doc->setModifiedSinceSave();
@@ -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(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX);
 
                 // std::cout << "Drawing " << bbox2;
                 if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) {
@@ -1513,8 +1516,8 @@ sp_export_detect_size(GtkObject * base) {
                 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;
index a3612f60e18f7f1cb0fa763739f4688337737fb9..fe264892abdcdf7175bac6f0400bfae0aff92c79 100644 (file)
@@ -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 +294,7 @@ all_items (SPObject *r, GSList *l, bool hidden, bool locked)
     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->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 +344,7 @@ void sp_find_dialog_find(GObject *, GObject *dlg)
         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 +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: "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);
         }
 
index 40665e08ea5de165c092c9a29a241c4f25f8b59f..8b5ac1784ce9bd29d59b9f22147c572ea5406b5f 100644 (file)
@@ -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 +42,8 @@
 #include "../widgets/sp-attribute-widget.h"
 #include "../widgets/sp-widget.h"
 
+using Inkscape::DocumentUndo;
+
 #define MIN_ONSCREEN_DISTANCE 50
 
 static GtkWidget *dlg = NULL;
@@ -398,8 +401,8 @@ sp_item_widget_sensitivity_toggled (GtkWidget *widget, SPWidget *spw)
 
     item->setLocked(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
 
-    sp_document_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 +420,8 @@ sp_item_widget_hidden_toggled(GtkWidget *widget, SPWidget *spw)
 
     item->setExplicitlyHidden(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
 
-    sp_document_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));
 }
@@ -449,9 +452,9 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw )
         SPException ex;
         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,
-                                _("Set object ID"));
+        item->setAttribute("id", id, &ex);
+        DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM,
+                          _("Set object ID"));
     }
 
     /* Retrieve the label widget for the object's label */
@@ -465,16 +468,16 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw )
     SPObject *obj = (SPObject*)item;
     if (strcmp (label, obj->defaultLabel())) {
         obj->setLabel(label);
-        sp_document_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,
-                         _("Set object title"));
+        DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM,
+                          _("Set object title"));
 
     /* Retrieve the description */
     GtkTextView *tv = GTK_TEXT_VIEW(gtk_object_get_data(GTK_OBJECT(spw), "desc"));
@@ -483,8 +486,8 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw )
     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,
-                         _("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));
index 476a551f13269f3df0e9889e06ab109ac602f060..12105c8c045f14c1250dce472d6c19fec908a804 100644 (file)
@@ -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 +202,11 @@ all_text_items (SPObject *r, GSList *l, bool hidden, bool locked)
     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->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 +239,8 @@ gint compare_text_bboxes (gconstpointer a, gconstpointer b)
     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 +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 +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 +780,8 @@ sp_spellcheck_accept (GObject *, GObject *dlg)
             // 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,
-                              _("Fix spelling"));
+            SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_TEXT,
+                                 _("Fix spelling"));
         }
     }
 
index 8a8fe6a29c972c2654ee503533d23e35a8874723..61f56e3f7fec8ac12aa32c4d3e1434937700173a 100644 (file)
@@ -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 +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 +641,7 @@ sp_text_edit_dialog_apply( GtkButton */*button*/, GtkWidget *dlg )
         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;
         }
@@ -661,8 +664,8 @@ sp_text_edit_dialog_apply( GtkButton */*button*/, GtkWidget *dlg )
     }
 
     // complete the transaction
-    sp_document_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 +730,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg,
                 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);
index bd442b8872a1ec375b0f36f38f9722b7c3b4cc37..c90cde490ba02dfd0812b1c57a19ddadfbe2934f 100644 (file)
@@ -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 +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 +683,8 @@ void set_tree_document(SPDocument *document)
     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 +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,
-                         _("Drag XML subtree"));
+        DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+                           _("Drag XML subtree"));
     } else {
-        sp_document_cancel(current_document);
+        DocumentUndo::cancel(current_document);
     }
 }
 
@@ -1275,7 +1278,7 @@ void on_document_uri_set(gchar const */*uri*/, SPDocument *document)
 {
     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 +1365,7 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/)
     gtk_main();
 
     if (selected_repr != NULL && name.text) {
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document);
+        Inkscape::XML::Document *xml_doc = current_document->getReprDoc();
         Inkscape::XML::Node *new_repr;
         new_repr = xml_doc->createElement(name.text);
         Inkscape::GC::release(new_repr);
@@ -1371,8 +1374,8 @@ void cmd_new_element_node(GtkObject */*object*/, gpointer /*data*/)
         set_tree_select(new_repr);
         set_dt_select(new_repr);
 
-        sp_document_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 +1386,12 @@ void cmd_new_text_node(GtkObject */*object*/, gpointer /*data*/)
 {
     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,
-                     _("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 +1408,8 @@ void cmd_duplicate_node(GtkObject */*object*/, gpointer /*data*/)
     Inkscape::XML::Node *dup = selected_repr->duplicate(parent->document());
     parent->addChild(dup, selected_repr);
 
-    sp_document_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 +1425,8 @@ void cmd_delete_node(GtkObject */*object*/, gpointer /*data*/)
     g_assert(selected_repr != NULL);
     sp_repr_unparent(selected_repr);
 
-    sp_document_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 +1443,8 @@ void cmd_delete_attr(GtkObject */*object*/, gpointer /*data*/)
         updated->updateRepr();
     }
 
-    sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
-                     _("Delete attribute"));
+    DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR,
+                       _("Delete attribute"));
 }
 
 
@@ -1469,8 +1472,8 @@ void cmd_set_attr(GtkObject */*object*/, gpointer /*data*/)
         updated->updateRepr();
     }
 
-    sp_document_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 +1502,8 @@ void cmd_raise_node(GtkObject */*object*/, gpointer /*data*/)
 
     parent->changeOrder(selected_repr, ref);
 
-    sp_document_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 +1519,8 @@ void cmd_lower_node(GtkObject */*object*/, gpointer /*data*/)
 
     parent->changeOrder(selected_repr, selected_repr->next());
 
-    sp_document_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 +1549,8 @@ void cmd_indent_node(GtkObject */*object*/, gpointer /*data*/)
     parent->removeChild(repr);
     prev->addChild(repr, ref);
 
-    sp_document_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 +1570,8 @@ void cmd_unindent_node(GtkObject */*object*/, gpointer /*data*/)
     parent->removeChild(repr);
     grandparent->addChild(repr, parent);
 
-    sp_document_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);
 
index 34c60b140e0382f4d37544ef3198f08561bdd4e3..df73eb78e0496470ec00255661e57c5d0ca4ff14 100644 (file)
@@ -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 +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 +32,8 @@
 #include "canvas-grid.h"
 #include "canvas-axonomgrid.h"
 
+using Inkscape::DocumentUndo;
+
 namespace Inkscape {
 
 static gchar const *const grid_name[] = {
@@ -247,7 +248,7 @@ CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, SPDocument * doc, Gri
 
     // first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete.
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
     Inkscape::XML::Node *newnode;
     newnode = xml_doc->createElement("inkscape:grid");
     newnode->setAttribute("type", getSVGName(gridtype));
@@ -255,7 +256,7 @@ CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, SPDocument * doc, Gri
     repr->appendChild(newnode);
     Inkscape::GC::release(newnode);
 
-    sp_document_done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid"));
 }
 
 /*
index b0b3ee184eed8eec3fbd584891b33bad05234cfe..9a39168c29368743cf1b5cbf38de554812bf6efc 100644 (file)
@@ -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 +50,10 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) {
         if (!SVGElem) return 0;
         
         // prep the document
-        sp_document_ensure_up_to_date(document);
+        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);
@@ -100,7 +101,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) {
         {
             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);
     }
 
@@ -118,7 +119,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) {
             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 ) ) {
index fa4754248f082b84ff2eea883dd0bec593da7977..61e6bad67beff4b1f69070662badafd0b7949af0 100644 (file)
@@ -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 +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 +77,4 @@ struct SPDocumentPrivate {
        bool seeking;
 };
 
-#endif
+#endif // SEEN_SP_DOCUMENT_PRIVATE_H
index 6a7f8822c1d1d32b8c5a2d2f7f199fbd60869cfc..e71b9bad5bd6af2919f10d936106b419a1cb4f19 100644 (file)
@@ -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
  */
index e63fe8a529c552e19f12a82419d4ef6a1635f8f1..1559dc5ba6cb10945fcb6ddc8aa37d00c37441c3 100644 (file)
@@ -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 +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 +62,7 @@
 #include "xml/repr.h"
 #include "document-private.h"
 #include "inkscape.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)
+
+void Inkscape::DocumentUndo::setUndoSensitive(SPDocument *doc, bool sensitive)
 {
        g_assert (doc != NULL);
        g_assert (doc->priv != NULL);
@@ -112,20 +100,19 @@ sp_document_set_undo_sensitive (SPDocument *doc, bool sensitive)
  * 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 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)
+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);
+    maybeDone(doc, NULL, event_type, event_description);
 }
 
-void sp_document_reset_key( Inkscape::Application * /*inkscape*/, SPDesktop * /*desktop*/, GtkObject *base )
+void Inkscape::DocumentUndo::resetKey( Inkscape::Application * /*inkscape*/, SPDesktop * /*desktop*/, GtkObject *base )
 {
     SPDocument *doc = reinterpret_cast<SPDocument *>(base);
     doc->actionkey.clear();
@@ -163,9 +150,8 @@ public:
 
 }
 
-void
-sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type,
-                        Glib::ustring event_description)
+void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const unsigned int event_type,
+                                       Glib::ustring const &event_description)
 {
        g_assert (doc != NULL);
        g_assert (doc->priv != NULL);
@@ -178,9 +164,9 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev
 
        doc->collectOrphans();
 
-       sp_document_ensure_up_to_date (doc);
+       doc->ensureUpToDate();
 
-       sp_document_clear_redo (doc);
+       DocumentUndo::clearRedo(doc);
 
        Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc));
        doc->priv->partial = NULL;
@@ -214,8 +200,7 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev
   doc->priv->commit_signal.emit();
 }
 
-void
-sp_document_cancel (SPDocument *doc)
+void Inkscape::DocumentUndo::cancel(SPDocument *doc)
 {
        g_assert (doc != NULL);
        g_assert (doc->priv != NULL);
@@ -246,8 +231,7 @@ static void finish_incomplete_transaction(SPDocument &doc) {
        }
 }
 
-gboolean
-sp_document_undo (SPDocument *doc)
+gboolean Inkscape::DocumentUndo::undo(SPDocument *doc)
 {
        using Inkscape::Debug::EventTracker;
        using Inkscape::Debug::SimpleEvent;
@@ -292,8 +276,7 @@ sp_document_undo (SPDocument *doc)
        return ret;
 }
 
-gboolean
-sp_document_redo (SPDocument *doc)
+gboolean Inkscape::DocumentUndo::redo(SPDocument *doc)
 {
        using Inkscape::Debug::EventTracker;
        using Inkscape::Debug::SimpleEvent;
@@ -338,8 +321,7 @@ sp_document_redo (SPDocument *doc)
        return ret;
 }
 
-void
-sp_document_clear_undo (SPDocument *doc)
+void Inkscape::DocumentUndo::clearUndo(SPDocument *doc)
 {
         if (doc->priv->undo)
                 doc->priv->undoStackObservers.notifyClearUndoEvent();
@@ -356,8 +338,7 @@ sp_document_clear_undo (SPDocument *doc)
        }
 }
 
-void
-sp_document_clear_redo (SPDocument *doc)
+void Inkscape::DocumentUndo::clearRedo(SPDocument *doc)
 {
         if (doc->priv->redo)
                 doc->priv->undoStackObservers.notifyClearRedoEvent();
diff --git a/src/document-undo.h b/src/document-undo.h
new file mode 100644 (file)
index 0000000..9be260f
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef SEEN_SP_DOCUMENT_UNDO_H
+#define SEEN_SP_DOCUMENT_UNDO_H
+
+
+namespace Inkscape {
+
+class DocumentUndo
+{
+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 :
index 677883112660bfcd219f73d696f43316f11be0cf..a473daa3ca640d341daf92bb280947ef7d8b784c 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_DOCUMENT_C__
-
 /** \file
  * SPDocument manipulation
  *
@@ -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
@@ -61,6 +61,8 @@
 #include "xml/repr.h"
 #include "xml/rebase-hrefs.h"
 
+using Inkscape::DocumentUndo;
+
 // Higher number means lower priority.
 #define SP_DOCUMENT_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE - 2)
 
@@ -148,8 +150,8 @@ SPDocument::~SPDocument() {
             priv->partial = NULL;
         }
 
-        sp_document_clear_redo(this);
-        sp_document_clear_undo(this);
+        DocumentUndo::clearRedo(this);
+        DocumentUndo::clearUndo(this);
 
         if (root) {
             root->releaseReferences();
@@ -198,7 +200,7 @@ SPDocument::~SPDocument() {
 
     if (oldSignalsConnected) {
         g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE),
-                                             reinterpret_cast<gpointer>(sp_document_reset_key),
+                                             reinterpret_cast<gpointer>(DocumentUndo::resetKey),
                                              static_cast<gpointer>(this));
     } else {
         _selection_changed_connection.disconnect();
@@ -239,12 +241,13 @@ SPDocument::setCurrentPersp3D(Persp3D * const persp) {
     //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) ) {
-        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));
+        }
     }
 }
 
@@ -288,20 +291,16 @@ void SPDocument::reset_key (void */*dummy*/)
     actionkey.clear();
 }
 
-SPDocument *
-sp_document_create(Inkscape::XML::Document *rdoc,
-                   gchar const *uri,
-                   gchar const *base,
-                   gchar const *name,
-                   unsigned int keepalive)
+SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc,
+                                  gchar const *uri,
+                                  gchar const *base,
+                                  gchar const *name,
+                                  unsigned int keepalive)
 {
-    SPDocument *document;
-    Inkscape::XML::Node *rroot;
-    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
-    rroot = rdoc->root();
+    SPDocument *document = new SPDocument();
 
-    document = new SPDocument();
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    Inkscape::XML::Node *rroot = rdoc->root();
 
     document->keepalive = keepalive;
 
@@ -318,10 +317,11 @@ sp_document_create(Inkscape::XML::Document *rdoc,
     // base is simply the part of the path before filename; e.g. when running "inkscape ../file.svg" the base is "../"
     // which is why we use g_get_current_dir() in calculating the abs path above
     //This is NULL for a new document
-    if (base)
+    if (base) {
         document->base = g_strdup(base);
-    else
+    } else {
         document->base = NULL;
+    }
     document->name = g_strdup(name);
 
     document->root = sp_object_repr_build_tree(document, rroot);
@@ -413,13 +413,13 @@ sp_document_create(Inkscape::XML::Document *rdoc,
         document->setCurrentPersp3DImpl(persp_impl);
     }
 
-    sp_document_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
     g_signal_connect(G_OBJECT(INKSCAPE), "change_selection",
-                     G_CALLBACK(sp_document_reset_key), document);
+                     G_CALLBACK(DocumentUndo::resetKey), document);
     g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop",
-                     G_CALLBACK(sp_document_reset_key), document);
+                     G_CALLBACK(DocumentUndo::resetKey), document);
     document->oldSignalsConnected = true;
 
     return document;
@@ -429,8 +429,7 @@ sp_document_create(Inkscape::XML::Document *rdoc,
  * 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 *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new)
 {
     SPDocument *doc;
     Inkscape::XML::Document *rdoc;
@@ -472,7 +471,7 @@ sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new)
     //# 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);
@@ -480,8 +479,7 @@ sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new)
     return doc;
 }
 
-SPDocument *
-sp_document_new_from_mem(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;
@@ -500,44 +498,38 @@ sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepaliv
 
     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 *SPDocument::doRef()
 {
-    g_return_val_if_fail(doc != NULL, NULL);
-    Inkscape::GC::anchor(doc);
-    return doc;
+    Inkscape::GC::anchor(this);
+    return this;
 }
 
-SPDocument *
-sp_document_unref(SPDocument *doc)
+SPDocument *SPDocument::doUnref()
 {
-    g_return_val_if_fail(doc != NULL, NULL);
-    Inkscape::GC::release(doc);
+    Inkscape::GC::release(this);
     return NULL;
 }
 
-gdouble sp_document_width(SPDocument *document)
+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->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)
+void SPDocument::setWidth(gdouble width, const SPUnit *unit)
 {
-    SPRoot *root = SP_ROOT(document->root);
+    SPRoot *root = SP_ROOT(this->root);
 
     if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox=
         root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit);
@@ -561,9 +553,9 @@ sp_document_set_width (SPDocument *document, gdouble width, const SPUnit *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)
 {
-    SPRoot *root = SP_ROOT(document->root);
+    SPRoot *root = SP_ROOT(this->root);
 
     if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox=
         root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit);
@@ -587,56 +579,21 @@ void sp_document_set_height (SPDocument * document, gdouble height, const SPUnit
     SP_OBJECT (root)->updateRepr();
 }
 
-gdouble sp_document_height(SPDocument *document)
+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->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() 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());
 }
 
 /**
@@ -653,7 +610,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
     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 */
@@ -665,9 +622,8 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
     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");
+        if (nv != NULL) {
+            gchar const * const units_abbr = nv->getAttribute("units");
             SPUnit const *margin_units = NULL;
             if (units_abbr != NULL) {
                 margin_units = sp_unit_get_by_abbreviation(units_abbr);
@@ -675,14 +631,10 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
             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_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);
         }
     }
     
@@ -691,8 +643,8 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
             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())
@@ -708,14 +660,22 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
     }
 }
 
-static void
-do_change_uri(SPDocument *const document, gchar const *const filename, bool const rebase)
+void SPDocument::setBase( gchar const* base )
 {
-    g_return_if_fail(document != 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
@@ -730,32 +690,32 @@ do_change_uri(SPDocument *const document, gchar const *const filename, bool cons
     } 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 = 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 = 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);
+    DocumentUndo::setUndoSensitive(this, saved);
 
 
-    g_free(document->name);
-    g_free(document->base);
-    g_free(document->uri);
-    document->name = new_name;
-    document->base = new_base;
-    document->uri = new_uri;
+    g_free(this->name);
+    g_free(this->base);
+    g_free(this->uri);
+    this->name = new_name;
+    this->base = new_base;
+    this->uri = new_uri;
 
-    document->priv->uri_set_signal.emit(document->uri);
+    this->priv->uri_set_signal.emit(this->uri);
 }
 
 /**
@@ -765,11 +725,9 @@ do_change_uri(SPDocument *const document, gchar const *const filename, bool cons
  *
  * \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);
-
-    do_change_uri(document, filename, false);
+    do_change_uri(filename, false);
 }
 
 /**
@@ -778,19 +736,14 @@ void sp_document_set_uri(SPDocument *document, gchar const *filename)
  *
  * \see sp_document_set_uri
  */
-void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *filename)
+void SPDocument::changeUriAndHrefs(gchar const *filename)
 {
-    g_return_if_fail(document != NULL);
-
-    do_change_uri(document, filename, true);
+    do_change_uri(filename, true);
 }
 
-void
-sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height)
+void SPDocument::emitResizedSignal(gdouble width, gdouble height)
 {
-    g_return_if_fail(doc != 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 +843,8 @@ SPDocument::removeUndoObserver(Inkscape::UndoStackObserver& observer)
     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 +857,8 @@ sigc::connection SPDocument::connectIdChanged(gchar const *id,
     return priv->id_changed_signals[g_quark_from_string(id)].connect(slot);
 }
 
-void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) {
+void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object)
+{
     if (object) {
         g_assert(g_hash_table_lookup(priv->reprdef, repr) == NULL);
         g_hash_table_insert(priv->reprdef, repr, object);
@@ -913,12 +868,14 @@ void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *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))
@@ -949,16 +906,15 @@ Glib::ustring SPDocument::getLanguage() {
 
 /* Object modification root handler */
 
-void
-sp_document_request_modified(SPDocument *doc)
+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 +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 = DocumentUndo::getUndoSensitive(this);
+            DocumentUndo::setUndoSensitive(this, false);
 
             this->root->updateDisplay((SPCtx *)&ctx, 0);
 
-            sp_document_set_undo_sensitive(this, saved);
+            DocumentUndo::setUndoSensitive(this, saved);
         }
         this->_emitModified();
     }
@@ -1017,8 +973,7 @@ SPDocument::_updateDocument()
  * 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)
+gint SPDocument::ensureUpToDate()
 {
     // Bring the document up-to-date, specifically via the following:
     //   1a) Process all document updates.
@@ -1027,9 +982,9 @@ sp_document_ensure_up_to_date(SPDocument *doc)
     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--;
@@ -1043,19 +998,19 @@ sp_document_ensure_up_to_date(SPDocument *doc)
         // 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
+        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
+        g_source_remove(rerouting_handler_id);
+        rerouting_handler_id = 0;
     }
     return counter>0;
 }
@@ -1109,17 +1064,16 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey,
 {
     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) ) {
-        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);
-            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 +1086,45 @@ Returns true if an item is among the descendants of group (recursively).
  */
 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) ) {
-        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)
+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) ) {
-
-        if (!SP_IS_ITEM(o)) continue;
-
-        SPItem *item = SP_ITEM(o);
-        NRArenaItem *arenaitem = sp_item_get_arenaitem(item, 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);
-            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 +1135,21 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s
 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) ) {
-        if (!SP_IS_ITEM(o)) continue;
+    for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
+        if (!SP_IS_ITEM(o)) {
+            continue;
+        }
 
-        if (upto && SP_ITEM(o) == upto)
+        if (upto && SP_ITEM(o) == upto) {
             break;
+        }
 
         if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
             // if nothing found yet, recurse into the group
@@ -1205,12 +1159,12 @@ find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gbool
                 newseen = NULL;
             }
 
-            if (item_is_in_group(upto, SP_GROUP(o)))
+            if (item_is_in_group(upto, SP_GROUP(o))) {
                 break;
-
+            }
         } else {
             SPItem *child = SP_ITEM(o);
-            NRArenaItem *arenaitem = sp_item_get_arenaitem(child, dkey);
+            NRArenaItem *arenaitem = child->get_arenaitem(dkey);
 
             // seen remembers the last (topmost) of items pickable at this point
             if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL
@@ -1226,15 +1180,16 @@ find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gbool
 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) ) {
-        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) {
@@ -1243,7 +1198,7 @@ find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p)
         }
         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) {
@@ -1260,13 +1215,11 @@ find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p)
  * 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::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->priv != NULL, NULL);
 
-    return find_items_in_area(NULL, SP_GROUP(document->root), dkey, box, is_within);
+    return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within);
 }
 
 /*
@@ -1276,16 +1229,14 @@ GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::
  *
  */
 
-GSList *sp_document_partial_items_in_box(SPDocument *document, 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->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)
+GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
 {
     GSList *items = NULL;
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1297,7 +1248,7 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto
     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 = getItemAtPoint(key, points[i],
                                                  false, NULL);
         if (item && !g_slist_find(items, item))
             items = g_slist_prepend (items, item);
@@ -1309,95 +1260,86 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto
     return items;
 }
 
-SPItem *
-sp_document_item_at_point(SPDocument *document, 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->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)
+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->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)
+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(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);
-    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);
+        GQuark q = g_quark_from_string(key);
+        priv->resources_changed_signals[q].emit();
 
-    document->priv->resources_changed_signals[q].emit();
+        result = true;
+    }
 
-    return TRUE;
+    return result;
 }
 
-gboolean
-sp_document_remove_resource(SPDocument *document, 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(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);
-    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);
+        GQuark q = g_quark_from_string(key);
+        priv->resources_changed_signals[q].emit();
 
-    document->priv->resources_changed_signals[q].emit();
+        result = true;
+    }
 
-    return TRUE;
+    return result;
 }
 
-GSList const *
-sp_document_get_resource_list(SPDocument *document, gchar const *key)
+GSList const *SPDocument::getResourceList(gchar const *key) const
 {
-    g_return_val_if_fail(document != 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,
-                                                       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 +1351,40 @@ sp_document_resource_list_free(gpointer /*key*/, gpointer value, gpointer /*data
     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->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->firstChild(); i; i = i->getNext() ) {
             vacuum_document_recursive(i);
         }
     }
 }
 
-unsigned int
-vacuum_document(SPDocument *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 = start;
     unsigned int newend = start;
 
     unsigned int iterations = 0;
@@ -1454,11 +1392,11 @@ vacuum_document(SPDocument *document)
     do {
         end = newend;
 
-        vacuum_document_recursive(SP_DOCUMENT_ROOT(document));
-        document->collectOrphans();
+        vacuum_document_recursive(root);
+        this->collectOrphans();
         iterations++;
 
-        newend = objects_in_document(document);
+        newend = objects_in_document(this);
 
     } while (iterations < 100 && newend < end);
 
index 4f5f045c5566fb5819fcb59a5898740637b844a3..82c874cb73678f284b2e62e67dad2d7efdd93e9e 100644 (file)
@@ -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,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 +30,7 @@
 #include "gc-anchored.h"
 #include <glibmm/ustring.h>
 #include "verbs.h"
+#include "document-undo.h"
 #include <vector>
 #include <set>
 
@@ -64,10 +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:
     typedef sigc::signal<void, SPObject *> IDChangedSignal;
     typedef sigc::signal<void> ResourcesChangedSignal;
     typedef sigc::signal<void, guint> ModifiedSignal;
@@ -89,10 +93,13 @@ struct SPDocument : public Inkscape::GC::Managed<>,
     SPObject *root;             ///< Our SPRoot
     CRCascade *style_cascade;
 
+protected:
     gchar *uri;   ///< A filename (not a URI yet), or NULL
     gchar *base;  ///< To be used for resolving relative hrefs.
     gchar *name;  ///< basename(uri) or other human-readable label for the document.
 
+public:
+
     SPDocumentPrivate *priv;
 
     /// Last action key
@@ -113,6 +120,27 @@ struct SPDocument : public Inkscape::GC::Managed<>,
 
     bool oldSignalsConnected;
 
+    /** Returns our SPRoot */
+    SPObject *getRoot() { return root; }
+
+    Inkscape::XML::Node *getReprRoot() { return rroot; }
+
+    /** Our Inkscape::XML::Document. */
+    Inkscape::XML::Document *getReprDoc() { return rdoc; }
+    Inkscape::XML::Document const *getReprDoc() const { return rdoc; }
+
+    /** A filename (not a URI yet), or NULL */
+    gchar const *getURI() const { return uri; }
+    void setUri(gchar const *uri);
+
+    /** To be used for resolving relative hrefs. */
+    gchar const *getBase() const { return base; };
+    void setBase( gchar const* base );
+
+    /** basename(uri) or other human-readable label for the document. */
+    gchar const* getName() const { return name; }
+
+
     void setCurrentPersp3D(Persp3D * const persp);
     inline void setCurrentPersp3DImpl(Persp3DImpl * const persp_impl) { current_persp3d_impl = persp_impl; }
     /*
@@ -121,28 +149,28 @@ struct SPDocument : public Inkscape::GC::Managed<>,
      */
     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();
@@ -180,83 +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);
 
-#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 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);
+};
 
 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);
-
-#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_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);
-
-/* Object modification root handler */
-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);
-
-/* Cancel (and revert) current unsaved actions */
-void sp_document_cancel(SPDocument *document);
-
-/* Undo and redo */
-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);
-
-
 /*
  * Ideas: How to overcome style invalidation nightmare
  *
@@ -271,26 +265,7 @@ sigc::connection sp_document_resources_changed_connect(SPDocument *document, con
  *
  */
 
-/*
- * 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);
-
-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);
-
-unsigned int vacuum_document(SPDocument *document);
-
-
-#endif
+#endif // SEEN_SP_DOCUMENT_H
 
 /*
   Local Variables:
index 3f33f9499809ff22f9c5410e5cc60742a58e66d1..62ae67336cad48236adbbcb3c29132257aa716b6 100644 (file)
@@ -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 +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 +439,7 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/)
         /* 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();
@@ -639,12 +640,12 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
 
     /* 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 */
@@ -677,11 +678,11 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
 
             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,
+        DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL,
                          _("Draw path"));
 
         // When quickly drawing several subpaths with Shift, the next subpath may be finished and
@@ -695,7 +696,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
     c->unref();
 
     /* Flush pending updates */
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 }
 
 /**
@@ -789,7 +790,7 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
     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));
@@ -819,8 +820,8 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
        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
@@ -839,11 +840,12 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
     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"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot"));
 }
 
 /*
index 5415fdc80fb050af4193d3c11cab77911811b5b9..b7344889ff67836fe81fac969ca6db79a291d001 100644 (file)
@@ -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 +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 +351,8 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
 
 
                 if (!(sp_desktop_selection(desktop)->isEmpty())) {
-                    sp_document_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..93d4262cd172512dbfe53d9fe6befc064f398009 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_DYNA_DRAW_CONTEXT_C__
-
 /*
  * Handwriting-like drawing mode
  *
@@ -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 +64,8 @@
 
 #include "dyna-draw-context.h"
 
+using Inkscape::DocumentUndo;
+
 #define DDC_RED_RGBA 0xff0000ff
 
 #define TOLERANCE_CALLIGRAPHIC 0.1
@@ -599,7 +600,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context,
                     }
 
                     // 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 +1003,7 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize, bool subtract)
     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 */
@@ -1012,7 +1013,7 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize, bool subtract)
 
             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();
@@ -1040,8 +1041,8 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize, bool subtract)
         dc->repr = NULL;
     }
 
-    sp_document_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
index 9b00dcd036eaa13ed3ba3b1a7d4b22bc3ad217f1..68c0989bc945b1a80c8ad3e5b6764ad2df468ecf 100644 (file)
@@ -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 +66,8 @@
 
 #include "eraser-context.h"
 
+using Inkscape::DocumentUndo;
+
 #define ERC_RED_RGBA 0xff0000ff
 
 #define TOLERANCE_ERASER 0.1
@@ -716,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 */
@@ -726,7 +729,7 @@ set_to_accumulated(SPEraserContext *dc)
 
             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();
@@ -741,7 +744,7 @@ set_to_accumulated(SPEraserContext *dc)
             Inkscape::Preferences *prefs = Inkscape::Preferences::get();
             
             gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
-            Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+            Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
 
             SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr));
             Geom::OptRect eraserBbox = acid->getBounds(Geom::identity());
@@ -750,10 +753,10 @@ set_to_accumulated(SPEraserContext *dc)
             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)->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)->getItemsAtPoints(desktop->dkey, r->getPoints());
                 }
                 toWorkOn = g_slist_remove( toWorkOn, acid );
             } else {
@@ -829,10 +832,10 @@ set_to_accumulated(SPEraserContext *dc)
 
 
     if ( workDone ) {
-        sp_document_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));
+        DocumentUndo::cancel(sp_desktop_document(desktop));
     }
 }
 
index a4109a91cb754a2877c379c91431f40575ae79b8..828ce3d5b1d02ab950dc31ab76eb789603ca24d3 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_EVENT_CONTEXT_C__
-
 /** \file
  * Main event handling, and related helper functions.
  *
@@ -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.
@@ -1103,20 +1102,21 @@ guint get_group0_keyval(GdkEventKey *event) {
  * 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 +1131,7 @@ sp_event_context_over_item(SPDesktop *desktop, SPItem *item,
         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;
index b183be93cbf5e367576cd412c83fb34cce932e54..a652b7c969b423daf90a1b2928bc9e262987f438 100644 (file)
@@ -123,7 +123,7 @@ application_interface_document_close_all (ApplicationInterface *object,
     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);
 */
 
index b8b0c2ade314f609f3d5632e6e3184a38d6a40d2..836ad33976cb284358636fa65a722587a175ac3f 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "sp-object.h"
 
-#include "document.h" // sp_document_repr_doc
+#include "document.h" // getReprDoc()
 
 #include "desktop-style.h" //sp_desktop_get_style
 
@@ -189,7 +189,7 @@ Inkscape::XML::Node *
 dbus_create_node (SPDesktop *desk, const gchar *type)
 {
     SPDocument * doc = sp_desktop_document (desk);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     return xml_doc->createElement(type);
 }
@@ -517,11 +517,10 @@ document_interface_image (DocumentInterface *object, int x, int y, gchar *filena
     return strdup(newNode->attribute("id"));
 }
 
-gchar* 
-document_interface_node (DocumentInterface *object, gchar *type, GError **error)
+gchar *document_interface_node (DocumentInterface *object, gchar *type, GError **error)
 {
     SPDocument * doc = sp_desktop_document (object->desk);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::XML::Node *newNode =  xml_doc->createElement(type);
 
index 9a22c07b7c4e3ed809deef3e3170586cd6662336..51aa42da67fe8699770247393ed1931f235e7572 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Authors:
  *   Ted Gould <ted@gould.cx>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2002-2007 Authors
  *
@@ -258,7 +259,7 @@ Effect::prefs (Inkscape::UI::View::View * doc)
     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
index 7ed3891951c33a38ebd6328d7a57dfc0f3c2a4bb..f9e099c26f3e27be229adfcb4c073847d11b4be9 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Authors:
  *   Ted Gould <ted@gould.cx>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007-2008 Authors
  *
@@ -162,14 +163,14 @@ ExecutionEnv::cancel (void) {
 
 void
 ExecutionEnv::undo (void) {
-    sp_document_cancel(_doc->doc());
+    DocumentUndo::cancel(_doc->doc());
     reselect();
     return;
 }
 
 void
 ExecutionEnv::commit (void) {
-    sp_document_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..bc143fd14ece526f129b0c68576dc9d107e8081e 100644 (file)
@@ -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
  *
@@ -532,9 +533,8 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
     } // data_read
 
     if (mydoc != NULL) {
-        g_free(mydoc->base);
-        mydoc->base = NULL;
-        sp_document_change_uri_and_hrefs(mydoc, filenameArg);
+        mydoc->setBase(0);
+        mydoc->changeUriAndHrefs(filenameArg);
     }
 
     // make sure we don't leak file descriptors from g_file_open_tmp
index 2ab821e445635da2f1fe53d3f4274b436c78096c..c929ba19a429c6e0062ea0daca978b9e2234b8c4 100644 (file)
@@ -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 +176,7 @@ XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename)
     }
     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 +191,7 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const
     g_return_if_fail(doc != NULL);
     g_return_if_fail(filename != NULL);
 
-    Inkscape::XML::Node *repr = NULL;
-    repr = sp_document_repr_root (doc);
+    Inkscape::XML::Node *repr = doc->getReprRoot();
 
     std::string tempfilename_out;
     int tempfd_out = 0;
@@ -202,7 +203,7 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const
     }
 
     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();
     }
 
index a82c7ba7778559c215a171f4c359f0d3efde46a4..ba6b8383c3d0e133803a93f84b36ba2c359684e0 100644 (file)
@@ -72,7 +72,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
         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);
 
index c81fdd0298df8286fa35fdc7ff56aa14811e404e..eb26fc58148bb61320121c8a7fe7ab8a2255526e 100644 (file)
@@ -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 +55,14 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
     CairoRenderer *renderer;
     CairoRenderContext *ctx;
 
-    sp_document_ensure_up_to_date(doc);
+    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 +78,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
     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..07312aab180d8c948fd86ac4dc4ba19a21839a03 100644 (file)
@@ -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 +67,7 @@ static bool
 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->ensureUpToDate();
 
     SPItem *base = NULL;
 
@@ -77,7 +79,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
     }
     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 +88,8 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
 
     /* 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();
@@ -110,7 +112,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
     }
 
     /* Release arena */
-    sp_item_invoke_hide(base, dkey);
+    base->invoke_hide(dkey);
     nr_object_unref((NRObject *) arena);
 
     renderer->destroyContext(ctx);
index 368d827b172e1e7eecf8010fe3eb2cf16709e51c..7eda3c5104d942ab480265af364b285fd6fedc7a 100644 (file)
@@ -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 +17,7 @@
 #define EXTENSION_INTERNAL_CAIRO_PS_OUT_H
 
 #include "extension/implementation/implementation.h"
+#include "sp-item.h"
 
 #ifdef HAVE_CAIRO_PDF
 
index 6caa21d248f80a469625b6fcdc669c86bd2b43f1..18a654e275731310005e360bdc1c76c49a1518c3 100644 (file)
@@ -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
  *
@@ -983,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) ) {
+    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 +1087,14 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
 
     // 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 = pat_i->firstChild() ; child; child = child->getNext() ) {
                 if (SP_IS_ITEM (child)) {
-                    sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_REFERENCE_FLAGS);
+                    SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS);
                     _renderer->renderItem(pattern_ctx, SP_ITEM (child));
                 }
             }
@@ -1120,9 +1121,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
     // 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 = 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
index 32df1193b97730eac1072dd09be3c484a2956c77..8406e2a3b53d951f251a89728299a7450ae7253a 100644 (file)
@@ -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 +57,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
                             bool texttopath, bool omittext, bool filtertobitmap, int resolution,
                             const gchar * const exportId, bool exportDrawing, bool exportCanvas)
 {
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
 /* Start */
 
@@ -69,18 +71,19 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
     }
     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();
@@ -102,7 +105,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
     }
 
     /* Release arena */
-    sp_item_invoke_hide(base, dkey);
+    base->invoke_hide(dkey);
     nr_object_unref((NRObject *) arena);
 
     renderer->destroyContext(ctx);
index 988f6126385a1d5f9539abaa8d391d58261e3c1a..67f9354d8cac97085e57fc87b6f18d90cbc29df8 100644 (file)
@@ -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,7 +186,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
 
     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);
 
@@ -450,7 +450,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
 
     // 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;
@@ -481,7 +481,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
                                  (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 +603,17 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
 
     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) {
@@ -632,7 +633,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
 
     if (ret && !pageBoundingBox)
     {
-        double high = sp_document_height(doc);
+        double high = doc->getHeight();
         if (ctx->_vector_based_target)
             high *= PT_PER_PX;
 
@@ -672,7 +673,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
 
     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->firstChild() ; child; child = child->getNext() ) {
         if (SP_IS_ITEM(child)) {
             SPItem *item = SP_ITEM(child);
 
@@ -730,7 +731,7 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask)
 
     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->firstChild() ; child; child = child->getNext() ) {
         if (SP_IS_ITEM(child)) {
             SPItem *item = SP_ITEM(child);
             renderItem(ctx, item);
index f1a26a3134c4cde8b77090c3defb9f46b2f7973c..7fa7c7ff5fad95ac6c9da0e42b1cc7579274784a 100644 (file)
@@ -7,6 +7,7 @@
 /*
  * Authors:
  *        Miklos Erdelyi <erdelyim@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Miklos Erdelyi
  * 
@@ -23,7 +24,7 @@
 
 //#include "libnrtype/font-instance.h"
 #include "style.h"
-
+#include "sp-item.h"
 #include <cairo.h>
 
 class SPClipPath;
index 474dd17932b1fa9d7d453d30c5335e072222bc95..7d379477b37169fbc0278cdd3cb3562ac4e86e72 100644 (file)
@@ -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 +111,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
     gchar *oldoutput;
     unsigned int ret;
 
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
     mod = Inkscape::Extension::get_print(PRINT_EMF_WIN32);
     oldconst = mod->get_param_string("destination");
@@ -120,7 +122,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
     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);
@@ -2367,7 +2369,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
 
 //    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;
index bd42b0eb6e8a03358533ca00dc0426167265820a..58249620b6dc7918e43a300a652791117a456ac0 100644 (file)
@@ -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 +137,8 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
     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;
@@ -146,8 +148,8 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
         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;
@@ -232,7 +234,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
     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;
 }
index c2d80b28b4e02dc0d9e235e2d186dc4c2914fcbb..90dc5dd6f0c61ea2a53ebf8a065846e3bdaa881e 100644 (file)
@@ -132,7 +132,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d
     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..c3a30a2f002f072dcc1ed128a2274d1058b7857a 100644 (file)
@@ -55,9 +55,9 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
             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 = 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 +79,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
         }
 
         // Create image node
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+        Inkscape::XML::Document *xml_doc = doc->getReprDoc();
         Inkscape::XML::Node *image_node = xml_doc->createElement("svg:image");
         sp_repr_set_svg_double(image_node, "width", width);
         sp_repr_set_svg_double(image_node, "height", height);
@@ -100,11 +100,11 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
         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);
+        DocumentUndo::setUndoSensitive(doc, saved);
     } else {
         printf("GdkPixbuf loader failed\n");
     }
index 5b3e0c16ef2e37bf7427d6951906fd7777730ed7..e92a4e17e0e14f0ccb6257abac3cce709f39b1cc 100644 (file)
@@ -5,6 +5,7 @@
 /*
  * Authors:
  *   Ted Gould <ted@gould.cx>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2005 Authors
  *
@@ -256,7 +257,7 @@ GimpGrad::open (Inkscape::Extension::Input */*module*/, gchar const *filename)
 
         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..a19ab75388c49e36a1d4ab0a44f63d4487481752 100644 (file)
@@ -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 +88,14 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
         /* 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]));
 
@@ -111,8 +112,10 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
 
     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.
+    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());
index b371b01058543d0a79a9d29e7c05ce19887fc773..7098027c7847dd4dfc3316c1cff9b1ba0b50902d 100644 (file)
@@ -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
  *
@@ -493,7 +494,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id)
 
     // 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 +636,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id)
 
     // 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)
index 4a469a7500a0da118ed649fa5ff19fad21ebe443..1477d5daf78985605a31d6b1a613d67e733403be 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * Authors:
  *   Michael Forbes <miforbes@mbhs.edu>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004 Authors
  *
@@ -55,7 +57,7 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons
     gchar * oldoutput;
     unsigned int ret;
 
-    sp_document_ensure_up_to_date (doc);
+    doc->ensureUpToDate();
 
     mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX);
     oldconst = mod->get_param_string("destination");
@@ -66,16 +68,16 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons
     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..44b64c5f8f999fdb3da78ec39b81ce0846d696d0 100644 (file)
@@ -1,10 +1,9 @@
-#define __SP_LATEX_C__
-
 /*
  * LaTeX Printing
  *
  * Author:
  *  Michael Forbes <miforbes@mbhs.edu>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004 Authors
  * 
@@ -128,8 +127,8 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
     }
 
     // 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) {
 
@@ -139,10 +138,10 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
         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());
 }
index b37316d8fc6a77c5d628d6d328068b1196f85f7b..fd99afe31b71f2fedd8c9dd503d97e277ce4d44d 100644 (file)
@@ -1,5 +1,3 @@
-#define EXTENSION_INTERNAL_LATEX_TEXT_RENDERER_CPP
-
 /** \file
  * Rendering LaTeX file (pdf/eps/ps+latex output)
  *
@@ -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
  *
@@ -58,7 +58,7 @@ 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->ensureUpToDate();
 
     SPItem *base = NULL;
 
@@ -70,7 +70,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
     }
     else {
         // we want to export the entire document from root
-        base = SP_ITEM(sp_document_root(doc));
+        base = SP_ITEM(doc->getRoot());
         pageBoundingBox = !exportDrawing;
     }
 
@@ -311,7 +311,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
     }
 
     // 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 @@ Flowing in rectangle is possible, not in arb shape.
     }
 
     // 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,16 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
 {
 // 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.");
@@ -517,7 +518,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
     }
 
     // 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;
index 4f3f1ac89bc8f4b9c8932afdb32a445c32ede929..b5c842a40c6dbf6b3857b1874f893ae54d89e522 100644 (file)
@@ -14,6 +14,7 @@
  *
  * Authors:
  *   Bob Jamison
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006, 2007 Bob Jamison
  *
@@ -945,9 +946,9 @@ static Glib::ustring formatTransform(Geom::Matrix &tf)
 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;
@@ -964,11 +965,11 @@ static Geom::Matrix getODFTransform(const SPItem *item)
  */
 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 +2003,7 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
     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))
         {
index 3854ddfe126a785d763254b6659a9f4ce2b0d4e2..9ad2610989b6da0dfa60856ba91084c2a9f5ecef 100644 (file)
@@ -11,6 +11,7 @@
  *
  * Authors:
  *   Bob Jamison
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Bob Jamison
  *
@@ -47,7 +48,7 @@
 
 #include <dom/util/ziptool.h>
 #include <dom/io/domstream.h>
-
+#include "sp-item.h"
 
 namespace Inkscape
 {
index 937fefb1117636f7c1cba87534697813c7e4960c..2c7ea3b33f7f35fc08294931af1b593a54b0aa14 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Authors:
  *   miklos erdelyi
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007 Authors
  *
@@ -58,7 +59,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
     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..ae3e473a5d72d3dd187adb56505ecbe5d29b0c47 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Authors:
  *   miklos erdelyi
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007 Authors
  *
@@ -659,9 +660,9 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
     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 = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(doc, false); // No need to undo in this temporary document
 
     // Create builder
     gchar *docname = g_path_get_basename(uri);
@@ -735,7 +736,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
     delete dlg;
 
     // Restore undo
-    sp_document_set_undo_sensitive(doc, saved);
+    DocumentUndo::setUndoSensitive(doc, saved);
 
     return doc;
 }
index e343dbf338a62d404c7c2f6c12679d7acc532dcb..8b414239a708d9c8e5a8a537491aeef07518801e 100644 (file)
@@ -3,6 +3,7 @@
  * 
  * Authors:
  *   miklos erdelyi
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2007 Authors
  *
@@ -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();
index 7b1fe8b870f25174eec19d6484b7ac224a75985e..a130b692354142786208ac3b1bd8fcfe97aa75bd 100644 (file)
@@ -10,6 +10,7 @@
  *
  * Authors:
  *   Bob Jamison <ishmal@inkscape.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2008 Authors
  *
@@ -300,7 +301,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
     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 );
 
     /*
index b10aa87ec0d4d62fbe6b04be28f8056b801d12da..946ff22fe196a7651d2efce60f1efc866f864aed 100644 (file)
@@ -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 +184,19 @@ Svg::open (Inkscape::Extension::Input */*mod*/, const gchar *uri)
 #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 +239,17 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena
     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..8b4ff13c840b34138f4bd1cb202a5be47fa50251 100644 (file)
@@ -3,6 +3,7 @@
  */
 /* Author:
  *   Lauris Kaplinski <lauris@kaplinski.com>
+ *   Abhishek Sharma
  *
  * This code is in public domain
  */
@@ -226,10 +227,10 @@ PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
     };
     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;
 
index c37d5705b4bc0b0077fc2506a9b129ed0b6bd79f..70fa28967aa72ba21a7b1b73d2edd02dbdf43cb1 100644 (file)
@@ -6,6 +6,7 @@
  *
  * Authors:
  *   Ted Gould <ted@gould.cx>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Authors
  *
@@ -86,7 +87,7 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
 
     //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..ac7c8b8dd7df668cda1b4d9dd8f95496b88beac9 100644 (file)
@@ -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
  *
@@ -345,10 +346,9 @@ Parameter::new_child (Inkscape::XML::Node * parent)
     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;
 
index 8ae71b8e6a31bc5f9244e4e5d059ccc56a12c095..0f0435c0f9ac58c1ada30d9b2af26403ed85f08b 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Authors:
  *   Ted Gould <ted@gould.cx>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2002-2004 Authors
  *
@@ -14,7 +15,7 @@
 
 #include "display/nr-arena-forward.h"
 #include "forward.h"
-
+#include "sp-item.h"
 namespace Inkscape {
 namespace Extension {
 
index 5412a5cc0b2a5de3c9e59cbcefa8060917be3016..cf58f2733f27285224af9f974934699ca93a16c2 100644 (file)
@@ -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 +113,7 @@ open(Extension *key, gchar const *filename)
        to make sure for this release -- TJG */
     doc->setModifiedSinceSave(false);
 
-    sp_document_set_uri(doc, filename);
+    doc->setUri(filename);
 
     return doc;
 }
@@ -256,11 +258,11 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
         throw Output::file_read_only();
     }
 
-    Inkscape::XML::Node *repr = sp_document_repr_root(doc);
+    Inkscape::XML::Node *repr = doc->getReprRoot();
 
 
     // remember attributes in case this is an unofficial save and/or overwrite fails
-    gchar *saved_uri = g_strdup(doc->uri);
+    gchar *saved_uri = g_strdup(doc->getURI());
     bool saved_modified = false;
     gchar *saved_output_extension = NULL;
     gchar *saved_dataloss = NULL;
@@ -268,14 +270,14 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
     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);
+        // 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 = DocumentUndo::getUndoSensitive(doc);
+        DocumentUndo::setUndoSensitive(doc, false);
         {
             // also save the extension for next use
             store_file_extension_in_prefs (omod->get_id(), save_method);
@@ -285,7 +287,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
                 repr->setAttribute("inkscape:dataloss", "true");
             }
         }
-        sp_document_set_undo_sensitive(doc, saved);
+        DocumentUndo::setUndoSensitive(doc, saved);
         doc->setModifiedSinceSave(false);
     }
 
@@ -295,14 +297,14 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
     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 = 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);
+            DocumentUndo::setUndoSensitive(doc, saved);
+            doc->changeUriAndHrefs(saved_uri);
         }
         doc->setModifiedSinceSave(saved_modified);
         // free used ressources
@@ -317,13 +319,13 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
 
     // 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 = 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);
+        DocumentUndo::setUndoSensitive(doc, saved);
         doc->setModifiedSinceSave(saved_modified);
 
         g_free(saved_output_extension);
@@ -590,8 +592,8 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) {
         case FILE_SAVE_METHOD_SAVE_AS:
         {
             bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true);
-            if (doc->uri && use_current_dir) {
-                path = Glib::path_get_dirname(doc->uri);
+            if (doc->getURI() && use_current_dir) {
+                path = Glib::path_get_dirname(doc->getURI());
             } else {
                 path = prefs->getString("/dialogs/save_as/path");
             }
@@ -604,8 +606,8 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) {
             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.
index f7cd6a09afb06e30f1811cd91eb8e23422171eb2..bde985ea56c2e3f670d6d41eafac6358b7ccd8f7 100644 (file)
@@ -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
@@ -62,6 +64,8 @@
 #include "uri.h"
 #include "xml/rebase-hrefs.h"
 
+using Inkscape::DocumentUndo;
+
 #ifdef WITH_GNOME_VFS
 # include <libgnomevfs/gnome-vfs.h>
 #endif
@@ -114,22 +118,17 @@ static void sp_file_add_recent(gchar const *uri)
 /**
  * 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( !templ.empty() ? templ.c_str() : 0 , TRUE, true );
     g_return_val_if_fail(doc != NULL, NULL);
 
-    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();
 
     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);
 
@@ -236,9 +235,9 @@ 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->ensureUpToDate();
             desktop->change_document(doc);
-            sp_document_resized_signal_emit (doc, sp_document_width(doc), sp_document_height(doc));
+            doc->emitResizedSignal(doc->getWidth(), doc->getHeight());
         } else {
             // create a whole new desktop and window
             SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL));
@@ -248,13 +247,13 @@ sp_file_open(const Glib::ustring &uri,
 
         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;
@@ -271,8 +270,7 @@ sp_file_open(const Glib::ustring &uri,
 /**
  *  Handle prompting user for "do you want to revert"?  Revert on "OK"
  */
-void
-sp_file_revert_dialog()
+void sp_file_revert_dialog()
 {
     SPDesktop  *desktop = SP_ACTIVE_DESKTOP;
     g_assert(desktop != NULL);
@@ -280,10 +278,10 @@ sp_file_revert_dialog()
     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 +547,14 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d
 /**
  * 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->vacuumDocument();
 
-    sp_document_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 +756,10 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
     save_loc = save_path;
     save_loc.append(G_DIR_SEPARATOR_S);
 
+    // TODO fixed buffer is bad:
     char formatBuf[256];
     int i = 1;
-    if (!doc->uri) {
+    if ( !doc->getURI() ) {
         // We are saving for the first time; create a unique default filename
         snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str());
         save_loc.append(formatBuf);
@@ -775,7 +771,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
             save_loc.append(formatBuf);
         }
     } else {
-        snprintf(formatBuf, 255, _("%s"), Glib::path_get_basename(doc->uri).c_str());
+        snprintf(formatBuf, 255, _("%s"), Glib::path_get_basename(doc->getURI()).c_str());
         save_loc.append(formatBuf);
     }
 
@@ -837,8 +833,8 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
         // 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 +857,7 @@ sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc)
     bool success = true;
 
     if (doc->isModifiedSinceSave()) {
-        if ( doc->uri == NULL )
+        if ( doc->getURI() == NULL )
         {
             // Hier sollte in Argument mitgegeben werden, das anzeigt, da� das Dokument das erste
             // Mal gespeichert wird, so da� als default .svg ausgew�hlt wird und nicht die zuletzt
@@ -869,7 +865,7 @@ sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc)
             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 +958,22 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
     }
 
     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));
-             child != NULL; child = SP_OBJECT_NEXT(child))
-        {
-            if (SP_IS_ITEM(child)) items_count++;
+        for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext()) {
+            if (SP_IS_ITEM(child)) {
+                items_count++;
+            }
         }
 
         // Create a new group if necessary.
@@ -996,15 +992,13 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
         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));
-             child != NULL; child = SP_OBJECT_NEXT(child) )
-        {
+        for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext() ) {
             if (SP_IS_ITEM(child)) {
                 Inkscape::XML::Node *newitem = SP_OBJECT_REPR(child)->duplicate(xml_in_doc);
 
@@ -1022,14 +1016,12 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
             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);
-                         x != NULL; x = SP_OBJECT_NEXT(x))
-                    {
+                    for ( SPObject *x = child->firstChild(); x; x = x->getNext() ) {
                         SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(x)->duplicate(xml_in_doc), last_def);
                     }
                 }
                 else if (!strcmp(tag, "svg:style")) {
-                    SP_DOCUMENT_ROOT(in_doc)->appendChildRepr(SP_OBJECT_REPR(child)->duplicate(xml_in_doc));
+                    in_doc->getRoot()->appendChildRepr(SP_OBJECT_REPR(child)->duplicate(xml_in_doc));
                 }
             }
         }
@@ -1045,14 +1037,14 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
             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();
+            // 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)->ensureUpToDate();
                 Geom::OptRect sel_bbox = selection->bounds();
                 if (sel_bbox) {
                     Geom::Point m( desktop->point() - sel_bbox->midpoint() );
@@ -1061,9 +1053,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
             }
         }
 
-        sp_document_unref(doc);
-        sp_document_done(in_doc, SP_VERB_FILE_IMPORT,
-                         _("Import"));
+        doc->doUnref();
+        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 +1247,7 @@ sp_file_export_dialog(Gtk::Window &parentWindow)
 
         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 +1300,7 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow)
 
     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())
index 63e618dcf8fc2f297a2d98cbb7328ea1f922f191..d6900b1f675ae8f28cffe0b598d8b0a42598cbcc 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FILTER_CHEMISTRY_C__
-
 /*
  * Various utility methods for filters
  *
@@ -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,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 +49,7 @@ count_filter_hrefs(SPObject *o, SPFilter *filter)
         i ++;
     }
 
-    for (SPObject *child = sp_object_first_child(o);
-         child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) {
         i += count_filter_hrefs(child, filter);
     }
 
@@ -94,14 +92,14 @@ SPFilter *new_filter(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 filter
     Inkscape::XML::Node *repr;
     repr = xml_doc->createElement("svg:filter");
 
     // Append the new filter node to defs
-    SP_OBJECT_REPR(defs)->appendChild(repr);
+    defs->appendChild(repr);
     Inkscape::GC::release(repr);
 
     // get corresponding object
@@ -117,7 +115,7 @@ SPFilter *new_filter(SPDocument *document)
 SPFilterPrimitive *
 filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveType type)
 {
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(filter->document);
+    Inkscape::XML::Document *xml_doc = filter->document->getReprDoc();
 
     //create filter primitive node
     Inkscape::XML::Node *repr;
@@ -168,7 +166,8 @@ filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveT
     }
 
     //set primitive as child of filter node
-    filter->repr->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 +189,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion
 
     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Document *xml_doc = document->getReprDoc();
 
     // create a new filter
     Inkscape::XML::Node *repr;
@@ -217,7 +216,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion
     Inkscape::GC::release(b_repr);
     
     // Append the new filter node to defs
-    SP_OBJECT_REPR(defs)->appendChild(repr);
+    defs->appendChild(repr);
     Inkscape::GC::release(repr);
 
     // get corresponding object
@@ -245,7 +244,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo
 
     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Document *xml_doc = document->getReprDoc();
 
     // create a new filter
     Inkscape::XML::Node *repr;
@@ -253,7 +252,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo
     repr->setAttribute("inkscape:collect", "always");
 
     // Append the new filter node to defs
-    SP_OBJECT_REPR(defs)->appendChild(repr);
+    defs->appendChild(repr);
     Inkscape::GC::release(repr);
  
     // get corresponding object
@@ -319,7 +318,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo
 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;
@@ -330,7 +329,7 @@ new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mod
         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));
 }
@@ -344,37 +343,35 @@ new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mod
  * 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);
+        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) {
index 4c41184db4f9f4c6652538cae6c15910e1f377f7..9a52d86f751c56929a4da47aa812521353af3558 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEBLEND_CPP__
-
 /** \file
  * SVG <feBlend> implementation.
  *
@@ -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 +102,8 @@ sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re
     }
 
     /*LOAD ATTRIBUTES FROM REPR HERE*/
-    sp_object_read_attr(object, "mode");
-    sp_object_read_attr(object, "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 +201,8 @@ sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags)
     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" );
     }
 
     /* Unlike normal in, in2 is required attribute. Make sure, we can call
@@ -213,7 +212,9 @@ sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags)
     {
         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.
+        object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2));
     }
 
     if (((SPObjectClass *) feBlend_parent_class)->update) {
index da1c91632fe6f9e646e60b3f3ffe0fc4ca0dd3c1..6018afe093c0b445a85d7d5b1b14fbbeac6dc08c 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FECOLORMATRIX_CPP__
-
 /** \file
  * SVG <feColorMatrix> implementation.
  *
@@ -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 +97,8 @@ sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::No
     }
 
     /*LOAD ATTRIBUTES FROM REPR HERE*/
-    sp_object_read_attr(object, "type");
-    sp_object_read_attr(object, "values");
+    object->readAttr( "type" );
+    object->readAttr( "values" );
 }
 
 /**
index 2fad817971c2e16ca20edc374a5cb9348f67d430..a245e1c89f21349c81d16e0e2ca1ba2a9fe60bb2 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEFUNCNODE_CPP__
-
 /** \file
  * SVG <funcR>, <funcG>, <funcB> and <funcA> implementations.
  */
@@ -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 +167,17 @@ sp_fefuncnode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
     }
 
     //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" );
 
 
 //is this necessary?
-    sp_document_add_resource(document, "fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ?
+    document->addResource("fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ?
 }
 
 /**
@@ -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)->removeResource("fefuncnode", SP_OBJECT(object));
     }
 
 //TODO: release resources here
@@ -296,8 +295,8 @@ sp_fefuncnode_update(SPObject *object, SPCtx *ctx, guint flags)
     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" );
     }
 
     if (((SPObjectClass *) feFuncNode_parent_class)->update) {
index f1d4a709bbeb06a43c6a4eaa3612b0177ca2db9b..c6ff4f5f200c0a835c6e74fbb084ab3fa5d60055 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FECOMPONENTTRANSFER_CPP__
-
 /** \file
  * SVG <feComponentTransfer> implementation.
  *
@@ -7,6 +5,7 @@
 /*
  * Authors:
  *   hugo Rodrigues <haa.rodrigues@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Hugo Rodrigues
  *
@@ -100,7 +99,7 @@ sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::X
     /*LOAD ATTRIBUTES FROM REPR HERE*/
 
     //do we need this?
-    sp_document_add_resource(document, "feComponentTransfer", object);
+    document->addResource("feComponentTransfer", object);
 }
 
 static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_componenttransfer)
index 9398aeea766666c3bb9ffc5986ee8cbfc8879748..c2b47c4c2d487c1ab5597e00437bf761b456ca55 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FECOMPOSITE_CPP__
-
 /** \file
  * SVG <feComposite> implementation.
  *
@@ -7,6 +5,7 @@
 /*
  * Authors:
  *   hugo Rodrigues <haa.rodrigues@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Hugo Rodrigues
  *
@@ -101,14 +100,14 @@ sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
 
     SPFeComposite *comp = SP_FECOMPOSITE(object);
 
-    sp_object_read_attr(object, "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" );
     }
-    sp_object_read_attr(object, "in2");
+    object->readAttr( "in2" );
 
     /* Unlike normal in, in2 is required attribute. Make sure, we can call
      * it by some name. */
@@ -240,7 +239,9 @@ sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags)
     {
         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) {
index 45c0a080efea76dd69a69df128ef5fd684a6b343..3f141996793a39df1e18191e2827e5a9de84de62 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FECONVOLVEMATRIX_CPP__
-
 /** \file
  * SVG <feConvolveMatrix> implementation.
  *
@@ -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 +109,15 @@ sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML:
     }
 
     /*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" );
 }
 
 /**
index ca7a8423cacee396063133dcb5c6409646c48829..95faa4a2923546bbba6618a94958ad30513a1fca 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEDIFFUSELIGHTING_CPP__
-
 /** \file
  * SVG <feDiffuseLighting> implementation.
  *
@@ -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 +117,10 @@ sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML
     }
 
     /*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" );
     
 }
 
@@ -224,10 +223,10 @@ static void
 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" );
     }
 
     if (((SPObjectClass *) feDiffuseLighting_parent_class)->update) {
index 956719d10c909bdc91d58a5bc86bb0cdbf5aed7f..a6ad8b81aa70295b54b6b341652a6df5a3ea1453 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEDISPLACEMENTMAP_CPP__
-
 /** \file
  * SVG <feDisplacementMap> implementation.
  *
@@ -7,6 +5,7 @@
 /*
  * Authors:
  *   hugo Rodrigues <haa.rodrigues@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Hugo Rodrigues
  *
@@ -97,10 +96,10 @@ sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML
     }
 
     /*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" );
 
     /* Unlike normal in, in2 is required attribute. Make sure, we can call
      * it by some name. */
@@ -218,7 +217,9 @@ sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flags)
     {
         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.
+        object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2));
     }
 
     if (((SPObjectClass *) feDisplacementMap_parent_class)->update) {
index ee366a23d95f2479bafa00e007cf5abe85a1e220..2207bc8e449535829a2b842388ccfba3986e8397 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEDISTANTLIGHT_CPP__
-
 /** \file
  * SVG <fedistantlight> implementation.
  */
@@ -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 +100,11 @@ sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::N
     }
 
     //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" );
 
 //is this necessary?
-    sp_document_add_resource(document, "fedistantlight", object);
+    document->addResource("fedistantlight", object);
 }
 
 /**
@@ -118,7 +117,7 @@ sp_fedistantlight_release(SPObject *object)
 
     if (SP_OBJECT_DOCUMENT(object)) {
         /* Unregister ourselves */
-        sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fedistantlight", SP_OBJECT(object));
+        SP_OBJECT_DOCUMENT(object)->removeResource("fedistantlight", SP_OBJECT(object));
     }
 
 //TODO: release resources here
@@ -189,8 +188,8 @@ sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags)
 
     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" );
     }
 
     if (((SPObjectClass *) feDistantLight_parent_class)->update) {
index cf7ce662fc3eba7ff2ac9b3052076b6895d777c2..25780c1aec9cb4cc1062b3ae66ae5a8164ef6dc3 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEFLOOD_CPP__
-
 /** \file
  * SVG <feFlood> implementation.
  *
@@ -7,6 +5,7 @@
 /*
  * Authors:
  *   hugo Rodrigues <haa.rodrigues@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Hugo Rodrigues
  *
@@ -96,8 +95,8 @@ sp_feFlood_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re
     }
 
     /*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" );
 }
 
 /**
index 69a4b601833c72a1e8560a2168e5d2e298893438..bbe775c18b5e294f938769841047a68b994c738b 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEIMAGE_CPP__
-
 /** \file
  * SVG <feImage> implementation.
  *
@@ -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 +99,11 @@ static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::X
 
     /*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" );
 
 }
 
index 1f92df4d662cedcd707fb13a6c61f46a6dd4e321..b7b06a94a4dd2bb82b68a575b950e1667945ff40 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEMERGENODE_CPP__
-
 /** \file
  * feMergeNode implementation. A feMergeNode contains the name of one
  * input image for feMerge.
@@ -8,6 +6,7 @@
  * Authors:
  *   Kees Cook <kees@outflux.net>
  *   Niko Kiirala <niko@kiirala.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004,2007 authors
  *
@@ -84,7 +83,7 @@ sp_feMergeNode_init(SPFeMergeNode *feMergeNode)
 static void
 sp_feMergeNode_build(SPObject *object, SPDocument */*document*/, Inkscape::XML::Node */*repr*/)
 {
-    sp_object_read_attr(object, "in");
+    object->readAttr( "in" );
 }
 
 /**
index 668f94c4c37bd6d5ce0500b4bad1654b978796d6..7ae65c48ded2734434862fbe8adc66b6b76f0126 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEMORPHOLOGY_CPP__
-
 /** \file
  * SVG <feMorphology> implementation.
  *
@@ -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 +96,8 @@ sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod
     }
 
     /*LOAD ATTRIBUTES FROM REPR HERE*/
-    sp_object_read_attr(object, "operator");
-    sp_object_read_attr(object, "radius");
+    object->readAttr( "operator" );
+    object->readAttr( "radius" );
 }
 
 /**
index 2db9316500c1e46e4566c60d82f378bd94d191ec..48ee895dc88d9c0657ca3f5999d37949db8d82de 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEOFFSET_CPP__
-
 /** \file
  * SVG <feOffset> implementation.
  *
@@ -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 +95,8 @@ sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r
         ((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" );
 }
 
 /**
@@ -151,8 +150,8 @@ static void
 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" );
     }
 
     if (((SPObjectClass *) feOffset_parent_class)->update) {
index a4939023eaabc6e134e4cd1202d7ca9a949e916b..c9eebcb18868dfa371ac17bf4645cd5822908894 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FEPOINTLIGHT_CPP__
-
 /** \file
  * SVG <fepointlight> implementation.
  */
@@ -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 +103,12 @@ sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod
     }
 
     //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" );
 
 //is this necessary?
-    sp_document_add_resource(document, "fepointlight", object);
+    document->addResource("fepointlight", object);
 }
 
 /**
@@ -122,7 +121,7 @@ sp_fepointlight_release(SPObject *object)
 
     if (SP_OBJECT_DOCUMENT(object)) {
         /* Unregister ourselves */
-        sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fepointlight", SP_OBJECT(object));
+        SP_OBJECT_DOCUMENT(object)->removeResource("fepointlight", SP_OBJECT(object));
     }
 
 //TODO: release resources here
@@ -211,9 +210,9 @@ sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags)
 
     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" );
     }
 
     if (((SPObjectClass *) fePointLight_parent_class)->update) {
index 6ed540892e640d2d902b6772bc62c92eed32cef3..41eb38e61aa78c09a193c42670cd9d5f2642c5af 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FESPECULARLIGHTING_CPP__
-
 /** \file
  * SVG <feSpecularLighting> implementation.
  *
@@ -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 +119,11 @@ sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XM
     }
 
     /*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" );
     
 }
 
@@ -250,11 +249,11 @@ static void
 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" );
     }
 
     if (((SPObjectClass *) feSpecularLighting_parent_class)->update) {
index 6d13479756015a6e48d3e241a54213a053778a42..dac9b87e7d11f7cf3cb75aec066758e2ee51cca6 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FESPOTLIGHT_CPP__
-
 /** \file
  * SVG <fespotlight> implementation.
  */
@@ -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 +113,17 @@ sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
     }
 
     //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" );
 
 //is this necessary?
-    sp_document_add_resource(document, "fespotlight", object);
+    document->addResource("fespotlight", object);
 }
 
 /**
@@ -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)->removeResource("fespotlight", SP_OBJECT(object));
     }
 
 //TODO: release resources here
@@ -309,14 +308,14 @@ sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags)
 
     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" );
     }
 
     if (((SPObjectClass *) feSpotLight_parent_class)->update) {
index 268eca643b0b21863c364c5f5f22d47c93589db6..739001311da63814c822c86d3f9dcf51114d587b 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FETURBULENCE_CPP__
-
 /** \file
  * SVG <feTurbulence> implementation.
  *
@@ -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 +99,11 @@ sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod
     }
 
     /*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" );
 }
 
 /**
index 282ccbeb6285b81004fb5f6bce783c080997a24e..dd26782a37897239b14882be3fad5febee95c517 100644 (file)
@@ -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 +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,8 @@
 #include "trace/imagemap.h"
 #include "trace/potrace/inkscape-potrace.h"
 
+using Inkscape::DocumentUndo;
+
 static void sp_flood_context_class_init(SPFloodContextClass *klass);
 static void sp_flood_context_init(SPFloodContext *flood_context);
 static void sp_flood_context_dispose(GObject *object);
@@ -417,8 +419,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
     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;
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+    //XML Tree being used here directly while it shouldn't be...."
+    Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
 
     long totalNodeCount = 0L;
 
@@ -481,14 +483,14 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
             g_free(str);
         }
 
-        layer_repr->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 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
 
     /* 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->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) {
@@ -798,7 +800,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
     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));
@@ -807,7 +809,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
     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(document->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY);
     nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine);
 
     NRGC gc(NULL);
@@ -850,7 +852,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
     nr_pixblock_release(&B);
     
     // Hide items
-    sp_item_invoke_hide(SP_ITEM(sp_document_root(document)), dkey);
+    SP_ITEM(document->getRoot())->invoke_hide(dkey);
     
     nr_object_unref((NRObject *) arena);
     
@@ -905,7 +907,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
     }
 
     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]));
@@ -1119,7 +1121,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
 
     g_free(trace_px);
     
-    sp_document_done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area"));
+    DocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area"));
 }
 
 static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
@@ -1136,10 +1138,9 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem
             
             SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE);
             
-            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"));
+            // 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 +1279,7 @@ static void sp_flood_finish(SPFloodContext *rc)
         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,
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET,
                         _("Fill bounded area"));
 
         rc->item = NULL;
index d4a98fbff915016f7c4b14e848307406fecccffe..97d2c15ed437b70f925189699b5520f6514cdc29 100644 (file)
@@ -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 +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))
-
-GType sp_document_get_type ();
-
 /* Objects */
 
-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))
-
-GType sp_object_get_type ();
-
-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))
-
-GType sp_item_get_type ();
-
 class SPGroup;
 class SPGroupClass;
 
index d5b3ddb0978ab1d12193525f9176d51030958361..fb5dab648249b11873d83796c86b256a48b483d4 100644 (file)
@@ -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
@@ -107,7 +108,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr
 
     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Document *xml_doc = document->getReprDoc();
     // create a new private gradient of the requested type
     Inkscape::XML::Node *repr;
     if (type == SP_GRADIENT_TYPE_LINEAR) {
@@ -160,8 +161,7 @@ guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
         i ++;
     }
 
-    for (SPObject *child = sp_object_first_child(o);
-         child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) {
         i += count_gradient_hrefs(child, gr);
     }
 
@@ -198,7 +198,7 @@ SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *ve
 
     // Check the number of uses of the gradient within this object;
     // if we are private and there are no other users,
-    if (!vector->isSwatch() && (SP_OBJECT_HREFCOUNT(gr) <= count_gradient_hrefs(user, gr))) {
+    if (!vector->isSwatch() && (gr->hrefcount <= count_gradient_hrefs(user, gr))) {
         // check vector
         if ( gr != vector && gr->ref->getObject() != vector ) {
             /* our href is not the vector, and vector is different from gr; relink */
@@ -213,7 +213,7 @@ SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *ve
     if ((gr->hasStops()) ||
         (gr->state != SP_GRADIENT_STATE_UNKNOWN) ||
         (SP_OBJECT_PARENT(gr) != SP_OBJECT(defs)) ||
-        (SP_OBJECT_HREFCOUNT(gr) > 1)) {
+        (gr->hrefcount > 1)) {
         // we have to clone a fresh new private gradient for the given vector
 
         // create an empty one
@@ -254,9 +254,9 @@ SPGradient *sp_gradient_fork_vector_if_necessary(SPGradient *gr)
     if (!prefs->getBool("/options/forkgradientvectors/value", true))
         return gr;
 
-    if (SP_OBJECT_HREFCOUNT(gr) > 1) {
+    if (gr->hrefcount > 1) {
         SPDocument *doc = SP_OBJECT_DOCUMENT(gr);
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+        Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
         Inkscape::XML::Node *repr = SP_OBJECT_REPR (gr)->duplicate(xml_doc);
         SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(repr, NULL);
@@ -298,7 +298,7 @@ SPGradient *sp_gradient_reset_to_userspace(SPGradient *gr, SPItem *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)->ensureUpToDate();
     Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine
 
     if (!bbox)
@@ -364,7 +364,7 @@ SPGradient *sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar
         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)->ensureUpToDate();
         Geom::Matrix bbox2user;
         Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine
         if ( bbox ) {
@@ -741,8 +741,7 @@ void sp_item_gradient_reverse_vector(SPItem *item, bool fill_or_stroke)
     GSList *child_reprs = NULL;
     GSList *child_objects = NULL;
     std::vector<double> offsets;
-    for (SPObject *child = sp_object_first_child(vector);
-         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));
@@ -792,7 +791,7 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
 
     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
@@ -1065,7 +1064,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po
     }
 
     if (SP_GRADIENT(gradient)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
-        sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item));
+        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,
@@ -1073,7 +1072,7 @@ Geom::Point sp_item_gradient_get_coords(SPItem *item, guint point_type, guint po
                             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);
 }
 
@@ -1110,11 +1109,11 @@ SPGradient *sp_item_set_gradient(SPItem *item, SPGradient *gr, SPGradientType ty
         /* 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
index f104bbd413aad9a0666b4b15d3ec29a9f242420c..d37e9b02270ba0e21149dda51c2842161893f18e 100644 (file)
@@ -4,6 +4,7 @@
  * 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 +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 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc)
     }
 
     if (g_slist_length(these_stops) > 0 && doc) {
-        sp_document_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 @@ sp_gradient_simplify(SPGradientContext *rc, double tolerance)
     }
 
     if (g_slist_length(todel) > 0) {
-        sp_document_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 @@ sp_gradient_context_add_stop_near_point (SPGradientContext *rc, SPItem *item,  G
 
     ec->get_drag()->addStopNearPoint (item, mouse_p, tolerance/desktop->current_zoom());
 
-    sp_document_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 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     sp_gradient_reset_to_userspace(priv, item);
                 }
 
-                sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
-                                  _("Create default gradient"));
+                DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
+                                   _("Create default gradient"));
             }
             ret = TRUE;
         }
@@ -813,8 +815,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     }
                 }
                 // we did an undoable action
-                sp_document_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 +927,7 @@ static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint
                                    -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
index d5ab64794cb33ad544bc56c102c6afd073273ebe..2e9a21acf2ccceb0786e36ae253a8c716c073e9d 100644 (file)
@@ -5,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 +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
@@ -185,7 +188,7 @@ Glib::ustring GrDrag::makeStopSafeColor( gchar const *str, bool &isNull )
         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() ) {
@@ -194,7 +197,7 @@ Glib::ustring GrDrag::makeStopSafeColor( gchar const *str, bool &isNull )
                     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();
                         }
@@ -622,8 +625,8 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
                 d_new->updateKnotShape ();
                 d_new->updateTip ();
                 d_new->updateDependencies(true);
-                sp_document_done (sp_desktop_document (d_new->parent->desktop), SP_VERB_CONTEXT_GRADIENT,
-                                  _("Merge gradient handles"));
+                DocumentUndo::done(sp_desktop_document (d_new->parent->desktop), SP_VERB_CONTEXT_GRADIENT,
+                                   _("Merge gradient handles"));
                 return;
             }
         }
@@ -927,8 +930,8 @@ gr_knot_ungrabbed_handler (SPKnot *knot, unsigned int state, gpointer data)
     dragger->updateDependencies(true);
 
     // we did an undoable action
-    sp_document_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 +983,8 @@ gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data)
             }
 
             SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
-            sp_document_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 +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:
@@ -1784,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 +1866,7 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial)
 
     if (write_repr && did) {
         // we did an undoable action
-        sp_document_maybe_done (sp_desktop_document (desktop), "grmoveh", SP_VERB_CONTEXT_GRADIENT,
+        DocumentUndo::maybeDone(sp_desktop_document (desktop), "grmoveh", SP_VERB_CONTEXT_GRADIENT,
                                 _("Move gradient handle(s)"));
         return;
     }
@@ -1899,7 +1902,7 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial)
 
         if (write_repr && did) {
             // we did an undoable action
-            sp_document_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 +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) ;
-              child != NULL ;
-              child = SP_OBJECT_NEXT(child) )
+        for ( SPObject *child = (stopinfo->vector)->firstChild() ; child ; child = child->getNext() )
         {
-            if ( SP_IS_STOP(child) )  len ++;
+            if ( SP_IS_STOP(child) ) {
+                len ++;
+            }
         }
         if (len > 2)
         {
@@ -2188,7 +2191,7 @@ GrDrag::deleteSelected (bool just_one)
     }
 
     if (document) {
-        sp_document_done ( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") );
+        DocumentUndo::done( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") );
     }
 }
 
index 0905cd94c96f3b8b0d57ce3ab2c9fbfa983c7cc0..4f536beb3a4cbe5f1fc31799aeb3309368eecdc0 100644 (file)
@@ -4,6 +4,7 @@
 /*
  * Authors:
  *   Tim Dwyer <Tim.Dwyer@infotech.monash.edu.au>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2005 Authors
  *
@@ -126,7 +127,7 @@ void graphlayout(GSList const *const items) {
          ++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());
@@ -228,7 +229,7 @@ void graphlayout(GSList const *const items) {
             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());
index f50062d2dab062152625d4167191643269e9b40d..69becad5dd421f83ed7a8bcad092680acd801045 100644 (file)
@@ -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)
@@ -51,12 +51,12 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey)
          && !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->firstChild() ; child; child = child->getNext() ) {
             hide_other_items_recursively(child, list, dkey);
         }
     }
@@ -104,16 +104,16 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/,
      /* 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->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));
@@ -122,7 +122,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/,
      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(doc->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY);
      nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine);
 
      NRGC gc(NULL);
@@ -131,7 +131,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/,
      // We show all and then hide all items we don't want, instead of showing only requested items,
      // because that would not work if the shown item references something in defs
      if (items_only) {
-         hide_other_items_recursively(sp_document_root(doc), items_only, dkey);
+         hide_other_items_recursively(doc->getRoot(), items_only, dkey);
      }
 
      NRRectL final_bbox;
@@ -186,7 +186,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/,
     {
         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(doc->getRoot())->invoke_hide(dkey);
      nr_object_unref((NRObject *) arena);
 
 //    gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL);
index 754372f23b35e40b22d22c2d2961c0a96090dac4..d3fe2771ff8d07970153b3b1427879a0d08a0977 100644 (file)
@@ -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,7 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data)
 /**
  * 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)
@@ -371,12 +370,12 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey)
          && !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->firstChild() ; child; child = child->getNext() ) {
             hide_other_items_recursively(child, list, dkey);
         }
     }
@@ -422,10 +421,10 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
         return true;
     }
 
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
     /* Calculate translation by transforming to document coordinates (flipping Y)*/
-    Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - sp_document_height(doc));
+    Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - doc->getHeight());
 
     /*  This calculation is only valid when assumed that (x0,y0)= area.corner(0) and (x1,y1) = area.corner(2)
      * 1) a[0] * x0 + a[2] * y1 + a[4] = 0.0
@@ -461,16 +460,16 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
     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(doc->getRoot())->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
     nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine);
 
     // We show all and then hide all items we don't want, instead of showing only requested items,
     // because that would not work if the shown item references something in defs
     if (items_only) {
-        hide_other_items_recursively(sp_document_root(doc), items_only, dkey);
+        hide_other_items_recursively(doc->getRoot(), items_only, dkey);
     }
 
     ebp.status = status;
@@ -490,7 +489,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
     }
 
     // Hide items, this releases arenaitem
-    sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), dkey);
+    SP_ITEM(doc->getRoot())->invoke_hide(dkey);
 
     /* Free arena */
     nr_object_unref((NRObject *) arena);
index 1c184da725c75c4dc9eb0700c380f255aa8b3e64..4ec61c54aeb5b16a212723ae5b177582e075a966 100644 (file)
@@ -1,5 +1,3 @@
-#define __INK_STOCK_ITEMS__
-
 /*
  * Stock-items
  *
@@ -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 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current
     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->ensureUpToDate();
         } else {
             edoc = TRUE;
         }
@@ -70,7 +70,7 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current
         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 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc)
     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->ensureUpToDate();
         } else {
             edoc = TRUE;
         }
@@ -114,7 +114,7 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc)
         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 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc)
     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->ensureUpToDate();
         } else {
             edoc = TRUE;
         }
@@ -157,7 +157,7 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc)
         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,11 @@ SPObject *get_stock_item(gchar const *urn)
 
         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));
-                 child != NULL;
-                 child = SP_OBJECT_NEXT(child))
+            for ( SPObject *child = defs->firstChild(); child; child = child->getNext() )
             {
                 if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") &&
                     !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) &&
@@ -213,11 +211,9 @@ SPObject *get_stock_item(gchar const *urn)
             
         }
         else if (!strcmp(base,"pattern"))  {
-            for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)) ;
-                 child != NULL;
-                 child = SP_OBJECT_NEXT(child) )
+            for ( SPObject *child = defs->firstChild() ; child; child = child->getNext() )
             {
-                if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") &&
+                if (child->getRepr()->attribute("inkscape:stockid") &&
                     !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) &&
                     SP_IS_PATTERN(child))
                 {
@@ -227,9 +223,7 @@ SPObject *get_stock_item(gchar const *urn)
             
         }
         else if (!strcmp(base,"gradient"))  {
-            for (SPObject *child = sp_object_first_child(SP_OBJECT(defs));
-                 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")) &&
index 43ce393ddf6c82fa2999797b10664b8e2625a9d7..0594fe8e66f6191d82faf2169bd553e98a12f659 100644 (file)
@@ -1,9 +1,10 @@
-#define __ID_CLASH_C__
 /** \file
  * Routines for resolving ID clashes when importing or pasting.
  *
  * Authors:
  *   Stephen Silver <sasilver@users.sourceforge.net>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2008 authors
  *
@@ -164,9 +165,8 @@ find_references(SPObject *elem, refmap_type *refmap)
         }
     }
     
-    /* recurse */
-    for (SPObject *child = sp_object_first_child(elem);
-         child; child = SP_OBJECT_NEXT(child) )
+    // recurse
+    for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
     {
         find_references(child, refmap);
     }
@@ -203,9 +203,8 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
             id_changes->push_back(id_changeitem_type(elem, old_id));
     }
 
-    /* recurse */
-    for (SPObject *child = sp_object_first_child(elem);
-         child; child = SP_OBJECT_NEXT(child) )
+    // recurse
+    for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
     {
         change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes);
     }
@@ -263,7 +262,7 @@ prevent_id_clashes(SPDocument *imported_doc, SPDocument *current_doc)
 {
     refmap_type *refmap = new refmap_type;
     id_changelist_type id_changes;
-    SPObject *imported_root = SP_DOCUMENT_ROOT(imported_doc);
+    SPObject *imported_root = imported_doc->getRoot();
         
     find_references(imported_root, refmap);
     change_clashing_ids(imported_doc, current_doc, imported_root, refmap,
index e4edb9d108c4a1369d1c98af324619dc08941de7..4309775675cd95924f7bb72ee6b2affc72059513 100644 (file)
@@ -330,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 +530,7 @@ inkscape_trackalt() {
 
 void inkscape_trackalt(guint trackvalue)
 {
-       inkscape->trackalt = trackvalue;
+    inkscape->trackalt = trackvalue;
 }
 
 
@@ -609,13 +609,13 @@ inkscape_crash_handler (int /*signum*/)
           ++iter) {
         SPDocument *doc = iter->first;
         Inkscape::XML::Node *repr;
-        repr = sp_document_repr_root (doc);
+        repr = doc->getReprRoot();
         if (doc->isModifiedSinceSave()) {
             const gchar *docname;
 
             /* originally, the document name was retrieved from
              * the sodipod:docname attribute */
-            docname = doc->name;
+            docname = doc->getName();
             if (docname) {
                 /* Removes an emergency save suffix if present: /(.*)\.[0-9_]*\.[0-9_]*\.[~\.]*$/\1/ */
                 const char* d0 = strrchr ((char*)docname, '.');
@@ -643,7 +643,7 @@ inkscape_crash_handler (int /*signum*/)
 
             // Find a location
             const char* locations[] = {
-                doc->base,
+                doc->getBase(),
                 g_get_home_dir(),
                 g_get_tmp_dir(),
                 curdir,
@@ -667,7 +667,7 @@ inkscape_crash_handler (int /*signum*/)
                 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++;
         }
index c151991dd8f469721d6c6b6bd9176f944bc0fbf0..09adb8c2d3c684c763004bfa175fe272e4821a3b 100644 (file)
@@ -1,5 +1,3 @@
-#define __SPSVGVIEW_C__
-
 /*
  * Inkscape - an ambitious vector drawing program
  *
@@ -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 +166,7 @@ sp_svgview_main_key_press (GtkWidget */*widget*/, GdkEventKey *event, struct SPS
     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 +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);
@@ -299,7 +298,7 @@ main (int argc, const char **argv)
                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;
                }
@@ -313,21 +312,21 @@ main (int argc, const char **argv)
        return 1; /* none of the slides loadable */
 
     w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-    gtk_window_set_title (GTK_WINDOW (w), SP_DOCUMENT_NAME (ss.doc));
+    gtk_window_set_title( GTK_WINDOW(w), ss.doc->getName() );
     gtk_window_set_default_size (GTK_WINDOW (w),
-                                MIN ((int)sp_document_width (ss.doc), (int)gdk_screen_width () - 64),
-                                MIN ((int)sp_document_height (ss.doc), (int)gdk_screen_height () - 64));
+                                MIN ((int)(ss.doc)->getWidth (), (int)gdk_screen_width () - 64),
+                                MIN ((int)(ss.doc)->getHeight (), (int)gdk_screen_height () - 64));
     gtk_window_set_policy (GTK_WINDOW (w), TRUE, TRUE, FALSE);
     ss.window = w;
 
     g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss);
     g_signal_connect (G_OBJECT (w), "key_press_event", (GCallback) sp_svgview_main_key_press, &ss);
 
-    sp_document_ensure_up_to_date (ss.doc);
+    (ss.doc)->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 +443,7 @@ static void
 sp_svgview_set_document(struct SPSlideShow *ss, SPDocument *doc, int current)
 {
     if (doc && doc != ss->doc) {
-        sp_document_ensure_up_to_date (doc);
+        doc->ensureUpToDate();
         reinterpret_cast<SPSVGView*>(SP_VIEW_WIDGET_VIEW (ss->view))->setDocument (doc);
         ss->doc = doc;
         ss->current = current;
@@ -459,7 +458,7 @@ sp_svgview_show_next (struct SPSlideShow *ss)
     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 +474,7 @@ sp_svgview_show_prev (struct SPSlideShow *ss)
     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 +492,7 @@ sp_svgview_goto_first (struct SPSlideShow *ss)
     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 +510,7 @@ sp_svgview_goto_last (struct SPSlideShow *ss)
     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);
index b51178eb8c4813f53bd47ea58223c0d0cedf59f3..0fd2b65ead4617801f81823cb04f3e033729d4b9 100644 (file)
@@ -5,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,8 @@
 #include "ige-mac-menu.h"
 #endif
 
+using Inkscape::DocumentUndo;
+
 /* Drag and Drop */
 typedef enum {
     URI_LIST,
@@ -1125,7 +1129,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
             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);
@@ -1164,7 +1168,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                             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 );
@@ -1182,7 +1186,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                     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 ) {
@@ -1216,13 +1220,13 @@ sp_ui_drag_data_received(GtkWidget *widget,
                                         //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"));
+                        DocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient") );
                         desktop->event_context->get_drag()->updateDraggers();
                     }
                 }
@@ -1230,7 +1234,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                 //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"));
                 //    }
                 //}
 
@@ -1251,7 +1255,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                                 ( !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);
 
@@ -1268,8 +1272,8 @@ sp_ui_drag_data_received(GtkWidget *widget,
                     sp_desktop_apply_css_recursive( item, css, true );
                     item->updateRepr();
 
-                    sp_document_done( doc , SP_VERB_NONE,
-                                      _("Drop color"));
+                    DocumentUndo::done( doc , SP_VERB_NONE,
+                                        _("Drop color") );
                 }
             }
         }
@@ -1296,7 +1300,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                         unsigned int b = color.getB();
 
                         SPGradient* matches = 0;
-                        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 ( color.descr == grad->getId() ) {
@@ -1326,13 +1330,13 @@ sp_ui_drag_data_received(GtkWidget *widget,
                 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"));
+                        DocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient") );
                         desktop->event_context->get_drag()->updateDraggers();
                     }
                 }
@@ -1354,7 +1358,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                                 ( !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);
 
@@ -1371,8 +1375,8 @@ sp_ui_drag_data_received(GtkWidget *widget,
                     sp_desktop_apply_css_recursive( item, css, true );
                     item->updateRepr();
 
-                    sp_document_done( doc , SP_VERB_NONE,
-                                      _("Drop color"));
+                    DocumentUndo::done( doc , SP_VERB_NONE,
+                                        _("Drop color") );
                 }
             }
         }
@@ -1395,7 +1399,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
             Inkscape::XML::Node *newgroup = rnewdoc->createElement("svg:g");
             newgroup->setAttribute("style", style);
 
-            Inkscape::XML::Document * xml_doc =  sp_document_repr_doc(doc);
+            Inkscape::XML::Document * xml_doc =  doc->getReprDoc();
             for (Inkscape::XML::Node *child = repr->firstChild(); child != NULL; child = child->next()) {
                 Inkscape::XML::Node *newchild = child->duplicate(xml_doc);
                 newgroup->appendChild(newchild);
@@ -1414,7 +1418,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
 
             // move to mouse pointer
             {
-                sp_document_ensure_up_to_date(sp_desktop_document(desktop));
+                sp_desktop_document(desktop)->ensureUpToDate();
                 Geom::OptRect sel_bbox = selection->bounds();
                 if (sel_bbox) {
                     Geom::Point m( desktop->point() - sel_bbox->midpoint() );
@@ -1423,8 +1427,8 @@ sp_ui_drag_data_received(GtkWidget *widget,
             }
 
             Inkscape::GC::release(newgroup);
-            sp_document_done(doc, SP_VERB_NONE,
-                             _("Drop SVG"));
+            DocumentUndo::done( doc, SP_VERB_NONE,
+                             _("Drop SVG") );
             break;
         }
 
@@ -1457,8 +1461,8 @@ sp_ui_drag_data_received(GtkWidget *widget,
 
             ext->set_param_optiongroup("link", save ? "embed" : "link");
             ext->set_gui(true);
-            sp_document_done( doc , SP_VERB_NONE,
-                              _("Drop bitmap image"));
+            DocumentUndo::done( doc , SP_VERB_NONE,
+                                _("Drop bitmap image") );
             break;
         }
     }
index 30fda6a392b468b74e3be8dd3ffe0a00d6a0b7f7..01732e911002afab5952ba629790d5e398e2be17 100644 (file)
@@ -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,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 +18,7 @@
 #include <gtk/gtkstyle.h>
 
 #include "forward.h"
-
+#include "sp-item.h"
 
 /**
  *  Create a new document window.
@@ -69,7 +70,7 @@ void sp_ui_dialog_title_string (Inkscape::Verb * verb, gchar* c);
 void sp_ui_error_dialog (const gchar * message);
 bool sp_ui_overwrite_file (const gchar * filename);
 
-#endif
+#endif // SEEN_SP_INTERFACE_H
 
 /*
   Local Variables:
index a506d472a8c999ec1e9888f0fea3da8ce3e351de..9f40a7dc6ff39cdfb0ed6e7851422eaf7944e283 100644 (file)
@@ -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 @@ char const* specialnodekeys[] = {
  * 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 @@ XMLNodeTracker::setSessionManager(const SessionManager *val)
 
 void 
 XMLNodeTracker::put(const Glib::ustring &key, const XML::Node &nodeArg)
-{      
+{
     keyNodeTable.put(key, &nodeArg);
 }
 
@@ -159,7 +159,7 @@ XMLNodeTracker::isTracking(const XML::Node &node)
 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 @@ XMLNodeTracker::remove(const XML::Node &nodeArg)
 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,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..60d0b73781a47d1bbb7d4247af9496a4f70dfbe3 100644 (file)
@@ -4,6 +4,7 @@
  * Authors:
  * David Yip <yipdw@rose-hulman.edu>
  * Bob Jamison (Pedro port)
+ *   Abhishek Sharma
  *
  * Copyright (c) 2005 Authors
  *
@@ -56,15 +57,15 @@ SessionManager *sessionManagerInstance = NULL;
 
 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 +227,8 @@ SessionManager::processWhiteboardEvent(Pedro::XmppEvent const& event)
 {
     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 +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 +367,7 @@ makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, G
     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;
@@ -378,17 +379,14 @@ makeInkboardDocument(int code, gchar const* rootname, State::SessionType type, G
 // 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();
 
     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);
 
index f8f4866637afa5746f2fdeb3bf21586ac5303747..005ca24c71c1fbe2e1b8bbb8112c5c5401f4ed26 100644 (file)
@@ -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 +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);
 
@@ -89,7 +88,7 @@ KnotHolderEntity::update_knot()
 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;
@@ -103,7 +102,7 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p)
 Geom::Point
 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;
@@ -159,7 +158,7 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
 
     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 +208,7 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &
     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 +242,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
     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);
 }
 
index 824f16c3e596766a995a0f7c2756d57ca5d339b8..28c991fdec590cb479cc3df875db2493452acfa2 100644 (file)
@@ -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 +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 +428,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
                                 g_signal_emit(knot,
                                               knot_signals[UNGRABBED], 0,
                                               event->button.state);
-                                sp_document_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;
index df5c1cad9d4f93e104786b1c98ffe9b3439afd72..f5e28618eff8fb641fd5f2acfbc4a1cb85cfcde0 100644 (file)
@@ -1,5 +1,3 @@
-#define __KNOT_HOLDER_C__
-
 /*
  * Container for SPKnot visual handles
  *
@@ -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...
+    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 +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 +123,7 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state)
     }
 
     if (SP_IS_SHAPE(item)) {
-        sp_shape_set_shape(SP_SHAPE(item));
+        SP_SHAPE(item)->setShape();
     }
 
     knot_holder->update_knots();
@@ -146,8 +148,8 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state)
     }
 
     // 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,
-                     _("Change handle"));
+    DocumentUndo::done(SP_OBJECT_DOCUMENT(item), object_verb,
+                       _("Change handle"));
 }
 
 void
@@ -163,14 +165,14 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state)
     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 +227,8 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/)
                 object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET;
         }
 
-        sp_document_done(SP_OBJECT_DOCUMENT (object), object_verb,
-                         _("Move handle"));
+        DocumentUndo::done(SP_OBJECT_DOCUMENT (object), object_verb,
+                           _("Move handle"));
     }
 }
 
index 7cf582f7af5506bf527b51809f2cb07b63a267b8..84f21cd979b2377dc214c5e384a28a8294ea2ce7 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Authors:
  *   MenTaLguY <mental@rydia.net>
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2004 MenTaLguY
  *
@@ -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 +39,7 @@ SPObject *next_sibling_layer(SPObject *layer) {
     using std::find_if;
 
     return find_if<SPObject::SiblingIterator>(
-        SP_OBJECT_NEXT(layer), NULL, &is_layer
+        layer->getNext(), NULL, &is_layer
     );
 }
 
@@ -174,7 +177,7 @@ SPObject *create_layer(SPObject *root, SPObject *layer, LayerRelativePosition po
         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);
index 1e1bb8c339ae9e9f9f8770e907e5ab6ac9fcc66b..95cefc229f44351203035c37a2136e61a7bf4d39 100644 (file)
@@ -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 +184,7 @@ void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify
         }
 
         std::set<Glib::ustring> currentNames;
-        GSList const *layers=sp_document_get_resource_list(_document, "layer");
+        GSList const *layers=_document->getResourceList("layer");
         SPObject *root=_desktop->currentRoot();
         if ( root ) {
             for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
@@ -218,7 +219,7 @@ void LayerManager::_setDocument(SPDocument *document) {
     }
     _document = document;
     if (document) {
-        _resource_connection = sp_document_resources_changed_connect(document, "layer", sigc::mem_fun(*this, &LayerManager::_rebuild));
+        _resource_connection = document->connectResourcesChanged("layer", sigc::mem_fun(*this, &LayerManager::_rebuild));
     }
     _rebuild();
 }
@@ -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->getResourceList("layer");
     SPObject *root=_desktop->currentRoot();
     if ( root ) {
         _addOne(root);
@@ -269,13 +270,15 @@ void LayerManager::_rebuild() {
                         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;
index 9dbd27b5041383c10ff45e94ed130433e367f429..3ea57de23f3f3110134db2e8654e8dd82d19c7ca 100644 (file)
@@ -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
  */
@@ -256,11 +255,10 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
     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 +522,7 @@ Effect::getHelperPaths(SPLPEItem *lpeitem)
     //       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..fef4e1f8777573e3e58e7ceadcd65caff833d2e7 100644 (file)
@@ -3,6 +3,7 @@
  */
 /* Authors:
  *   Jean-Francois Barraud <jf.barraud@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007 Authors
  *
@@ -509,7 +510,7 @@ void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &p
         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 +648,8 @@ KnotHolderEntityCrossingSwitcher::knot_click(guint state)
             //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?
-                 _("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);
index a3a0faf3755b37e8f38d1ae75aef8b70d743003e..1af2ed6caeb13f1480e076b1bdb245fa180d09a2 100644 (file)
@@ -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 +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 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem)
     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..e6fc95f866e2ec01aee2ed4b09c12e1757f2bb65 100644 (file)
@@ -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 +30,7 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute)
     
     Geom::Matrix transform;
     if (absolute) {
-        transform = sp_item_i2doc_affine(item);
+        transform = item->i2doc_affine();
     }
     else {
         transform = Geom::identity();
index aa916318d8da70ab7586da2aa859837d5194633c..389e18d20cf56d9cb5cbcb887c02206629f91a65 100644 (file)
@@ -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 +103,14 @@ LivePathEffectObject::livepatheffect_build(SPObject *object, SPDocument *documen
     if (((SPObjectClass *) livepatheffect_parent_class)->build)
         (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr);
 
-    sp_object_read_attr(object, "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 +131,7 @@ LivePathEffectObject::livepatheffect_release(SPObject *object)
 /*
     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 +246,11 @@ livepatheffect_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/,
  * 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..3bedecccbfc969aa84c5ff77232753a32815e829 100644 (file)
@@ -5,11 +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..8d9b2376ff586770d7b5b8da664c629fa6b770f0 100644 (file)
@@ -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 +208,7 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt)
     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 +365,7 @@ PathParam::linked_modified(SPObject *linked_obj, guint /*flags*/)
 {
     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 +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,
-                     _("Paste path parameter"));
+    DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                       _("Paste path parameter"));
 }
 
 void
@@ -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,
-                         _("Link path parameter to path"));
+        DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                           _("Link path parameter to path"));
     }
 }
 
index 8aa350d86a1ca5f073f714a9b55ae6e030d1407b..f259492962d927d3d5421be5e529f26887428894 100644 (file)
@@ -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 +393,8 @@ lpetool_context_switch_mode(SPLPEToolContext *lc, Inkscape::LivePathEffect::Effe
 
 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 +473,7 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select
     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 +515,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc)
     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);
index eda6d0b03ca9882163bf6ced1d040dca62ff4a84..a1b21cc4d0f65b1cf1fb3ad2cba4787ab2648ec0 100644 (file)
@@ -1,5 +1,3 @@
-#define __MAIN_C__
-
 /** \file
  * Inkscape - an ambitious vector drawing program
  *
@@ -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.
@@ -1023,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->vacuumDocument();
             }
             if (sp_vacuum_defs && !sp_export_svg) {
                 // save under the name given in the command line
@@ -1040,9 +1040,9 @@ void sp_process_file_list(GSList *fl)
                 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 +1196,15 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g
             return;
         }
     } else {
-        o = SP_DOCUMENT_ROOT(doc);
+        o = doc->getRoot();
     }
 
     if (o) {
-        sp_document_ensure_up_to_date (doc);
+        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) {
@@ -1219,15 +1219,12 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g
     }
 }
 
-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->ensureUpToDate();
         do_query_all_recurse(o);
     }
 }
@@ -1237,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 @@ sp_do_export_png(SPDocument *doc)
         SPObject *o_area = NULL;
         if (sp_export_id && sp_export_area_drawing) {
             o = doc->getObjectById(sp_export_id);
-            o_area = SP_DOCUMENT_ROOT (doc);
+            o_area = doc->getRoot();
         } else if (sp_export_id) {
             o = doc->getObjectById(sp_export_id);
             o_area = o;
         } else if (sp_export_area_drawing) {
-            o = SP_DOCUMENT_ROOT (doc);
+            o = doc->getRoot();
             o_area = o;
         }
 
@@ -1330,9 +1327,9 @@ sp_do_export_png(SPDocument *doc)
             }
 
             // write object bbox to area
-            sp_document_ensure_up_to_date (doc);
+            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 {
@@ -1355,9 +1352,9 @@ sp_do_export_png(SPDocument *doc)
         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->ensureUpToDate();
         Geom::Point origin (SP_ROOT(doc->root)->x.computed, SP_ROOT(doc->root)->y.computed);
-        area = Geom::Rect(origin, origin + sp_document_dimensions(doc));
+        area = Geom::Rect(origin, origin + doc->getDimensions());
     }
 
     // set filename and dpi from options, if not yet set from the hints
@@ -1451,8 +1448,8 @@ sp_do_export_png(SPDocument *doc)
     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);
index e4c2e0c305633929ea8df52a65a2e748b3250ea7..0ec92a1ff2147b00573ad9703e86d10a7628083c 100644 (file)
@@ -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 +140,14 @@ sp_marker_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *re
        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" );
 
        if (((SPObjectClass *) parent_class)->build)
                ((SPObjectClass *) parent_class)->build (object, document, repr);
@@ -524,8 +523,10 @@ sp_marker_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X
                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 +710,10 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro
     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");
 
@@ -740,7 +740,7 @@ generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::M
             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);
index 9c0b61b9c6f7e78ee5c7672b2f12c7b1c075c2de..27e75afab1340151367e3dd5db22cdc65f5446ef 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_OBJECT_EDIT_C__
-
 /*
  * Node editing extension to objects
  *
@@ -7,6 +5,7 @@
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   Mitsuru Oka
  *   Maximilian Albert <maximilian.albert@gmail.com>
+ *   Abhishek Sharma
  *
  * Licensed under GNU GPL
  */
@@ -482,7 +481,7 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom
 
     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 +657,7 @@ Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point co
     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);
index 51b4944980cff4a0ddc24b5f25d7e1e6d6b6825d..43651f002405e12ced35ea1743a6862668ec5bfb 100644 (file)
@@ -5,6 +5,8 @@
  * Authors:
  *   Carl Hetherington <inkscape@carlh.net>
  *   Diederik van Lierop <mail@diedenrezi.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2005 - 2010 Authors
  *
@@ -100,7 +102,8 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
     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->firstChild(); o; o = o->getNext() ) {
+        g_assert(_snapmanager->getDesktop() != NULL);
         if (SP_IS_ITEM(o) && !(_snapmanager->getDesktop()->itemIsHidden(SP_ITEM(o)) && !clip_or_mask)) {
             // Snapping to items in a locked layer is allowed
             // Don't snap to hidden objects, unless they're a clipped path or a mask
@@ -123,11 +126,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
                         // 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, 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, true, item->i2doc_affine());
                         }
                     }
                 }
@@ -139,12 +142,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
                     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
@@ -242,7 +244,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t,
                     }
                 }
 
-                sp_item_snappoints(root_item, *_points_to_snap_to, &_snapmanager->snapprefs);
+                root_item->getSnappoints(*_points_to_snap_to, &_snapmanager->snapprefs);
 
                 // restore the original snap preferences
                 _snapmanager->snapprefs.setSnapIntersectionCS(old_pref);
@@ -254,7 +256,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t,
                 // 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());
                 }
             }
@@ -342,7 +344,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc,
  * Returns index of first NR_END bpath in array.
  */
 
-void Inkscape::ObjectSnapper::_collectPaths(Geom::Point p,
+void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
                                          Inkscape::SnapSourceType const source_type,
                                          bool const &first_point) const
 {
@@ -384,7 +386,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point p,
                 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;
             }
 
@@ -420,7 +422,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point p,
                             // 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();
@@ -436,10 +438,10 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point p,
                     // 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));
                         }
                     }
@@ -659,7 +661,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
     /* 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, false, Geom::identity());
+        _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity());
     }
 
     // TODO: Argh, UGLY! Get rid of this here, move this logic to the snap manager
@@ -722,7 +724,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
     /* 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(pp, pp);
-        _findCandidates(sp_document_root(_snapmanager->getDocument()), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity());
+        _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity());
     }
 
     // A constrained snap, is a snap in only one degree of freedom (specified by the constraint line).
@@ -763,7 +765,7 @@ void Inkscape::ObjectSnapper::guideFreeSnap(SnappedConstraints &sc,
     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());
+    _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity());
     _snapTranslatingGuide(sc, p, guide_normal);
 
 }
@@ -778,7 +780,7 @@ void Inkscape::ObjectSnapper::guideConstrainedSnap(SnappedConstraints &sc,
     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());
+    _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity());
     _snapTranslatingGuide(sc, p, guide_normal);
 
 }
@@ -817,7 +819,7 @@ 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 +836,8 @@ Geom::PathVector* Inkscape::ObjectSnapper::_getPathvFromRect(Geom::Rect const re
 
 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));
index 6a796b2ed01504dcfb96a669e27000fc1ebd1b90..bec3c5cbff27f23c51bd27e83da0d13fad7c6c6c 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_PATH_CHEMISTRY_C__
-
 /*
  * Here are handlers for modifying selections, specific to paths
  *
@@ -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,8 @@
 #include "selection-chemistry.h"
 #include "path-chemistry.h"
 
+using Inkscape::DocumentUndo;
+
 void
 sp_selected_path_combine(SPDesktop *desktop)
 {
@@ -135,12 +137,14 @@ 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);
 
@@ -150,10 +154,11 @@ sp_selected_path_combine(SPDesktop *desktop)
         // set path data corresponding to new curve
         gchar *dstring = sp_svg_write_path(curve->get_pathvector());
         curve->unref();
-        if (path_effect)
+        if (path_effect) {
             repr->setAttribute("inkscape:original-d", dstring);
-        else
+        } else {
             repr->setAttribute("d", dstring);
+        }
         g_free(dstring);
 
         // add the new group to the parent of the topmost
@@ -162,8 +167,8 @@ sp_selected_path_combine(SPDesktop *desktop)
         // 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, 
-                         _("Combine"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE, 
+                           _("Combine"));
 
         selection->set(repr);
 
@@ -213,8 +218,10 @@ sp_selected_path_break_apart(SPDesktop *desktop)
         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...
+        gchar *style = g_strdup(SP_OBJECT(item)->getRepr()->attribute("style"));
+        // XML Tree being used directly here while it shouldn't be...
+        gchar *path_effect = g_strdup(SP_OBJECT(item)->getRepr()->attribute("inkscape:path-effect"));
 
         Geom::PathVector apv = curve->get_pathvector() * SP_ITEM(path)->transform;
 
@@ -272,8 +279,8 @@ sp_selected_path_break_apart(SPDesktop *desktop)
     desktop->clearWaitingCursor();
 
     if (did) {
-        sp_document_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 +321,8 @@ sp_selected_path_to_curves(SPDesktop *desktop, bool interactive)
     if (interactive) {
         desktop->clearWaitingCursor();
         if (did) {
-            sp_document_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 +539,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
 
     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 +634,8 @@ sp_selected_path_reverse(SPDesktop *desktop)
     desktop->clearWaitingCursor();
 
     if (did) {
-        sp_document_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."));
     }
index 543d7efde48969e800621dd1d11905bf05008eeb..74208444b04418be0e1b862fffad32cb71c8f6d0 100644 (file)
@@ -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,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 +118,10 @@ static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML:
 
     /* 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" );
 
     if (repr) {
         repr->addListener (&persp3d_repr_events, object);
@@ -206,20 +208,19 @@ persp3d_update(SPObject *object, SPCtx *ctx, guint flags)
         ((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);
@@ -246,20 +247,18 @@ persp3d_create_xml_element (SPDocument *document, Persp3DImpl *dup) {// if dup i
     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) ) {
-        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 +340,8 @@ persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo) {
     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,
-                         _("Toggle vanishing point"));
+        DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+                           _("Toggle vanishing point"));
     }
 }
 
@@ -352,8 +351,8 @@ persp3d_toggle_VPs (std::list<Persp3D *> p, Proj::Axis axis) {
     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,
-                     _("Toggle multiple vanishing points"));
+    DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+                       _("Toggle multiple vanishing points"));
 }
 
 void
@@ -564,12 +563,9 @@ persp3d_print_debugging_info (Persp3D *persp) {
     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) ) {
-        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));
         }
index ba29b17ad55b3db9edea6dcb4dadd0e285e69e3b..e0601aa339eb930a9568868011416e79f08e9533 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_PRINT_C__
-
 /** \file
  * Frontend to printing
  */
@@ -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 @@ sp_print_preview_document(SPDocument *doc)
     Inkscape::Extension::Print *mod;
     unsigned int ret;
 
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
     mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT);
 
@@ -102,16 +102,16 @@ sp_print_preview_document(SPDocument *doc)
 
         /* fixme: This has to go into module constructor somehow */
         /* Create new arena */
-        mod->base = SP_ITEM(sp_document_root(doc));
+        mod->base = SP_ITEM(doc->getRoot());
         mod->arena = NRArena::create();
-        mod->dkey = sp_item_display_key_new(1);
-        mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+        mod->dkey = SPItem::display_key_new(1);
+        mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
         /* Print document */
         ret = mod->begin(doc);
-        sp_item_invoke_print(mod->base, &context);
+        (mod->base)->invoke_print(&context);
         ret = mod->finish();
         /* Release arena */
-        sp_item_invoke_hide(mod->base, mod->dkey);
+        (mod->base)->invoke_hide(mod->dkey);
         mod->base = NULL;
         mod->root = NULL;
         nr_object_unref((NRObject *) mod->arena);
@@ -124,14 +124,14 @@ sp_print_preview_document(SPDocument *doc)
 void
 sp_print_document(Gtk::Window& parentWindow, SPDocument *doc)
 {
-    sp_document_ensure_up_to_date(doc);
+    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);
@@ -139,7 +139,7 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc)
     (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 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename)
     gchar *oldoutput;
     unsigned int ret;
 
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
     mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_PS);
     oldconst = mod->get_param_string("destination");
@@ -163,16 +163,16 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename)
     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 b70926947605ea5c8f14a06a5772e67c191c26de..27ab7549715bad75a6ab20dc650503c2c375ce6b 100644 (file)
@@ -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,7 +19,7 @@ ProfileManager::ProfileManager(SPDocument *document) :
     _doc(document),
     _knownProfiles()
 {
-    _resource_connection = sp_document_resources_changed_connect( _doc, "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) );
+    _resource_connection = _doc->connectResourcesChanged(  "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) );
 }
 
 ProfileManager::~ProfileManager()
@@ -31,7 +32,7 @@ void ProfileManager::_resourcesChanged()
 {
     std::vector<SPObject*> newList;
     if (_doc) {
-        const GSList *current = sp_document_get_resource_list( _doc, "iccprofile" );
+        const GSList *current = _doc->getResourceList( "iccprofile" );
         while ( current ) {
             newList.push_back(SP_OBJECT(current->data));
             current = g_slist_next(current);
index 99b56a103ad295edd1f50289960ca0042e9fca4e..c9378cf530a8aec6b4332c9d4ded4b7514458b06 100644 (file)
@@ -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>
@@ -295,6 +296,50 @@ struct rdf_work_entity_t rdf_work_entities [] = {
     }
 };
 
+
+// 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 +476,14 @@ rdf_string(struct rdf_t * rdf)
 */
 
 
-/**
- *  \brief   Pull the text out of an RDF entity, depends on how it's stored
- *  \return  A pointer to the entity's static contents as a string
- *  \param   repr    The XML element to extract from
- *  \param   entity  The desired RDF/Work entity
- *  
- */
-const gchar *
-rdf_get_repr_text ( Inkscape::XML::Node * repr, struct rdf_work_entity_t * entity )
+const gchar *RDFImpl::getReprText( Inkscape::XML::Node const * repr, struct rdf_work_entity_t const & entity )
 {
     g_return_val_if_fail (repr != NULL, NULL);
-    g_return_val_if_fail (entity != NULL, NULL);
     static gchar * bag = NULL;
     gchar * holder = NULL;
 
-    Inkscape::XML::Node * temp=NULL;
-    switch (entity->datatype) {
+    Inkscape::XML::Node const * temp = NULL;
+    switch (entity.datatype) {
         case RDF_CONTENT:
             temp = sp_repr_children(repr);
             if ( temp == NULL ) return NULL;
@@ -510,13 +546,11 @@ rdf_get_repr_text ( Inkscape::XML::Node * repr, struct rdf_work_entity_t * entit
     return NULL;
 }
 
-unsigned int
-rdf_set_repr_text ( Inkscape::XML::Node * repr,
-                    struct rdf_work_entity_t * entity,
-                    gchar const * text )
+unsigned int RDFImpl::setReprText( Inkscape::XML::Node * repr,
+                                   struct rdf_work_entity_t const & entity,
+                                   gchar const * text )
 {
     g_return_val_if_fail ( repr != NULL, 0);
-    g_return_val_if_fail ( entity != NULL, 0);
     g_return_val_if_fail ( text != NULL, 0);
     gchar * str = NULL;
     gchar** strlist = NULL;
@@ -530,12 +564,12 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
     g_return_val_if_fail (xmldoc != NULL, FALSE);
 
     // set document's title element to the RDF title
-    if (!strcmp(entity->name, "title")) {
+    if (!strcmp(entity.name, "title")) {
         SPDocument *doc = SP_ACTIVE_DOCUMENT;
         if(doc && doc->root) doc->root->setTitle(text);
     }
 
-    switch (entity->datatype) {
+    switch (entity.datatype) {
         case RDF_CONTENT:
             temp = sp_repr_children(parent);
             if ( temp == NULL ) {
@@ -643,187 +677,263 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
     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 +1022,20 @@ rdf_match_license(Inkscape::XML::Node const *repr, struct rdf_license_t const *l
     return result;
 }
 
-/**
- *  \brief   Attempts to match and retrieve a known RDF/License from the document XML
- *  \return  A pointer to the static RDF license structure
- *  
- */
-struct rdf_license_t *
-rdf_get_license(SPDocument * document)
+// Public API:
+struct rdf_license_t *rdf_get_license(SPDocument const * document)
 {
-    Inkscape::XML::Node const *repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, FALSE );
+    return RDFImpl::getLicense(document);
+}
+
+struct rdf_license_t *RDFImpl::getLicense(SPDocument const *document)
+{
+    Inkscape::XML::Node const *repr = getXmlRepr( document, XML_TAG_NAME_LICENSE );
     if (repr) {
-        for (struct rdf_license_t * license = rdf_licenses;
-             license->name; license++ ) {
-            if ( rdf_match_license ( repr, license ) ) return license;
+        for ( struct rdf_license_t * license = rdf_licenses; license->name; license++ ) {
+            if ( rdf_match_license( repr, license ) ) {
+                return license;
+            }
         }
     }
 #ifdef DEBUG_MATCH
@@ -935,38 +1046,39 @@ rdf_get_license(SPDocument * document)
     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 +1092,46 @@ struct rdf_entity_default_t rdf_defaults[] = {
     { 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++
index e7a1f946f476bf439e548a496d4d917ead368efa..bed01aed09fa2931514237307da1a6a72bd4296b 100644 (file)
--- a/src/rdf.h
+++ b/src/rdf.h
@@ -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 +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:
index 86f0b54a3631a32d0f33fea8f0bd93d3a235dd70..bcb1bf7347e615586a761896448014d229fcdf6d 100644 (file)
@@ -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,8 @@
 #include "context-fns.h"
 #include "shape-editor.h"
 
+using Inkscape::DocumentUndo;
+
 //static const double goldenratio = 1.61803398874989484820; // golden ratio
 
 static void sp_rect_context_class_init(SPRectContextClass *klass);
@@ -466,16 +468,16 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state)
             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 +551,8 @@ static void sp_rect_finish(SPRectContext *rc)
         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,
-                         _("Create rectangle"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
+                           _("Create rectangle"));
 
         rc->item = NULL;
     }
@@ -575,7 +577,7 @@ static void sp_rect_cancel(SPRectContext *rc)
 
     sp_canvas_end_forced_full_redraws(desktop->canvas);
 
-    sp_document_cancel(sp_desktop_document(desktop));
+    DocumentUndo::cancel(sp_desktop_document(desktop));
 }
 
 
index 975b4becb988e0ae7ec29412fa367e5630757bad..b01ae52281c488bb6729e36bc19ded590ac74438 100644 (file)
@@ -4,6 +4,7 @@
 /*
 * Authors:
 *   Tim Dwyer <tgdwyer@gmail.com>
+ *   Abhishek Sharma
 *
 * Copyright (C) 2005 Authors
 *
@@ -48,7 +49,7 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG
                ++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..6d8c4d0489b9290aec093ad1d98dfd21285952bf 100644 (file)
@@ -13,7 +13,7 @@ void satisfied_guide_cns(SPDesktop const &desktop,
     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));
             }
         }
index 8756524dd6b37c01078f93f0c96ae3d82414057d..171178c4132f2bd7b46e87b98eb6d2da30273c49 100644 (file)
@@ -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 +83,7 @@ void Inkscape::SelCue::_updateItemBboxes()
         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 +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 +191,7 @@ void Inkscape::SelCue::_newTextBaselines()
                         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);
                 }
             }
index 028c8634b62435475a926670ec97082a881c66f7..febcc282d7b2f5a349b1cc893bd1dc948d5000f3 100644 (file)
@@ -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 +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 +223,7 @@ sp_select_context_abort(SPEventContext *event_context)
             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));
+                    DocumentUndo::undo(sp_desktop_document(desktop));
                 }
 
                 sp_object_unref( SP_OBJECT(sc->item), NULL);
@@ -230,7 +231,7 @@ sp_select_context_abort(SPEventContext *event_context)
                 // 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));
+                DocumentUndo::undo(sp_desktop_document(desktop));
             }
             sc->item = NULL;
 
@@ -510,14 +511,14 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                     // and also when we started within tolerance, but trespassed tolerance outside of item
                     Inkscape::Rubberband::get(desktop)->stop();
                     SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear();
-                    item_at_point = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), FALSE);
+                    item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE);
                     if (!item_at_point) // if no item at this point, try at the click point (bug 1012200)
-                        item_at_point = desktop->item_at_point(Geom::Point(xp, yp), FALSE);
+                        item_at_point = desktop->getItemAtPoint(Geom::Point(xp, yp), FALSE);
                     if (item_at_point || sc->moved || sc->button_press_alt) {
                         // drag only if starting from an item, or if something is already grabbed, or if alt-dragging
                         if (!sc->moved) {
-                            item_in_group = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE);
-                            group_at_point = desktop->group_at_point(Geom::Point(event->button.x, event->button.y));
+                            item_in_group = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE);
+                            group_at_point = desktop->getGroupAtPoint(Geom::Point(event->button.x, event->button.y));
                             if (SP_IS_LAYER(selection->single()))
                                 group_at_point = SP_GROUP(selection->single());
 
@@ -614,9 +615,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         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)->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)->getItemsAtPoints(desktop->dkey, r->getPoints());
                         }
 
                         seltrans->resetState();
index 8b917de55ed8201a7da335684856c9962c673fb5..d63ee7e83efe6b2452033b132de084a5277b5930 100644 (file)
@@ -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 +106,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
 
 #include "ui/clipboard.h"
 
+using Inkscape::DocumentUndo;
 using Geom::X;
 using Geom::Y;
 
@@ -241,7 +243,7 @@ void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::D
 
     // 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);
@@ -250,7 +252,7 @@ void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::D
 
 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
@@ -259,7 +261,7 @@ GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip
         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());
@@ -300,8 +302,8 @@ void sp_selection_delete(SPDesktop *desktop)
 
     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,
-                             _("Delete text"));
+            DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                               _("Delete text"));
             return;
         }
 
@@ -326,31 +328,31 @@ void sp_selection_delete(SPDesktop *desktop)
      */
     tools_switch( desktop, tools_active( desktop ) );
 
-    sp_document_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) ) {
-            add_ids_recursive(ids, child);
+        if (SP_IS_GROUP(obj)) {
+            for (SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
+                add_ids_recursive(ids, child);
+            }
         }
     }
 }
 
 void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = desktop->doc();
-    Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document* xml_doc = doc->getReprDoc();
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     // check if something is selected
@@ -407,7 +409,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
                 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);
@@ -420,7 +422,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
                 gchar *source_href = SP_OFFSET(old_clone)->sourceHref;
                     if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) {
                         gchar *newref = g_strdup_printf("#%s", new_ids[j]);
-                        doc->getObjectById(new_ids[i])->repr->setAttribute("xlink:href", newref);
+                        doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", newref);
                         g_free(newref);
                     }
                 }
@@ -430,8 +432,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
 
 
     if ( !suppressDone ) {
-        sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE,
-                         _("Duplicate"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE,
+                           _("Duplicate"));
     }
 
     selection->setReprList(newsel);
@@ -455,14 +457,13 @@ void sp_edit_clear_all(SPDesktop *dt)
         items = g_slist_remove(items, items->data);
     }
 
-    sp_document_done(doc, SP_VERB_EDIT_CLEAR_ALL,
-                     _("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 = from->firstChild() ; child; child = child->getNext() ) {
         if (SP_IS_ITEM(child) &&
             !desktop->isLayer(SP_ITEM(child)) &&
             (!onlysensitive || !SP_ITEM(child)->isLocked()) &&
@@ -593,7 +594,7 @@ void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XM
             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
@@ -632,11 +633,12 @@ void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XM
 
 void sp_selection_group(SPDesktop *desktop)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -656,8 +658,8 @@ void sp_selection_group(SPDesktop *desktop)
 
     sp_selection_group_impl(p, group, xml_doc, doc);
 
-    sp_document_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 +719,8 @@ void sp_selection_ungroup(SPDesktop *desktop)
 
     g_slist_free(items);
 
-    sp_document_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 +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) ) {
-        if (i->next == child)
-            return i;
+    SPObject *prev = 0;
+    if ( child && SP_IS_GROUP(child->parent) ) {
+        prev = child->getPrev();
     }
-    return NULL;
+    return prev;
 }
 
 void
@@ -835,7 +833,7 @@ sp_selection_raise(SPDesktop *desktop)
             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)) {
@@ -852,9 +850,9 @@ sp_selection_raise(SPDesktop *desktop)
         g_slist_free(rev);
     }
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE,
-                     //TRANSLATORS: "Raise" means "to raise an object" in the undo history
-                     C_("Undo action", "Raise"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE,
+                       //TRANSLATORS: "Raise" means "to raise an object" in the undo history
+                       C_("Undo action", "Raise"));
 }
 
 void sp_selection_raise_to_top(SPDesktop *desktop)
@@ -888,8 +886,8 @@ void sp_selection_raise_to_top(SPDesktop *desktop)
 
     g_slist_free(rl);
 
-    sp_document_done(document, SP_VERB_SELECTION_TO_FRONT,
-                     _("Raise to top"));
+    DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT,
+                       _("Raise to top"));
 }
 
 void
@@ -930,7 +928,7 @@ sp_selection_lower(SPDesktop *desktop)
             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)) {
@@ -951,8 +949,8 @@ sp_selection_lower(SPDesktop *desktop)
         g_slist_free(rev);
     }
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER,
-                     _("Lower"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER,
+                       _("Lower"));
 }
 
 void sp_selection_lower_to_bottom(SPDesktop *desktop)
@@ -988,7 +986,7 @@ 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->firstChild();
         while (!SP_IS_ITEM(pc)) {
             minpos += 1;
             pc = pc->next;
@@ -998,22 +996,24 @@ void sp_selection_lower_to_bottom(SPDesktop *desktop)
 
     g_slist_free(rl);
 
-    sp_document_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)))
-            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)))
-            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)
@@ -1037,7 +1037,7 @@ take_style_from_item(SPItem *item)
         (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)) {
+        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) {
@@ -1054,7 +1054,7 @@ take_style_from_item(SPItem *item)
     }
 
     // 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 +1073,7 @@ void sp_selection_paste(SPDesktop *desktop, bool in_place)
 {
     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"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste"));
     }
 }
 
@@ -1081,7 +1081,7 @@ void sp_selection_paste_style(SPDesktop *desktop)
 {
     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"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style"));
     }
 }
 
@@ -1090,8 +1090,8 @@ void sp_selection_paste_livepatheffect(SPDesktop *desktop)
 {
     Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
     if (cm->pastePathEffect(desktop)) {
-        sp_document_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 +1123,8 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop)
 
     }
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
-                     _("Remove live path effect"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
+                       _("Remove live path effect"));
 }
 
 void sp_selection_remove_filter(SPDesktop *desktop)
@@ -1144,8 +1144,8 @@ 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,
-                     _("Remove filter"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER,
+                       _("Remove filter"));
 }
 
 
@@ -1153,8 +1153,8 @@ void sp_selection_paste_size(SPDesktop *desktop, bool apply_x, bool apply_y)
 {
     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,
-                         _("Paste size"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE,
+                           _("Paste size"));
     }
 }
 
@@ -1162,8 +1162,8 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a
 {
     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,
-                         _("Paste size separately"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY,
+                           _("Paste size separately"));
     }
 }
 
@@ -1183,7 +1183,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
     SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
     if (next) {
         GSList *temp_clip = NULL;
-        sp_selection_copy_impl(items, &temp_clip, sp_document_repr_doc(dt->doc()));
+        sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc());
         sp_selection_delete_impl(items, false, false);
         next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
         GSList *copied;
@@ -1198,8 +1198,8 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
         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,
-                             _("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 +1228,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
     SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
     if (next) {
         GSList *temp_clip = NULL;
-        sp_selection_copy_impl(items, &temp_clip, sp_document_repr_doc(dt->doc())); // we're in the same doc, so no need to copy defs
+        sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
         sp_selection_delete_impl(items, false, false);
         next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
         GSList *copied;
@@ -1243,8 +1243,8 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
         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,
-                             _("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 +1346,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
         // 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(item->firstChild())) ));
         // ...both a flowtext and its frame?
         bool transform_flowtext_with_frame = (SP_IS_FLOWTEXT(item) && selection->includes( SP_FLOWTEXT(item)->get_frame(NULL))); // (only the first frame is checked so far)
         // ...both an offset and its source?
@@ -1381,16 +1381,17 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
          * 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" );
         } 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);
+            for ( SPObject *region = item->firstChild() ; region ; region = region->getNext() ) {
+                if (SP_IS_FLOWREGION(region) || SP_IS_FLOWREGIONEXCLUDE(region)) {
+                    for ( SPObject *use = region->firstChild() ; use ; use = use->getNext() ) {
+                        if ( SP_IS_USE(use) ) {
+                            SP_USE(use)->doWriteTransform(use->getRepr(), item->transform.inverse(), NULL, compensate);
+                        }
+                    }
                 }
             }
         } else if (transform_clone_with_original) {
@@ -1399,10 +1400,10 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
             // 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" );
 
             // 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;
@@ -1416,25 +1417,25 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
 
                 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
@@ -1459,8 +1460,8 @@ void sp_selection_remove_transform(SPDesktop *desktop)
         l = l->next;
     }
 
-    sp_document_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 +1562,9 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw)
         sp_item_rotate_rel(item, rot_90);
     }
 
-    sp_document_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 +1580,12 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees)
 
     sp_selection_rotate_relative(selection, *center, angle_degrees);
 
-    sp_document_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 +1627,12 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
 
     sp_selection_rotate_relative(selection, *center, zangle);
 
-    sp_document_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 +1657,12 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
     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()),
-                           ( (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 +1686,8 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times)
 
     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,
-                     _("Scale by whole factor"));
+    DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT,
+                       _("Scale by whole factor"));
 }
 
 void
@@ -1700,14 +1701,14 @@ sp_selection_move(SPDesktop *desktop, gdouble dx, gdouble dy)
     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,
-                               _("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,
-                               _("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,
-                         _("Move"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT,
+                           _("Move"));
     }
 }
 
@@ -1726,14 +1727,14 @@ sp_selection_move_screen(SPDesktop *desktop, gdouble dx, gdouble dy)
     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,
-                               _("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,
-                               _("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,
-                         _("Move"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT,
+                           _("Move"));
     }
 }
 
@@ -1750,15 +1751,15 @@ SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, SPObject *r
 struct Forward {
     typedef SPObject *Iterator;
 
-    static Iterator children(SPObject *o) { return sp_object_first_child(o); }
-    static Iterator siblings_after(SPObject *o) { return SP_OBJECT_NEXT(o); }
+    static Iterator children(SPObject *o) { return o->firstChild(); }
+    static Iterator siblings_after(SPObject *o) { return o->getNext(); }
     static void dispose(Iterator /*i*/) {}
 
     static SPObject *object(Iterator i) { return i; }
-    static Iterator next(Iterator i) { return SP_OBJECT_NEXT(i); }
+    static Iterator next(Iterator i) { return i->getNext(); }
 };
 
-struct Reverse {
+struct ListReverse {
     typedef GSList *Iterator;
 
     static Iterator children(SPObject *o) {
@@ -1778,10 +1779,14 @@ struct Reverse {
 
 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 +1842,7 @@ sp_selection_item_prev(SPDesktop *desktop)
         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 +2005,7 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
 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();
@@ -2015,15 +2020,15 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item)
 }
 
 
-void
-sp_selection_clone(SPDesktop *desktop)
+void sp_selection_clone(SPDesktop *desktop)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+    Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
 
     // check if something is selected
     if (selection->isEmpty()) {
@@ -2060,8 +2065,8 @@ sp_selection_clone(SPDesktop *desktop)
         Inkscape::GC::release(clone);
     }
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE,
-                     C_("Action","Clone"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE,
+                       C_("Action", "Clone"));
 
     selection->setReprList(newsel);
 
@@ -2110,8 +2115,8 @@ sp_selection_relink(SPDesktop *desktop)
     if (!relinked) {
         desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection."));
     } else {
-        sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE,
-                         _("Relink clone"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE,
+                           _("Relink clone"));
     }
 }
 
@@ -2182,8 +2187,8 @@ sp_selection_unlink(SPDesktop *desktop)
         desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
     }
 
-    sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE,
-                     _("Unlink clone"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE,
+                       _("Unlink clone"));
 }
 
 void
@@ -2210,7 +2215,7 @@ sp_select_clone_original(SPDesktop *desktop)
     } 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)->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
@@ -2234,8 +2239,8 @@ sp_select_clone_original(SPDesktop *desktop)
         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();
@@ -2261,11 +2266,12 @@ sp_select_clone_original(SPDesktop *desktop)
 
 void sp_selection_to_marker(SPDesktop *desktop, bool apply)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -2275,7 +2281,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
         return;
     }
 
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
     Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX);
     boost::optional<Geom::Point> c = selection->center();
     if ( !r || !c ) {
@@ -2283,7 +2289,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
     }
 
     // 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));
 
@@ -2294,7 +2300,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
     // 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();
@@ -2338,8 +2344,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
 
     g_slist_free(items);
 
-    sp_document_done(doc, SP_VERB_EDIT_SELECTION_2_MARKER,
-                     _("Objects to marker"));
+    DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER,
+                       _("Objects to marker"));
 }
 
 static void sp_selection_to_guides_recursive(SPItem *item, bool deleteitem, bool wholegroups) {
@@ -2348,7 +2354,7 @@ static void sp_selection_to_guides_recursive(SPItem *item, bool deleteitem, bool
             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) {
             item->deleteObject(true);
@@ -2379,17 +2385,18 @@ void sp_selection_to_guides(SPDesktop *desktop)
         sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups);
     }
 
-    sp_document_done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides"));
+    DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides"));
 }
 
 void
 sp_selection_tile(SPDesktop *desktop, bool apply)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -2399,14 +2406,14 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
         return;
     }
 
-    sp_document_ensure_up_to_date(doc);
+    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));
 
@@ -2417,7 +2424,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
     // 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();
@@ -2482,18 +2489,18 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
 
     g_slist_free(items);
 
-    sp_document_done(doc, SP_VERB_EDIT_TILE,
-                     _("Objects to pattern"));
+    DocumentUndo::done(doc, SP_VERB_EDIT_TILE,
+                       _("Objects to pattern"));
 }
 
-void
-sp_selection_untile(SPDesktop *desktop)
+void sp_selection_untile(SPDesktop *desktop)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -2530,7 +2537,7 @@ sp_selection_untile(SPDesktop *desktop)
         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 = pattern->firstChild() ; child != NULL; child = child->next ) {
             Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc);
             SPItem *i = SP_ITEM(desktop->currentLayer()->appendChildRepr(copy));
 
@@ -2538,10 +2545,10 @@ sp_selection_untile(SPDesktop *desktop)
            // 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->ensureUpToDate();
 
             Geom::Matrix transform( i->transform * pat_transform );
-            sp_item_write_transform(i, SP_OBJECT_REPR(i), transform);
+            i->doWriteTransform(SP_OBJECT_REPR(i), transform);
 
             new_select = g_slist_prepend(new_select, i);
         }
@@ -2554,8 +2561,8 @@ sp_selection_untile(SPDesktop *desktop)
     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,
-                         _("Pattern to objects"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE,
+                           _("Pattern to objects"));
         selection->setList(new_select);
     }
 }
@@ -2606,16 +2613,13 @@ sp_selection_get_export_hints(Inkscape::Selection *selection, char const **filen
     }
 }
 
-void
-sp_document_get_export_hints(SPDocument *doc, char const **filename, float *xdpi, float *ydpi)
+void sp_document_get_export_hints(SPDocument *doc, char const **filename, float *xdpi, float *ydpi)
 {
-    Inkscape::XML::Node * repr = sp_document_repr_root(doc);
-    gchar const *dpi_string;
+    Inkscape::XML::Node * repr = doc->getReprRoot();
 
     *filename = repr->attribute("inkscape:export-filename");
 
-    dpi_string = NULL;
-    dpi_string = repr->attribute("inkscape:export-xdpi");
+    gchar const *dpi_string = repr->attribute("inkscape:export-xdpi");
     if (dpi_string != NULL) {
         *xdpi = atof(dpi_string);
     }
@@ -2627,14 +2631,14 @@ sp_document_get_export_hints(SPDocument *doc, char const **filename, float *xdpi
     }
 }
 
-void
-sp_selection_create_bitmap_copy(SPDesktop *desktop)
+void sp_selection_create_bitmap_copy(SPDesktop *desktop)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *document = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Document *xml_doc = document->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -2650,7 +2654,7 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop)
 
     // Get the bounding box of the selection
     NRRect bbox;
-    sp_document_ensure_up_to_date(document);
+    document->ensureUpToDate();
     selection->bounds(&bbox);
     if (NR_RECT_DFLS_TEST_EMPTY(&bbox)) {
         desktop->clearWaitingCursor();
@@ -2671,7 +2675,7 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop)
 
     // Create the filename.
     gchar *const basename = g_strdup_printf("%s-%s-%u.png",
-                                            document->name,
+                                            document->getName(),
                                             SP_OBJECT_REPR(items->data)->attribute("id"),
                                             current);
     // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,
@@ -2680,8 +2684,8 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop)
 
     // 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);
@@ -2754,7 +2758,7 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop)
     }
 
     // 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;
@@ -2817,8 +2821,8 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop)
         gdk_pixbuf_unref(pb);
 
         // Complete undoable transaction
-        sp_document_done(document, SP_VERB_SELECTION_CREATE_BITMAP,
-                         _("Create bitmap"));
+        DocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP,
+                           _("Create bitmap"));
     }
 
     desktop->clearWaitingCursor();
@@ -2836,14 +2840,14 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop)
  * If \a apply_clip_path parameter is true, clipPath is created, otherwise mask
  *
  */
-void
-sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer)
+void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer)
 {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -2865,7 +2869,7 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la
     }
     // /END FIXME
 
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
     GSList *items = g_slist_copy((GSList *) selection->itemList());
 
@@ -2980,7 +2984,7 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la
 
         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);
         }
@@ -3033,18 +3037,20 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la
     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"));
-    else
-        sp_document_done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask"));
+    if (apply_clip_path) {
+        DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path"));
+    } else {
+        DocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask"));
+    }
 }
 
 void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
-    if (desktop == NULL)
+    if (desktop == NULL) {
         return;
+    }
 
     SPDocument *doc = sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     // check if something is selected
@@ -3056,7 +3062,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
     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->ensureUpToDate();
 
     gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
     std::map<SPObject*,SPItem*> referenced_objects;
@@ -3109,7 +3115,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
     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->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);
@@ -3138,7 +3144,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
             // 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);
@@ -3159,10 +3165,11 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
     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"));
-    else
-        sp_document_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 +3206,8 @@ void
 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,
-                         _("Fit Page to Selection"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION,
+                           _("Fit Page to Selection"));
     }
 }
 
@@ -3213,9 +3220,9 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins)
 {
     g_return_val_if_fail(doc != NULL, false);
 
-    sp_document_ensure_up_to_date(doc);
+    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 +3235,8 @@ void
 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,
-                         _("Fit Page to Drawing"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_DRAWING,
+                           _("Fit Page to Drawing"));
     }
 }
 
@@ -3249,8 +3256,8 @@ void fit_canvas_to_selection_or_drawing(SPDesktop *desktop) {
                            ? 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,
-                         _("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"));
     }
 };
 
index 1f975975a6abc696f22199aaa9dfdc923b5392d7..65d1ba296a27a17ba0eb99aee6b65a0851220ed0 100644 (file)
@@ -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 +18,7 @@
  */
 
 #include "forward.h"
+#include "sp-item.h"
 #include "2geom/forward.h"
 
 namespace Inkscape { class Selection; }
index c9d6871c3ddc953210db6d01496082f0cef9df6b..7bc6adf38e454da21c871e2f9f283015919b9d6f 100644 (file)
@@ -4,6 +4,7 @@
  * Authors:
  *   MenTaLguY <mental@rydia.net>
  *   bulia byak <buliabyak@users.sf.net>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2006 Authors
  *
@@ -178,7 +179,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
         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,
index a4508d9bb2d0458901a76d2abcdb4710fe5eb0b8..9cef87076db5dd20c0179fd888ead40d975f9c61 100644 (file)
@@ -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 +375,7 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const
 
     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 +394,8 @@ NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const {
 
     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;
@@ -438,7 +439,7 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc
     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 +461,7 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPointsConvexHull(Sna
 
     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;
index cdfcee7420a3cf84017ca4708553bf43b96ff810..b0e19e60c5d9747835c2a9ea498c8621bded7c74 100644 (file)
@@ -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 +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 +267,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
         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
     }
 
@@ -333,7 +335,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
             // 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
@@ -429,7 +431,7 @@ void Inkscape::SelTrans::transform(Geom::Matrix const &rel_affine, Geom::Point c
         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 +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,
-                             _("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,
-                             _("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,
-                             _("Rotate"));
+            DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
+                               _("Rotate"));
         } else {
-            sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
-                             _("Skew"));
+            DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
+                               _("Skew"));
         }
 
     } else {
@@ -526,8 +528,8 @@ void Inkscape::SelTrans::ungrab()
                 SPItem *it = (SPItem*)SP_OBJECT(l->data);
                 SP_OBJECT(it)->updateRepr();
             }
-            sp_document_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 +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);
@@ -601,8 +603,8 @@ void Inkscape::SelTrans::stamp()
             Inkscape::GC::release(copy_repr);
             l = l->next;
         }
-        sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
-                         _("Stamp"));
+        DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
+                           _("Stamp"));
     }
 
     if ( fixup && _stamp_cache ) {
@@ -790,8 +792,8 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa
                     _center_is_set = false;  // center has changed
                     _updateHandles();
                 }
-                sp_document_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:
index aabefdfdb4cfe14d87607bd310b746fcad061e11..e57ac8a585ea0c9487fd2f5358c56a603fe4ec06 100644 (file)
@@ -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 +88,14 @@ static void sp_anchor_build(SPObject *object, SPDocument *document, Inkscape::XM
         ((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" );
 }
 
 static void sp_anchor_release(SPObject *object)
@@ -154,13 +153,15 @@ static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Doc
     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
+        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) {
index 132d0aa0f1b8b9088a1efb96efc0a09e00e85edb..f0796b7c61209caeb14fc251ed00663a5d40e050 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_ANIMATION_C__
-
 /** \file
  * SVG <animate> implementation.
  *
@@ -8,6 +6,7 @@
 /*
  * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2002 Lauris Kaplinski
  *
@@ -89,18 +88,18 @@ sp_animation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *
     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" );
 }
 
 static void
@@ -176,15 +175,15 @@ sp_ianimation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
     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" );
 }
 
 static void
index 856c10b1e3791a157c400a6055d8a76ada4e22b5..16368b9c6f64e00c6545119b631d7817363095ae 100644 (file)
@@ -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,47 @@ struct SPClipPathView {
     NRRect bbox;
 };
 
-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);
-
 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;
+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)
 {
     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::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::init(SPClipPath *cp)
 {
     cp->clipPathUnits_set = FALSE;
     cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE;
@@ -98,24 +85,22 @@ sp_clippath_init(SPClipPath *cp)
     cp->display = NULL;
 }
 
-static void
-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" );
 
     /* Register ourselves */
-    sp_document_add_resource(document, "clipPath", object);
+    document->addResource("clipPath", object);
 }
 
-static void
-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)->removeResource("clipPath", object);
     }
 
     SPClipPath *cp = SP_CLIPPATH(object);
@@ -124,18 +109,17 @@ sp_clippath_release(SPObject * 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::set(SPObject *object, unsigned int key, gchar const *value)
 {
     SPClipPath *cp = SP_CLIPPATH(object);
 
     switch (key) {
-       case SP_ATTR_CLIPPATHUNITS:
+        case SP_ATTR_CLIPPATHUNITS:
             cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE;
             cp->clipPathUnits_set = FALSE;
             if (value) {
@@ -148,26 +132,25 @@ sp_clippath_set(SPObject *object, unsigned int key, gchar const *value)
             }
             object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
             break;
-       default:
-            if (((SPObjectClass *) parent_class)->set)
-                ((SPObjectClass *) parent_class)->set(object, key, value);
+        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::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) {
@@ -177,8 +160,7 @@ sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::
     }
 }
 
-static void
-sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags)
+void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
         flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -188,7 +170,7 @@ sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags)
 
     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 = og->firstChild(); child; child = child->getNext()) {
         g_object_ref(G_OBJECT(child));
         l = g_slist_prepend(l, child);
     }
@@ -215,8 +197,7 @@ sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags)
     }
 }
 
-static void
-sp_clippath_modified(SPObject *object, guint flags)
+void SPClipPath::modified(SPObject *object, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
         flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -226,7 +207,7 @@ sp_clippath_modified(SPObject *object, guint flags)
 
     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 = og->firstChild(); child; child = child->getNext()) {
         g_object_ref(G_OBJECT(child));
         l = g_slist_prepend(l, child);
     }
@@ -241,33 +222,30 @@ sp_clippath_modified(SPObject *object, guint flags)
     }
 }
 
-static Inkscape::XML::Node *
-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) {
+        ((SPObjectClass *) (SPClipPathClass::static_parent_class))->write(object, xml_doc, repr, flags);
+    }
 
     return repr;
 }
 
-NRArenaItem *
-sp_clippath_show(SPClipPath *cp, 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(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);
+    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 = firstChild() ; child ; child = child->getNext() ) {
         if (SP_IS_ITEM(child)) {
-            NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(child), arena, key, SP_ITEM_REFERENCE_FLAGS);
+            NRArenaItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS);
             if (ac) {
                 /* The order is not important in clippath */
                 nr_arena_item_add_child(ai, ac, NULL);
@@ -275,32 +253,28 @@ sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key)
         }
     }
 
-    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 (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)
+void SPClipPath::hide(unsigned int key)
 {
-    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 = 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 = 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);
+            display = sp_clippath_view_list_remove(display, v);
             return;
         }
     }
@@ -308,10 +282,9 @@ sp_clippath_hide(SPClipPath *cp, unsigned int key)
     g_assert_not_reached();
 }
 
-void
-sp_clippath_set_bbox(SPClipPath *cp, 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 = display; v != NULL; v = v->next) {
         if (v->key == key) {
             if (!NR_DF_TEST_CLOSE(v->bbox.x0, bbox->x0, NR_EPSILON) ||
                 !NR_DF_TEST_CLOSE(v->bbox.y0, bbox->y0, NR_EPSILON) ||
@@ -324,24 +297,26 @@ 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 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)){};
-    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 +355,11 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view)
 }
 
 // Create a mask element (using passed elements), add it to <defs>
-const gchar *
-sp_clippath_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");
 
@@ -400,7 +374,7 @@ sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* app
         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);
         }
     }
 
index 02395f3d2e605bd911320182be32a7b623689724..a622df1f6b351401faead55c43ac8c8a59c73cec 100644 (file)
@@ -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_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CLIPPATH, SPClipPath))
-#define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CLIPPATH, SPClipPathClass))
-#define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CLIPPATH))
-#define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CLIPPATH))
+#define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type())
+#define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CLIPPATH, SPClipPath))
+#define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_CLIPPATH, SPClipPathClass))
+#define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CLIPPATH))
+#define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_CLIPPATH))
 
 class SPClipPathView;
 
@@ -27,27 +29,55 @@ class SPClipPathView;
 #include "uri-references.h"
 #include "xml/node.h"
 
-struct SPClipPath : public SPObjectGroup {
-       class Reference;
+class SPClipPath : public SPObjectGroup {
+public:
+    class Reference;
 
-       unsigned int clipPathUnits_set : 1;
-       unsigned int clipPathUnits : 1;
+    unsigned int clipPathUnits_set : 1;
+    unsigned int clipPathUnits : 1;
 
-       SPClipPathView *display;
-};
+    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);
+
+    void setBBox(unsigned int key, NRRect *bbox);
+    void getBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
 
-struct SPClipPathClass {
-       SPObjectGroupClass parent_class;
+private:
+    static void init(SPClipPath *clippath);
+
+    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;
 };
 
-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;
+
+    friend class SPClipPath;
+};
 
 class SPClipPathReference : public Inkscape::URIReference {
 public:
-       SPClipPathReference(SPObject *obj) : URIReference(obj) {}
-       SPClipPath *getObject() const {
-               return (SPClipPath *)URIReference::getObject();
-       }
+    SPClipPathReference(SPObject *obj) : URIReference(obj) {}
+    SPClipPath *getObject() const {
+        return (SPClipPath *)URIReference::getObject();
+    }
+
 protected:
     /**
      * If the owner element of this reference (the element with <... clippath="...">)
@@ -55,14 +85,16 @@ protected:
      * \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...
+            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_clippath = NULL;
             gchar const * obj_name = NULL;
@@ -82,15 +114,18 @@ protected:
             return false;
         }
         return true;
-       }
+    }
 };
 
-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);
+#endif // SEEN_SP_CLIPPATH_H
 
-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 :
index 7f019979a7bd65b95fd3589de02aba5310a80d06..0a5a6d7bdde9e9fb72ae144ba76ab29c7e0355c5 100644 (file)
@@ -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 +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" );
 }
 
 
@@ -405,7 +406,7 @@ SPConnEndPair::reroutePathFromLibavoid(void)
 
     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;
index 3ad6954a25204497c27d4ea2f3bb24d74d47c91a..07dd852f230fe988b809d812b4ad7fc215e5fc7d 100644 (file)
@@ -66,7 +66,7 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p
     if (!SP_IS_SHAPE(item)) return false;
 
     // make sure it has an associated curve
-    SPCurve* item_curve = sp_shape_get_curve(SP_SHAPE(item));
+    SPCurve* item_curve = SP_SHAPE(item)->getCurve();
     if (!item_curve) return false;
 
     // apply transformations (up to common ancestor)
index aa0cb0be7643f285f71af3c052fa78cb4596c24e..2737b3f5c1a2bf8b4c3a333d7b3b9d9ea609df2b 100644 (file)
@@ -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_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;
+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 */
             sizeof(SPDefs),
-            16,        /* n_preallocs */
-            (GInstanceInitFunc) sp_defs_init,
-            NULL,      /* value_table */
+            16, /* n_preallocs */
+            (GInstanceInitFunc) init,
+            NULL,       /* value_table */
         };
         defs_type = g_type_register_static(SP_TYPE_OBJECT, "SPDefs", &defs_info, (GTypeFlags) 0);
     }
@@ -53,30 +45,30 @@ GType sp_defs_get_type(void)
     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::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::init(SPDefs */*defs*/)
 {
 
 }
 
-static void 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::update(SPObject *object, SPCtx *ctx, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
         flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -95,7 +87,7 @@ static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags)
     }
 }
 
-static void sp_defs_modified(SPObject *object, guint flags)
+void SPDefs::modified(SPObject *object, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
         flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -104,7 +96,7 @@ static void sp_defs_modified(SPObject *object, guint flags)
     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->firstChild() ; child; child = child->getNext() ) {
         g_object_ref(G_OBJECT(child));
         l = g_slist_prepend(l, child);
     }
@@ -117,11 +109,11 @@ static void sp_defs_modified(SPObject *object, guint flags)
         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::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
     if (flags & SP_OBJECT_WRITE_BUILD) {
 
@@ -130,9 +122,11 @@ static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Docum
         }
 
         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) {
@@ -142,13 +136,13 @@ static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Docum
         }
 
     } 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);
         }
     }
 
-    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;
index 4b6f7a5b712b3c49bd6b059f00f5edf46a733bb0..83003f4ad631d1cfb3af50c10e17cc5911c3928b 100644 (file)
@@ -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);
+       
+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;
-};
 
-GType sp_defs_get_type(void);
+private:
+    static void sp_defs_class_init(SPDefsClass *dc);
+    static SPObjectClass *static_parent_class;
+
+    friend class SPDefs;       
+};
 
 
-#endif /* !SEEN_SP_DEFS_H */
+#endif // !SEEN_SP_DEFS_H
 
 /*
   Local Variables:
index d2472c914e87ebb600787d4ec2571502c30084b0..ef58e4d6e316b6866ff46efaa3a9dc139270c5fb 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_ELLIPSE_C__
-
 /*
  * SVG <ellipse> and related implementations
  *
@@ -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.
@@ -154,7 +153,7 @@ sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags)
             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();
         }
     }
 
@@ -192,7 +191,7 @@ static void sp_genericellipse_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;
@@ -259,12 +258,12 @@ static void sp_genericellipse_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, 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 +282,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vector<Inkscap
 
     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 +434,10 @@ sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re
     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" );
 }
 
 static Inkscape::XML::Node *
@@ -583,9 +582,9 @@ sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
     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" );
 }
 
 static Inkscape::XML::Node *
@@ -708,14 +707,14 @@ sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
     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" );
 
-    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" );
 }
 
 /*
@@ -857,7 +856,7 @@ static void
 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)
index 265c72b14590046eacbde8f8d123ba9fc3bb54ff..30eda7159e8508987bfc2db46b3f2b3869caf1e6 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FILTER_PRIMITIVE_CPP__
-
 /** \file
  * Superclass for all the filter primitives
  *
@@ -8,6 +6,7 @@
  * Authors:
  *   Kees Cook <kees@outflux.net>
  *   Niko Kiirala <niko@kiirala.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2007 Authors
  *
@@ -99,8 +98,8 @@ sp_filter_primitive_build(SPObject *object, SPDocument *document, Inkscape::XML:
         ((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" );
 }
 
 /**
@@ -164,8 +163,8 @@ sp_filter_primitive_update(SPObject *object, SPCtx *ctx, guint flags)
     //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" );
     }
 
     if (((SPObjectClass *) filter_primitive_parent_class)->update) {
@@ -259,7 +258,8 @@ int sp_filter_primitive_name_previous_out(SPFilterPrimitive *prim) {
             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.
+            i_prim->getRepr()->setAttribute("result", name.c_str());
             return slot;
         } else {
             return i_prim->image_out;
index a39cc64372d4ee2c4fa43fbc81bfb63d2a14b12f..cfd6253a3e7c0e64b8b9dd023abfad2e95ea0c92 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FILTER_CPP__
-
 /** \file
  * SVG <filter> implementation.
  */
@@ -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 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
     }
 
     //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" );
 
 //is this necessary?
-    sp_document_add_resource(document, "filter", object);
+    document->addResource("filter", object);
 }
 
 /**
@@ -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)->removeResource("filter", SP_OBJECT(object));
     }
 
 //TODO: release resources here
@@ -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) ) {
-            crepr = child->updateRepr(doc, NULL, flags);
-            if (crepr) l = g_slist_prepend (l, crepr);
+        GSList *l = NULL;
+        for ( SPObject *child = object->firstChild(); child; child = child->getNext() ) {
+            Inkscape::XML::Node *crepr = child->updateRepr(doc, NULL, flags);
+            if (crepr) {
+                l = g_slist_prepend (l, crepr);
+            }
         }
         while (l) {
             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
@@ -304,7 +303,7 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N
             l = g_slist_remove (l, l->data);
         }
     } else {
-        for (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);
         }
     }
index 6d679701fdc098836244aa32d3a4be38644d7c79..4d07cffd7bc0b3039d79f2b60986fc0a71587445 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FLOWDIV_C__
-
 /*
  */
 
@@ -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) ) {
-               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) ) {
-               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 +186,55 @@ sp_flowdiv_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
                ((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) ) {
-                       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) ) {
-                       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 +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) ) {
-               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) ) {
-               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) ) {
-                       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) ) {
-                       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 +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) ) {
-               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) ) {
-               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) ) {
-                       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) ) {
-                       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 +746,14 @@ sp_flowregionbreak_write (SPObject *object, Inkscape::XML::Document *xml_doc, In
 
        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 :
index 79007cac7735a7494fb43db723ef5395de4f491c..680589b551e4090e0336703a4ec4f69f6291c1ec 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_FLOWREGION_C__
-
 /*
  */
 
@@ -143,105 +141,101 @@ sp_flowregion_remove_child (SPObject * object, Inkscape::XML::Node * child)
 }
 
 
-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) ) {
-               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) ) {
-        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) ) {
-               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) ) {
-            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
-            Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
-            if (crepr) l = g_slist_prepend(l, crepr);
+        for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) {
+            if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) {
+                Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+                if (crepr) {
+                    l = g_slist_prepend(l, crepr);
+                }
+            }
         }
 
         while (l) {
@@ -251,16 +245,18 @@ sp_flowregion_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscap
         }
 
     } else {
-        for ( SPObject *child = sp_object_first_child(object) ; 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 +357,97 @@ sp_flowregionexclude_remove_child (SPObject * object, Inkscape::XML::Node * chil
 }
 
 
-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) ) {
-               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) ) {
-               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) ) {
-               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->firstChild() ; child; child = child->getNext() ) {
             Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
-            if (crepr) l = g_slist_prepend(l, crepr);
+            if (crepr) {
+                l = g_slist_prepend(l, crepr);
+            }
         }
 
         while (l) {
@@ -466,15 +457,16 @@ sp_flowregionexclude_write (SPObject *object, Inkscape::XML::Document *xml_doc,
         }
 
     } 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);
         }
     }
 
-       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 +512,7 @@ static void         GetDest(SPObject* child,Shape **computed)
                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 ();
        }
@@ -548,3 +540,13 @@ static void         GetDest(SPObject* child,Shape **computed)
        }
 }
 
+/*
+  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 :
index b01146d60a3797408a608e4f7f058e717e0aa9fc..3af12064ff622e7f1b31f7888bd537307ce5a24e 100644 (file)
@@ -139,21 +139,21 @@ sp_flowtext_remove_child(SPObject *object, Inkscape::XML::Node *child)
     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->firstChild() ; child ; child = child->getNext() ) {
         g_object_ref(G_OBJECT(child));
         l = g_slist_prepend(l, child);
     }
@@ -177,7 +177,7 @@ sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags)
     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));
@@ -186,8 +186,7 @@ sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags)
     }
 }
 
-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;
@@ -199,7 +198,7 @@ sp_flowtext_modified(SPObject *object, guint flags)
     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));
@@ -207,17 +206,17 @@ sp_flowtext_modified(SPObject *object, guint flags)
         }
     }
 
-    for (SPObject *o = sp_object_first_child(SP_OBJECT(ft)) ; 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 +229,7 @@ sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r
         (* ((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
 }
 
 static void
@@ -241,7 +240,8 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value)
     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.
+            SPCSSAttr *opts = sp_repr_css_attr((SP_OBJECT(group))->getRepr(), "inkscape:layoutOptions");
             {
                 gchar const *val = sp_repr_css_property(opts, "justification", NULL);
                 if (val != NULL && !object->style->text_align.set) {
@@ -291,18 +291,21 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value)
     }
 }
 
-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->firstChild() ; child ; child = child->getNext() ) {
             Inkscape::XML::Node *c_repr = NULL;
             if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) {
                 c_repr = child->updateRepr(xml_doc, NULL, flags);
             }
-            if ( c_repr ) l = g_slist_prepend(l, c_repr);
+            if ( c_repr ) {
+                l = g_slist_prepend(l, c_repr);
+            }
         }
         while ( l ) {
             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
@@ -310,15 +313,16 @@ sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
             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->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 +355,9 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx)
     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;
     }
@@ -362,9 +366,9 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx)
     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 +396,7 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vector<Inkscape::Sna
     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 +412,7 @@ sp_flowtext_show(SPItem *item, NRArena *arena, unsigned/* key*/, unsigned /*flag
 
     // 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 +460,7 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
         *pending_line_break_object = NULL;
     }
 
-    for (SPObject *child = sp_object_first_child(root) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+    for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) {
         if (SP_IS_STRING(child)) {
             if (*pending_line_break_object) {
                 if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object))
@@ -466,23 +470,27 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
                 }
                 *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())) {
             _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 +505,18 @@ Shape* SPFlowtext::_buildExclusionShape() const
     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 +556,7 @@ SPFlowtext::getAsText()
 
     SPItem *item = SP_ITEM(this);
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(this));
+    Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(this)->getReprDoc();
     Inkscape::XML::Node *repr = xml_doc->createElement("svg:text");
     repr->setAttribute("xml:space", "preserve");
     repr->setAttribute("style", SP_OBJECT_REPR(this)->attribute("style"));
@@ -650,40 +659,36 @@ SPFlowtext::getAsText()
 
 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) ) {
+    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) ) {
-        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 +703,7 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0,
 {
     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));
@@ -742,7 +747,7 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0,
     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;
 }
index 1912676d42471e8cc171afcbaa685b1f446bf9b6..93e2eeac82ea178191b3c006b50d3ed1303640c9 100644 (file)
@@ -3,7 +3,6 @@
 #endif
 
 #ifdef ENABLE_SVG_FONTS
-#define __SP_FONTFACE_C__
 
 /*
  * SVG <font-face> element implementation
@@ -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 @@ static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape::
         ((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" );
 }
 
 static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/)
@@ -780,39 +780,39 @@ static void
 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" );
     }
 
     if (((SPObjectClass *) parent_class)->update) {
@@ -866,39 +866,41 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D
     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.
+        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) {
index b2003cf08cd84eebfd25fd4756ad85b8df21349c..64f7bd481162cfc4930b6c7b7249b71bde341d98 100644 (file)
@@ -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 +102,14 @@ static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML:
         ((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" );
 
-    sp_document_add_resource(document, "font", object);
+    document->addResource("font", object);
 }
 
 
@@ -150,7 +151,7 @@ sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child)
 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)->removeResource("font", object);
 
     if (((SPObjectClass *) parent_class)->release) {
         ((SPObjectClass *) parent_class)->release(object);
@@ -232,12 +233,12 @@ static void
 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" );
     }
 
     if (((SPObjectClass *) parent_class)->update) {
@@ -263,12 +264,14 @@ static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Docum
     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
+        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) {
index 6bb1f64e7dc79e563b669d9aa1fd14f4db3db30a..1c28fb76fdf7513c548ffbfcd16feb3ae36bfe81 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_GAUSSIANBLUR_CPP__
-
 /** \file
  * SVG <gaussianBlur> implementation.
  *
@@ -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 +99,7 @@ sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod
         ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr);
     }
 
-    sp_object_read_attr(object, "stdDeviation");
+    object->readAttr( "stdDeviation" );
 
 }
 
@@ -143,7 +142,7 @@ static void
 sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
-        sp_object_read_attr(object, "stdDeviation");
+        object->readAttr( "stdDeviation" );
     }
 
     if (((SPObjectClass *) gaussianBlur_parent_class)->update) {
index d62fbb2c295f8a7e7464be7ce725c070e661f7e7..7a9f9b2ff1372307f6227fdb030252e42c5c78cf 100644 (file)
@@ -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 +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 +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 +111,11 @@ static void sp_glyph_kerning_build(SPObject *object, SPDocument *document, Inksc
         ((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" );
 }
 
 static void sp_glyph_kerning_release(SPObject *object)
@@ -216,10 +217,10 @@ sp_glyph_kerning_update(SPObject *object, SPCtx *ctx, guint flags)
 
     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" );
     }
 
     if (((SPObjectClass *) parent_class)->update) {
@@ -250,11 +251,13 @@ static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::X
     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.
+        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) {
index 0b3b85d3f73df50bf40ae542eafd740ffed9caac..6f72381335e323a7a681f1dd4e711b3b7bec4f9c 100644 (file)
@@ -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 +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 +91,16 @@ static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML
         ((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" );
 }
 
 static void sp_glyph_release(SPObject *object)
@@ -250,16 +251,16 @@ sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags)
 
     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" );
     }
 
     if (((SPObjectClass *) parent_class)->update) {
@@ -290,16 +291,18 @@ static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Docu
     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.
+        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) {
index a664218e0627a4336a59eda6b0c05af2973b2678..2a061595eea857747f53549d647ff6f68ea5f06f 100644 (file)
@@ -1,4 +1,3 @@
-
 #ifndef SEEN_SP_GRADIENT_TEST_H
 #define SEEN_SP_GRADIENT_TEST_H
 
@@ -25,7 +24,7 @@ public:
     {
         if ( _doc )
         {
-            sp_document_unref( _doc );
+            _doc->doUnref();
         }
     }
 
@@ -56,13 +55,13 @@ public:
         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 +73,7 @@ public:
         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);
@@ -136,7 +135,7 @@ public:
             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 );
index cd57f40b5ef76fe9ba281a4d07813f94dc634b53..1b8f9a11137a0e1e311200c2c00ca7ad97a81145 100644 (file)
@@ -6,6 +6,8 @@
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
  *   Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 1999-2002 Lauris Kaplinski
  * Copyright (C) 2000-2001 Ximian, Inc.
@@ -142,10 +144,10 @@ static void sp_stop_build(SPObject *object, SPDocument *document, Inkscape::XML:
     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" );
 }
 
 /**
@@ -169,7 +171,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value)
          * 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 {
@@ -177,7 +179,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value)
                 }
             }
             {
-                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;
             }
@@ -186,7 +188,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value)
         }
         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 {
@@ -199,7 +201,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value)
         }
         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;
             }
@@ -291,7 +293,7 @@ void SPGradient::setSwatch( bool swatch )
     if ( swatch != isSwatch() ) {
         this->swatch = swatch; // to make isSolid() work, this happens first
         gchar const* paintVal = swatch ? (isSolid() ? "solid" : "gradient") : 0;
-        sp_object_setAttribute( this, "osb:paint", paintVal, 0 );
+        setAttribute( "osb:paint", paintVal, 0 );
 
         requestModified( SP_OBJECT_MODIFIED_FLAG );
     }
@@ -308,7 +310,7 @@ sp_stop_get_rgba32(SPStop const *const stop)
      * 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);
         }
@@ -417,21 +419,21 @@ void SPGradientImpl::build(SPObject *object, SPDocument *document, Inkscape::XML
         (* ((SPObjectClass *) gradient_parent_class)->build)(object, document, repr);
     }
 
-    for ( SPObject *ochild = sp_object_first_child(object); ochild; ochild = ochild->next ) {
+    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( "osb:paint" );
 
-    /* Register ourselves */
-    sp_document_add_resource(document, "gradient", object);
+    // Register ourselves
+    document->addResource("gradient", object);
 }
 
 /**
@@ -442,12 +444,12 @@ void SPGradientImpl::release(SPObject *object)
     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)->removeResource("gradient", SP_OBJECT(object));
     }
 
     if (gradient->ref) {
@@ -541,7 +543,7 @@ void SPGradientImpl::setGradientAttr(SPObject *object, unsigned key, gchar const
                 // Might need to flip solid/gradient
                 Glib::ustring paintVal = ( gr->hasStops() && (gr->getStopCount() == 0) ) ? "solid" : "gradient";
                 if ( paintVal != value ) {
-                    sp_object_setAttribute( gr, "osb:paint", paintVal.c_str(), 0 );
+                    gr->setAttribute( "osb:paint", paintVal.c_str(), 0 );
                     modified = true;
                 }
             }
@@ -600,13 +602,13 @@ void SPGradientImpl::childAdded(SPObject *object, Inkscape::XML::Node *child, In
         (* ((SPObjectClass *) gradient_parent_class)->child_added)(object, child, ref);
     }
 
-    SPObject *ochild = sp_object_get_child_by_repr(object, child);
+    SPObject *ochild = object->get_child_by_repr(child);
     if ( ochild && SP_IS_STOP(ochild) ) {
         gr->has_stops = TRUE;
         if ( gr->getStopCount() > 0 ) {
-            gchar const * attr = gr->repr->attribute("osb:paint");
+            gchar const * attr = gr->getAttribute("osb:paint");
             if ( attr && strcmp(attr, "gradient") ) {
-                sp_object_setAttribute( gr, "osb:paint", "gradient", 0 );
+                gr->setAttribute( "osb:paint", "gradient", 0 );
             }
         }
     }
@@ -629,8 +631,7 @@ void SPGradientImpl::removeChild(SPObject *object, Inkscape::XML::Node *child)
     }
 
     gr->has_stops = FALSE;
-    SPObject *ochild;
-    for ( ochild = sp_object_first_child(object) ; 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;
@@ -638,9 +639,9 @@ void SPGradientImpl::removeChild(SPObject *object, Inkscape::XML::Node *child)
     }
 
     if ( gr->getStopCount() == 0 ) {
-        gchar const * attr = gr->repr->attribute("osb:paint");
+        gchar const * attr = gr->getAttribute("osb:paint");
         if ( attr && strcmp(attr, "solid") ) {
-            sp_object_setAttribute( gr, "osb:paint", "solid", 0 );
+            gr->setAttribute( "osb:paint", "solid", 0 );
         }
     }
 
@@ -668,7 +669,7 @@ void SPGradientImpl::modified(SPObject *object, guint flags)
 
     // 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->firstChild() ; child; child = child->getNext() ) {
         g_object_ref(G_OBJECT(child));
         l = g_slist_prepend(l, child);
     }
@@ -686,7 +687,7 @@ void SPGradientImpl::modified(SPObject *object, guint flags)
 SPStop* SPGradient::getFirstStop()
 {
     SPStop* first = 0;
-    for (SPObject *ochild = sp_object_first_child(this); ochild && !first; ochild = SP_OBJECT_NEXT(ochild)) {
+    for (SPObject *ochild = firstChild(); ochild && !first; ochild = ochild->getNext()) {
         if (SP_IS_STOP(ochild)) {
             first = SP_STOP(ochild);
         }
@@ -718,7 +719,7 @@ Inkscape::XML::Node *SPGradientImpl::write(SPObject *object, Inkscape::XML::Docu
 
     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->firstChild(); child; child = child->getNext()) {
             Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
             if (crepr) {
                 l = g_slist_prepend(l, crepr);
@@ -961,7 +962,7 @@ sp_gradient_repr_write_vector(SPGradient *gr)
     g_return_if_fail(gr != NULL);
     g_return_if_fail(SP_IS_GRADIENT(gr));
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(gr));
+    Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(gr)->getReprDoc();
     Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr);
 
     /* We have to be careful, as vector may be our own, so construct repr list at first */
@@ -1023,9 +1024,7 @@ bool SPGradient::invalidateVector()
 void SPGradient::rebuildVector()
 {
     gint len = 0;
-    for ( SPObject *child = sp_object_first_child(SP_OBJECT(this)) ;
-          child != NULL ;
-          child = SP_OBJECT_NEXT(child) ) {
+    for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) {
         if (SP_IS_STOP(child)) {
             len ++;
         }
@@ -1047,9 +1046,7 @@ void SPGradient::rebuildVector()
         }
     }
 
-    for (SPObject *child = sp_object_first_child(SP_OBJECT(this)) ;
-         child != NULL;
-         child = SP_OBJECT_NEXT(child) ) {
+    for ( SPObject *child = firstChild(); child; child = child->getNext() ) {
         if (SP_IS_STOP(child)) {
             SPStop *stop = SP_STOP(child);
 
@@ -1530,10 +1527,10 @@ static void sp_lineargradient_build(SPObject *object,
     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" );
 }
 
 /**
@@ -1807,11 +1804,11 @@ sp_radialgradient_build(SPObject *object, SPDocument *document, Inkscape::XML::N
     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" );
 }
 
 /**
index e42b2ed322e5c5fa4c66b49a590ceb1c22e843c9..e5c63d04e03b3cf10d318a06b286254580b0f059 100644 (file)
@@ -1,7 +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,7 @@ public:
     }
 };
 
-
-#endif /* !__SP_GUIDE_ATTACHMENT_H__ */
+#endif // SEEN_SP_GUIDE_ATTACHMENT_H
 
 /*
   Local Variables:
index f5edf7d97cf3a63baf9820d97bf57822ae640f1b..f92d791162e5267677eb10804185d5c4280771a0 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_GUIDE_C__
-
 /*
  * Inkscape guideline implementation
  *
@@ -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,7 @@
 #include <2geom/angle.h>
 #include "document.h"
 
+using Inkscape::DocumentUndo;
 using std::vector;
 
 enum {
@@ -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 +159,8 @@ static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML
         (* ((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" );
 }
 
 static void sp_guide_release(SPObject *object)
@@ -241,10 +242,10 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
     }
 }
 
-SPGuide *
-sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) {
-    SPDocument *doc=sp_desktop_document(desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+SPGuide *SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2)
+{
+    SPDocument *doc = sp_desktop_document(desktop);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide");
 
@@ -253,7 +254,7 @@ sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &p
     sp_repr_set_point(repr, "position", pt1);
     sp_repr_set_point(repr, "orientation", n);
 
-    SP_OBJECT_REPR(desktop->namedview)->appendChild(repr);
+    desktop->namedview->appendChild(repr);
     Inkscape::GC::release(repr);
 
     SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr));
@@ -263,7 +264,7 @@ sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &p
 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);
     }
 }
 
@@ -273,7 +274,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) {
     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]);
 
@@ -284,30 +285,28 @@ sp_guide_create_guides_around_page(SPDesktop *dt) {
 
     sp_guide_pt_pairs_to_guides(dt, pts);
 
-    sp_document_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, 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);
+    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(canvas != NULL);
     g_assert(SP_IS_CANVAS(canvas));
 
-    for (GSList *l = guide->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);
+            views = g_slist_remove(views, l->data);
             return;
         }
     }
@@ -315,14 +314,12 @@ void sp_guide_hide(SPGuide *guide, SPCanvas *canvas)
     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(canvas != NULL);
     g_assert(SP_IS_CANVAS(canvas));
 
-    for (GSList *l = guide->views; l != NULL; l = l->next) {
+    for (GSList *l = views; l != NULL; l = l->next) {
         if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
             sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive);
             return;
@@ -332,14 +329,14 @@ void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive)
     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 - 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 - point_on_line, normal_to_line);
 }
 
 /**
@@ -358,7 +355,8 @@ void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool
     /* 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.
+        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 +386,8 @@ void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line,
     /* 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
+        sp_repr_set_point(SP_OBJECT(&guide)->getRepr(), "orientation", normal_to_line);
     }
 
 /*  DISABLED CODE BECAUSE  SPGuideAttachment  IS NOT USE AT THE MOMENT (johan)
@@ -458,7 +457,8 @@ void sp_guide_remove(SPGuide *guide)
     }
     guide->attached_items.clear();
 
-    sp_repr_unparent(SP_OBJECT(guide)->repr);
+    //XML Tree being used directly while it shouldn't be.
+    sp_repr_unparent(SP_OBJECT(guide)->getRepr());
 }
 
 /*
index 91c181a7046146d9ea21d5f4894a5cb393f96993..4fc4032db44b2b08cff27a78fededf4ffa91553b 100644 (file)
@@ -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,8 @@
  *
  * Copyright (C) Lauris Kaplinski 2000
  * Copyright (C) Johan Engelen 2007
+ *   Abhishek Sharma
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  */
 
@@ -25,7 +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:
     Geom::Point normal_to_line;
     Geom::Point point_on_line;
 
@@ -34,27 +37,27 @@ struct SPGuide : public SPObject {
     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;
 };
 
-struct SPGuideClass {
+class SPGuideClass {
+public:
     SPObjectClass parent_class;
 };
 
 GType sp_guide_get_type();
 
-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);
-
-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 +65,7 @@ void sp_guide_remove(SPGuide *guide);
 char *sp_guide_description(SPGuide const *guide, const bool verbose = true);
 
 
-#endif /* !SP_GUIDE_H */
+#endif // SEEN_SP_GUIDE_H
 
 /*
   Local Variables:
index 68bafdeab9345e0c50c9e0bc43d99e4136740124..ad9e79de2ba576a9fec46f9c2538ffdfa44cc722 100644 (file)
@@ -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 +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 +586,7 @@ sp_image_class_init (SPImageClass * klass)
     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 +638,16 @@ sp_image_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
         ((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" );
 
     /* Register */
-    sp_document_add_resource (document, "image", object);
+    document->addResource("image", object);
 }
 
 static void
@@ -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)->removeResource("image", SP_OBJECT(object));
     }
 
     if (image->href) {
@@ -838,9 +839,13 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags)
             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.
+                object->getRepr()->attribute("xlink:href"),
+
+                //XML Tree being used directly while it shouldn't be.
+                object->getRepr()->attribute("sodipodi:absref"),
+                doc->getBase());
             if (pixbuf) {
                 pixbuf = sp_image_pixbuf_force_rgba (pixbuf);
 // BLIP
@@ -1056,7 +1061,9 @@ sp_image_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
     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...
+    repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio"));
 #if ENABLE_LCMS
     if (image->color_profile) {
         repr->setAttribute("color-profile", image->color_profile);
@@ -1352,7 +1359,7 @@ static void sp_image_snappoints(SPItem const *item, std::vector<Inkscape::SnapCa
         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));
index 5884277521c9a24fcfac82d519363029c005d18d..30d08558465b4283ed19be3f9f68eff251da1bbe 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_GROUP_C__
-
 /*
  * SVG <g> implementation
  *
@@ -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,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 +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" );
 
     if (((SPObjectClass *)parent_class)->build) {
         ((SPObjectClass *)parent_class)->build(object, document, repr);
@@ -154,7 +156,7 @@ static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML
 
 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)->removeResource("layer", object);
     }
     if (((SPObjectClass *)parent_class)->release) {
         ((SPObjectClass *)parent_class)->release(object);
@@ -219,28 +221,27 @@ sp_group_modified (SPObject *object, guint flags)
     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) ) {
-            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
-            crepr = child->updateRepr(xml_doc, NULL, flags);
-            if (crepr) l = g_slist_prepend (l, crepr);
+        for (SPObject *child = object->firstChild(); child; child = child->getNext() ) {
+            if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) {
+                Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+                if (crepr) {
+                    l = g_slist_prepend (l, crepr);
+                }
+            }
         }
         while (l) {
             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
@@ -248,9 +249,10 @@ sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
             l = g_slist_remove (l, l->data);
         }
     } else {
-        for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
-            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
-            child->updateRepr(flags);
+        for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+            if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) {
+                child->updateRepr(flags);
+            }
         }
     }
 
@@ -268,8 +270,9 @@ sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
         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 +327,12 @@ sp_group_hide (SPItem *item, unsigned int key)
     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));
-         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 +345,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
     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);
@@ -353,7 +354,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
     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);
@@ -368,7 +369,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
     /* 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 = group->firstChild() ; child; child = child->getNext() ) {
 
         if (SP_IS_ITEM (child)) {
 
@@ -377,7 +378,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
             /* 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));
             /*
@@ -487,7 +488,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
         // 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))
@@ -496,38 +497,36 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
         items = g_slist_remove (items, items->data);
     }
 
-    if (do_done)
-        sp_document_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) ) {
-        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));
-    while ( child && strcmp (SP_OBJECT_REPR(child)->name(), name) ) {
-        child = SP_OBJECT_NEXT(child);
+    SPObject *child = (ref) ? ref->getNext() : group->firstChild();
+    while ( child && strcmp(child->getRepr()->name(), name) ) {
+        child = child->getNext();
     }
     return child;
 }
@@ -535,9 +534,9 @@ sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *nam
 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)->addResource("layer", this);
         } else if ( _layer_mode == LAYER ) {
-            sp_document_remove_resource(SP_OBJECT_DOCUMENT(this), "layer", this);
+            SP_OBJECT_DOCUMENT(this)->removeResource("layer", this);
         }
         _layer_mode = mode;
         _updateLayerMode();
@@ -575,12 +574,10 @@ void SPGroup::_updateLayerMode(unsigned int display_key) {
 
 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) ) {
-            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 +601,7 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) {
             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);
@@ -612,16 +609,16 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) {
             }
         }
     } 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 +706,7 @@ void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned
         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 +719,7 @@ void CGroup::onPrint(SPPrintContext *ctx) {
     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);
     }
@@ -730,7 +727,7 @@ void CGroup::onPrint(SPPrintContext *ctx) {
 
 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 = _group->firstChild() ; o ; o = o->getNext() ) {
         if (SP_IS_ITEM(o)) {
             len++;
         }
@@ -771,7 +768,7 @@ void CGroup::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, u
         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 +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);
     }
@@ -800,11 +797,11 @@ void CGroup::hide (unsigned int key) {
 
 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 +855,12 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
             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..928d6f82f7fa2c8e431a26889f2a838882937c46 100644 (file)
@@ -25,7 +25,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin
     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 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin
        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 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin
 
         /* 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);
index 78628f4a527d5a82acd80102d3d0ca1d95e22680..de4c7dca1977b67bc20e5b25a46d2ac208a7e79b 100644 (file)
@@ -15,13 +15,13 @@ void sp_item_rm_unsatisfied_cns(SPItem &item)
         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]);
index e401f437cfe5d9aa2241357f1fb9b50841914bc6..81780220cae38fc62becf485ce00f6786de8491e 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_ITEM_TRANSFORM_C__
-
 /*
  * Transforming single items
  *
@@ -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 +24,9 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation)
     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()) {
@@ -39,11 +38,11 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation)
 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 +55,8 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY)
     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 +67,9 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY)
 
 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);
 }
 
 /*
index c90df01ba83c0fff7be59a0e3bcc3e036e11012d..315d0910812c8f007a50489c158158abb303a462 100644 (file)
@@ -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);
index d213ce2d7414688c0a2787367358a3aea68f99aa..755ee0bf40211c2df9cffd0f382776bef83a3a5d 100644 (file)
@@ -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 +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_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 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 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,
@@ -126,60 +111,59 @@ sp_item_get_type(void)
 /**
  * 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)
 {
     item->init();
 }
 
 void SPItem::init() {
-    this->sensitive = TRUE;
+    sensitive = TRUE;
 
-    this->transform_center_x = 0;
-    this->transform_center_y = 0;
+    transform_center_x = 0;
+    transform_center_y = 0;
 
-    this->_is_evaluated = true;
-    this->_evaluated_status = StatusUnknown;
+    _is_evaluated = true;
+    _evaluated_status = StatusUnknown;
 
-    this->transform = Geom::identity();
+    transform = Geom::identity();
 
-    this->display = NULL;
+    display = NULL;
 
-    this->clip_ref = new SPClipPathReference(this);
-    sigc::signal<void, SPObject *, SPObject *> cs1=this->clip_ref->changedSignal();
-    sigc::slot2<void,SPObject*, SPObject *> sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), this);
+    clip_ref = new SPClipPathReference(this);
+    sigc::signal<void, SPObject *, SPObject *> cs1 = clip_ref->changedSignal();
+    sigc::slot2<void,SPObject*, SPObject *> sl1 = sigc::bind(sigc::ptr_fun(clip_ref_changed), this);
     _clip_ref_connection = cs1.connect(sl1);
 
-    this->mask_ref = new SPMaskReference(this);
-    sigc::signal<void, SPObject *, SPObject *> cs2=this->mask_ref->changedSignal();
+    mask_ref = new SPMaskReference(this);
+    sigc::signal<void, SPObject *, SPObject *> cs2 = mask_ref->changedSignal();
     sigc::slot2<void,SPObject*, SPObject *> sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), this);
     _mask_ref_connection = cs2.connect(sl2);
 
-    this->avoidRef = new SPAvoidRef(this);
+    avoidRef = new SPAvoidRef(this);
 
-    new (&this->constraints) std::vector<SPGuideConstraint>();
+    new (&constraints) std::vector<SPGuideConstraint>();
 
-    new (&this->_transformed_signal) sigc::signal<void, Geom::Matrix const *, SPItem *>();
+    new (&_transformed_signal) sigc::signal<void, Geom::Matrix const *, SPItem *>();
 }
 
 bool SPItem::isVisibleAndUnlocked() const {
@@ -200,8 +184,8 @@ bool SPItem::isLocked() const {
 }
 
 void SPItem::setLocked(bool locked) {
-    this->repr->setAttribute("sodipodi:insensitive",
-                             ( locked ? "1" : NULL ));
+    setAttribute("sodipodi:insensitive",
+                 ( locked ? "1" : NULL ));
     updateRepr();
 }
 
@@ -251,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;
         if (SP_IS_SWITCH(parent)) {
             SP_SWITCH(parent)->resetChildEvaluated();
         }
@@ -270,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 );
+    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 +300,13 @@ bool SPItem::isCenterSet() {
 
 Geom::Point SPItem::getCenter() const {
     // for getBounds() to work
-    sp_document_ensure_up_to_date( this->document );
+    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 +323,20 @@ void SPItem::raiseToTop() {
     using Inkscape::Algorithms::find_last_if;
 
     SPObject *topmost=find_last_if<SPObject::SiblingIterator>(
-        this->next, NULL, &is_item
+        next, NULL, &is_item
     );
     if (topmost) {
-        Inkscape::XML::Node *repr = this->repr;
-        sp_repr_parent(repr)->changeOrder( repr, topmost->repr );
+        getRepr()->parent()->changeOrder( getRepr(), topmost->getRepr() );
     }
 }
 
 void SPItem::raiseOne() {
     SPObject *next_higher=std::find_if<SPObject::SiblingIterator>(
-        this->next, NULL, &is_item
+        next, NULL, &is_item
     );
     if (next_higher) {
-        Inkscape::XML::Node *repr = this->repr;
-        Inkscape::XML::Node *ref = next_higher->repr;
-        sp_repr_parent(repr)->changeOrder(repr, ref);
+        Inkscape::XML::Node *ref = next_higher->getRepr();
+        getRepr()->parent()->changeOrder(getRepr(), ref);
     }
 }
 
@@ -368,16 +346,15 @@ void SPItem::lowerOne() {
 
     MutableList<SPObject &> next_lower=std::find_if(
         reverse_list<SPObject::SiblingIterator>(
-            this->parent->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 );
-        sp_repr_parent(repr)->changeOrder(repr, ref);
+        Inkscape::XML::Node *ref = ( next_lower ? next_lower->getRepr() : NULL );
+        getRepr()->parent()->changeOrder(getRepr(), ref);
     }
 }
 
@@ -388,40 +365,37 @@ void SPItem::lowerToBottom() {
 
     MutableList<SPObject &> bottom=find_last_if(
         reverse_list<SPObject::SiblingIterator>(
-            this->parent->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 );
-        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)
 {
-    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" );
 
-    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)
 {
     SPItem *item = (SPItem *) object;
 
@@ -429,7 +403,7 @@ sp_item_release(SPObject *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;
@@ -448,8 +422,8 @@ sp_item_release(SPObject *object)
         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) {
@@ -460,8 +434,7 @@ sp_item_release(SPObject *object)
     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)
 {
     SPItem *item = (SPItem *) object;
 
@@ -469,9 +442,9 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value)
         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;
         }
@@ -547,45 +520,43 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value)
                 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)
 {
     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)->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)->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)->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)
 {
     if (old_mask) {
         /* Hide mask */
@@ -596,10 +567,10 @@ mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
     }
     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),
@@ -612,13 +583,13 @@ mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
     }
 }
 
-static void
-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) {
+        (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags);
+    }
 
     if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) {
         if (flags & SP_OBJECT_MODIFIED_FLAG) {
@@ -632,10 +603,10 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
 
         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->setBBox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
                 }
             }
             if (mask) {
@@ -656,7 +627,7 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
     /* 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 {
@@ -670,8 +641,7 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
         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)
 {
     SPObject *child;
     SPItem *item = SP_ITEM(object);
@@ -682,7 +652,7 @@ sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape
         Inkscape::XML::Node *crepr;
         GSList *l;
         l = NULL;
-        for (child = sp_object_first_child(object); child != NULL; child = child->next ) {
+        for (child = object->firstChild(); child != NULL; child = child->next ) {
             if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue;
             crepr = child->updateRepr(xml_doc, NULL, flags);
             if (crepr) l = g_slist_prepend (l, crepr);
@@ -693,7 +663,7 @@ sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape
             l = g_slist_remove (l, l->data);
         }
     } else {
-        for (child = sp_object_first_child(object) ; child != NULL; child = child->next ) {
+        for (child = object->firstChild() ; child != NULL; child = child->next ) {
             if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue;
             child->updateRepr(flags);
         }
@@ -726,8 +696,8 @@ sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape
         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 +712,19 @@ Geom::OptRect SPItem::getBounds(Geom::Matrix const &transform,
                                       unsigned int /*dkey*/) const
 {
     Geom::OptRect r;
-    sp_item_invoke_bbox_full(this, 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)
+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)
+void SPItem::invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type)
 {
-    sp_item_invoke_bbox_full(item, bbox, transform, type, clear);
+    invoke_bbox_full( bbox, transform, type, clear);
 }
 
 /** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and
@@ -766,12 +734,8 @@ sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transf
  * \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)
+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));
-
     if (clear) {
         bbox = Geom::OptRect();
     }
@@ -783,14 +747,14 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c
     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 ( 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;
@@ -830,7 +794,7 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c
                 }
 
                 // 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();
@@ -843,9 +807,9 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c
                 temp_bbox.y1 += dy1;
             }
         }
-        if (item->clip_ref->getObject()) {
+        if (clip_ref->getObject()) {
             NRRect b;
-            sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags);
+            SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags);
             nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b);
         }
     }
@@ -874,11 +838,8 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c
  * 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)
+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(bbox != NULL);
 
     if (clear) {
@@ -891,14 +852,14 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &t
     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 && clip_ref->getObject()) {
         NRRect b;
-        sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags);
+        SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags);
         nr_rect_d_intersect (&this_bbox, &this_bbox, &b);
     }
 
@@ -908,19 +869,15 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &t
     }
 }
 
-unsigned sp_item_pos_in_parent(SPItem *item)
+unsigned SPItem::pos_in_parent()
 {
-    g_assert(item != NULL);
-    g_assert(SP_IS_ITEM(item));
-
-    SPObject *parent = item->parent;
     g_assert(parent != NULL);
     g_assert(SP_IS_OBJECT(parent));
 
-    SPObject *object = item;
+    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->firstChild() ; iter ; iter = iter->next) {
         if ( iter == object ) {
             return pos;
         }
@@ -933,31 +890,28 @@ unsigned sp_item_pos_in_parent(SPItem *item)
     return 0;
 }
 
-void
-sp_item_bbox_desktop(SPItem *item, 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(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;
@@ -971,34 +925,24 @@ static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape:
 
 }
 
-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;
-    }
-
     // 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(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++) {
@@ -1008,12 +952,12 @@ void sp_item_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidateP
                 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()));
                     }
                 }
@@ -1022,26 +966,24 @@ void sp_item_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidateP
     }
 }
 
-void
-sp_item_invoke_print(SPItem *item, 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 ( !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, 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);
+                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*/)
 {
     return g_strdup(_("Object"));
 }
@@ -1051,27 +993,23 @@ sp_item_private_description(SPItem */*item*/)
  *
  * Must be freed by caller.
  */
-gchar *
-sp_item_description(SPItem *item)
+gchar *SPItem::description()
 {
-    g_assert(item != NULL);
-    g_assert(SP_IS_ITEM(item));
-
-    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();
-            gchar *snew;
+        if ( style && style->filter.href && style->filter.href->getObject() ) {
+            const gchar *label = style->filter.href->getObject()->label();
+            gchar *snew = 0;
             if (label) {
                 snew = g_strdup_printf (_("%s; <i>filtered (%s)</i>"), s, _(label));
             } else {
@@ -1093,8 +1031,7 @@ sp_item_description(SPItem *item)
  * \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)
+unsigned SPItem::display_key_new(unsigned numkeys)
 {
     static unsigned dkey = 0;
 
@@ -1103,51 +1040,48 @@ sp_item_display_key_new(unsigned numkeys)
     return dkey - numkeys;
 }
 
-NRArenaItem *
-sp_item_invoke_show(SPItem *item, 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(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(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->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)->setBBox(clip_key, &bbox);
             cp->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
         }
-        if (item->mask_ref->getObject()) {
-            SPMask *mask = item->mask_ref->getObject();
+        if (mask_ref->getObject()) {
+            SPMask *mask = mask_ref->getObject();
 
-            if (!item->display->arenaitem->key) {
-                NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
+            if (!display->arenaitem->key) {
+                NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3));
             }
-            int mask_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem);
+            int mask_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem);
 
             // Show and set mask
             NRArenaItem *ac = sp_mask_show(mask, arena, mask_key);
@@ -1156,44 +1090,40 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
 
             // 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);
             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)
+void SPItem::invoke_hide(unsigned key)
 {
-    g_assert(item != NULL);
-    g_assert(SP_IS_ITEM(item));
-
-    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())->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;
             }
@@ -1209,34 +1139,29 @@ sp_item_invoke_hide(SPItem *item, unsigned key)
 
 // Adjusters
 
-void
-sp_item_adjust_pattern (SPItem *item, Geom::Matrix const &postmul, bool set)
+void SPItem::adjust_pattern (Geom::Matrix const &postmul, bool set)
 {
-    SPStyle *style = item->style;
-
-    if ( style && style->fill.isPaintserver() ) {
-        SPPaintServer *server = item->style->getFillPaintServer();
+    if (style && (style->fill.isPaintserver())) {
+        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 = 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 )
 {
-    SPStyle *style = item->style;
-
     if ( style && style->fill.isPaintserver() ) {
-        SPPaintServer *server = item->style->getFillPaintServer();
+        SPPaintServer *server = style->getFillPaintServer();
         if ( SP_IS_GRADIENT(server) ) {
 
             /**
@@ -1248,25 +1173,23 @@ void sp_item_adjust_gradient( SPItem *item, Geom::Matrix const &postmul, bool se
              * \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" );
 
             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 )
 {
-    SPStyle *style = item->style;
-
     if ( style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE(ex, 1.0, NR_EPSILON) ) {
         style->stroke_width.computed *= ex;
         style->stroke_width.set = TRUE;
@@ -1278,18 +1201,17 @@ void sp_item_adjust_stroke( SPItem *item, gdouble ex )
             style->stroke_dash.offset *= ex;
         }
 
-        item->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 = item->getRepr()->attribute("transform");
     if (t_attr) {
         Geom::Matrix t;
         if (sp_svg_transform_read(t_attr, &t)) {
@@ -1304,18 +1226,17 @@ sp_item_transform_repr (SPItem *item)
 /**
  * Recursively scale stroke width in \a item and its children by \a expansion.
  */
-void
-sp_item_adjust_stroke_width_recursive(SPItem *item, 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))
-        return;
-
-    for (SPObject *o = item->children; o != NULL; o = o->next) {
-        if (SP_IS_ITEM(o))
-            sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion);
+    if ( !SP_IS_USE(this) ) {
+        for ( SPObject *o = children; o; o = o->getNext() ) {
+            if (SP_IS_ITEM(o)) {
+                SP_ITEM(o)->adjust_stroke_width_recursive(expansion);
+            }
+        }
     }
 }
 
@@ -1338,24 +1259,23 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Matrix 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)
+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 = 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);
             }
         }
     }
@@ -1365,31 +1285,29 @@ sp_item_adjust_paint_recursive (SPItem *item, Geom::Matrix advertized_transform,
 // 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);
-    else
-        sp_item_adjust_gradient (item, 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)
+void SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set)
 {
-    if ( !SP_IS_LPE_ITEM(item) )
-        return;
-
-    SPLPEItem *lpeitem = SP_LPE_ITEM (item);
-    if ( sp_lpe_item_has_path_effect(lpeitem) ) {
-        sp_lpe_item_fork_path_effects_if_necessary(lpeitem);
-
-        // now that all LPEs are forked_if_necessary, we can apply the transform
-        PathEffectList effect_list =  sp_lpe_item_get_effect_list(lpeitem);
-        for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++)
-        {
-            LivePathEffectObject *lpeobj = (*it)->lpeobject;
-            if (lpeobj && lpeobj->get_lpe()) {
-                Inkscape::LivePathEffect::Effect * effect = lpeobj->get_lpe();
-                effect->transform_multiply(postmul, set);
+    if ( SP_IS_LPE_ITEM(this) ) {
+        SPLPEItem *lpeitem = SP_LPE_ITEM (this);
+        if ( sp_lpe_item_has_path_effect(lpeitem) ) {
+            sp_lpe_item_fork_path_effects_if_necessary(lpeitem);
+
+            // now that all LPEs are forked_if_necessary, we can apply the transform
+            PathEffectList effect_list =  sp_lpe_item_get_effect_list(lpeitem);
+            for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++)
+            {
+                LivePathEffectObject *lpeobj = (*it)->lpeobject;
+                if (lpeobj && lpeobj->get_lpe()) {
+                    Inkscape::LivePathEffect::Effect * effect = lpeobj->get_lpe();
+                    effect->transform_multiply(postmul, set);
+                }
             }
         }
     }
@@ -1403,11 +1321,8 @@ sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool s
  * 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)
+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(repr != NULL);
 
     // calculate the relative transform, if not given by the adv attribute
@@ -1415,7 +1330,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co
     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();
@@ -1424,26 +1339,26 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co
          // 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)
@@ -1451,36 +1366,32 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co
     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() && 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();
+    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)
+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);
-
-    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) {
+        return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event);
+    }
 
     return FALSE;
 }
@@ -1489,35 +1400,26 @@ sp_item_event(SPItem *item, SPEvent *event)
  * 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)
+void SPItem::set_item_transform(Geom::Matrix const &transform_matrix)
 {
-    g_return_if_fail(item != NULL);
-    g_return_if_fail(SP_IS_ITEM(item));
-
-    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));
+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);
+    } 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();
     }
-
-    /* .. otherwise simply place the guides around the item's bounding box */
-
-    sp_item_convert_to_guides(item);
 }
 
 
@@ -1557,66 +1459,56 @@ Geom::Matrix SPItem::getRelativeTransform(SPObject const *dest) const {
  * 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));
-
-    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, 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) );
-
     Geom::Matrix dt2p; /* desktop to item parent transform */
-    if (item->parent) {
-        dt2p = sp_item_i2d_affine(static_cast<SPItem *>(item->parent)).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, -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)
+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 *new_view;
-
     g_assert(item != NULL);
     g_assert(SP_IS_ITEM(item));
     g_assert(arenaitem != NULL);
     g_assert(NR_IS_ARENA_ITEM(arenaitem));
 
-    new_view = g_new(SPItemView, 1);
+    SPItemView *new_view = g_new(SPItemView, 1);
 
     new_view->next = list;
     new_view->flags = flags;
@@ -1626,8 +1518,7 @@ sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigne
     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)
 {
     if (view == list) {
         list = list->next;
@@ -1648,10 +1539,9 @@ sp_item_view_list_remove(SPItemView *list, SPItemView *view)
  * Return the arenaitem corresponding to the given item in the display
  * with the given key
  */
-NRArenaItem *
-sp_item_get_arenaitem(SPItem *item, unsigned key)
+NRArenaItem *SPItem::get_arenaitem(unsigned key)
 {
-    for ( SPItemView *iv = item->display ; iv ; iv = iv->next ) {
+    for ( SPItemView *iv = display ; iv ; iv = iv->next ) {
         if ( iv->key == key ) {
             return iv->arenaitem;
         }
@@ -1660,36 +1550,34 @@ sp_item_get_arenaitem(SPItem *item, unsigned key)
     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(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) {
+    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) {
+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;
index 7387a63cfa4f94c44543d00e9472798faed2377f..4ba3dc7a45788a5a2714364c3131566aac9f34f6 100644 (file)
@@ -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,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 +54,15 @@ enum {
  * Also, this probably goes to SPObject base class.
  *
  */
-struct SPEvent {
+class SPEvent {
+public:
     unsigned int type;
     gpointer data;
 };
 
 /// SPItemView
-struct SPItemView {
+class SPItemView {
+public:
     SPItemView *next;
     unsigned int flags;
     unsigned int key;
@@ -79,7 +82,8 @@ struct SPItemView {
 #define SP_ITEM_REFERENCE_FLAGS (1 << 1)
 
 /// Contains transformations to document/viewport and the viewport size.
-struct SPItemCtx {
+class SPItemCtx {
+public:
     SPCtx ctx;
     /** Item to document transformation */
     Geom::Matrix i2doc;
@@ -89,8 +93,19 @@ struct SPItemCtx {
     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 {
+class SPItem : public SPObject {
+public:
+    static GType getType();
     enum BBoxType {
         // legacy behavior: includes crude stroke, markers; excludes long miters, blur margin; is known to be wrong for caps
         APPROXIMATE_BBOX,
@@ -160,6 +175,36 @@ struct SPItem : public SPObject {
     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) const;
+    void invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated));
+
+    unsigned pos_in_parent();
+    gchar *description();
+    void invoke_print(SPPrintContext *ctx);
+    static unsigned int display_key_new(unsigned int numkeys);
+    NRArenaItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags);
+    void invoke_hide(unsigned int key);
+    void getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs=0) const;
+    void adjust_pattern(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false);
+    void adjust_gradient(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false);
+    void adjust_stroke(gdouble ex);
+    void adjust_stroke_width_recursive(gdouble ex);
+    void adjust_paint_recursive(Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern);
+    void adjust_livepatheffect(Geom::Matrix const &postmul, bool set = false);
+    void doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true);
+    void set_item_transform(Geom::Matrix const &transform_matrix);
+    void convert_item_to_guides();
+    gint emitEvent (SPEvent &event);
+    NRArenaItem *get_arenaitem(unsigned int key);
+    void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated));
+    Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
+    Geom::Matrix i2doc_affine() const;
+    Geom::Matrix i2d_affine() const;
+    void set_i2d_affine(Geom::Matrix const &transform);
+    Geom::Matrix dt2i_affine() const;
+    void convert_to_guides();
 
 private:
     enum EvaluatedStatus
@@ -169,10 +214,29 @@ private:
 
     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 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;
 };
 
 /// The SPItem vtable.
-struct SPItemClass {
+class SPItemClass {
+public:
     SPObjectClass parent_class;
 
     /** BBox union in given coordinate system */
@@ -201,58 +265,19 @@ struct SPItemClass {
 
     /** 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);
+// 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);
-
 /* fixme: - these are evil, but OK */
 
 /* Fill *TRANSFORM with the item-to-desktop transform.  See doc/coordinates.txt
@@ -261,15 +286,10 @@ Geom::Matrix sp_item_i2doc_affine(SPItem const *item);
  *
  * \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);
 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);
-
-#endif
+#endif // SEEN_SP_ITEM_H
 
 /*
   Local Variables:
index d0ce32397d7ffe801b0447c7c5c8b39a902a42c7..b8c5a19b74da73b6b5eca1ea2c3f0ae2405f4786 100644 (file)
@@ -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_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);
+SPShapeClass * SPLineClass::static_parent_class = 0;
 
-static SPShapeClass *parent_class;
-
-GType
-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,
-                       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)
 {
-       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;
+    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;
+    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::update;
 
-       SPShapeClass *shape_class = (SPShapeClass *) klass;
-       shape_class->set_shape = sp_line_set_shape;
+    SPShapeClass *shape_class = (SPShapeClass *) klass;
+    shape_class->set_shape = SPLine::setShape;
 }
 
-static void
-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::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr)
 {
-        if (((SPObjectClass *) parent_class)->build) {
-               ((SPObjectClass *) 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");
+    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::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);
-               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::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);
-       }
-
-       if (((SPObjectClass *) parent_class)->update)
-               ((SPObjectClass *) 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::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);
+    }
 
-       return repr;
+    return repr;
 }
 
-static gchar *
-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::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());
 
-       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]);
 }
 
-static Geom::Matrix
-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());
 
-       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::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
 
-       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 :
index cc6802b7f6d3f1ece91f5ca275a1d3ebefac79cf..8bcb8164552fbf8f4673a4016989923cc4daf14d 100644 (file)
@@ -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_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;
-};
+class SPLine : public SPShape {
+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);
+       
+    friend class SPLine;
+};
 
 
-#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 :
index 43eb3c52e69cde0684a68001423e15e568e506c3..afd36d2ddef30cf1a68293cd86112984c86cf416 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_LPE_ITEM_CPP__
-
 /** \file
  * Base class for live path effect items
  */
@@ -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 +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" );
 
     if (((SPObjectClass *) parent_class)->build) {
         ((SPObjectClass *) parent_class)->build(object, document, repr);
@@ -681,7 +680,7 @@ sp_lpe_item_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape:
         (* ((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 +691,7 @@ static void
 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));
         }
index 15be0348f3088be6127f73a7210fa8f54e8a65b3..dde91b0625280d8b1f8afa0643a7c3bd9555c38d 100644 (file)
@@ -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 @@ sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr
                ((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" );
 
        /* Register ourselves */
-       sp_document_add_resource (document, "mask", object);
+       document->addResource("mask", object);
 }
 
 static void
@@ -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)->removeResource("mask", object);
        }
 
        SPMask *cp = SP_MASK (object);
@@ -180,8 +180,7 @@ sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML
        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) {
@@ -191,68 +190,66 @@ sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML
        }
 }
 
-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)) {
-               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)) {
-               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 +271,7 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTr
 {
     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");
     
@@ -289,7 +286,7 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTr
         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);
         }
     }
 
@@ -300,8 +297,7 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTr
     return mask_id;
 }
 
-NRArenaItem *
-sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key)
+NRArenaItem *sp_mask_show(SPMask *mask, NRArena *arena, unsigned int key)
 {
        g_return_val_if_fail (mask != NULL, NULL);
        g_return_val_if_fail (SP_IS_MASK (mask), NULL);
@@ -311,9 +307,9 @@ sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key)
        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 = mask->firstChild() ; child; child = child->getNext() ) {
                if (SP_IS_ITEM (child)) {
-                       NRArenaItem *ac = sp_item_invoke_show (SP_ITEM (child), arena, key, SP_ITEM_REFERENCE_FLAGS);
+                       NRArenaItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS);
                        if (ac) {
                                /* The order is not important in mask */
                                nr_arena_item_add_child (ai, ac, NULL);
@@ -331,15 +327,14 @@ sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key)
        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 = 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);
                }
        }
 
index 0b995f0ce85ded208bd1b6bf6da4d1486ad077e9..d8b6b33ea9b7607e21d6f4879bd6bde90c95ab91 100644 (file)
@@ -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 +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();
             gchar const * owner_name = NULL;
             gchar const * owner_mask = NULL;
             gchar const * obj_name = NULL;
@@ -94,4 +97,4 @@ void sp_mask_set_bbox (SPMask *mask, unsigned int key, NRRect *bbox);
 
 const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform);
 
-#endif
+#endif // SEEN_SP_MASK_H
index 7d5c42763de6633ea7b782313a0d807ff3acabd6..9604fe0cac23dbadb7c867d99728f4d93608decd 100644 (file)
@@ -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 @@ static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inksc
         ((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" );
 }
 
 static void sp_missing_glyph_release(SPObject *object)
@@ -176,11 +176,14 @@ static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::X
     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.
+        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) {
index be2bcd478781ef9d9be4535f15116e4e50131ef4..59ef4762da6f8433a8d804a942bffb82324e7355 100644 (file)
@@ -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,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 +178,7 @@ static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *doc
         // 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));
@@ -204,7 +206,7 @@ static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *doc
         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 +219,57 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
         (* ((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( "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)->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 +333,17 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_GRIDTOLERANCE:
-                       nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000);
-                       object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-                       break;
+        nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_GUIDETOLERANCE:
-                       nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20);
-            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-            break;
+        nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_OBJECTTOLERANCE:
-                       nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20);
-            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-            break;
+        nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_GUIDECOLOR:
             nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00);
             if (value) {
@@ -448,10 +450,10 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED:
-                       nv->window_maximized = value ? atoi(value) : 0;
-                       object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-                       break;
-       case SP_ATTR_INKSCAPE_SNAP_GLOBAL:
+        nv->window_maximized = value ? atoi(value) : 0;
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_GLOBAL:
             nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
@@ -468,14 +470,14 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
     case SP_ATTR_INKSCAPE_SNAP_GRIDS:
-                       nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE);
-                       object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-                       break;
+        nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
     case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES:
-                       nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE);
-                       object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-                       break;
-       case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES:
+        nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE);
+        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        break;
+    case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES:
             nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
@@ -484,18 +486,18 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             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;
@@ -667,10 +669,9 @@ static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *chil
             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 +729,9 @@ static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::
 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);
     }
@@ -752,6 +753,12 @@ void SPNamedView::show(SPDesktop *desktop)
 
 #define MIN_ONSCREEN_DISTANCE 50
 
+void SPNamedView::writeNewGrid(SPDocument *document,int gridtype)
+{
+    g_assert(this->getRepr() != NULL);
+    Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype));
+}
+
 /*
  * Restores window geometry from the document settings or defaults in prefs
  */
@@ -763,25 +770,25 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
 
     // restore window size and position stored with the document
     if (geometry_from_file) {
-       if (nv->window_maximized) {
-               Gtk::Window *win = desktop->getToplevel();
-               if (win){
-                       win->maximize();
-               }
-       } else {
-               gint w = MIN(gdk_screen_width(), nv->window_width);
-                       gint h = MIN(gdk_screen_height(), nv->window_height);
-                       // prevent the window from moving off the screen to the right or to the bottom
-                       gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
-                       gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
-                       // prevent the window from moving off the screen to the left or to the top
-                       x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x);
-                       y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y);
-                       if (w>0 && h>0) {
-                               desktop->setWindowSize(w, h);
-                               desktop->setWindowPosition(Geom::Point(x, y));
-                       }
-       }
+        if (nv->window_maximized) {
+            Gtk::Window *win = desktop->getToplevel();
+            if (win){
+                win->maximize();
+            }
+        } else {
+            gint w = MIN(gdk_screen_width(), nv->window_width);
+            gint h = MIN(gdk_screen_height(), nv->window_height);
+            // prevent the window from moving off the screen to the right or to the bottom
+            gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
+            gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
+            // prevent the window from moving off the screen to the left or to the top
+            x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x);
+            y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y);
+            if (w>0 && h>0) {
+                desktop->setWindowSize(w, h);
+                desktop->setWindowPosition(Geom::Point(x, y));
+            }
+        }
     }
 
     // restore zoom and view
@@ -800,6 +807,17 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
     }
 }
 
+bool SPNamedView::getSnapGlobal() const
+{
+    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;
@@ -814,8 +832,7 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop)
     }
     // if that didn't work out, look for the topmost layer
     if (!layer) {
-        SPObject *iter = sp_object_first_child(SP_DOCUMENT_ROOT(document));
-        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 +854,15 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
     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 = DocumentUndo::getUndoSensitive(sp_desktop_document(desktop));
+    DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), false);
 
     sp_repr_set_svg_double(view, "inkscape:zoom", desktop->current_zoom());
     sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[Geom::X]);
     sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]);
 
     if (save_geometry_in_file) {
-       gint w, h, x, y;
+        gint w, h, x, y;
         desktop->getWindowGeometry(x, y, w, h);
         sp_repr_set_int(view, "inkscape:window-width", w);
         sp_repr_set_int(view, "inkscape:window-height", h);
@@ -857,7 +874,7 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
     view->setAttribute("inkscape:current-layer", desktop->currentLayer()->getId());
 
     // restore undoability
-    sp_document_set_undo_sensitive(sp_desktop_document(desktop), saved);
+    DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), saved);
 }
 
 void SPNamedView::hide(SPDesktop const *desktop)
@@ -866,7 +883,7 @@ 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 +897,28 @@ void SPNamedView::activateGuides(gpointer desktop, gboolean active)
     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)
@@ -914,10 +931,10 @@ 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 = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(doc, false);
     sp_repr_set_boolean(repr, "showguides", v);
-    sp_document_set_undo_sensitive(doc, saved);
+    DocumentUndo::setUndoSensitive(doc, saved);
 
     doc->setModifiedSinceSave();
 }
@@ -929,10 +946,10 @@ void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_docu
     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 = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(doc, false);
     sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible);
-    sp_document_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 +962,7 @@ gchar const *SPNamedView::getName() const
 {
     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 +1027,47 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id)
     return (SPNamedView *) nv;
 }
 
+void SPNamedView::setGuides(bool v)
+{
+    g_assert(this->getRepr() != NULL);
+    sp_repr_set_boolean(this->getRepr(), "showguides", v);
+    sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v);
+}
+
+/**
+ * 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.
  */
index 7a54b2dc56580c6018cce83e0cef8ce8a6a4143b..86b16a5577e2bb63b6e2775340d56a25498a0fca 100644 (file)
@@ -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 +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;
@@ -81,6 +84,14 @@ struct SPNamedView : public SPObjectGroup {
 
     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;
 };
 
 struct SPNamedViewClass {
index 1d5c0433974a67fdccfd647864aa3886e2920e07..001d7898f0b366ea82a6f94cfc0f0ea9bc6c2a6f 100644 (file)
@@ -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_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 SPObjectClass *parent_class;
+SPObjectClass * SPObjectGroupClass::static_parent_class = 0;
 
-GType
-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,
-                       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)
 {
-       GObjectClass * object_class;
-       SPObjectClass * sp_object_class;
+    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);
 
-       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::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::init(SPObjectGroup * /*objectgroup*/)
 {
 }
 
-static void
-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);
+    }
 
-       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::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);
+    }
 
-       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::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);
+    }
 
-       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::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) ) {
-                       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) ) {
-                       child->updateRepr(flags);
-               }
-       }
-
-       if (((SPObjectClass *) (parent_class))->write)
-               ((SPObjectClass *) (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 :
index 5d67df6fecea0518c615f1cec8b9c9a156f2ae44..a666a316a6ca4881a50e5be2cedb7eeee441727e 100644 (file)
@@ -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);
+
+private:
+    static void init(SPObjectGroup *objectgroup);
 
-struct SPObjectGroupClass {
-       SPObjectClass parent_class;
+    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;   
 };
 
-GType sp_objectgroup_get_type (void);
+class SPObjectGroupClass {
+public:
+    SPObjectClass parent_class;
+
+private:
+    static void sp_objectgroup_class_init(SPObjectGroupClass *klass);
+    static SPObjectClass *static_parent_class;
 
-#endif
+    friend class SPObjectGroup;        
+};
+
+#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 :
index 17f2706adc4713ebe61311d747d162adec160df6..475a57521c3780306c877c6cd5864733803a6150 100644 (file)
@@ -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 +106,7 @@ sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr)
     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;
 }
index 4e85acf5340704d9a519ca8d36c7b7c089b344e0..02ad3ea938e68991cdaf835ef2ff8edb40bff69e 100644 (file)
@@ -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 @@
  */
 
 #include "forward.h"
-
+#include "sp-object.h"
 namespace Inkscape {
 namespace XML {
 class Node;
@@ -21,13 +21,13 @@ 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:
index 7fe0996997850fb1a462552cd53c38b8f9519415..17def7f1554f1a13f6b68d5a2fcc8f6cbf7d3993 100644 (file)
@@ -1,4 +1,3 @@
-#define __SP_OBJECT_C__
 /** \file
  * SPObject implementation.
  *
@@ -6,6 +5,8 @@
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   bulia byak <buliabyak@users.sf.net>
  *   Stephen Silver <sasilver@users.sourceforge.net>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 1999-2008 authors
  * Copyright (C) 2001-2002 Ximian, Inc.
@@ -76,41 +77,14 @@ using std::strstr;
 # define debug(f, a...) /**/
 #endif
 
-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 */
-
-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);
-
 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_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 +118,19 @@ public:
 };
 
 
-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)
+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,
@@ -172,34 +145,32 @@ sp_object_get_type(void)
 /**
  * Initializes the SPObject vtable.
  */
-static void
-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);
 
-    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)
 {
     debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object));
 
@@ -208,7 +179,10 @@ sp_object_init(SPObject *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;
     SPObjectImpl::setIdNull(object);
 
     object->_collection_policy = SPObject::COLLECT_WITH_PARENT;
@@ -232,8 +206,7 @@ sp_object_init(SPObject *object)
 /**
  * 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)
 {
     SPObject *spobject = (SPObject *)object;
 
@@ -247,8 +220,8 @@ sp_object_finalize(GObject *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 +268,15 @@ gchar const* SPObject::getId() const {
     return id;
 }
 
+Inkscape::XML::Node * SPObject::getRepr() {
+    return repr;
+}
+
+Inkscape::XML::Node const* SPObject::getRepr() const{
+    return repr;
+}
+
+
 /**
  * Increase reference count of object, with possible debugging.
  *
@@ -302,8 +284,7 @@ gchar const* SPObject::getId() const {
  * \return object, NULL is error.
  * \pre object points to real object
  */
-SPObject *
-sp_object_ref(SPObject *object, SPObject *owner)
+SPObject *sp_object_ref(SPObject *object, SPObject *owner)
 {
     g_return_val_if_fail(object != NULL, NULL);
     g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
@@ -322,8 +303,7 @@ sp_object_ref(SPObject *object, SPObject *owner)
  * \return always NULL
  * \pre object points to real object
  */
-SPObject *
-sp_object_unref(SPObject *object, SPObject *owner)
+SPObject *sp_object_unref(SPObject *object, SPObject *owner)
 {
     g_return_val_if_fail(object != NULL, NULL);
     g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
@@ -344,8 +324,7 @@ sp_object_unref(SPObject *object, SPObject *owner)
  * \return object, NULL is error
  * \pre object points to real object
  */
-SPObject *
-sp_object_href(SPObject *object, gpointer /*owner*/)
+SPObject *sp_object_href(SPObject *object, gpointer /*owner*/)
 {
     g_return_val_if_fail(object != NULL, NULL);
     g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
@@ -365,8 +344,7 @@ sp_object_href(SPObject *object, gpointer /*owner*/)
  * \return always NULL
  * \pre object points to real object and hrefcount>0
  */
-SPObject *
-sp_object_hunref(SPObject *object, gpointer /*owner*/)
+SPObject *sp_object_hunref(SPObject *object, gpointer /*owner*/)
 {
     g_return_val_if_fail(object != NULL, NULL);
     g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
@@ -381,10 +359,9 @@ sp_object_hunref(SPObject *object, gpointer /*owner*/)
 /**
  * Adds increment to _total_hrefcount of object and its parents.
  */
-void
-SPObject::_updateTotalHRefCount(int increment) {
+void SPObject::_updateTotalHRefCount(int increment) {
     SPObject *topmost_collectable = NULL;
-    for ( SPObject *iter = this ; iter ; iter = SP_OBJECT_PARENT(iter) ) {
+    for ( SPObject *iter = this ; iter ; iter = iter->parent ) {
         iter->_total_hrefcount += increment;
         if ( iter->_total_hrefcount < iter->hrefcount ) {
             g_critical("HRefs overcounted");
@@ -403,15 +380,14 @@ SPObject::_updateTotalHRefCount(int increment) {
 /**
  * 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 +403,7 @@ bool same_objects(SPObject const &a, SPObject const &b) {
 /**
  * Returns youngest object being parent to this and object.
  */
-SPObject const *
-SPObject::nearestCommonAncestor(SPObject const *object) const {
+SPObject const *SPObject::nearestCommonAncestor(SPObject const *object) const {
     g_return_val_if_fail(object != NULL, NULL);
 
     using Inkscape::Algorithms::longest_common_suffix;
@@ -436,11 +411,15 @@ SPObject::nearestCommonAncestor(SPObject const *object) const {
 }
 
 SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) {
-    if (obj == NULL || ancestor == NULL)
-        return NULL;
-    if (SP_OBJECT_PARENT(obj) == ancestor)
-        return obj;
-    return AncestorSon(SP_OBJECT_PARENT(obj), ancestor);
+    SPObject const *result = 0;
+    if ( obj && ancestor ) {
+        if (obj->parent == ancestor) {
+            result = obj;
+        } else {
+            result = AncestorSon(obj->parent, ancestor);
+        }
+    }
+    return result;
 }
 
 /**
@@ -452,26 +431,29 @@ SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) {
  *    1    first object's position is greater than the second
  *   -1    first object's position is less than the second   \endverbatim
  */
-int
-sp_object_compare_position(SPObject const *first, SPObject const *second)
+int sp_object_compare_position(SPObject const *first, SPObject const *second)
 {
-    if (first == second) return 0;
-
-    SPObject const *ancestor = first->nearestCommonAncestor(second);
-    if (ancestor == NULL) return 0; // cannot compare, no common ancestor!
-
-    // we have an object and its ancestor (should not happen when sorting selection)
-    if (ancestor == first)
-        return 1;
-    if (ancestor == second)
-        return -1;
-
-    SPObject const *to_first = AncestorSon(first, ancestor);
-    SPObject const *to_second = AncestorSon(second, ancestor);
+    int result = 0;
+    if (first != second) {
+        SPObject const *ancestor = first->nearestCommonAncestor(second);
+        // Need a common ancestor to be able to compare
+        if ( ancestor ) {
+            // we have an object and its ancestor (should not happen when sorting selection)
+            if (ancestor == first) {
+                result = 1;
+            } else if (ancestor == second) {
+                result = -1;
+            } else {
+                SPObject const *to_first = AncestorSon(first, ancestor);
+                SPObject const *to_second = AncestorSon(second, ancestor);
 
-    g_assert(SP_OBJECT_PARENT(to_second) == SP_OBJECT_PARENT(to_first));
+                g_assert(to_second->parent == to_first->parent);
 
-    return sp_repr_compare_position(SP_OBJECT_REPR(to_first), SP_OBJECT_REPR(to_second));
+                result = sp_repr_compare_position(to_first->getRepr(), to_second->getRepr());
+            }
+        }
+    }
+    return result;
 }
 
 
@@ -479,26 +461,34 @@ sp_object_compare_position(SPObject const *first, SPObject const *second)
  * 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);
+}
+
+void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr)
+{
+    g_assert(this->getRepr() != NULL);
+    sp_repr_css_change(this->getRepr(), css, attr);
+}
+
 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) ) {
-        if (add_ref)
+    for ( SPObject *child = firstChild() ; child; child = child->getNext() ) {
+        if (add_ref) {
             g_object_ref (G_OBJECT (child));
+        }
 
         l = g_slist_prepend (l, child);
     }
@@ -509,23 +499,20 @@ GSList *SPObject::childList(bool add_ref, Action) {
 /** Gets the label property for the object or a default if no label
  *  is defined.
  */
-gchar const *
-SPObject::label() const {
+gchar const *SPObject::label() const {
     return _label;
 }
 
 /** Returns a default label property for the object. */
-gchar const *
-SPObject::defaultLabel() const {
+gchar const *SPObject::defaultLabel() const {
     if (_label) {
         return _label;
     } else {
         if (!_default_label) {
-            gchar const *id=SP_OBJECT_ID(this);
-            if (id) {
-                _default_label = g_strdup_printf("#%s", id);
+            if (getId()) {
+                _default_label = g_strdup_printf("#%s", getId());
             } else {
-                _default_label = g_strdup_printf("<%s>", SP_OBJECT_REPR(this)->name());
+                _default_label = g_strdup_printf("<%s>", getRepr()->name());
             }
         }
         return _default_label;
@@ -533,9 +520,8 @@ SPObject::defaultLabel() const {
 }
 
 /** 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);
 }
 
 
@@ -569,10 +555,8 @@ void SPObject::requestOrphanCollection() {
     }
 }
 
-/** 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)) {
+void SPObject::_sendDeleteSignalRecursive() {
+    for (SPObject *child = firstChild(); child; child = child->getNext()) {
         child->_delete_signal.emit(child);
         child->_sendDeleteSignalRecursive();
     }
@@ -585,8 +569,7 @@ SPObject::_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) {
@@ -596,7 +579,7 @@ SPObject::deleteObject(bool propagate, bool propagate_descendants)
         this->_sendDeleteSignalRecursive();
     }
 
-    Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
+    Inkscape::XML::Node *repr = getRepr();
     if (repr && sp_repr_parent(repr)) {
         sp_repr_unparent(repr);
     }
@@ -611,59 +594,57 @@ SPObject::deleteObject(bool propagate, bool propagate_descendants)
  * 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)
+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);
+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 {
@@ -674,32 +655,31 @@ sp_object_reorder(SPObject *object, SPObject *prev) {
     }
     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));
+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;
@@ -709,57 +689,56 @@ sp_object_detach(SPObject *parent, SPObject *object) {
     if (prev) {
         prev->next = next;
     } else {
-        parent->children = next;
+        this->children = next;
     }
     if (!next) {
-        parent->_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 *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(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 ( 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)
 {
     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, object->cloned);
 }
 
 /**
@@ -773,11 +752,11 @@ sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XM
  * 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);
     }
 }
 
@@ -789,14 +768,14 @@ static void sp_object_release(SPObject *object)
  * 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)
 {
     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);
+    }
 }
 
 /**
@@ -805,13 +784,13 @@ sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child)
  * 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);
 }
 
@@ -826,15 +805,14 @@ static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child
  * 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)
 {
     /* 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);
@@ -842,73 +820,98 @@ sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
             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, 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) {
         Inkscape::GC::anchor(repr);
-    object->cloned = cloned;
+    }
+    this->cloned = cloned;
 
-    if (!SP_OBJECT_IS_CLONED(object)) {
-        object->document->bindObjectToRepr(object->repr, object);
+    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);
+}
+
+unsigned SPObject::getPosition(){
+    g_assert(this->repr);
+
+    return repr->position();
+}
+
+void SPObject::appendChild(Inkscape::XML::Node *child) {
+    g_assert(this->repr);
+
+    repr->appendChild(child);
+}
+
+void SPObject::addChild(Inkscape::XML::Node *child, Inkscape::XML::Node * prev)
+{
+    g_assert(this->repr);
+
+    repr->addChild(child,prev);
 }
 
 void SPObject::releaseReferences() {
@@ -926,7 +929,7 @@ 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);
         }
@@ -952,33 +955,33 @@ void SPObject::releaseReferences() {
 }
 
 
-SPObject *SPObject::getNext()
-{
-    return next;
-}
-
 SPObject *SPObject::getPrev()
 {
-    return sp_object_prev(this);
+    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)
 {
     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)
 {
     SPObject *object = SP_OBJECT(data);
 
@@ -992,8 +995,7 @@ sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node
  *
  * \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)
 {
     SPObject *object = SP_OBJECT(data);
 
@@ -1005,14 +1007,15 @@ sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node
 /**
  * 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)
 {
     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 ( !object->cloned && object->getRepr()->type() == Inkscape::XML::ELEMENT_NODE ) {
                 SPDocument *document=object->document;
                 SPObject *conflict=NULL;
 
@@ -1027,7 +1030,7 @@ sp_object_private_set(SPObject *object, unsigned int key, gchar const *value)
                         sp_object_ref(conflict, NULL);
                         // give the conflicting object a new ID
                         gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL);
-                        SP_OBJECT_REPR(conflict)->setAttribute("id", new_conflict_id);
+                        conflict->getRepr()->setAttribute("id", new_conflict_id);
                         g_free(new_conflict_id);
                         sp_object_unref(conflict, NULL);
                     } else {
@@ -1092,47 +1095,45 @@ sp_object_private_set(SPObject *object, unsigned int key, gchar const *value)
 /**
  * Call virtual set() function of object.
  */
-void
-sp_object_set(SPObject *object, 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)
+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.
+    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)
 {
     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
@@ -1144,13 +1145,13 @@ sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gch
 /**
  * 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)
 {
     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 +1173,10 @@ sp_xml_get_space_string(unsigned int space)
 /**
  * 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)
 {
     if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) {
-        repr = SP_OBJECT_REPR(object)->duplicate(doc);
+        repr = object->getRepr()->duplicate(doc);
         if (!( flags & SP_OBJECT_WRITE_EXT )) {
             repr->setAttribute("inkscape:collect", NULL);
         }
@@ -1197,7 +1197,7 @@ sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape
             repr->setAttribute("inkscape:collect", NULL);
         }
 
-        SPStyle const *const obj_style = SP_OBJECT_STYLE(object);
+        SPStyle const *const obj_style = object->style;
         if (obj_style) {
             gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET);
             repr->setAttribute("style", ( *s ? s : NULL ));
@@ -1236,10 +1236,9 @@ sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape
 /**
  * Update this object's XML node with flags value.
  */
-Inkscape::XML::Node *
-SPObject::updateRepr(unsigned int flags) {
-    if (!SP_OBJECT_IS_CLONED(this)) {
-        Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
+Inkscape::XML::Node * SPObject::updateRepr(unsigned int flags) {
+    if ( !cloned ) {
+        Inkscape::XML::Node *repr = getRepr();
         if (repr) {
             return updateRepr(repr->document(), repr, flags);
         } else {
@@ -1256,28 +1255,27 @@ SPObject::updateRepr(unsigned int flags) {
  *  reprs in another document (e.g. a temporary document used when
  *  saving as "Plain SVG"
  */
-Inkscape::XML::Node *
-SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) {
+Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) {
     g_assert(doc != NULL);
 
-    if (SP_OBJECT_IS_CLONED(this)) {
+    if (cloned) {
         /* cloned objects have no repr */
         return NULL;
     }
     if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->write) {
         if (!(flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-            repr = SP_OBJECT_REPR(this);
+            repr = getRepr();
         }
         return ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->write(this, doc, repr, flags);
     } else {
         g_warning("Class %s does not implement ::write", G_OBJECT_TYPE_NAME(this));
         if (!repr) {
             if (flags & SP_OBJECT_WRITE_BUILD) {
-                repr = SP_OBJECT_REPR(this)->duplicate(doc);
+                repr = getRepr()->duplicate(doc);
             }
             /// \todo FIXME: else probably error (Lauris) */
         } else {
-            repr->mergeFrom(SP_OBJECT_REPR(this), "id");
+            repr->mergeFrom(getRepr(), "id");
         }
         return repr;
     }
@@ -1290,8 +1288,7 @@ SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, un
  * recursively add CHILD_MODIFIED flag to
  * parent and ancestors (as far up as necessary).
  */
-void
-SPObject::requestDisplayUpdate(unsigned int flags)
+void SPObject::requestDisplayUpdate(unsigned int flags)
 {
     g_return_if_fail( this->document != NULL );
 
@@ -1313,11 +1310,10 @@ SPObject::requestDisplayUpdate(unsigned int flags)
      * 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));
+            document->requestModified();
         }
     }
 }
@@ -1325,15 +1321,14 @@ SPObject::requestDisplayUpdate(unsigned int flags)
 /**
  * Update views
  */
-void
-SPObject::updateDisplay(SPCtx *ctx, unsigned int flags)
+void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags)
 {
     g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE));
 
     update_in_progress ++;
 
 #ifdef SP_OBJECT_DEBUG_CASCADE
-    g_print("Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), SP_OBJECT_ID(this), flags, this->uflags, this->mflags);
+    g_print("Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags);
 #endif
 
     /* Get this flags */
@@ -1357,8 +1352,9 @@ SPObject::updateDisplay(SPCtx *ctx, unsigned int 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(...)
     {
@@ -1378,8 +1374,7 @@ SPObject::updateDisplay(SPCtx *ctx, unsigned int flags)
  * request display update, which trickles down and relies on the
  * flags set during this pass...
  */
-void
-SPObject::requestModified(unsigned int flags)
+void SPObject::requestModified(unsigned int flags)
 {
     g_return_if_fail( this->document != NULL );
 
@@ -1397,11 +1392,10 @@ SPObject::requestModified(unsigned int flags)
      * 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));
+            document->requestModified();
         }
     }
 }
@@ -1412,14 +1406,13 @@ SPObject::requestModified(unsigned int flags)
  *  later delivery here.  Once emitModified() is called, those flags don't
  *  need to be stored any longer.
  */
-void
-SPObject::emitModified(unsigned int flags)
+void SPObject::emitModified(unsigned int flags)
 {
     /* only the MODIFIED_CASCADE flag is legal here */
     g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE));
 
 #ifdef SP_OBJECT_DEBUG_CASCADE
-    g_print("Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), SP_OBJECT_ID(this), flags, this->uflags, this->mflags);
+    g_print("Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags);
 #endif
 
     flags |= this->mflags;
@@ -1437,54 +1430,62 @@ SPObject::emitModified(unsigned int flags)
     g_object_unref(G_OBJECT(this));
 }
 
-gchar const *
-sp_object_tagName_get(SPObject const *object, SPException *ex)
+gchar const *SPObject::getTagName(SPException *ex) const
 {
+    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.
+    return getRepr()->name();
 }
 
-gchar const *
-sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex)
+gchar const *SPObject::getAttribute(gchar const *key, SPException *ex) const
 {
+    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.
+    return (gchar const *) getRepr()->attribute(key);
 }
 
-void
-sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex)
+void SPObject::setAttribute(gchar const *key, gchar const *value, SPException *ex)
 {
+    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.
+    getRepr()->setAttribute(key, value, false);
 }
 
-void
-sp_object_removeAttribute(SPObject *object, 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.
+    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);
 }
 
 /* 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)
 {
     static unsigned long count = 0;
 
@@ -1492,7 +1493,8 @@ sp_object_get_unique_id(SPObject *object, gchar const *id)
 
     count++;
 
-    gchar const *name = object->repr->name();
+    //XML Tree being used here.
+    gchar const *name = object->getRepr()->name();
     g_assert(name != NULL);
 
     gchar const *local = strchr(name, ':');
@@ -1549,14 +1551,14 @@ sp_object_get_unique_id(SPObject *object, gchar const *id)
  * <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)
+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.
+    gchar const *style = getRepr()->attribute("style");
     if (style) {
         size_t const len = strlen(key);
         char const *p;
@@ -1564,9 +1566,15 @@ sp_object_get_style_property(SPObject const *object, gchar const *key, gchar con
                 != NULL )
         {
             p += len;
-            while ((*p <= ' ') && *p) p++;
-            if (*p++ != ':') break;
-            while ((*p <= ' ') && *p) p++;
+            while ((*p <= ' ') && *p) {
+                p++;
+            }
+            if (*p++ != ':') {
+                break;
+            }
+            while ((*p <= ' ') && *p) {
+                p++;
+            }
             size_t const inherit_len = sizeof("inherit") - 1;
             if (*p
                 && !(strneq(p, "inherit", inherit_len)
@@ -1577,12 +1585,14 @@ sp_object_get_style_property(SPObject const *object, gchar const *key, gchar con
             }
         }
     }
-    gchar const *val = object->repr->attribute(key);
+
+    //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;
@@ -1591,8 +1601,7 @@ sp_object_get_style_property(SPObject const *object, gchar const *key, gchar con
 /**
  * Lifts SVG version of all root objects to version.
  */
-void
-SPObject::_requireSVGVersion(Inkscape::Version version) {
+void SPObject::_requireSVGVersion(Inkscape::Version version) {
     for ( SPObject::ParentIterator iter=this ; iter ; ++iter ) {
         SPObject *object=iter;
         if (SP_IS_ROOT(object)) {
@@ -1604,20 +1613,6 @@ SPObject::_requireSVGVersion(Inkscape::Version version) {
     }
 }
 
-/**
- * Returns previous object in sibling list or NULL.
- */
-SPObject *
-sp_object_prev(SPObject *child)
-{
-    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)
-            return i;
-    }
-    return NULL;
-}
-
 /* Titles and descriptions */
 
 /* Note:
@@ -1635,8 +1630,7 @@ sp_object_prev(SPObject *child)
  * The caller must free the returned string using g_free() - see comment
  * for getTitleOrDesc() below.
  */
-gchar *
-SPObject::title() const
+gchar * SPObject::title() const
 {
     return getTitleOrDesc("svg:title");
 }
@@ -1647,8 +1641,7 @@ SPObject::title() const
  * (if any) should be deleted.
  * The second argument is optional - see setTitleOrDesc() below for details.
  */
-bool
-SPObject::setTitle(gchar const *title, bool verbatim)
+bool SPObject::setTitle(gchar const *title, bool verbatim)
 {
     return setTitleOrDesc(title, "svg:title", verbatim);
 }
@@ -1658,8 +1651,7 @@ SPObject::setTitle(gchar const *title, bool 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");
 }
@@ -1670,8 +1662,7 @@ SPObject::desc() const
  * description (if any) should be deleted.
  * The second argument is optional - see setTitleOrDesc() below for details.
  */
-bool
-SPObject::setDesc(gchar const *desc, bool verbatim)
+bool SPObject::setDesc(gchar const *desc, bool verbatim)
 {
     return setTitleOrDesc(desc, "svg:desc", verbatim);
 }
@@ -1686,12 +1677,14 @@ SPObject::setDesc(gchar const *desc, bool 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;
 }
 
 /**
@@ -1711,8 +1704,7 @@ SPObject::getTitleOrDesc(gchar const *svg_tagname) const
  * The return value is true if a change was made to the title/description,
  * and usually false otherwise.
  */
-bool
-SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim)
+bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim)
 {
     if (!verbatim) {
         // If the new title/description is just whitespace,
@@ -1725,7 +1717,9 @@ SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verb
                     break;
                 }
             }
-            if (just_whitespace) value = NULL;
+            if (just_whitespace) {
+                value = NULL;
+            }
         }
         // Don't stomp on mark-up if there is no real change.
         if (value) {
@@ -1733,7 +1727,9 @@ SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verb
             if (current_value) {
                 bool different = std::strcmp(current_value, value);
                 g_free(current_value);
-                if (!different) return false;
+                if (!different) {
+                    return false;
+                }
             }
         }
     }
@@ -1741,7 +1737,9 @@ SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verb
     SPObject *elem = findFirstChild(svg_tagname);
 
     if (value == NULL) {
-        if (elem == NULL) return false;
+        if (elem == NULL) {
+            return false;
+        }
         // delete the title/description(s)
         while (elem) {
             elem->deleteObject();
@@ -1750,7 +1748,7 @@ SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verb
         return true;
     }
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Document *xml_doc = document->getReprDoc();
 
     if (elem == NULL) {
         // create a new 'title' or 'desc' element, putting it at the
@@ -1775,13 +1773,14 @@ SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verb
  * Find the first child of this object with a given tag name,
  * and return it.  Returns NULL if there is no matching child.
  */
-SPObject *
-SPObject::findFirstChild(gchar const *tagname) const
+SPObject * SPObject::findFirstChild(gchar const *tagname) const
 {
     for (SPObject *child = children; child; child = child->next)
     {
         if (child->repr->type() == Inkscape::XML::ELEMENT_NODE &&
-            !strcmp(child->repr->name(), tagname)) return child;
+            !strcmp(child->repr->name(), tagname)) {
+            return child;
+        }
     }
     return NULL;
 }
@@ -1791,8 +1790,7 @@ SPObject::findFirstChild(gchar const *tagname) const
  * 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("");
 
index 59cab2328252d99cebe84bf2b760a5620f6360fd..5d3183d9c7245897ad6f2e80930477d2c9bc1b66 100644 (file)
@@ -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_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 +68,7 @@
 #include "forward.h"
 #include "version.h"
 #include "util/forward-pointer-iterator.h"
+#include "desktop-style.h"
 
 namespace Inkscape {
 namespace XML {
@@ -137,7 +143,8 @@ SPObject *sp_object_href(SPObject *object, gpointer owner);
 SPObject *sp_object_hunref(SPObject *object, gpointer owner);
 
 /// A refcounting tree node object.
-struct SPObject : public GObject {
+class SPObject : public GObject {
+public:
     enum CollectionPolicy {
         COLLECT_WITH_PARENT,
         ALWAYS_COLLECT
@@ -154,10 +161,10 @@ struct SPObject : public GObject {
     SPObject *children; /* Our children */
     SPObject *_last_child; /* Remembered last child */
     SPObject *next; /* Next object in linked list */
-    Inkscape::XML::Node *repr; /* Our xml representation */
 
 private:
     gchar *id; /* Our very own unique id */
+    Inkscape::XML::Node *repr; /* Our xml representation */
 public:
 
     /**
@@ -165,6 +172,20 @@ public:
      */
     gchar const* getId() const;
 
+    /**
+     * Returns the XML representation of tree
+     */
+    //Inkscape::XML::Node const* getRepr() const;
+//protected:
+    Inkscape::XML::Node * getRepr();
+
+    /**
+     * Returns the XML representation of tree
+     */
+    Inkscape::XML::Node const* getRepr() const;
+
+public:
+
     /** @brief cleans up an SPObject, releasing its references and
      *         requesting that references to it be released
      */
@@ -221,18 +242,28 @@ public:
     /* A non-const version can be similarly constructed if you want one.
      * (Don't just cast away the constness, which would be ill-formed.) */
 
-    SPObject *getNext();
+    SPObject *getNext() {return next;}
+    SPObject const *getNext() const {return next;}
+
+    /**
+     * Returns previous object in sibling list or NULL.
+     */
     SPObject *getPrev();
 
     bool hasChildren() const { return ( children != NULL ); }
 
     SPObject *firstChild() { return children; }
     SPObject const *firstChild() const { return children; }
+
     SPObject *lastChild() { return _last_child; }
     SPObject const *lastChild() const { return _last_child; }
 
     enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };
-    /** @brief Retrieves children as a GSList */
+
+    /**
+     * Retrieves the children as a GSList object, optionally ref'ing the children
+     * in the process, if add_ref is specified.
+     */
     GSList *childList(bool add_ref, Action action = ActionGeneral);
 
     SPObject *appendChildRepr(Inkscape::XML::Node *repr);
@@ -482,7 +513,9 @@ public:
         return _modified_signal.connect(slot);
     }
 
+    /** Sends the delete signal to all children of this object recursively */
     void _sendDeleteSignalRecursive();
+
     void _updateTotalHRefCount(int increment);
 
     void _requireSVGVersion(unsigned major, unsigned minor) {
@@ -498,6 +531,25 @@ public:
     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);
+    void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned);
+    long long int getIntAttribute(char const *key, long long int def);
+    unsigned getPosition();
+    gchar const * getAttribute(gchar const *name,SPException *ex=0) const;
+    void appendChild(Inkscape::XML::Node *child);
+    void addChild(Inkscape::XML::Node *child,Inkscape::XML::Node *prev=0);
+    void setKeyValue(unsigned int key, gchar const *value);
+    void setAttribute(gchar const *key, gchar const *value, SPException *ex=0);
+    void readAttr(gchar const *key);
+    gchar const *getTagName(SPException *ex) const;
+    void removeAttribute(gchar const *key, SPException *ex=0);
+    gchar const *getStyleProperty(gchar const *key, gchar const *def) const;
+    void setCSS(SPCSSAttr *css, gchar const *attr);
+    void changeCSS(SPCSSAttr *css, gchar const *attr);
+    bool storeAsDouble( gchar const *key, double *val ) const;
 
 private:
     // Private member functions used in the definitions of setTitle(),
@@ -507,11 +559,41 @@ private:
     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_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);
+    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);
+
+    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);
+
+
+    friend class SPObjectClass;
     friend class SPObjectImpl;
 };
 
 /// The SPObject vtable.
-struct SPObjectClass {
+class SPObjectClass {
+public:
     GObjectClass parent_class;
 
     void (* build) (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr);
@@ -533,44 +615,17 @@ struct SPObjectClass {
     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);
 
-/* Style */
+    friend class SPObject;
+};
 
-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);
-
 
 #endif // SP_OBJECT_H_SEEN
 
index a43bc873d0084e6376ae1383ddce561f224bed5f..51bb1e1ccc190c845e808588b3f47b2a26a99114 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_OFFSET_C__
-
 /** \file
  * Implementation of <path sodipodi:type="inkscape:offset">.
  */
@@ -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 +216,42 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
     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.
+    if (object->getRepr()->attribute("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.
+        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" );
     }
-    if (object->repr->attribute("inkscape:original")) {
-        sp_object_read_attr (object, "inkscape:original");
+    if (object->getRepr()->attribute("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" );
     }
-    if (object->repr->attribute("xlink:href")) {
-        sp_object_read_attr(object, "xlink:href");
+    if (object->getRepr()->attribute("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" );
     }
 }
 
@@ -278,7 +280,7 @@ sp_offset_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
 
 
     // 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 +407,7 @@ sp_offset_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 ();
     }
     offset->isUpdating=false;
 
@@ -454,12 +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.
+        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;
@@ -510,7 +513,7 @@ sp_offset_set_shape(SPShape *shape)
         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();
@@ -708,7 +711,7 @@ sp_offset_set_shape(SPShape *shape)
         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 +951,11 @@ sp_offset_top_point (SPOffset * offset, Geom::Point *px)
         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 +1052,7 @@ sp_offset_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPOffset
     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 +1079,7 @@ sp_offset_source_modified (SPObject */*iSource*/, guint /*flags*/, SPItem *item)
     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 +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;
     }
@@ -1145,7 +1148,8 @@ refresh_offset_source(SPOffset* offset)
         delete res;
         delete orig;
 
-        SP_OBJECT (offset)->repr->setAttribute("inkscape:original", res_d);
+        //XML Tree being used diectly here while it shouldn't be.
+        SP_OBJECT (offset)->getRepr()->setAttribute("inkscape:original", res_d);
 
         free (res_d);
     }
index 54d2a201a1480225c438fb778d5ca44d71baa7a1..66a70e0f1dc35e78a1f90b9a81f158c57e00a5ba 100644 (file)
@@ -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 +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 +213,10 @@ static void
 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" );
 
     sp_conn_end_pair_build(object);
 
@@ -225,13 +224,13 @@ sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
         ((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" );
 
     /* 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 +278,11 @@ sp_path_set(SPObject *object, unsigned int key, gchar const *value)
                     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 +391,16 @@ sp_path_set_transform(SPItem *item, Geom::Matrix const &xform)
     }
 
     // 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 +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 +445,7 @@ g_message("sp_path_update_patheffect writes 'd' attribute");
                 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 +504,7 @@ sp_path_get_curve_for_edit (SPPath *path)
                                 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();
     }
 }
 
index a2fc9a6b29b76840eb3c752cf3a0c304522b02d6..fbba4cc48caaa56c21939104603deaffebd44288 100644 (file)
@@ -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 @@ sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *r
        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" );
 
        /* Register ourselves */
-       sp_document_add_resource (document, "pattern", object);
+       document->addResource("pattern", object);
 }
 
 static void
@@ -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)->removeResource("pattern", SP_OBJECT (object));
        }
 
        if (pat->ref) {
@@ -323,16 +323,16 @@ sp_pattern_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::
        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);
@@ -347,21 +347,20 @@ sp_pattern_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::
 
 /* 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) ) {
-                               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
@@ -463,19 +462,17 @@ count_pattern_hrefs(SPObject *o, SPPattern *pat)
         i ++;
     }
 
-    for (SPObject *child = sp_object_first_child(o);
-         child != NULL; child = SP_OBJECT_NEXT(child)) {
+    for ( SPObject *child = o->firstChild(); child != NULL; child = child->next ) {
         i += count_pattern_hrefs(child, pat);
     }
 
     return i;
 }
 
-SPPattern *
-pattern_chain (SPPattern *pattern)
+SPPattern *pattern_chain(SPPattern *pattern)
 {
        SPDocument *document = SP_OBJECT_DOCUMENT (pattern);
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+        Inkscape::XML::Document *xml_doc = document->getReprDoc();
        Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
 
        Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern");
@@ -495,7 +492,7 @@ pattern_chain (SPPattern *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->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 +523,9 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Matrix postmul, bool se
        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");
@@ -554,22 +550,21 @@ pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matr
                        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
-                       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 +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) ) {
-               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 +671,7 @@ sp_pattern_painter_release (SPObject *obj, SPPatPainter *painter)
     painter->_release_connections->erase(obj);
        }
 
-       sp_item_invoke_hide(SP_ITEM(obj), painter->dkey);
+       SP_ITEM(obj)->invoke_hide(painter->dkey);
 }
 
 /**
@@ -757,30 +753,29 @@ sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, G
        /* 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) ) {
-                               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);
-                                       // 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 +1041,15 @@ sp_pat_fill (SPPainter *painter, NRPixBlock *pb)
      } 
        }
 }
+
+
+/*
+  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 :
index cf716b2f8b2cdae57ad154256f1981c5025621e7..f50504a76fac0f69972d16bfad5b81a2665f6b39 100644 (file)
@@ -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 +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 +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:
index 014c68c9b75652ba8af992a904325b2c0daca8db..1067da72e7613ea1a6cab95d24f5a89afd6866d8 100644 (file)
@@ -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 +83,7 @@ static void sp_polygon_build(SPObject *object, SPDocument *document, Inkscape::X
         ((SPObjectClass *) parent_class)->build(object, document, repr);
     }
 
-    sp_object_read_attr(object, "points");
+    object->readAttr( "points" );
 }
 
 
@@ -116,7 +115,7 @@ static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::Do
     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 +208,7 @@ void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value)
                  * 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;
         }
index 08f446d6124a5685c228de1c09e218ba46f2e33b..d0954f2393b2357a72bb351a2f6ace1207454fad 100644 (file)
@@ -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_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 SPShapeClass *parent_class;
+SPShapeClass * SPPolyLineClass::static_parent_class=0;
 
-GType
-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,
-                       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)
 {
-       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);
+    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;
+    sp_object_class->build = SPPolyLine::build;
+    sp_object_class->set = SPPolyLine::set;
+    sp_object_class->write = SPPolyLine::write;
 
-       item_class->description = sp_polyline_description;
+    item_class->description = SPPolyLine::getDescription;
 }
 
-static void
-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::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);
+    }
 
-       sp_object_read_attr (object, "points");
+    object->readAttr( "points" );
 }
 
-static void
-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);
-               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);
-               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::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);
+    }
 
-       return repr;
+    return repr;
 }
 
-static gchar *
-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 :
index 3ee18d6a56283aec16d09cabb0e927a1a76192b1..277529b49840c085a69b651fe1f8f20e5dfa37ca 100644 (file)
@@ -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 init(SPPolyLine *polyline);
+
+    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;
+    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;   
+};
 
-#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 :
index bdfae7c99905e315c36fd002d4bcc3e934bc3d2f..94be7551b3a00a5db40c24ada82fdb4ff99be567 100644 (file)
@@ -113,12 +113,12 @@ sp_rect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
     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" );
 }
 
 static void
@@ -185,7 +185,7 @@ sp_rect_update(SPObject *object, SPCtx *ctx, guint flags)
         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 @@ 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;
     }
 
@@ -281,7 +281,7 @@ sp_rect_set_shape(SPShape *shape)
     }
 
     c->closepath();
-    sp_shape_set_curve_insync(SP_SHAPE(rect), c, TRUE);
+    SP_SHAPE(rect)->setCurveInsync( c, TRUE);
     c->unref();
 }
 
@@ -379,13 +379,13 @@ sp_rect_set_transform(SPItem *item, Geom::Matrix const &xform)
     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 @@ static void sp_rect_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan
 
     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 @@ 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);
index 9a97bc2173e025779bd9b6a53bf55905e6e3eff8..09d96739b262ed4d6d8e006e55be4c701afc7443 100644 (file)
@@ -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 +65,15 @@ gdouble sp_rect_get_visible_height (SPRect *rect);
 
 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 :
index d5a1e064021d602057e4d3d629bf69f182459844..5f868539b1eab0449e7366d1342fca5f615a751e 100644 (file)
@@ -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 @@ sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
     SPGroup *group = (SPGroup *) object;
     SPRoot *root = (SPRoot *) object;
 
-    if ( !object->repr->attribute("version") ) {
+    //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" );
     /* 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" );
 
     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) ) {
+    // 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,21 @@ sp_root_set(SPObject *object, unsigned int key, gchar const *value)
  * 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) ) {
+        // 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 +377,9 @@ static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child)
     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) ) {
+        SPObject *iter = 0;
+        // We search for first remaining <defs> node - it is not beautiful, but works
+        for ( iter = object->firstChild() ; iter ; iter = iter->getNext() ) {
             if ( SP_IS_DEFS(iter) && (SPDefs *)iter != root->defs ) {
                 root->defs = (SPDefs *)iter;
                 break;
@@ -391,8 +391,9 @@ static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child)
         }
     }
 
-    if (((SPObjectClass *) (parent_class))->remove_child)
+    if (((SPObjectClass *) (parent_class))->remove_child) {
         (* ((SPObjectClass *) (parent_class))->remove_child)(object, child);
+    }
 }
 
 /**
@@ -566,7 +567,7 @@ sp_root_modified(SPObject *object, guint flags)
 
     /* 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)->emitResizedSignal(root->width.computed, root->height.computed);
     }
 }
 
index ad41b8021dc2d2a73eb23ccdea9f58e2e41b0223..3b6a8796d076dc578a6b845b0ba744da1165d2e4 100644 (file)
@@ -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 @@ sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
     }
 
     //Read values of key attributes from XML nodes into object.
-    sp_object_read_attr(object, "xlink:href");
+    object->readAttr( "xlink:href" );
 
-    sp_document_add_resource(document, "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)->removeResource("script", SP_OBJECT(object));
     }
 
     if (((SPObjectClass *) parent_class)->release)
@@ -139,9 +139,11 @@ TODO:
         }
 
         GSList *l = NULL;
-        for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) {
             Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
-            if (crepr) l = g_slist_prepend(l, crepr);
+            if (crepr) {
+                l = g_slist_prepend(l, crepr);
+            }
         }
 
         while (l) {
@@ -151,7 +153,7 @@ TODO:
         }
 
     } 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);
         }
     }
index 4bbfbc1e12fcbc728be7c8330d213942a0bcb418..35364692b29b680a2841d79f42c801c945de3858 100644 (file)
@@ -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
  */
 
 #define noSHAPE_VERBOSE
 
-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);
 void sp_shape_print (SPItem * item, SPPrintContext * ctx);
-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;
+SPLPEItemClass * SPShapeClass::parent_class = 0;
 
 /**
  * Registers the SPShape class with Gdk and returns its type number.
  */
-GType
-sp_shape_get_type (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,
@@ -104,8 +87,7 @@ sp_shape_get_type (void)
  * 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)
 {
     GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
     SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass);
@@ -114,20 +96,20 @@ sp_shape_class_init (SPShapeClass *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;
@@ -136,8 +118,7 @@ sp_shape_class_init (SPShapeClass *klass)
 /**
  * Initializes an SPShape object.
  */
-static void
-sp_shape_init (SPShape *shape)
+void SPShape::sp_shape_init(SPShape *shape)
 {
     for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) {
         new (&shape->release_connect[i]) sigc::connection();
@@ -147,8 +128,7 @@ sp_shape_init (SPShape *shape)
     shape->curve = NULL;
 }
 
-static void
-sp_shape_finalize (GObject *object)
+void SPShape::sp_shape_finalize(GObject *object)
 {
     SPShape *shape=(SPShape *)object;
 
@@ -159,8 +139,8 @@ sp_shape_finalize (GObject *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);
     }
 }
 
@@ -171,11 +151,10 @@ sp_shape_finalize (GObject *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)
 {
-    if (((SPObjectClass *) (parent_class))->build) {
-       (*((SPObjectClass *) (parent_class))->build) (object, document, repr);
+    if (((SPObjectClass *) (SPShapeClass::parent_class))->build) {
+       (*((SPObjectClass *) (SPShapeClass::parent_class))->build) (object, document, repr);
     }
 
     for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
@@ -193,8 +172,7 @@ sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
  *
  * \see sp_object_release()
  */
-static void
-sp_shape_release (SPObject *object)
+void SPShape::sp_shape_release(SPObject *object)
 {
     SPItem *item;
     SPShape *shape;
@@ -218,26 +196,24 @@ sp_shape_release (SPObject *object)
         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)
 {
-    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)
 {
-    if (((SPObjectClass *)(parent_class))->write) {
-        ((SPObjectClass *)(parent_class))->write(object, doc, repr, flags);
+    if (((SPObjectClass *)(SPShapeClass::parent_class))->write) {
+        ((SPObjectClass *)(SPShapeClass::parent_class))->write(object, doc, repr, flags);
     }
 
     return repr;
@@ -247,14 +223,13 @@ sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::No
  * 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)
 {
     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
@@ -294,17 +269,17 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
         }
     }
 
-    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));
                 }
             }
         }
@@ -332,8 +307,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
  * Reference for behaviour of zero-length segments:
  * http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
  */
-Geom::Matrix
-sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2)
+Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2)
 {
     Geom::Point p = c1.pointAt(1);
     Geom::Curve * c1_reverse = c1.reverse();
@@ -359,8 +333,8 @@ sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2)
 
     return Geom::Rotate(ret_angle) * Geom::Translate(p);
 }
-Geom::Matrix
-sp_shape_marker_get_transform_at_start(Geom::Curve const & c)
+
+Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c)
 {
     Geom::Point p = c.pointAt(0);
     Geom::Matrix ret = Geom::Translate(p);
@@ -376,8 +350,8 @@ sp_shape_marker_get_transform_at_start(Geom::Curve const & c)
 
     return ret;
 }
-Geom::Matrix
-sp_shape_marker_get_transform_at_end(Geom::Curve const & c)
+
+Geom::Matrix sp_shape_marker_get_transform_at_end(Geom::Curve const & c)
 {
     Geom::Point p = c.pointAt(1);
     Geom::Matrix ret = Geom::Translate(p);
@@ -403,8 +377,7 @@ sp_shape_marker_get_transform_at_end(Geom::Curve const & c)
  *
  * @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)
 {
     SPStyle *style = ((SPObject *) shape)->style;
 
@@ -514,13 +487,12 @@ sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai)
 /**
  * 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)
 {
     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) {
@@ -534,7 +506,7 @@ sp_shape_modified (SPObject *object, unsigned int flags)
  * 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) {
@@ -588,7 +560,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
                     }
 
                     // Union with bboxes of the markers, if any
-                    if (sp_shape_has_markers (shape) && !shape->curve->get_pathvector().empty()) {
+                    if ( shape->hasMarkers()  && !shape->curve->get_pathvector().empty() ) {
                         /** \todo make code prettier! */
                         Geom::PathVector const & pathv = shape->curve->get_pathvector();
                         // START marker
@@ -612,7 +584,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
 
                                     // 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);
                                 }
@@ -640,7 +612,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
                                     }
                                     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
@@ -667,7 +639,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
                                             }
                                             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);
                                         }
 
@@ -688,7 +660,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
                                     }
                                     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);
                                 }
                             }
@@ -723,7 +695,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &
 
                                     // 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 +724,7 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Matrix tr, SPStyle* 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;
 }
 /**
@@ -783,13 +755,13 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
         }
 
     /* 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);
 
@@ -876,8 +848,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
 /**
  * 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*/)
 {
     SPObject *object = SP_OBJECT(item);
     SPShape *shape = SP_SHAPE(item);
@@ -900,18 +871,18 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int
         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));
             }
         }
 
@@ -925,8 +896,7 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int
 /**
  * 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)
 {
     SPShape *shape;
     SPItemView *v;
@@ -945,8 +915,8 @@ sp_shape_hide (SPItem *item, unsigned int key)
       }
     }
 
-    if (((SPItemClass *) parent_class)->hide) {
-      ((SPItemClass *) parent_class)->hide (item, key);
+    if (((SPItemClass *) SPShapeClass::parent_class)->hide) {
+      ((SPItemClass *) SPShapeClass::parent_class)->hide (item, key);
     }
 }
 
@@ -954,19 +924,18 @@ sp_shape_hide (SPItem *item, unsigned int key)
 * \param shape Shape.
 * \return TRUE if the shape has any markers, or FALSE if not.
 */
-int
-sp_shape_has_markers (SPShape const *shape)
+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])
         );
 }
 
@@ -976,10 +945,9 @@ sp_shape_has_markers (SPShape const *shape)
 * \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)
+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;
     }
@@ -987,7 +955,7 @@ sp_shape_number_of_markers (SPShape *shape, int type)
     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;
@@ -999,11 +967,11 @@ sp_shape_number_of_markers (SPShape *shape, int type)
         }
         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;
@@ -1017,7 +985,7 @@ sp_shape_number_of_markers (SPShape *shape, int type)
         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 +1030,7 @@ static void
 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 +1085,10 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value)
 /**
  * Calls any registered handlers for the set_shape action
  */
-void
-sp_shape_set_shape (SPShape *shape)
+void SPShape::setShape()
 {
-    g_return_if_fail (shape != NULL);
-    g_return_if_fail (SP_IS_SHAPE (shape));
-
-    if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape) {
-      SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape (shape);
+    if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape) {
+      SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape (this);
     }
 }
 
@@ -1134,30 +1098,28 @@ sp_shape_set_shape (SPShape *shape)
  * 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)
+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)
+SPCurve * SPShape::getCurve()
 {
-    if (shape->curve) {
-        return shape->curve->copy();
+    if (this->curve) {
+        return this->curve->copy();
     }
     return NULL;
 }
@@ -1165,17 +1127,16 @@ sp_shape_get_curve (SPShape *shape)
 /**
  * Same as sp_shape_set_curve but without updating the display
  */
-void
-sp_shape_set_curve_insync (SPShape *shape, 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();
         }
     }
 }
@@ -1183,7 +1144,7 @@ sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner)
 /**
  * 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));
@@ -1202,10 +1163,10 @@ static void sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCa
     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));
         }
index 4b1ded23649394f2066412c1d4be334d62b72817..78855c1c7d32606f98b0801045964801d736f3e8 100644 (file)
@@ -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 +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 {
+class SPShape : public SPLPEItem {
+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];
+       
+    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;
+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_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);
 
-GType sp_shape_get_type (void);
+    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);
 
-// 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; 
+};
+
+class SPShapeClass {
+public:
+    SPLPEItemClass item_class;
+
+    /* Build bpath from extra shape attributes */
+    void (* set_shape) (SPShape *shape);
+
+private:
+    static SPLPEItemClass *parent_class;
+    static void sp_shape_class_init (SPShapeClass *klass);
+
+    friend class SPShape;
+};
 
-// 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);
 
 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 :
index 329df8eb64d199e963a39014be66db1ee9dbcbe6..42fc5289f7e70bf6d9cc5e0f5b7de88b40a0ff1c 100644 (file)
@@ -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 +12,7 @@
 /*
  * Authors:
  *   Kees Cook <kees@outflux.net>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004 Kees Cook
  *
@@ -110,18 +109,18 @@ sp_skeleton_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r
     /*
        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" );
     */
 }
 
index c309c60ccfd8059ec75e516beb342b88e670cd20..cfe02947a26af5276f16532be2bea8f2aafb06df 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_SPIRAL_C__
-
 /** \file
  * <sodipodi:spiral> implementation
  */
@@ -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 +128,13 @@ sp_spiral_build (SPObject * object, SPDocument * document, Inkscape::XML::Node *
     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" );
 }
 
 /**
@@ -287,7 +286,7 @@ static void
 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 +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;
@@ -470,12 +469,12 @@ sp_spiral_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();
     }
@@ -533,7 +532,7 @@ static void sp_spiral_snappoints(SPItem const *item, std::vector<Inkscape::SnapC
     }
 
     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
index 3694a7cd1025904042fa2c013de8d295fc88be3a..b94e2dbc4b38d1f122eeb8295ec6789522ad3ab9 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_STAR_C__
-
 /*
  * <sodipodi:star> implementation
  *
@@ -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 +117,16 @@ sp_star_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * r
     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" );
 }
 
 static Inkscape::XML::Node *
@@ -270,7 +269,7 @@ sp_star_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)
@@ -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;
@@ -509,12 +508,12 @@ sp_star_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();
     }
@@ -560,7 +559,7 @@ static void sp_star_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan
     }
 
     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));
     }
 }
index 15fc93e2f116b90684016d865f3f38fee0c8a0cb..0c0a3b03aa19f3c9fbf981227e634ef47ddca7a6 100644 (file)
@@ -69,7 +69,7 @@ SPColor SPStop::getEffectiveColor() const
 {
     SPColor ret;
     if (currentColor) {
-        char const *str = sp_object_get_style_property(this, "color", NULL);
+        char const *str = getStyleProperty("color", NULL);
         /* Default value: arbitrarily black.  (SVG1.1 and CSS2 both say that the initial
          * value depends on user agent, and don't give any further restrictions that I can
          * see.) */
index b424ac3d8c318ee10e14af386b7c4b1f97fa886f..c116e8dd854b3f2f1dcd6d59eaf8b074cdb20d1a 100644 (file)
@@ -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,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.
+    gchar const *xml_string = string->getRepr()->content();
     // see algorithms described in svg 1.1 section 10.15
     if (object->xml_space.value == SP_XML_SPACE_PRESERVE) {
         for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) {
             gunichar c = g_utf8_get_char(xml_string);
-            if (c == 0xa || c == 0xd || c == '\t') c = ' ';
+            if ((c == 0xa) || (c == 0xd) || (c == '\t')) {
+                c = ' ';
+            }
             string->string += c;
         }
     }
@@ -129,17 +133,22 @@ sp_string_read_content(SPObject *object)
         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);
 }
index 0c01136f6af47df3d97b86a4efc73af5215210db..53362d3e374096a3ad1e8bef63757a7135a26810 100644 (file)
@@ -1,4 +1,3 @@
-
 #ifndef SEEN_SP_STYLE_ELEM_TEST_H
 #define SEEN_SP_STYLE_ELEM_TEST_H
 
@@ -23,7 +22,7 @@ public:
     {
         if ( _doc )
         {
-            sp_document_unref( _doc );
+            _doc->doUnref();
         }
     }
 
@@ -56,16 +55,16 @@ public:
         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 +81,7 @@ public:
         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);
         {
@@ -108,7 +107,7 @@ public:
         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 );
@@ -138,7 +137,7 @@ public:
         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);
index 5a57d548b83e9e0d772e5f17c6d8be5f355fe720..02ed80445346aedd73f1e6fe39bcb6e59221760e 100644 (file)
@@ -317,7 +317,8 @@ sp_style_elem_read_content(SPObject *const object)
      * 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.
+    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 @@ sp_style_elem_build(SPObject *object, SPDocument *document, Inkscape::XML::Node
 {
     sp_style_elem_read_content(object);
 
-    sp_object_read_attr(object, "type");
-    sp_object_read_attr(object, "media");
+    object->readAttr( "type" );
+    object->readAttr( "media" );
 
     static Inkscape::XML::NodeEventVector const nodeEventVector = {
         child_add_rm_cb,   // child_added
index 37be6f75eef0b384e418c3ade98eec793fb86b89..19c014b9b50e76c46168158a2f3eda7b8bcf34ce 100644 (file)
@@ -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,13 @@ CSwitch::~CSwitch() {
 }
 
 SPObject *CSwitch::_evaluateFirst() {
-    for (SPObject *child = sp_object_first_child(_group) ; 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 +170,7 @@ void CSwitch::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key,
         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;
@@ -177,3 +179,14 @@ void CSwitch::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key,
         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 :
index 41004db6e37154db0e98ae5ae6f687d2dc2af5ae..6c8d3cd82a7433e64b6f2d70f52f0ec237b62e27 100644 (file)
@@ -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 +109,8 @@ sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *re
     group = (SPGroup *) object;
     symbol = (SPSymbol *) object;
 
-    sp_object_read_attr (object, "viewBox");
-    sp_object_read_attr (object, "preserveAspectRatio");
+    object->readAttr( "viewBox" );
+    object->readAttr( "preserveAspectRatio" );
 
     if (((SPObjectClass *) parent_class)->build)
         ((SPObjectClass *) parent_class)->build (object, document, repr);
@@ -393,11 +392,15 @@ sp_symbol_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::X
         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.
+    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)
+    if (((SPObjectClass *) (parent_class))->write) {
         ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
+    }
 
     return repr;
 }
index 4b896db9cd980ad8d90d8f6a4408bb1e2165b618..80eb786f28754cbfed3928c5b7cc6d5c62de92af 100644 (file)
@@ -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 +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" );
 
     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
 }
 
 static void
@@ -211,8 +213,7 @@ sp_text_remove_child (SPObject *object, Inkscape::XML::Node *rch)
     text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
 }
 
-static void
-sp_text_update (SPObject *object, SPCtx *ctx, guint flags)
+static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags)
 {
     SPText *text = SP_TEXT (object);
 
@@ -223,9 +224,9 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags)
     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->firstChild() ; child ; child = child->getNext() ) {
         sp_object_ref (SP_OBJECT (child), object);
         l = g_slist_prepend (l, child);
     }
@@ -249,7 +250,7 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags)
         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));
@@ -259,14 +260,16 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags)
     }
 }
 
-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
@@ -275,7 +278,7 @@ sp_text_modified (SPObject *object, guint flags)
     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));
@@ -283,16 +286,15 @@ sp_text_modified (SPObject *object, guint flags)
         }
     }
 
-    /* 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 (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
         sp_object_ref (SP_OBJECT (child), object);
         l = g_slist_prepend (l, child);
     }
     l = g_slist_reverse (l);
     while (l) {
-        child = SP_OBJECT (l->data);
+        SPObject *child = SP_OBJECT (l->data);
         l = g_slist_remove (l, child);
         if (cflags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
             child->emitModified(cflags);
@@ -301,24 +303,28 @@ sp_text_modified (SPObject *object, guint flags)
     }
 }
 
-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) ) {
-            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
+        for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) {
+                continue;
+            }
             Inkscape::XML::Node *crepr = NULL;
             if (SP_IS_STRING(child)) {
                 crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
             } else {
                 crepr = child->updateRepr(xml_doc, NULL, flags);
             }
-            if (crepr) l = g_slist_prepend (l, crepr);
+            if (crepr) {
+                l = g_slist_prepend (l, crepr);
+            }
         }
         while (l) {
             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
@@ -326,8 +332,10 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
             l = g_slist_remove (l, l->data);
         }
     } else {
-        for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
-            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
+        for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
+            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) {
+                continue;
+            }
             if (SP_IS_STRING(child)) {
                 SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str());
             } else {
@@ -343,12 +351,13 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
         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 +396,7 @@ sp_text_show(SPItem *item, NRArena *arena, unsigned /* key*/, unsigned /*flags*/
 
     // 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 +451,7 @@ static void sp_text_snappoints(SPItem const *item, std::vector<Inkscape::SnapCan
     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 +492,13 @@ sp_text_set_transform (SPItem *item, Geom::Matrix const &xform)
     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 +511,13 @@ sp_text_print (SPItem *item, SPPrintContext *ctx)
     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);
 }
@@ -550,14 +559,16 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio
     if (SP_IS_TSPAN(root))
         if (SP_TSPAN(root)->role != SP_TSPAN_ROLE_UNSPECIFIED) {
             // we need to allow the first line not to have role=line, but still set the source_cookie to the right value
-            SPObject *prev_object = SP_OBJECT_PREV(root);
+            SPObject *prev_object = root->getPrev();
             if (prev_object && SP_IS_TSPAN(prev_object)) {
-                if (!layout.inputExists())
+                if (!layout.inputExists()) {
                     layout.appendText("", prev_object->style, prev_object, &optional_attrs);
+                }
                 layout.appendControlCode(Inkscape::Text::Layout::PARAGRAPH_BREAK, prev_object);
             }
-            if (!root->hasChildren())
+            if (!root->hasChildren()) {
                 layout.appendText("", root->style, root, &optional_attrs);
+            }
             length++;     // interpreting line breaks as a character for the purposes of x/y/etc attributes
                           // is a liberal interpretation of the svg spec, but a strict reading would mean
                           // that if the first line is empty the second line would take its place at the
@@ -565,12 +576,12 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio
             child_attrs_offset--;
         }
 
-    for (SPObject *child = sp_object_first_child(root) ; 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 +595,7 @@ void SPText::rebuildLayout()
     Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs;
     _buildLayoutInput(this, optional_attrs, 0, false);
     layout.calculateFlow();
-    for (SPObject *child = firstChild() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+    for (SPObject *child = firstChild() ; child ; child = child->getNext() ) {
         if (SP_IS_TEXTPATH(child)) {
             SPTextPath const *textpath = SP_TEXTPATH(child);
             if (textpath->originalPath != NULL) {
@@ -596,14 +607,16 @@ void SPText::rebuildLayout()
     //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);
+            }
+        }
     }
 }
 
index 76d236cc9bfa91c584086b6f2f299e3028a268a8..2f30f6023b7df9f916ae10fc0c5f88e47cd4dba5 100644 (file)
@@ -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->firstChild() && SP_IS_TEXTPATH(obj->firstChild()))
 
 SPItem *sp_textpath_get_path_item(SPTextPath *tp);
 void sp_textpath_to_text(SPObject *tp);
index 37a5e21cee3456852da5ddf20045862c4698a44c..c2264f83e85516f37246e5b27f4d4aacbc572fa6 100644 (file)
@@ -7,11 +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>
 
index 66a8c1e7920f6ef75b5a0170d53669334eed6808..eddcd270c482a79be553201b5d7a21f5d9840833 100644 (file)
@@ -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 +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 @@ sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
         ((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" );
 }
 
 /**
@@ -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 @@ sp_tref_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTRef *tref)
         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,7 @@ sp_tref_fully_contained(SPObject *start_item, Glib::ustring::iterator &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
@@ -516,20 +515,20 @@ sp_tref_update_text(SPTRef *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 +585,7 @@ sp_tref_convert_to_tspan(SPObject *obj)
             Inkscape::XML::Node *tref_parent = sp_repr_parent(tref_repr);
 
             SPDocument *document = SP_OBJECT(tref)->document;
-            Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+            Inkscape::XML::Document *xml_doc = document->getReprDoc();
 
             Inkscape::XML::Node *new_tspan_repr = xml_doc->createElement("svg:tspan");
 
@@ -633,7 +632,7 @@ sp_tref_convert_to_tspan(SPObject *obj)
     ////////////////////
     else {
         GSList *l = NULL;
-        for (SPObject *child = sp_object_first_child(obj) ; 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);
         }
index 056436ed3abf6cf785e950f1b428740bf8d1d578..2afd75e75992d303453514f2e9a76c9d06402057 100644 (file)
@@ -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 @@ sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr)
 {
     //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" );
        
     if (((SPObjectClass *) tspan_parent_class)->build)
         ((SPObjectClass *) tspan_parent_class)->build(object, doc, repr);
@@ -168,35 +168,36 @@ sp_tspan_set(SPObject *object, unsigned key, gchar const *value)
     }
 }
 
-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 ( 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 ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
         if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) {
             ochild->emitModified(flags);
         }
@@ -242,7 +243,7 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
        
     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->firstChild() ; child ; child = child->getNext() ) {
             Inkscape::XML::Node* c_repr=NULL;
             if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 c_repr = child->updateRepr(xml_doc, NULL, flags);
@@ -251,7 +252,9 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
             } else if ( SP_IS_STRING(child) ) {
                 c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
             }
-            if ( c_repr ) l = g_slist_prepend(l, c_repr);
+            if ( c_repr ) {
+                l = g_slist_prepend(l, c_repr);
+            }
         }
         while ( l ) {
             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
@@ -259,7 +262,7 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
             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->firstChild() ; child ; child = child->getNext() ) {
             if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 child->updateRepr(flags);
             } else if ( SP_IS_TEXTPATH(child) ) {
@@ -270,8 +273,9 @@ sp_tspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
         }
     }
        
-    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 +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");
-       
-    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 +445,26 @@ sp_textpath_set(SPObject *object, unsigned key, gchar const *value)
     }
 }
 
-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 ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
         if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) {
             ochild->updateDisplay(ctx, flags);
         }
@@ -483,18 +492,18 @@ void   refresh_textpath_source(SPTextPath* tp)
     }
 }
 
-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 ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) {
         if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) {
             ochild->emitModified(flags);
         }
@@ -526,7 +535,7 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
        
     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->firstChild() ; child ; child = child->getNext() ) {
             Inkscape::XML::Node* c_repr=NULL;
             if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 c_repr = child->updateRepr(xml_doc, NULL, flags);
@@ -535,7 +544,9 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
             } else if ( SP_IS_STRING(child) ) {
                 c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str());
             }
-            if ( c_repr ) l = g_slist_prepend(l, c_repr);
+            if ( c_repr ) {
+                l = g_slist_prepend(l, c_repr);
+            }
         }
         while ( l ) {
             repr->addChild((Inkscape::XML::Node *) l->data, NULL);
@@ -543,7 +554,7 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
             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->firstChild() ; child ; child = child->getNext() ) {
             if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) {
                 child->updateRepr(flags);
             } else if ( SP_IS_TEXTPATH(child) ) {
@@ -554,8 +565,9 @@ sp_textpath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
         }
     }
        
-    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 +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
index 914e416b3f77c357cc4db36a8098115fe2c5af98..a05dc0e93d498ddbcaef2ea23012b6d80d90e902 100644 (file)
@@ -222,7 +222,7 @@ void SPUsePath::refresh_source()
         return;
     }
     if (SP_IS_SHAPE(item)) {
-        curve = sp_shape_get_curve(SP_SHAPE(item));
+        curve = SP_SHAPE(item)->getCurve();
         if (curve == NULL)
             return;
     }
index b30819a5b6add09734bcd8d12a5800a0d2369355..73d46c8aa8b89058028c4ed44576d5e90db05ba5 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <forward.h>
+#include "sp-item.h"
 #include <uri-references.h>
 #include <sigc++/sigc++.h>
 
index ecb7eb788b137c69537c43312d9950e96ce06518..505c64fd225b326e448dca557ad9e1fb31b4c525 100644 (file)
@@ -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 @@ 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 @@ sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
         (* ((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" );
 
     // 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 @@ 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 @@ sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, uns
                                                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 @@ sp_use_print(SPItem *item, SPPrintContext *ctx)
     }
 
     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 @@ 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 @@ sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
     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 @@ 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 @@ sp_use_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPUse *self
         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;
@@ -512,7 +512,7 @@ sp_use_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPUse *self
     // 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 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use)
     use->_transformed_connection.disconnect();
 
     if (use->child) {
-        sp_object_detach(SP_OBJECT(use), use->child);
+        SP_OBJECT(use)->detach(use->child);
         use->child = NULL;
     }
 
@@ -537,13 +537,13 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use)
             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,26 @@ sp_use_modified(SPObject *object, guint flags)
     }
 }
 
-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 ;
+    if (!orig) {
+        return NULL;
+    }
 
     // Calculate the accumulated transform, starting from the original.
     Geom::Matrix t = sp_use_get_root_transform(use);
@@ -736,7 +741,7 @@ sp_use_unlink(SPUse *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;
 }
index 6730ab63b77a7fc1b6db06975aa855a3235cf61b..75488519273826d5040bac4f35714e9e042aed0b 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_SPIRAL_CONTEXT_C__
-
 /*
  * Spiral drawing context
  *
@@ -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,8 @@
 #include "context-fns.h"
 #include "shape-editor.h"
 
+using Inkscape::DocumentUndo;
+
 static void sp_spiral_context_class_init(SPSpiralContextClass * klass);
 static void sp_spiral_context_init(SPSpiralContext *spiral_context);
 static void sp_spiral_context_dispose(GObject *object);
@@ -397,8 +399,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
     return ret;
 }
 
-static void
-sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
+static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
 {
     SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
 
@@ -411,17 +412,17 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state)
             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);
@@ -475,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,
-                         _("Create spiral"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
+                           _("Create spiral"));
 
         sc->item = NULL;
     }
@@ -507,7 +508,7 @@ static void sp_spiral_cancel(SPSpiralContext *sc)
 
     sp_canvas_end_forced_full_redraws(desktop->canvas);
 
-    sp_document_cancel(sp_desktop_document(desktop));
+    DocumentUndo::cancel(sp_desktop_document(desktop));
 }
 
 /*
index e7787813d3830383700e0e69f9b70ce5937c7b5d..5f32e591ef906ab4b90c1dfd43a5060f6ef3e594 100644 (file)
@@ -1,4 +1,3 @@
-#define __SP_LIVAROT_C__
 /*
  *  splivarot.cpp
  *  Inkscape
@@ -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 +420,8 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
         {
             SP_OBJECT(l->data)->deleteObject();
         }
-        sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, 
-                         description);
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, 
+                           description);
         selection->clear();
 
         delete res;
@@ -451,11 +452,11 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
     // 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);
 
@@ -484,7 +485,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
 
     // 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
@@ -513,7 +514,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
         for (int i=0;i<nbRP;i++) {
             gchar *d = resPath[i]->svg_dump_path();
 
-            Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+            Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
             Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
             repr->setAttribute("style", style);
             if (mask)
@@ -559,7 +560,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
     } else {
         gchar *d = res->svg_dump_path();
 
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+        Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
         Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
         repr->setAttribute("style", style);
 
@@ -593,7 +594,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
     if (desc) g_free(desc);
 
     if (verb != SP_VERB_NONE) {
-        sp_document_done(sp_desktop_document(desktop), verb, description);
+        DocumentUndo::done(sp_desktop_document(desktop), verb, description);
     }
 
     delete res;
@@ -620,7 +621,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix
         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);
     }
 }
 
@@ -666,7 +667,7 @@ Geom::PathVector* item_outline(SPItem const *item)
 
     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();
     }
@@ -785,7 +786,7 @@ Geom::PathVector* item_outline(SPItem const *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();
@@ -894,7 +895,7 @@ sp_selected_path_outline(SPDesktop *desktop)
 
         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;
         }
@@ -1065,7 +1066,7 @@ sp_selected_path_outline(SPDesktop *desktop)
         if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether
 
             SPDocument * doc = sp_desktop_document(desktop);
-            Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+            Inkscape::XML::Document *xml_doc = doc->getReprDoc();
             Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
 
             // restore old style, but set old stroke style on fill
@@ -1082,9 +1083,9 @@ sp_selected_path_outline(SPDesktop *desktop)
             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
@@ -1096,7 +1097,7 @@ sp_selected_path_outline(SPDesktop *desktop)
                 // 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);
                 }
@@ -1196,7 +1197,7 @@ sp_selected_path_outline(SPDesktop *desktop)
                 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);
                 }
@@ -1223,8 +1224,8 @@ sp_selected_path_outline(SPDesktop *desktop)
     }
 
     if (did) {
-        sp_document_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 +1316,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
     }
     if (SP_IS_SHAPE(item))
     {
-        curve = sp_shape_get_curve(SP_SHAPE(item));
+        curve = SP_SHAPE(item)->getCurve();
         if (curve == NULL)
             return;
     }
@@ -1328,9 +1329,10 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
 
     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();
@@ -1426,11 +1428,11 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
     {
         // pas vraiment de points sur le resultat
         // donc il ne reste rien
-        sp_document_done(sp_desktop_document(desktop), 
-                         (updating ? SP_VERB_SELECTION_LINKED_OFFSET 
-                          : SP_VERB_SELECTION_DYNAMIC_OFFSET),
-                         (updating ? _("Create linked offset")
-                          : _("Create dynamic offset")));
+        DocumentUndo::done(sp_desktop_document(desktop), 
+                           (updating ? SP_VERB_SELECTION_LINKED_OFFSET 
+                            : SP_VERB_SELECTION_DYNAMIC_OFFSET),
+                           (updating ? _("Create linked offset")
+                            : _("Create dynamic offset")));
         selection->clear();
 
         delete res;
@@ -1444,7 +1446,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
 
         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
@@ -1458,7 +1460,9 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
         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);
@@ -1479,11 +1483,11 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
         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.
@@ -1495,11 +1499,11 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
         selection->set(nitem);
     }
 
-    sp_document_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 +1545,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
 
         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;
         }
@@ -1553,7 +1557,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
 
         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"));
 
@@ -1708,7 +1712,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
 
             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);
@@ -1726,7 +1730,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
             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);
 
@@ -1740,9 +1744,9 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
     }
 
     if (did) {
-        sp_document_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 +1787,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
     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;
     }
@@ -1795,7 +1799,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
     }
 
     // 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);
@@ -1805,7 +1809,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
        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"));
@@ -1845,7 +1849,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
         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
@@ -1885,7 +1889,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
     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 +1954,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
           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 +2004,8 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju
                                                         breakableAngles, true);
 
     if (didSomething)
-        sp_document_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 +2099,7 @@ pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool t
     
     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 +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))
index e7172acd4febc29ecf51ce3de7fce7a6af4f3ade..0cf74f59b97d5e617f8a841dbab2333bc478d278 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_SPRAY_CONTEXT_C__
-
 /*
  * Spray Tool
  *
@@ -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,8 @@
 #include "helper/action.h"
 
 #include <iostream>
+
+using Inkscape::DocumentUndo;
 using namespace std;
 
 
@@ -151,9 +153,9 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom
     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);
@@ -165,8 +167,8 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom
 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 +481,14 @@ bool sp_spray_recursive(SPDesktop *desktop,
     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);
@@ -527,11 +529,11 @@ bool sp_spray_recursive(SPDesktop *desktop,
             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);
@@ -569,12 +571,12 @@ bool sp_spray_recursive(SPDesktop *desktop,
             }
         }
     } 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 +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),
-                                     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),
-                                     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),
-                                     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;
             }
         }
index 910c048b6f67e26ab58b4a9377d09ca8f6ff0120..0fb20a2ab0a044ac928e5acc24ce919d162c7e6b 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_STAR_CONTEXT_C__
-
 /*
  * Star drawing context
  *
@@ -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,8 @@
 
 #include "star-context.h"
 
+using Inkscape::DocumentUndo;
+
 static void sp_star_context_class_init (SPStarContextClass * klass);
 static void sp_star_context_init (SPStarContext * star_context);
 static void sp_star_context_dispose (GObject *object);
@@ -425,17 +427,17 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state)
             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);
@@ -495,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,
-                         _("Create star"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+                           _("Create star"));
 
         sc->item = NULL;
     }
@@ -528,7 +530,7 @@ static void sp_star_cancel(SPStarContext *sc)
 
     sp_canvas_end_forced_full_redraws(desktop->canvas);
 
-    sp_document_cancel(sp_desktop_document(desktop));
+    DocumentUndo::cancel(sp_desktop_document(desktop));
 }
 
 /*
index 67a4d70141b2d70005ea4a509a8d3f38e9fb8148..064773d1d97a64e81bcd52539c8d9aadbf2a3ac2 100644 (file)
@@ -1,4 +1,3 @@
-
 #ifndef SEEN_STYLE_TEST_H
 #define SEEN_STYLE_TEST_H
 
@@ -22,7 +21,7 @@ public:
     {
         if ( _doc )
         {
-            sp_document_unref( _doc );
+            _doc->doUnref();
             _doc = 0;
         }
     }
index 551dd658516b594ea794405040c0aa6427b0d73b..d254ab6f484fc8bceff099b5f3cef80722de62c8 100644 (file)
@@ -5,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.
@@ -1015,7 +1016,9 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
              * 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);
@@ -1025,7 +1028,9 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *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) {
@@ -1284,9 +1289,11 @@ sp_style_merge_from_object_stylesheet(SPStyle *const style, SPObject const *cons
     }
 
     CRPropList *props = NULL;
+
+    //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.
index 10d9976566f04a3fed2b3b6f720a35e7e8504939..d2a31966afab6916bffb915ed373459e80094b6e 100644 (file)
@@ -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 +148,8 @@ sp_svg_view_widget_size_request (GtkWidget *widget, GtkRequisition *req)
                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;
index bd46dd17a6c86645eec790878106b47d4ce9ca28..ef87b38efecbf8dd5fac4887b7252091d6c81661 100644 (file)
@@ -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 @@ SPSVGView::~SPSVGView()
 {
     if (doc() && _drawing)
     {
-        sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey);
+        SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey);
         _drawing = NULL;
     }
 }
@@ -84,12 +84,12 @@ void
 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;
@@ -104,8 +104,8 @@ SPSVGView::doRescale (bool event)
     }
 
     if (event) {
-        emitResized (sp_document_width (doc()) * _hscale,
-                sp_document_height (doc()) * _vscale);
+        emitResized (doc()->getWidth () * _hscale,
+                doc()->getHeight () * _vscale);
     }
 }
 
@@ -152,7 +152,7 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG
                                spev.type = SP_EVENT_ACTIVATE;
                                 if ( spitem != 0 )
                                {
-                                 sp_item_event (spitem, &spev);
+                                 spitem->emitEvent (spev);
                                 }
                        }
                }
@@ -166,7 +166,7 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG
                spev.data = svgview;
                 if ( spitem != 0 )
                {
-                 sp_item_event (spitem, &spev);
+                 spitem->emitEvent (spev);
                 }
                break;
        case GDK_LEAVE_NOTIFY:
@@ -174,7 +174,7 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG
                spev.data = svgview;
                 if ( spitem != 0 )
                {
-                 sp_item_event (spitem, &spev);
+                 spitem->emitEvent (spev);
                 }
                break;
        default:
@@ -191,7 +191,7 @@ void
 SPSVGView::setDocument (SPDocument *document)
 {
     if (doc()) {
-        sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey);
+        SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey);
     }
 
     if (!_drawing) {
@@ -200,8 +200,7 @@ SPSVGView::setDocument (SPDocument *document)
     }
 
     if (document) {
-        NRArenaItem *ai = sp_item_invoke_show (
-                SP_ITEM (sp_document_root (document)),
+        NRArenaItem *ai = SP_ITEM( document->getRoot() )->invoke_show(
                 SP_CANVAS_ARENA (_drawing)->arena,
                 _dkey,
                 SP_ITEM_SHOW_DISPLAY);
index 19dacd9c8cf56b9fa6e3652b84a1564677f20e46..e1b8521621b6fc9c14bf55de0e0c47d653a80c2c 100644 (file)
@@ -1,4 +1,3 @@
-
 #ifndef SEEN_TEST_HELPERS_H
 #define SEEN_TEST_HELPERS_H
 
@@ -32,7 +31,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) )
         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 +40,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) )
         }
         else
         {
-            sp_document_unref( tmp );
+            tmp->doUnref();
         }
     }
 
index cc02c656e350b397dad443592c222ca25c606945..f2ea4367b9acd5ee27de6f2893d27e34d4dd3b56 100644 (file)
@@ -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,7 @@
 #include "sp-flowdiv.h"
 #include "sp-tspan.h"
 
+using Inkscape::DocumentUndo;
 
 SPItem *
 text_in_selection(Inkscape::Selection *selection)
@@ -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."));
@@ -133,13 +134,13 @@ text_put_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)->ensureUpToDate();
 
         selection->clear();
 
@@ -188,8 +189,8 @@ text_put_on_path()
     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, 
-                     _("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 +216,7 @@ text_remove_from_path()
             continue;
         }
 
-        SPObject *tp = sp_object_first_child(SP_OBJECT(items->data));
+        SPObject *tp = SP_OBJECT(items->data)->firstChild();
 
         did = true;
 
@@ -225,8 +226,8 @@ text_remove_from_path()
     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, 
-                         _("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 +253,7 @@ text_remove_all_kerns_recursively(SPObject *o)
         g_strfreev(xa_comma);
     }
 
-    for (SPObject *i = sp_object_first_child(o); 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 +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, 
-                         _("Remove manual kerns"));
+        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, 
+                           _("Remove manual kerns"));
     }
 }
 
@@ -302,7 +303,7 @@ text_flow_into_shape()
         return;
 
     SPDocument *doc = sp_desktop_document (desktop);
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+    Inkscape::XML::Document *xml_doc = doc->getReprDoc();
 
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
@@ -377,8 +378,8 @@ text_flow_into_shape()
 
     SP_OBJECT(text)->deleteObject (true);
 
-    sp_document_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 +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);
 
@@ -433,7 +434,7 @@ text_unflow ()
         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]);
@@ -473,8 +474,8 @@ text_unflow ()
     g_slist_free (old_objs);
     g_slist_free (new_objs);
 
-    sp_document_done(doc, SP_VERB_CONTEXT_TEXT, 
-                     _("Unflow flowed text"));
+    DocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, 
+                       _("Unflow flowed text"));
 }
 
 void
@@ -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);
@@ -530,9 +531,9 @@ flowtext_to_text()
     g_slist_free(items);
 
     if (did) {
-        sp_document_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)->
index 9d94e0e78ac11e500cb95d66ba9f7b353a22d313..66e5f9450a97f9335e54be7918a35805c0819874 100644 (file)
@@ -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,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 +341,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
         case GDK_BUTTON_PRESS:
             if (event->button.button == 1 && !event_context->space_panning) {
                 // find out clicked item, disregarding groups
-                item_ungrouped = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE);
+                item_ungrouped = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE);
                 if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) {
                     sp_desktop_selection(desktop)->set(item_ungrouped);
                     if (tc->text) {
@@ -423,7 +424,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
                 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);
@@ -432,7 +433,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
                 } 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 +474,7 @@ sp_text_context_setup_text(SPTextContext *tc)
     SPEventContext *ec = SP_EVENT_CONTEXT(tc);
 
     /* Create <text> */
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DESKTOP(ec)->doc());
+    Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DESKTOP(ec)->doc()->getReprDoc();
     Inkscape::XML::Node *rtext = xml_doc->createElement("svg:text");
     rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create
 
@@ -498,11 +499,11 @@ sp_text_context_setup_text(SPTextContext *tc)
     /* 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,
-                     _("Create text"));
+    DocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT,
+                      _("Create text"));
 }
 
 /**
@@ -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,
-                         _("Insert Unicode character"));
+        DocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM,
+                          _("Insert Unicode character"));
     }
 }
 
@@ -723,8 +724,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                         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,
-                                         _("Create flowed text"));
+                        DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                          _("Create flowed text"));
                     } else {
                         desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The frame is <b>too small</b> for the current font size. Flowed text not created."));
                     }
@@ -863,8 +864,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                     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,
-                                                     _("Insert no-break space"));
+                                    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                                      _("Insert no-break space"));
                                     return TRUE;
                                 }
                                 break;
@@ -900,8 +901,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                         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,
-                                                     _("Make bold"));
+                                    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                                      _("Make bold"));
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
                                     return TRUE;
@@ -918,8 +919,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                         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,
-                                                     _("Make italic"));
+                                    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                                      _("Make italic"));
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
                                     return TRUE;
@@ -957,8 +958,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
 
                                 sp_text_context_update_cursor(tc);
                                 sp_text_context_update_text_selection(tc);
-                                sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
-                                                 _("New line"));
+                                DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                                  _("New line"));
                                 return TRUE;
                             }
                             case GDK_BackSpace:
@@ -991,8 +992,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
 
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
-                                    sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
-                                                     _("Backspace"));
+                                    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                                      _("Backspace"));
                                 }
                                 return TRUE;
                             case GDK_Delete:
@@ -1022,8 +1023,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
 
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
-                                    sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
-                                                     _("Delete"));
+                                    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
+                                                      _("Delete"));
                                 }
                                 return TRUE;
                             case GDK_Left:
@@ -1039,8 +1040,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                             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,
-                                                               _("Kern to the left"));
+                                        DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT,
+                                                               _("Kern to the left"));
                                     } else {
                                         if (MOD__CTRL)
                                             tc->text_sel_end.cursorLeftWithControl();
@@ -1064,8 +1065,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                             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,
-                                                               _("Kern to the right"));
+                                        DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT,
+                                                               _("Kern to the right"));
                                     } else {
                                         if (MOD__CTRL)
                                             tc->text_sel_end.cursorRightWithControl();
@@ -1089,9 +1090,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                             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,
-                                                               _("Kern up"));
-
+                                        DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT,
+                                                               _("Kern up"));
                                     } else {
                                         if (MOD__CTRL)
                                             tc->text_sel_end.cursorUpWithControl();
@@ -1115,9 +1115,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                             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,
-                                                               _("Kern down"));
-
+                                        DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT,
+                                                               _("Kern down"));
                                     } else {
                                         if (MOD__CTRL)
                                             tc->text_sel_end.cursorDownWithControl();
@@ -1192,8 +1191,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                         } 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,
-                                                               _("Rotate counterclockwise"));
+                                        DocumentUndo::maybeDone(sp_desktop_document(desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT,
+                                                               _("Rotate counterclockwise"));
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
                                         return TRUE;
@@ -1213,8 +1212,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                         } 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,
-                                                                _("Rotate clockwise"));
+                                        DocumentUndo::maybeDone(sp_desktop_document(desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT,
+                                                               _("Rotate clockwise"));
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
                                         return TRUE;
@@ -1230,17 +1229,15 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                                 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,
-                                                                    _("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,
-                                                                    _("Contract letter spacing"));
-
+                                            DocumentUndo::maybeDone(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT,
+                                                                   _("Contract letter spacing"));
                                         }
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
@@ -1257,17 +1254,15 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
                                                 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,
-                                                                    _("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,
-                                                                    _("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 +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,
-                             _("Paste text"));
+            DocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT,
+                              _("Paste text"));
 
             return true;
         }
@@ -1520,8 +1515,8 @@ sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc)
         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,
-                     _("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 +1589,8 @@ sp_text_context_update_cursor(SPTextContext *tc,  bool scroll_to_see)
     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) {
@@ -1636,7 +1631,7 @@ sp_text_context_update_cursor(SPTextContext *tc,  bool 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 +1671,7 @@ static void sp_text_context_update_text_selection(SPTextContext *tc)
 
     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 +1723,7 @@ sp_text_context_forget_text(SPTextContext *tc)
         // 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 +1756,8 @@ sptc_commit(GtkIMContext */*imc*/, gchar *string, SPTextContext *tc)
     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,
-                     _("Type text"));
+    DocumentUndo::done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT,
+                      _("Type text"));
 }
 
 void
index 5bad33d290b28510900ec2dc98cd4b5ef779c2d6..2e6e2f9fa9b454fe5ae9579dec40a4531af86773 100644 (file)
@@ -4,6 +4,8 @@
  * Authors:
  *   bulia byak
  *   Richard Hughes
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-5 authors
  *
@@ -60,28 +62,32 @@ static void te_update_layout_now (SPItem *item)
     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 +206,29 @@ static const char * span_name_for_text_object(SPObject const *object)
     return NULL;
 }
 
-/** Recursively gets the length of all the SPStrings at or below the given
-\a item. Also adds 1 for each line break encountered. */
 unsigned sp_text_get_length(SPObject const *item)
 {
     unsigned length = 0;
 
-    if (SP_IS_STRING(item)) return SP_STRING(item)->string.length();
-    
-    if (is_line_break_object(item)) length++;
+    if (SP_IS_STRING(item)) {
+        length = SP_STRING(item)->string.length();
+    } else {
+        if (is_line_break_object(item)) {
+            length++;
+        }
     
-    for (SPObject const *child = item->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) {
-        if (SP_IS_STRING(child)) length += SP_STRING(child)->string.length();
-        else length += sp_text_get_length(child);
+        for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) {
+            if (SP_IS_STRING(child)) {
+                length += SP_STRING(child)->string.length();
+            } else {
+                length += sp_text_get_length(child);
+            }
+        }
     }
+    
     return length;
 }
 
-/** Recursively gets the length of all the SPStrings at or below the given
-\a item, before and not including \a upto. Also adds 1 for each line break encountered. */
 unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto)
 {
     unsigned length = 0;
@@ -237,7 +247,7 @@ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto)
     }
     
     // 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 +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 +327,13 @@ parent of the first line break node encountered.
 */
 static SPObject* split_text_object_tree_at(SPObject *split_obj, unsigned char_index)
 {
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(split_obj));
+    Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(split_obj)->getReprDoc();
     if (is_line_break_object(split_obj)) {
         Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, SP_OBJECT_REPR(split_obj));
         SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->addChild(new_node, SP_OBJECT_REPR(split_obj));
         Inkscape::GC::release(new_node);
-        split_attributes(split_obj, SP_OBJECT_NEXT(split_obj), char_index);
-        return SP_OBJECT_NEXT(split_obj);
+        split_attributes(split_obj, split_obj->getNext(), char_index);
+        return split_obj->getNext();
     }
 
     unsigned char_count_before = sum_sibling_text_lengths_before(split_obj);
@@ -336,10 +347,10 @@ static SPObject* split_text_object_tree_at(SPObject *split_obj, unsigned char_in
     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 +387,12 @@ Inkscape::Text::Layout::iterator sp_te_insert_line (SPItem *item, Inkscape::Text
         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 +431,17 @@ static SPString* sp_te_seek_next_string_recursive(SPObject *start_obj)
     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);
         }
-        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 +511,12 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
             if (source_obj->hasChildren()) {
                 source_obj = source_obj->firstChild();
                 if (SP_IS_FLOWTEXT(item)) {
-                    while (SP_IS_FLOWREGION(source_obj) || SP_IS_FLOWREGIONEXCLUDE(source_obj))
-                        source_obj = SP_OBJECT_NEXT(source_obj);
-                    if (source_obj == NULL)
+                    while (SP_IS_FLOWREGION(source_obj) || SP_IS_FLOWREGIONEXCLUDE(source_obj)) {
+                        source_obj = source_obj->getNext();
+                    }
+                    if (source_obj == NULL) {
                         source_obj = item;
+                    }
                 }
             }
             if (source_obj == item && SP_IS_FLOWTEXT(item)) {
@@ -507,7 +525,7 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
                 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 +625,16 @@ static SPObject* delete_line_break(SPObject *root, SPObject *item, bool *next_is
         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 +789,7 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start,
                 SPObject *next_item;
                 do {
                     bool is_sibling = true;
-                    next_item = SP_OBJECT_NEXT(sub_item);
+                    next_item = sub_item->getNext();
                     if (next_item == NULL) {
                         next_item = SP_OBJECT_PARENT(sub_item);
                         is_sibling = false;
@@ -804,16 +822,19 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start,
 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 +894,8 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str)
     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(text->firstChild());
+        object = text->firstChild();
         is_textpath = true;
     } else {
         repr = SP_OBJECT_REPR (text);
@@ -887,9 +908,10 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str)
     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 +979,7 @@ sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator cons
     // 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;
 
@@ -1015,7 +1037,7 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons
     // 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;
@@ -1121,7 +1143,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it
     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 +1215,7 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
     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) {
@@ -1341,7 +1363,7 @@ static void apply_css_recursive(SPObject *o, SPCSSAttr const *css)
 {
     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 = 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 +1386,12 @@ name of the xml for a text span (ie tspan or flowspan). */
 static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *css, SPObject *start_item, Glib::ustring::iterator start_text_iter, SPObject *end_item, Glib::ustring::iterator end_text_iter, char const *span_object_name)
 {
     bool passed_start = start_item == NULL ? true : false;
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(common_ancestor));
+    Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(common_ancestor)->getReprDoc();
     
-    for (SPObject *child = common_ancestor->firstChild() ; child != NULL ; child = SP_OBJECT_NEXT(child)) {
-        if (start_item == child)
+    for (SPObject *child = common_ancestor->firstChild() ; child ; child = child->getNext()) {
+        if (start_item == child) {
             passed_start = true;
+        }
 
         if (passed_start) {
             if (end_item && child->isAncestorOf(end_item)) {
@@ -1385,7 +1408,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *
 
                 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) {
@@ -1428,7 +1451,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *
                         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;
@@ -1440,7 +1463,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *
                     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 +1516,17 @@ static SPObject* ascend_while_first(SPObject *item, Glib::ustring::iterator text
                       -> abcdef                  */
 static bool tidy_operator_empty_spans(SPObject **item)
 {
-    if ((*item)->hasChildren()) return false;
-    if (is_line_break_object(*item)) return false;
-    if (SP_IS_STRING(*item) && !SP_STRING(*item)->string.empty()) return false;
-    SPObject *next = SP_OBJECT_NEXT(*item);
-    (*item)->deleteObject();
-    *item = next;
-    return true;
+    bool result = false;
+    if ( !(*item)->hasChildren()
+         && !is_line_break_object(*item)
+         && !(SP_IS_STRING(*item) && !SP_STRING(*item)->string.empty())
+        ) {
+        SPObject *next = (*item)->getNext();
+        (*item)->deleteObject();
+        *item = next;
+        result = true;
+    }
+    return result;
 }
 
 /**    inexplicable spans: abc<span style="">def</span>ghi
@@ -1507,7 +1534,8 @@ static bool tidy_operator_empty_spans(SPObject **item)
 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.
+    if (*item && sp_repr_is_meta_element((*item)->getRepr())) return false;
     if (SP_IS_STRING(*item)) return false;
     if (is_line_break_object(*item)) return false;
     TextTagAttributes *attrs = attributes_for_object(*item);
@@ -1520,7 +1548,7 @@ static bool tidy_operator_inexplicable_spans(SPObject **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;
@@ -1532,7 +1560,7 @@ static bool tidy_operator_inexplicable_spans(SPObject **item)
 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 +1633,12 @@ static bool redundant_double_nesting_processor(SPObject **item, SPObject *child,
     if (attrs && attrs->anyAttributesSet()) return false;
     if (!objects_have_equal_style(SP_OBJECT_PARENT(*item), child)) return false;
 
-    Inkscape::XML::Node *insert_after_repr;
-    if (!prepend) insert_after_repr = SP_OBJECT_REPR(*item);
-    else if (SP_OBJECT_PREV(*item)) insert_after_repr = SP_OBJECT_REPR(SP_OBJECT_PREV(*item));
-    else insert_after_repr = NULL;
+    Inkscape::XML::Node *insert_after_repr = 0;
+    if (!prepend) {
+        insert_after_repr = SP_OBJECT_REPR(*item);
+    } else if ((*item)->getPrev()) {
+        insert_after_repr = SP_OBJECT_REPR((*item)->getPrev());
+    }
     while (SP_OBJECT_REPR(child)->childCount()) {
         Inkscape::XML::Node *move_repr = SP_OBJECT_REPR(child)->firstChild();
         Inkscape::GC::anchor(move_repr);
@@ -1673,7 +1703,7 @@ static bool redundant_semi_nesting_processor(SPObject **item, SPObject *child, b
     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 +1733,7 @@ static bool tidy_operator_redundant_semi_nesting(SPObject **item)
 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 +1759,7 @@ static bool tidy_operator_styled_whitespace(SPObject **item)
     SPObject *test_item = *item;
     SPString *next_string;
     for ( ; ; ) {  // find the next string
-        next_string = sp_te_seek_next_string_recursive(SP_OBJECT_NEXT(test_item));
+        next_string = sp_te_seek_next_string_recursive(test_item->getNext());
         if (next_string) {
             next_string->string.insert(0, str);
             break;
@@ -1738,7 +1768,7 @@ static bool tidy_operator_styled_whitespace(SPObject **item)
             test_item = SP_OBJECT_PARENT(test_item);
             if (is_line_break_object(test_item)) break;
             if (SP_IS_FLOWTEXT(test_item)) return false;
-            SPObject *next = SP_OBJECT_NEXT(test_item);
+            SPObject *next = test_item->getNext();
             if (next) {
                 test_item = next;
                 break;
@@ -1753,7 +1783,7 @@ static bool tidy_operator_styled_whitespace(SPObject **item)
     }
     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 +1826,12 @@ static bool tidy_xml_tree_recursively(SPObject *root)
 
     for (SPObject *child = root->firstChild() ; child != NULL ; ) {
         if (SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) || SP_IS_TREF(child)) {
-            child = SP_OBJECT_NEXT(child);
+            child = child->getNext();
             continue;
         }
-        if (child->hasChildren())
+        if (child->hasChildren()) {
             changes |= tidy_xml_tree_recursively(child);
+        }
 
         unsigned i;
         for (i = 0 ; i < sizeof(tidy_operators) / sizeof(tidy_operators[0]) ; i++) {
@@ -1809,8 +1840,9 @@ static bool tidy_xml_tree_recursively(SPObject *root)
                 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 +1870,18 @@ void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &sta
     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
@@ -1871,7 +1908,7 @@ void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &sta
     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 +1957,22 @@ bool is_top_level_text_object (SPObject *obj)
             || SP_IS_FLOWTEXT(obj));
 }
 
-bool has_visible_text (SPObject *obj)
+bool has_visible_text(SPObject *obj)
 {
-    if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) 
-        return true; // maybe we should also check that it's not all whitespace?
+    bool hasVisible = false;
 
-    for (SPObject const *child = obj->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) {
-        if (has_visible_text((SPObject *) child))
-            return true;
+    if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) {
+        hasVisible = true; // maybe we should also check that it's not all whitespace?
+    } else {
+        for (SPObject const *child = obj->firstChild() ; child ; child = child->getNext()) {
+            if (has_visible_text((SPObject *) child)) {
+                hasVisible = true;
+                break;
+            }
+        }
     }
 
-    return false;
+    return hasVisible;
 }
 
 /*
@@ -1942,4 +1984,4 @@ bool has_visible_text (SPObject *obj)
   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 :
index 038458ff7af4eecaf12dda0ecb68b3b3f24cd78d..3d5efbbecb0e508edfc48a2c54e64fc8cdf9741f 100644 (file)
@@ -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,21 @@ typedef std::pair<Inkscape::Text::Layout::iterator, Inkscape::Text::Layout::iter
 
 
 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 +80,4 @@ bool is_part_of_text_subtree (SPObject *obj);
 bool is_top_level_text_object (SPObject *obj);
 bool has_visible_text (SPObject *obj);
 
-#endif
+#endif // SEEN_SP_TEXT_EDITING_H
index e2bd0e9f583581cc9dba0a9fc01c36f06644789a..48d25d0c45c9add015b360b28398094c486c5669 100644 (file)
@@ -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 +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);
 
@@ -264,7 +266,7 @@ Tracer::sioxProcessImage(SPImage *img,
     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 +445,7 @@ void Tracer::traceThread()
         return;
         }
     SPDocument *doc = SP_ACTIVE_DOCUMENT;
-    sp_document_ensure_up_to_date(doc);
+    doc->ensureUpToDate();
 
 
     SPImage *img = getSelectedSPImage();
@@ -482,7 +484,8 @@ void Tracer::traceThread()
         }
 
     //### 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.
+    Inkscape::XML::Node *imgRepr   = SP_OBJECT(img)->getRepr();
     Inkscape::XML::Node *par       = sp_repr_parent(imgRepr);
 
     //### Get some information for the new transform()
@@ -518,7 +521,7 @@ void Tracer::traceThread()
 
     //#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
@@ -549,7 +552,7 @@ void Tracer::traceThread()
         if (reprobj)
             {
             SPItem *newItem = SP_ITEM(reprobj);
-            sp_item_write_transform(newItem, pathRepr, tf, NULL);
+            newItem->doWriteTransform(pathRepr, tf, NULL);
             }
         if (nrPaths == 1)
             {
@@ -568,7 +571,7 @@ void Tracer::traceThread()
         }
 
     //## inform the document, so we can undo
-    sp_document_done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap"));
+    DocumentUndo::done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap"));
 
     engine = NULL;
 
index 29289e053adbb5ce3eabc63719f61e98e6a47ee1..1d0c004a4a40fc448a9cc87da6f729ab8734701c 100644 (file)
@@ -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,8 @@
 
 #include "tweak-context.h"
 
+using Inkscape::DocumentUndo;
+
 #define DDC_RED_RGBA 0xff0000ff
 
 #define DYNA_MIN_WIDTH 1.0e-6
@@ -425,7 +427,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
     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 = item->firstChild() ; child; child = child->getNext() ) {
             if (SP_IS_ITEM(child)) {
                 children = g_slist_prepend(children, child);
             }
@@ -442,7 +444,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
     } 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;
@@ -455,7 +457,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } 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;
@@ -469,7 +471,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } 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);
@@ -484,7 +486,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } 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;
@@ -497,7 +499,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } 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;
@@ -510,7 +512,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
         } 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;
@@ -524,7 +526,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
                             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();
@@ -562,7 +564,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
 
 
         // 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)) {
@@ -580,7 +582,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::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 +803,7 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
     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
@@ -863,10 +865,10 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
     double offset_l = 0;
     double offset_h = 0;
     SPObject *child_prev = NULL;
-    for (SPObject *child = sp_object_first_child(vector);
-         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 +925,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
     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 = 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,
@@ -940,7 +942,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
         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;
@@ -970,14 +972,14 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
         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 +1062,7 @@ sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::P
     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 +1260,56 @@ sp_tweak_context_root_handler(SPEventContext *event_context,
             tc->has_dilated = false;
             switch (tc->mode) {
                 case TWEAK_MODE_MOVE:
-                    sp_document_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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     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),
-                                     SP_VERB_CONTEXT_TWEAK, _("Blur tweak"));
+                    DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop),
+                                       SP_VERB_CONTEXT_TWEAK, _("Blur tweak"));
                     break;
             }
         }
index 90a9ba0f548e3a80f9a96b421a199a6017e4a790..d405afb8f6ec9b33ce237247f37e1c82e9fa7924 100644 (file)
@@ -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 +336,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place)
     }
 
     _pasteDocument(desktop, tempdoc, in_place);
-    sp_document_unref(tempdoc);
+    tempdoc->doUnref();
 
     return true;
 }
@@ -350,8 +351,7 @@ const gchar *ClipboardManagerImpl::getFirstObjectID()
         return NULL;
     }
 
-    Inkscape::XML::Node
-        *root = sp_document_repr_root(tempdoc);
+    Inkscape::XML::Node *root = tempdoc->getReprRoot();
 
     if (!root) {
         return NULL;
@@ -405,9 +405,8 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
         }
     }
 
-    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;
 
@@ -421,7 +420,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
         _userWarn(desktop, _("No style on the clipboard."));
     }
 
-    sp_document_unref(tempdoc);
+    tempdoc->doUnref();
     return pasted;
 }
 
@@ -455,7 +454,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
     }
 
     // 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) {
@@ -467,7 +466,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
         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;
                 }
@@ -484,7 +483,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
         }
         pasted = true;
     }
-    sp_document_unref(tempdoc);
+    tempdoc->doUnref();
     return pasted;
 }
 
@@ -509,7 +508,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
 
     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 +543,11 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop)
         _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 +566,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
         _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 ) {
@@ -577,7 +575,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
 
     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 +613,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
         // 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);
     }
@@ -702,7 +700,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
     }
     // Copy text paths
     if (SP_IS_TEXT_TEXTPATH(item)) {
-        _copyTextPath(SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item))));
+        _copyTextPath(SP_TEXTPATH(item->firstChild()));
     }
     // Copy clipping objects
     if (item->clip_ref->getObject()) {
@@ -759,7 +757,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
         _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 = pattern->firstChild() ; child ; child = child->getNext() ) {
             if (!SP_IS_ITEM (child)) {
                 continue;
             }
@@ -814,10 +812,9 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node,
 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);
@@ -847,11 +844,11 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo
     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->ensureUpToDate();
 
     // move selection either to original position (in_place) or to mouse pointer
     Geom::OptRect sel_bbox = selection->bounds();
@@ -894,11 +891,10 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc)
 {
     // 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 +1197,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
             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 +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);
@@ -1280,7 +1276,7 @@ void ClipboardManagerImpl::_createInternalClipboard()
 void ClipboardManagerImpl::_discardInternalClipboard()
 {
     if ( _clipboardSPDoc != NULL ) {
-        sp_document_unref(_clipboardSPDoc);
+        _clipboardSPDoc->doUnref();
         _clipboardSPDoc = NULL;
         _defs = NULL;
         _doc = NULL;
index 262fdcf32de710975a884b55186c7c1ab02a7dc8..c544d1999491ad4b599803618baca6d241e9d11a 100644 (file)
@@ -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,8 @@
 #include "preferences.h"
 #include "ui/dialog/dialog-manager.h"
 
+using Inkscape::DocumentUndo;
+
 static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu);
 
 /* Append object-specific part to context menu */
@@ -274,7 +276,7 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item)
     SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop");
     g_return_if_fail(desktop != NULL);
 
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+    Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
     Inkscape::XML::Node *repr = xml_doc->createElement("svg:a");
     SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item));
     SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr);
@@ -289,8 +291,8 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item)
     Inkscape::GC::release(repr);
     Inkscape::GC::release(child);
 
-    sp_document_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");
 
index c66cd4e965aae06a312a5d88f94ab8ea7198d42f..36846edc3c4ad928c1d1c4d7f3b92754aae86377 100644 (file)
@@ -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 +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);
index 8d467d53f331164f701d1a8d2ab68509a1dacbfe..8db5e7c0b1bef4e1bf70f7a427ba43df23be5c5e 100644 (file)
@@ -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 +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);
 
@@ -155,14 +156,14 @@ Gtk::Widget *build_splash_widget() {
     if ( version && SP_IS_TEXT(version) ) {
         sp_te_set_repr_text_multiline (SP_TEXT (version), Inkscape::version_string);
     }
-    sp_document_ensure_up_to_date(doc);
+    doc->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..48f0fbf22ee3eaf0a6f7b59e47da5f8ee4463113 100644 (file)
@@ -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 +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]);
@@ -163,14 +165,13 @@ private :
         }
 
         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_desktop_document(desktop)->getRoot() )->getBboxDesktop();
             if (b) {
                 mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
                                a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
@@ -216,9 +217,9 @@ private :
              it != selected.end();
              it++)
         {
-            sp_document_ensure_up_to_date(sp_desktop_document (desktop));
+            sp_desktop_document (desktop)->ensureUpToDate();
             if (!sel_as_group)
-                b = sp_item_bbox_desktop (*it);
+                b = (*it)->getBboxDesktop();
             if (b) {
                 Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X],
                                      a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]);
@@ -234,8 +235,8 @@ private :
         prefs->setInt("/options/clonecompensation/value", saved_compensation);
 
         if (changed) {
-            sp_document_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 +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));
             }
@@ -393,8 +394,8 @@ private :
         prefs->setInt("/options/clonecompensation/value", saved_compensation);
 
         if (changed) {
-            sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
-                               _("Distribute"));
+            DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+                                _("Distribute"));
         }
     }
     guint _index;
@@ -504,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,
-                         _("Remove overlaps"));
+        DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+                           _("Remove overlaps"));
     }
 };
 
@@ -535,8 +536,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,
-                         _("Arrange connector network"));
+        DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+                           _("Arrange connector network"));
     }
 };
 
@@ -628,10 +629,11 @@ private :
         // 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;
 
@@ -661,8 +663,8 @@ private :
         // restore compensation setting
         prefs->setInt("/options/clonecompensation/value", saved_compensation);
 
-        sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
-                          _("Unclump"));
+        DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
+                           _("Unclump"));
     }
 };
 
@@ -715,8 +717,8 @@ private :
             it != selected.end();
             ++it)
         {
-            sp_document_ensure_up_to_date(sp_desktop_document (desktop));
-            Geom::OptRect item_box = sp_item_bbox_desktop (*it);
+            sp_desktop_document (desktop)->ensureUpToDate();
+            Geom::OptRect item_box = (*it)->getBboxDesktop ();
             if (item_box) {
                 // find new center, staying within bbox
                 double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 +
@@ -732,8 +734,8 @@ private :
         // restore compensation setting
         prefs->setInt("/options/clonecompensation/value", saved_compensation);
 
-        sp_document_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 +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];
@@ -831,8 +833,8 @@ private :
             }
 
             if (changed) {
-                sp_document_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 {
@@ -844,7 +846,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();
                         Geom::Point t(0.0, 0.0);
                         t[_orientation] = b_min[_orientation] - base[_orientation];
                         sp_item_move_rel(*it, Geom::Translate(t));
@@ -854,8 +856,8 @@ private :
             }
 
             if (changed) {
-                sp_document_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"));
             }
         }
     }
@@ -1239,7 +1241,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
     {
         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) {
@@ -1256,7 +1258,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
     {
         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) {
index 97603a8a2a1786666f7fe39d7e209a6d410f1e24..9f163c00c495eee5dfb3bc1c18463b86bfb06ef0 100644 (file)
@@ -3,6 +3,7 @@
  */
 /* Authors:
  *   Jon A. Cruz
+ *   Abhishek Sharma
  *
  * Copyright (C) 2010 Jon A. Cruz
  *
@@ -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
@@ -486,7 +487,7 @@ void ColorItem::_updatePreviews()
                     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 +721,7 @@ void ColorItem::buttonClicked(bool secondary)
         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() );
+        DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() );
     }
 }
 
index f22509496ec8685cc96c32241da718e55b660524..16212bef7fb830a3830ddfdacf39aa755348226a 100644 (file)
@@ -8,6 +8,8 @@
  *   Jon Phillips <jon@rejon.org>
  *   Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
  *   Diederik van Lierop <mail@diedenrezi.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006-2008 Johan Engelen  <johan@shouraizou.nl>
  * Copyright (C) 2000 - 2008 Authors
@@ -404,7 +406,7 @@ DocumentProperties::linkSelectedProfile()
             g_warning("No color profile available.");
             return;
         }
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+        Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
         Inkscape::XML::Node *cprofRepr = xml_doc->createElement("svg:color-profile");
         gchar* tmp = static_cast<gchar*>(_menu.get_active()->get_data("name"));
         Glib::ustring nameStr = tmp ? tmp : "profile"; // TODO add some auto-numbering to avoid collisions
@@ -426,7 +428,7 @@ DocumentProperties::linkSelectedProfile()
         //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"));
+        DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile"));
 
         populate_linked_profiles_box();
     }
@@ -436,7 +438,7 @@ void
 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->getResourceList( "iccprofile" );
     if (current) _emb_profiles_observer.set(SP_OBJECT(current->data)->parent);
     while ( current ) {
         SPObject* obj = SP_OBJECT(current->data);
@@ -493,13 +495,15 @@ void DocumentProperties::removeSelectedProfile(){
         }
     }
 
-    const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "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.
+            sp_repr_unparent(obj->getRepr());
+            DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile"));
         }
         current = g_slist_next(current);
     }
@@ -565,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->getResourceList( "defs" );
     if (current) {
         _emb_profiles_observer.set(SP_OBJECT(current->data)->parent);
     }
@@ -623,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->getResourceList( "script" );
     if (current) {
         _ext_scripts_observer.set(SP_OBJECT(current->data)->parent);
     }
@@ -636,7 +640,7 @@ void DocumentProperties::addExternalScript(){
     if (!desktop){
         g_warning("No active desktop");
     } else {
-        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+        Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
         Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script");
         scriptRepr->setAttribute("xlink:href", (gchar*) _script_entry.get_text().c_str());
         _script_entry.set_text("");
@@ -644,7 +648,7 @@ void DocumentProperties::addExternalScript(){
         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..."));
+        DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script..."));
 
         populate_external_scripts_box();
     }
@@ -662,13 +666,15 @@ void DocumentProperties::removeExternalScript(){
         }
     }
 
-    const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "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.
+            sp_repr_unparent(obj->getRepr());
+            DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script"));
         }
         current = g_slist_next(current);
     }
@@ -679,7 +685,7 @@ void DocumentProperties::removeExternalScript(){
 
 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->getResourceList( "script" );
     if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent);
     while ( current ) {
         SPObject* obj = SP_OBJECT(current->data);
@@ -798,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 +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"));
+        DocumentUndo::done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid"));
     }
 }
 
index fbfdc4a9b5fca13c9b63a69de84e0a898dfc207a..855d5a223c6f71dcb58a57c07a13468dcf6d7696 100644 (file)
@@ -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 +124,9 @@ findExpanderWidgets(Gtk::Container *parent,
 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 +152,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName)
      * 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;
@@ -159,7 +160,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName)
 
     setDocument(doc);
 
-    sp_document_unref(doc);
+    doc->doUnref();
 
     return true;
 }
@@ -172,7 +173,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer)
         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;
@@ -180,7 +181,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer)
 
     setDocument(doc);
 
-    sp_document_unref(doc);
+    doc->doUnref();
 
     Inkscape::GC::request_early_collection();
 
index e2bf47db928b1652a20990518374ee2231ff8a5f..65bb49f1376bca4febbe1a342b7fd64278aae886 100644 (file)
@@ -4,6 +4,7 @@
 /* Authors:
  *   Joel Holdsworth
  *   The Inkscape Organization
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2008 The Inkscape Organization
  *
@@ -906,20 +907,20 @@ bool FileOpenDialogImplWin32::set_svg_preview()
 
     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;
@@ -936,9 +937,9 @@ bool FileOpenDialogImplWin32::set_svg_preview()
 
     // 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->ensureUpToDate ();
+    static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea,
+        static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE);
 
     NRArena *const arena = NRArena::create();
 
@@ -968,7 +969,7 @@ bool FileOpenDialogImplWin32::set_svg_preview()
     // Fail if the pixblock failed to allocate
     if(pixBlock.data.px == NULL)
     {
-        sp_document_unref(svgDoc);
+        svgDoc->doUnref();
         return false;
     }
 
@@ -980,7 +981,7 @@ bool FileOpenDialogImplWin32::set_svg_preview()
     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);
 
index bee6b7c9da7e73badd35517a9f3e9d26bd390ad3..ed7103be3c801a91fc4628d271e403d0e13c38b1 100644 (file)
@@ -5,6 +5,8 @@
  *   Nicholas Bishop <nicholasbishop@gmail.org>
  *   Rodrigo Kumpera <kumpera@gmail.com>
  *   Felipe C. da S. Sanches <juca@members.fsf.org>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007 Authors
  *
@@ -1021,16 +1023,18 @@ 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.
+                    sp_repr_unparent(child->getRepr());
 
                 if(ls != -1) {
-                    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(_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"));
+                DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source"));
                 update();
             }
 
@@ -1142,8 +1146,7 @@ void FilterEffectsDialog::FilterModifier::on_activate_desktop(Application*, SPDe
 
     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)->connectResourcesChanged("filter",sigc::mem_fun(me, &FilterModifier::update_filters));
 
     me->_dialog.setDesktop(desktop);
 
@@ -1214,7 +1217,7 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa
     if(iter) {
         SPFilter* filter = (*iter)[_columns.filter];
         filter->setLabel(text.c_str());
-        sp_document_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 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri
         }
 
         update_selection(sel);
-        sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS,  _("Apply filter"));
+        DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS,  _("Apply filter"));
     }
 }
 
@@ -1260,7 +1263,7 @@ void FilterEffectsDialog::FilterModifier::update_filters()
 {
     SPDesktop* desktop = _dialog.getDesktop();
     SPDocument* document = sp_desktop_document(desktop);
-    const GSList* filters = sp_document_get_resource_list(document, "filter");
+    const GSList* filters = document->getResourceList("filter");
 
     _model->clear();
 
@@ -1326,7 +1329,7 @@ void FilterEffectsDialog::FilterModifier::add_filter()
 
     select_filter(filter);
 
-    sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter"));
 }
 
 void FilterEffectsDialog::FilterModifier::remove_filter()
@@ -1335,9 +1338,11 @@ 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.
+        sp_repr_unparent(filter->getRepr());
+
+        DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter"));
 
         update_filters();
     }
@@ -1352,7 +1357,7 @@ void FilterEffectsDialog::FilterModifier::duplicate_filter()
         repr = repr->duplicate(repr->document());
         parent->appendChild(repr);
 
-        sp_document_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 @@ void FilterEffectsDialog::PrimitiveList::update()
             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.
+                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 @@ void FilterEffectsDialog::PrimitiveList::remove_selected()
     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_document_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 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
                     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.
+                            sp_repr_unparent(o->getRepr());
+                            DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS,
+                                               _("Remove merge node"));
                             (*get_selection()->get_selected())[_columns.primitive] = prim;
                         }
                         else
@@ -1925,10 +1935,12 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
                 }
                 // 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.
+                    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 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra
 
     filter->requestModified(SP_OBJECT_MODIFIED_FLAG);
 
-    sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive"));
+    DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive"));
 }
 
 // If a connection is dragged towards the top or bottom of the list, the list should scroll to follow.
@@ -2263,7 +2275,7 @@ void FilterEffectsDialog::add_primitive()
 
         _primitive_list.select(prim);
 
-        sp_document_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 +2371,7 @@ void FilterEffectsDialog::duplicate_primitive()
         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"));
+        DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive"));
 
         _primitive_list.update();
     }
@@ -2411,8 +2423,8 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons
 
             Glib::ustring undokey = "filtereffects:";
             undokey += name;
-            sp_document_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 +2479,9 @@ void FilterEffectsDialog::update_settings_view()
     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.
+        _settings->show_and_update(FPConverter.get_id_from_key(prim->getRepr()->name()), prim);
         _empty_settings.hide();
     }
 
index 7fad00f56d32eea7afc716e75d2e6c4a433d8fed..b6d6a0319cd122d7fe855be03ce5f47b1a086c78 100644 (file)
@@ -4,6 +4,8 @@
  * Authors:
  *   Bryce W. Harrington <bryce@bryceharrington.org>
  *   Johan Engelen <goejendaagh@zonnet.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2006 Authors
  *
@@ -76,8 +78,8 @@ Find::Find()
       _check_texts(_("Texts"), _("Search text objects")),
       _check_groups(_("Groups"), _("Search groups")),
       _check_clones(
-                  //TRANSLATORS: "Clones" is a noun indicating type of object to find
-                 C_("Find dialog", "Clones"), _("Search clones")),
+                    //TRANSLATORS: "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 @@ Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked)
     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->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 @@ 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);
index 5e66ca9b8960edbca6150278f5381d29ab9389db..f3d7ed9711a54219f545d9230685714e4c995872 100644 (file)
@@ -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 +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 +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"));
+            DocumentUndo::done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text"));
         }
     }
 }
index aac6024b9341c8ded3c8f1c2ada827fb49ee9b31..1ab0d51bc6f1a86bdfe3c95c264901c8883c65d8 100644 (file)
@@ -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 +109,8 @@ void GuidelinePropertiesDialog::_onApply()
 
     sp_guide_moveto(*_guide, newpos, true);
 
-    sp_document_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 +122,8 @@ void GuidelinePropertiesDialog::_onDelete()
 {
     SPDocument *doc = SP_OBJECT_DOCUMENT(_guide);
     sp_guide_remove(_guide);
-    sp_document_done(doc, SP_VERB_NONE, 
-                     _("Delete guide"));
+    DocumentUndo::done(doc, SP_VERB_NONE, 
+                       _("Delete guide"));
 }
 
 void GuidelinePropertiesDialog::_response(gint response)
@@ -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] ) );
index 07e1ff43052a02bec77f857367a7bdd70b672e2e..b507d9f9af4f05911483935289211c44d8764a9b 100644 (file)
@@ -5,6 +5,7 @@
  *   Jon A. Cruz
  *   Bob Jamison
  *   Other dudes from The Inkscape Organization
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004 Bob Jamison
  * Copyright (C) 2005,2010 Jon A. Cruz
@@ -443,10 +444,9 @@ void IconPreviewPanel::renderPreview( SPObject* obj )
     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( doc->getRoot() )->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY );
 
     for ( int i = 0; i < numEntries; i++ ) {
         guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i] );
@@ -462,7 +462,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj )
     }
     updateMagnify();
 
-    sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), visionkey);
+    SP_ITEM(doc->getRoot())->invoke_hide(visionkey);
     nr_object_unref((NRObject *) arena);
     renderTimer->stop();
     minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 );
index 1728ff3a6d95c9723d6fbf7140abae87b6812483..bf15bcd76af9103ff5828142c87d971a83895a40 100644 (file)
@@ -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 +106,8 @@ LayerPropertiesDialog::_apply()
     g_assert(_strategy != NULL);
 
     _strategy->perform(*this);
-    sp_document_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 +189,8 @@ void LayerPropertiesDialog::Rename::perform(LayerPropertiesDialog &dialog) {
                                          (gchar *)name.c_str(),
                                          FALSE
     );
-    sp_document_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"));
 }
index c3c0ae3c5b946bcfb6e15f2690e12433946f2cfc..0eca5bbca2435947c64d62dbc47a9630a99d85c6 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Authors:
  *   Jon A. Cruz
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006,2010 Jon A. Cruz
  *
@@ -468,8 +469,8 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol )
                 row[_model->_colVisible] = newValue;
                 item->setHidden( !newValue  );
                 item->updateRepr();
-                sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS,
-                                  newValue? _("Unhide layer") : _("Hide layer"));
+                DocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS,
+                                    newValue? _("Unhide layer") : _("Hide layer"));
             }
             break;
 
@@ -479,8 +480,8 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol )
                 row[_model->_colLocked] = newValue;
                 item->setLocked( newValue );
                 item->updateRepr();
-                sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS,
-                                  newValue? _("Lock layer") : _("Unlock layer"));
+                DocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS,
+                                    newValue? _("Lock layer") : _("Unlock layer"));
             }
             break;
         }
@@ -766,7 +767,7 @@ void LayersPanel::setDesktop( SPDesktop* desktop )
         }
     }
 /*
-    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);
index 706a84733932685d29ad568bec02459fe8b2dc29..bf60fe059471b7d465bdc839426dc09b4758a4d4 100644 (file)
@@ -5,6 +5,7 @@
  *   Johan Engelen <j.b.c.engelen@utwente.nl>
  *   Steren Giannini <steren.giannini@gmail.com>
  *   Bastien Bouclet <bgkweb@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2007 Authors
  * Released under GNU GPL.  Read the file 'COPYING' for more information.
@@ -376,8 +377,8 @@ LivePathEffectEditor::onApply()
 
             LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item);
 
-            sp_document_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 +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,
-                               _("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 +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,
-                               _("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 +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,
-                               _("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 +466,8 @@ void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str )
         /* 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,
-                          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"));
     }
 }
 
index 2456e10daa69931b9728436b7120af8b6e304b0d..a56cbfd9d65dd6066d4126c9cd5df143ba52f9dc 100644 (file)
@@ -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 +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 +182,7 @@ Print::Print(SPDocument *doc, SPItem *base) :
     _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;
@@ -190,8 +191,8 @@ Print::Print(SPDocument *doc, SPItem *base) :
     // 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);
index 51b206a85b7cb72110dbebd6fefcf089aa7bccb6..d8ff8ca56efac3466e6e0c9c6abb636777eb3ebb 100644 (file)
@@ -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 +172,7 @@ SessionPlaybackDialogImpl::_respCallback(int resp)
                        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());
index 1f11a412e9fb0ecb2b6ddd4ad5df4652a19d385c..042acb6e1b3e16a4e22620d16115998f2b164d20 100644 (file)
@@ -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 +119,8 @@ void SvgFontsDialog::AttrEntry::on_attr_changed(){
 
         Glib::ustring undokey = "svgfonts:";
         undokey += name;
-        sp_document_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 +165,17 @@ void SvgFontsDialog::on_kerning_value_changed(){
     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.
+    this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str());
+    DocumentUndo::maybeDone(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value"));
 
     //populate_kerning_pairs_box();
     kerning_preview.redraw();
@@ -243,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->getResourceList("font");
 
     _model->clear();
     for(const GSList *l = fonts; l; l = l->next) {
@@ -423,7 +427,7 @@ SvgFontsDialog::populate_kerning_pairs_box()
 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 +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"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph"));
 
     update_glyphs();
 }
@@ -505,8 +509,9 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){
         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));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
 
     update_glyphs();
 }
@@ -547,8 +552,10 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
     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.
+            obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv));
+            DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
         }
     }
 
@@ -566,8 +573,9 @@ void SvgFontsDialog::reset_missing_glyph_description(){
     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.
+            obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
+            DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph"));
         }
     }
 
@@ -579,10 +587,11 @@ void SvgFontsDialog::glyph_name_edit(const Glib::ustring&, const Glib::ustring&
     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.
+    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"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name"));
 
     update_glyphs();
 }
@@ -592,10 +601,11 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin
     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.
+    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"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode"));
 
     update_glyphs();
 }
@@ -604,9 +614,10 @@ 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.
+    sp_repr_unparent(font->getRepr());
     SPDocument* doc = sp_desktop_document(this->getDesktop());
-    sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font"));
 
     update_fonts();
 }
@@ -618,10 +629,12 @@ void SvgFontsDialog::remove_selected_glyph(){
     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"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph"));
 
     update_glyphs();
 }
@@ -633,10 +646,12 @@ void SvgFontsDialog::remove_selected_kerning_pair(){
     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"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair"));
 
     update_glyphs();
 }
@@ -707,11 +722,10 @@ void SvgFontsDialog::add_kerning_pair(){
     if (this->kerning_pair) return; //We already have this kerning pair
 
     SPDocument* document = sp_desktop_document(this->getDesktop());
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Document *xml_doc = document->getReprDoc();
 
     // create a new hkern node
-    Inkscape::XML::Node *repr;
-    repr = xml_doc->createElement("svg:hkern");
+    Inkscape::XML::Node *repr = xml_doc->createElement("svg:hkern");
 
     repr->setAttribute("u1", first_glyph.get_active_text().c_str());
     repr->setAttribute("u2", second_glyph.get_active_text().c_str());
@@ -724,7 +738,7 @@ void SvgFontsDialog::add_kerning_pair(){
     // get corresponding object
     this->kerning_pair = SP_HKERN( document->getObjectByRepr(repr) );
 
-    sp_document_done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair"));
+    DocumentUndo::done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair"));
 }
 
 Gtk::VBox* SvgFontsDialog::kerning_tab(){
@@ -774,11 +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 +826,12 @@ void set_font_family(SPFont* font, char* str){
     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.
+            obj->getRepr()->setAttribute("font-family", str);
         }
     }
 
-    sp_document_done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family"));
+    DocumentUndo::done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family"));
 }
 
 void SvgFontsDialog::add_font(){
@@ -833,14 +847,15 @@ 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.
+            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"));
+    DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font"));
 }
 
 SvgFontsDialog::SvgFontsDialog()
index 4c8a018fa5c2a8ae131dc022fb4eda3015482b3f..b2b1b26da5372ffa90117f8302a27e68f6588f9f 100644 (file)
@@ -5,6 +5,7 @@
 /* Authors:
  *   Jon A. Cruz
  *   John Bintz
+ *   Abhishek Sharma
  *
  * Copyright (C) 2005 Jon A. Cruz
  * Copyright (C) 2008 John Bintz
@@ -155,7 +156,7 @@ static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
         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->getResourceList("gradient");
             for (const GSList *item = gradients; item; item = item->next) {
                 SPGradient* grad = SP_GRADIENT(item->data);
                 if ( targetName == grad->getId() ) {
@@ -177,13 +178,13 @@ void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer us
         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");
+            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;
                 }
             }
@@ -199,13 +200,13 @@ void SwatchesPanelHook::deleteGradient( GtkMenuItem */*menuitem*/, gpointer /*us
         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->getResourceList("gradient");
             for (const GSList *item = gradients; item; item = item->next) {
                 SPGradient* grad = SP_GRADIENT(item->data);
                 if ( targetName == grad->getId() ) {
                     grad->setSwatch(false);
-                    sp_document_done(doc, SP_VERB_CONTEXT_GRADIENT,
-                                     _("Delete"));
+                    DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT,
+                                       _("Delete"));
                     break;
                 }
             }
@@ -320,7 +321,7 @@ gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, g
                     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())->getResourceList("gradient");
                         gint index = 0;
                         for (const GSList *curr = gradients; curr; curr = curr->next) {
                             SPGradient* grad = SP_GRADIENT(curr->data);
@@ -773,7 +774,7 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document )
             }
             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->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 +812,7 @@ static void recalcSwatchContents(SPDocument* doc,
 {
     std::vector<SPGradient*> newList;
 
-    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 ( grad->isSwatch() ) {
@@ -967,7 +968,8 @@ void SwatchesPanel::_updateFromSelection()
                             }
                         }
                         if ( target ) {
-                            gchar const* id = target->repr->attribute("id");
+                            //XML Tree being used directly here while it shouldn't be
+                            gchar const* id = target->getRepr()->attribute("id");
                             if ( id ) {
                                 fillId = id;
                             }
@@ -998,7 +1000,8 @@ void SwatchesPanel::_updateFromSelection()
                             }
                         }
                         if ( target ) {
-                            gchar const* id = target->repr->attribute("id");
+                            //XML Tree being used directly here while it shouldn't be
+                            gchar const* id = target->getRepr()->attribute("id");
                             if ( id ) {
                                 strokeId = id;
                             }
index b506109383cc8d2f7080ea9b0c94a9c8fca76da6..fccf5c105bbcb01c1210e6fc147c169f857ad7f6 100644 (file)
@@ -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 +47,8 @@ sp_compare_x_position(SPItem *first, SPItem *second)
     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 +87,8 @@ sp_compare_x_position(SPItem *first, SPItem *second)
 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 +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)->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;
         }
@@ -209,7 +210,7 @@ void TileDialog::Grid_Arrange ()
         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 +317,7 @@ g_print("\n row = %f     col = %f selection x= %f selection y = %f", total_row_h
              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];
@@ -336,16 +337,16 @@ g_print("\n row = %f     col = %f selection x= %f selection y = %f", total_row_h
                  // 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,
-                      _("Arrange in a grid"));
+    DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GRIDTILE,
+                       _("Arrange in a grid"));
 
 }
 
index 338e11d38bfca6896321f74798db7ad438ed7dd8..c895f0be9d3650e92a745e7a19496a6bcd032b92 100644 (file)
@@ -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.
@@ -636,7 +637,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
                      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.));
                     }
@@ -660,7 +661,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
                      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.));
                     }
@@ -687,8 +688,8 @@ Transformation::applyPageMove(Inkscape::Selection *selection)
         }
     }
 
-    sp_document_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 +705,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection)
             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
@@ -744,8 +745,8 @@ Transformation::applyPageScale(Inkscape::Selection *selection)
         }
     }
 
-    sp_document_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 +767,8 @@ Transformation::applyPageRotate(Inkscape::Selection *selection)
         }
     }
 
-    sp_document_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 +792,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection)
             } 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];
@@ -825,8 +826,8 @@ Transformation::applyPageSkew(Inkscape::Selection *selection)
         }
     }
 
-    sp_document_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 +846,15 @@ Transformation::applyPageTransform(Inkscape::Selection *selection)
     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,
-                     _("Edit transformation matrix"));
+    DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM,
+                       _("Edit transformation matrix"));
 }
 
 
index 111dc014d5841462475d78a7b6375a1349c76a38..17d0327581634fe5791dac201d220c6006922d4c 100644 (file)
@@ -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 +215,7 @@ UndoHistory::_onListSelectionChange()
 
             _event_log->blockNotifications();
             for ( --last ; curr_event != last ; ++curr_event ) {
-                sp_document_redo(_document);
+                DocumentUndo::redo(_document);
             }
             _event_log->blockNotifications(false);
 
@@ -248,7 +249,7 @@ UndoHistory::_onListSelectionChange()
 
             while ( selected != last_selected ) {
 
-                sp_document_undo(_document);
+                DocumentUndo::undo(_document);
 
                 if ( last_selected->parent() &&
                      last_selected == last_selected->parent()->children().begin() )
@@ -273,7 +274,7 @@ UndoHistory::_onListSelectionChange()
 
             while ( selected != last_selected ) {
 
-                sp_document_redo(_document);
+                DocumentUndo::redo(_document);
 
                 if ( !last_selected->children().empty() ) {
                     _event_log->setCurrEventParent(last_selected);
@@ -317,10 +318,10 @@ UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::T
         EventLog::const_iterator last = curr_event_parent->children().end();
 
         _event_log->blockNotifications();
-        sp_document_redo(_document);
+        DocumentUndo::redo(_document);
 
         for ( --last ; curr_event != last ; ++curr_event ) {
-            sp_document_redo(_document);
+            DocumentUndo::redo(_document);
         }
         _event_log->blockNotifications(false);
 
index 82446b7b438247675bfc0b44117f4d551458851e..ef1c764bbb35c0f35161a42093fa59e2c0c1dad8 100644 (file)
@@ -3,6 +3,7 @@
  */
 /* Authors:
  *   Krzysztof KosiÅ„ski <tweenk.pl@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2009 Authors
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -706,9 +707,9 @@ void MultiPathManipulator::_commit(CommitEvent cps)
     _selection.signal_update.emit();
     invokeForAll(&PathManipulator::writeXML);
     if (key) {
-        sp_document_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);
+        DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason);
     }
     signal_coords_changed.emit();
 }
@@ -717,7 +718,7 @@ void MultiPathManipulator::_commit(CommitEvent cps)
 void MultiPathManipulator::_done(gchar const *reason) {
     invokeForAll(&PathManipulator::update);
     invokeForAll(&PathManipulator::writeXML);
-    sp_document_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();
 }
 
index e046fb57338b67f5ce9a28878c9ebbe91379113b..8661e79465dbf13ef75c43501da10230c1d3eb5c 100644 (file)
@@ -3,6 +3,7 @@
  */
 /* Authors:
  *   Krzysztof KosiÅ„ski <tweenk@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2009 Authors
  * Released under GNU GPL, read the file 'COPYING' for more information
@@ -365,7 +366,8 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh
     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.
+    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?
@@ -380,7 +382,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh
         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
@@ -481,7 +483,7 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event)
 
             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,
@@ -612,8 +614,7 @@ void ink_node_tool_select_area(InkNodeTool *nt, Geom::Rect const &sel, GdkEventB
     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)->getItemsInBox(nt->desktop->dkey, sel);
         selection->setList(items);
         g_slist_free(items);
     } else {
index bb8ce0fb50722c41dfca5e658fb20ac5ac7e6e05..5ae9c4137255c7ab9cc1db66f7cb700045190448 100644 (file)
@@ -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 +109,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
     , _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)
@@ -119,7 +120,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
     , _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();
     }
@@ -1023,7 +1024,7 @@ void PathManipulator::_externalChange(unsigned type)
         } 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 +1105,9 @@ void PathManipulator::_createControlPointsFromGeometry()
     // 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.
+    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 +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.
+        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 +1301,10 @@ Glib::ustring PathManipulator::_nodetypesKey()
  * 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.
+    if (_lpe_key.empty()) return _path->getRepr();
+    //XML Tree being used here directly while it shouldn't be.
+    return LIVEPATHEFFECT(_path)->getRepr();
 }
 
 bool PathManipulator::_nodeClicked(Node *n, GdkEventButton *event)
@@ -1416,14 +1422,14 @@ void PathManipulator::_removeNodesFromSelection()
 void PathManipulator::_commit(Glib::ustring const &annotation)
 {
     writeXML();
-    sp_document_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,
-            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
index 1b498a846ec018112149d37bbeb6dd1ce5ded556..f05e024d19fd871971114fafe61deb5d10972782 100644 (file)
@@ -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 +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..650ed10f6897dc8bb87991f6ffa4bdd5590780bf 100644 (file)
@@ -1,5 +1,3 @@
-#define __COLOR_PICKER_C__
-
 /** \file
  * \brief  Color picker button & window
  *
@@ -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 +131,8 @@ sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp)
     (ptr->_preview).setRgba32 (rgba);
 
     if (ptr->_undo && SP_ACTIVE_DESKTOP)
-        sp_document_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;
index 968e35b6c053b3e1f7c584c55d279fb070781185..e191a93605cd82c582dbad1f415138b83378d37e 100644 (file)
@@ -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 +22,7 @@
 #include <gtkmm/entry.h>
 
 #include "inkscape.h"
+#include "sp-object.h"
 #include "rdf.h"
 #include "ui/widget/registry.h"
 
@@ -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 +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, 
-                          /* 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 +129,14 @@ EntityMultiLineEntry::~EntityMultiLineEntry()
     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 +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, 
-                          /* 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..c60e94ab724bc84fcf114dafbccc19b570b8133f 100644 (file)
@@ -4,6 +4,7 @@
  * Authors:
  *   Bob Jamison
  *   Other dudes from The Inkscape Organization
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004 The Inkscape Organization
  *
@@ -76,7 +77,7 @@ ImageIcon::ImageIcon(const ImageIcon &other)
 ImageIcon::~ImageIcon()
 {
     if (document)
-        sp_document_unref(document);
+        document->doUnref();
 }
 
 
@@ -98,11 +99,11 @@ bool ImageIcon::showSvgDocument(const SPDocument *docArg)
 {
 
     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 +128,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName)
 
     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;
@@ -135,7 +136,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName)
 
     showSvgDocument(doc);
 
-    sp_document_unref(doc);
+    doc->doUnref();
 
     return true;
 }
@@ -148,7 +149,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer)
         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;
@@ -156,7 +157,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer)
 
     showSvgDocument(doc);
 
-    sp_document_unref(doc);
+    doc->doUnref();
 
     return true;
 }
index 5fb8089b4a3b69fd4bd33ff528f40879c67a29df..6d1da0af09f660561e005a4c16beffc5533890e2 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Authors:
  *   MenTaLguY <mental@rydia.net>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004 MenTaLguY
  *
@@ -583,16 +584,16 @@ void LayerSelector::_prepareLabelRenderer(
 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,
-                         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,
-                         hide? _("Hide layer") : _("Unhide layer"));
+        DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE,
+                           hide? _("Hide layer") : _("Unhide layer"));
     }
 }
 
index a5f1d89be02b6ab48a6965c650270bef7e4dfd4e..c9550bb27604c31167a344dcdb463f218c4ebdf1 100644 (file)
@@ -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 +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, 
-                      /* 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..1de425da376b97856680a119645773f65f6017ea 100644 (file)
@@ -5,6 +5,7 @@
  *   Bryce W. Harrington <bryce@bryceharrington.org>
  *   Gustav Broberg <broberg@kth.se>
  *   Niko Kiirala <niko@kiirala.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004--2008 Authors
  *
@@ -168,7 +169,7 @@ ObjectCompositeSettings::_blendBlurValueChanged()
                                      SP_OBJECT_STYLE_MODIFIED_FLAG ));
     }
 
-    sp_document_maybe_done (document, _blur_tag.c_str(), _verb_code,
+    DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code,
                             _("Change blur"));
 
     // resume interruptibility
@@ -208,7 +209,7 @@ ObjectCompositeSettings::_opacityValueChanged()
 
     sp_repr_css_attr_unref (css);
 
-    sp_document_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
index 724848ca5f17bc39f819c295410c2d7d6210c2f4..f7cb6f145ea2518d2a46eaf218030ec824675676 100644 (file)
@@ -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
  *
@@ -415,14 +416,14 @@ PageSizer::setDim (double w, double h, bool changeList)
 
     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"));
+        DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size"));
     }
 
     if ( w != h ) {
index db31d08d340288573c82cf06bf0ddb0251919dee..04bd272856b2704feb2676071ad0fd97b5d8bcd7 100644 (file)
@@ -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 +350,15 @@ RegisteredColorPicker::on_changed (guint32 rgba)
 
     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 = 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);
+    DocumentUndo::setUndoSensitive(local_doc, saved);
 
     local_doc->setModifiedSinceSave();
-    sp_document_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..efb5eb70edb3f1865ffaa3945f4a4ab945416d53 100644 (file)
@@ -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 +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);
-        if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr);
-        sp_document_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);
+            DocumentUndo::done(local_doc, event_type, event_description);
         }
     }
 
index 7f260680bb6b817a111b2c40050f4a408d5654d1..107f4e8c6ef248088299a21f9094b280f5b2dee1 100644 (file)
@@ -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 +147,15 @@ Ruler::on_button_release_event(GdkEventButton *evb)
         _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, 
-                             /* 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);
     }
index 8e11c8308f10573b0c997b3f816a4548a3994d30..e7d8ac5a36bacd1188a2742c6ae02d05fb586290 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Author:
  *   buliabyak@gmail.com
+ *   Abhishek Sharma
  *
  * Copyright (C) 2005 author
  *
@@ -464,8 +465,8 @@ void SelectedStyle::dragDataReceived( GtkWidget */*widget*/,
                 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,
-                                  _("Drop color"));
+                DocumentUndo::done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE,
+                                    _("Drop color"));
             }
         }
         break;
@@ -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,
-                      _("Remove fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                        _("Remove fill"));
 }
 
 void SelectedStyle::on_stroke_remove() {
@@ -486,8 +487,8 @@ 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,
-                      _("Remove stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Remove stroke"));
 }
 
 void SelectedStyle::on_fill_unset() {
@@ -495,8 +496,8 @@ 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,
-                      _("Unset fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Unset fill"));
 }
 
 void SelectedStyle::on_stroke_unset() {
@@ -511,8 +512,8 @@ 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,
-                      _("Unset stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Unset stroke"));
 }
 
 void SelectedStyle::on_fill_opaque() {
@@ -520,8 +521,8 @@ 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,
-                      _("Make fill opaque"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Make fill opaque"));
 }
 
 void SelectedStyle::on_stroke_opaque() {
@@ -529,8 +530,8 @@ 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,
-                      _("Make fill opaque"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Make fill opaque"));
 }
 
 void SelectedStyle::on_fill_lastused() {
@@ -541,8 +542,8 @@ 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,
-                      _("Apply last set color to fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Apply last set color to fill"));
 }
 
 void SelectedStyle::on_stroke_lastused() {
@@ -553,8 +554,8 @@ 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,
-                      _("Apply last set color to stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Apply last set color to stroke"));
 }
 
 void SelectedStyle::on_fill_lastselected() {
@@ -564,8 +565,8 @@ 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,
-                      _("Apply last selected color to fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Apply last selected color to fill"));
 }
 
 void SelectedStyle::on_stroke_lastselected() {
@@ -575,8 +576,8 @@ 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,
-                      _("Apply last selected color to stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Apply last selected color to stroke"));
 }
 
 void SelectedStyle::on_fill_invert() {
@@ -595,8 +596,8 @@ 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,
-                      _("Invert fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Invert fill"));
 }
 
 void SelectedStyle::on_stroke_invert() {
@@ -615,8 +616,8 @@ 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,
-                      _("Invert stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Invert stroke"));
 }
 
 void SelectedStyle::on_fill_white() {
@@ -627,8 +628,8 @@ 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,
-                      _("White fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("White fill"));
 }
 
 void SelectedStyle::on_stroke_white() {
@@ -639,8 +640,8 @@ 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,
-                      _("White stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("White stroke"));
 }
 
 void SelectedStyle::on_fill_black() {
@@ -651,8 +652,8 @@ 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,
-                      _("Black fill"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Black fill"));
 }
 
 void SelectedStyle::on_stroke_black() {
@@ -663,8 +664,8 @@ 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,
-                      _("Black stroke"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                       _("Black stroke"));
 }
 
 void SelectedStyle::on_fill_copy() {
@@ -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,
-                      _("Paste fill"));
+        DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                           _("Paste fill"));
     }
 }
 
@@ -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,
-                      _("Paste stroke"));
+        DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                           _("Paste stroke"));
     }
 }
 
@@ -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,
-                      _("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 +854,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event)
         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,
-                      _("Change opacity"));
+        DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE,
+                           _("Change opacity"));
         return true;
     }
 
@@ -888,8 +889,8 @@ void SelectedStyle::on_popup_preset(int i) {
     // 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,
-                      _("Change stroke width"));
+    DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES,
+                       _("Change stroke width"));
 }
 
 void
@@ -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,
-                      _("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 +1275,19 @@ RotateableSwatch::do_motion(double by, guint modifier) {
     if (modifier == 3) { // Alt, do nothing
 
     } else if (modifier == 2) { // saturation
-        sp_document_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,
+        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,
+        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 +1316,15 @@ RotateableSwatch::do_release(double by, guint modifier) {
 
     if (modifier == 3) { // Alt, do nothing
     } else if (modifier == 2) { // saturation
-        sp_document_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,
+        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,
+        DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
                                 SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue"));
     }
 
@@ -1397,7 +1398,7 @@ RotateableStrokeWidth::do_motion(double by, guint modifier) {
     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,
+        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 +1412,7 @@ RotateableStrokeWidth::do_release(double by, guint modifier) {
     } else {
         value_adjust(startvalue, by, modifier, true);
         startvalue_set = false;
-        sp_document_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..f4780896b239cbfc2e1426a4e58851f44b6a99d0 100644 (file)
@@ -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 +147,7 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() {
 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();
     }
index 3a36127f4d74bd733e271621fd91642bf2a9b2be..cc179ddbca55b37d8ef2039060906076e67d3866 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Authors:
  *   Ralf Stephan <ralf@ark.in-berlin.de> 
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Authors
  *
@@ -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 = 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);
+    DocumentUndo::setUndoSensitive(doc, saved);
 
     doc->setModifiedSinceSave();
     
index 3226160dc8bacfcacbd9a52f0a87a44bbb77c5fe..1039351a334b6f780b6d8d222fa18da2f963cb1b 100644 (file)
@@ -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 +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 +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 +294,10 @@ unclump_push (SPItem *from, SPItem *what, double dist)
         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 +317,10 @@ unclump_pull (SPItem *to, SPItem *what, double dist)
         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 +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
index a98c84153bf382603295d212b2f69444a4a2690d..c0f9190b1967a6e84be76c2487b4321714921f27 100644 (file)
@@ -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 +19,7 @@
 
 #include "bad-uri-exception.h"
 #include "forward.h"
+#include "sp-object.h"
 
 namespace Inkscape {
 
index d8e27debd009161902a462a1148e3a518aa6e3de..f8e991623ded868fcd43c373feff2f8311bd04b2 100644 (file)
@@ -1,5 +1,3 @@
-#define __VANISHING_POINT_C__
-
 /*
  * Vanishing point for 3D perspectives
  *
@@ -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
  *
@@ -25,6 +24,8 @@
 #include "snap.h"
 #include "sp-namedview.h"
 
+using Inkscape::DocumentUndo;
+
 namespace Box3D {
 
 #define VP_KNOT_COLOR_NORMAL 0xffffff00
@@ -121,8 +122,8 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const *ppointer, guint state, g
             }
             // 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,
-                              _("Split vanishing points"));
+            DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+                              _("Split vanishing points"));
             return;
         }
     }
@@ -166,8 +167,8 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const *ppointer, guint state, g
                 //       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,
-                                  _("Merge vanishing points"));
+                DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
+                                  _("Merge vanishing points"));
 
                 return;
             }
@@ -232,8 +233,8 @@ vp_knot_ungrabbed_handler (SPKnot *knot, guint /*state*/, gpointer data)
     // 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,
-                     _("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;
index 8b5ec9b3bc8d57a7ca0fd23d1e563d96467f4f2f..a218e85dbf7d5359083ebcbbf56e717898bf93ca 100644 (file)
@@ -1,4 +1,3 @@
-#define __SP_VERBS_C__
 /**
  * \file verbs.cpp
  *
@@ -17,6 +16,7 @@
  *   David Turner <novalis@gnu.org>
  *   bulia byak <buliabyak@users.sf.net>
  *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) (date unspecified) Authors
@@ -82,6 +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
@@ -655,7 +657,7 @@ gchar const *Verb::get_tip(void)
                 g_free(shortcutString);
                 shortcutString = 0;
             } else {
-               _full_tip = g_strdup(_(_tip));
+                _full_tip = g_strdup(_(_tip));
             }
         }
         result = _full_tip;
@@ -1128,8 +1130,8 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
             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,
-                                 _("Switch to next layer"));
+                DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_NEXT,
+                                   _("Switch to next layer"));
                 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Switched to next layer."));
             } else {
                 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot go past last layer."));
@@ -1140,8 +1142,8 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
             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,
-                                 _("Switch to previous layer"));
+                DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_PREV,
+                                   _("Switch to previous layer"));
                 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Switched to previous layer."));
             } else {
                 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot go before first layer."));
@@ -1168,7 +1170,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
             SPItem *layer=SP_ITEM(dt->currentLayer());
             g_return_if_fail(layer != NULL);
 
-            SPObject *old_pos=SP_OBJECT_NEXT(layer);
+            SPObject *old_pos = layer->getNext();
 
             switch (verb) {
                 case SP_VERB_LAYER_TO_TOP:
@@ -1185,7 +1187,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
                     break;
             }
 
-            if ( SP_OBJECT_NEXT(layer) != old_pos ) {
+            if ( layer->getNext() != old_pos ) {
                 char const *message = NULL;
                 Glib::ustring description = "";
                 switch (verb) {
@@ -1206,7 +1208,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
                         description = _("Lower layer");
                         break;
                 };
-                sp_document_done(sp_desktop_document(dt), verb, description);
+                DocumentUndo::done(sp_desktop_document(dt), verb, description);
                 if (message) {
                     dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message);
                     g_free((void *) message);
@@ -1237,7 +1239,8 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
                 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 *parent = sp_repr_parent(selected);
                 Inkscape::XML::Node *dup = selected->duplicate(parent->document());
                 parent->addChild(dup, selected);
@@ -1251,8 +1254,8 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
                     dt->setCurrentLayer(new_layer);
                 }
 #endif
-                sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE,
-                                 _("Duplicate layer"));
+                DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE,
+                                   _("Duplicate layer"));
 
                 // TRANSLATORS: this means "The layer has been duplicated."
                 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Duplicated layer."));
@@ -1283,8 +1286,8 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
                     dt->setCurrentLayer(survivor);
                 }
 
-                sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE,
-                                 _("Delete layer"));
+                DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE,
+                                   _("Delete layer"));
 
                 // TRANSLATORS: this means "The layer has been deleted."
                 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Deleted layer."));
@@ -1298,7 +1301,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
                 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"));
+                DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo"));
             }
             break;
         }
@@ -1358,13 +1361,13 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
             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,
-                             _("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,
-                             _("Flip vertically"));
+            DocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL,
+                               _("Flip vertically"));
             break;
         case SP_VERB_OBJECT_SET_MASK:
             sp_selection_set_mask(dt, false, false);
@@ -2192,19 +2195,19 @@ LockAndHideVerb::perform(SPAction *action, void *data, void */*pdata*/)
     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"));
+            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"));
+            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"));
+            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"));
+            DocumentUndo::done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers"));
             break;
         default:
             return;
index d447abf2e1872a4a1010e9887df9cf1fc186c006..7a3e337ded52557484b94d5f626b51bbe21ae2f3 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_DESKTOP_WIDGET_C__
-
 /** \file
  * Desktop widget implementation
  */
@@ -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
@@ -709,8 +709,8 @@ sp_desktop_widget_realize (GtkWidget *widget)
     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 +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 +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);
 
@@ -880,12 +880,12 @@ SPDesktopWidget::shutdown()
             {
                 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;
                 }
 
@@ -900,7 +900,7 @@ SPDesktopWidget::shutdown()
         }
         /* Code to check data loss */
         bool allow_data_loss = FALSE;
-        while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) {
+        while (doc->getReprRoot()->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) {
             GtkWidget *dialog;
 
             /** \todo
@@ -914,7 +914,7 @@ SPDesktopWidget::shutdown()
                 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);
@@ -938,14 +938,14 @@ SPDesktopWidget::shutdown()
             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;
                 }
 
@@ -1575,7 +1575,7 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
 {
     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())->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 +1837,11 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale)
 
     /* 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..4edd434afc503bcd73b357af47f93480b0cfa318 100644 (file)
@@ -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 +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..b4272a3a47227afdff671ac880d22641c0d759fb 100644 (file)
@@ -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 +333,8 @@ void FillNStroke::setFillrule( SPPaintSelector::FillRule mode )
         sp_repr_css_attr_unref(css);
         css = 0;
 
-        sp_document_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 +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,
-                                   (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 +481,8 @@ void FillNStroke::updateFromPaint()
             sp_repr_css_attr_unref(css);
             css = 0;
 
-            sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
-                             (kind == FILL) ? _("Remove fill") : _("Remove stroke"));
+            DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+                               (kind == FILL) ? _("Remove fill") : _("Remove stroke"));
             break;
         }
 
@@ -496,8 +497,8 @@ void FillNStroke::updateFromPaint()
             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,
-                                   (kind == FILL) ? _("Set fill color") : _("Set stroke color"));
+            DocumentUndo::maybeDone(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
+                                    (kind == FILL) ? _("Set fill color") : _("Set stroke color"));
 
             if (kind == FILL) {
                 // resume interruptibility
@@ -556,7 +557,7 @@ void FillNStroke::updateFromPaint()
                     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(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style");
                         }
 
                         if (!vector) {
@@ -578,7 +579,7 @@ void FillNStroke::updateFromPaint()
                     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(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style");
                         }
 
                         SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL);
@@ -591,8 +592,8 @@ void FillNStroke::updateFromPaint()
                     css = 0;
                 }
 
-                sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
-                                 (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke"));
+                DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+                                   (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke"));
             }
             break;
 
@@ -608,7 +609,7 @@ void FillNStroke::updateFromPaint()
                      */
 
                 } else {
-                    Inkscape::XML::Node *patrepr = pattern->repr;
+                    Inkscape::XML::Node *patrepr = pattern->getRepr();
                     SPCSSAttr *css = sp_repr_css_attr_new();
                     gchar *urltext = g_strdup_printf("url(#%s)", patrepr->attribute("id"));
                     sp_repr_css_set_property(css, (kind == FILL) ? "fill" : "stroke", urltext);
@@ -622,7 +623,7 @@ void FillNStroke::updateFromPaint()
                     // 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 = reinterpret_cast<SPObject*>(i->data)->getRepr();
                         if ( (kind == STROKE) && !selrepr) {
                             continue;
                         }
@@ -651,9 +652,9 @@ void FillNStroke::updateFromPaint()
 
                 } // end if
 
-                sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
-                                 (kind == FILL) ? _("Set pattern on fill") :
-                                 _("Set pattern on stroke"));
+                DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+                                   (kind == FILL) ? _("Set pattern on fill") :
+                                   _("Set pattern on stroke"));
             } // end if
 
             break;
@@ -678,8 +679,8 @@ void FillNStroke::updateFromPaint()
                 sp_repr_css_attr_unref(css);
                 css = 0;
 
-                sp_document_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;
 
index 5b663c49302a284fbd02ce79d98ba2d1cad94930..49549de1c51d49e19a7b26122e1b671757774f93 100644 (file)
@@ -340,7 +340,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
 
     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..e7596ead42e5c99c2057b43e263b24ff616a877f 100644 (file)
@@ -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 +43,7 @@
 
 #include "toolbox.h"
 
+using Inkscape::DocumentUndo;
 
 //########################
 //##       Gradient     ##
@@ -150,8 +152,8 @@ gr_item_activate (GtkMenuItem *menuitem, gpointer data)
 
     gr_apply_gradient (selection, ev? ev->get_drag() : NULL, gr);
 
-    sp_document_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 +173,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient *
     GtkWidget *m = gtk_menu_new ();
 
     GSList *gl = NULL;
-    const GSList *gradients = sp_document_get_resource_list (document, "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() ) {
index 76bb9b8e1c9b63fa3473d092b723836a18d4e1bc..1be0aae8e658e5f7f0acf4d8303b5a55e4338b56 100644 (file)
@@ -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 +44,8 @@
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/adaptors/bind.h>
 
+using Inkscape::DocumentUndo;
+
 enum {
     VECTOR_SET,
     LAST_SIGNAL
@@ -253,7 +256,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
     /* 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)->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 +343,12 @@ static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *
     /* Namely - menuitems etc. will be fucked up */
     /* Hmmm - probably we can just re-set it as menuitem data (Lauris) */
 
-    //g_print("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID(gr));
+    //g_print("SPGradientVectorSelector: gradient %s activated\n", gr->getId());
     //g_message("Setting to gradient %p   swatch:%d   solid:%d", gr, gr->isSwatch(), gr->isSolid());
 
     norm = sp_gradient_ensure_vector_normalized(gr);
     if (norm != gr) {
-        //g_print("SPGradientVectorSelector: become %s after normalization\n", SP_OBJECT_ID(norm));
+        //g_print("SPGradientVectorSelector: become %s after normalization\n", norm->getId());
         /* But be careful that we do not have gradient saved anywhere else */
         g_object_set_data(G_OBJECT(mi), "gradient", norm);
     }
@@ -368,8 +371,8 @@ static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *
         /* 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,
-                          /* TODO: annotate */ "gradient-vector.cpp:350");
+        DocumentUndo::done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT,
+                           /* TODO: annotate */ "gradient-vector.cpp:350");
     }
 }
 
@@ -468,7 +471,7 @@ static void verify_grad(SPGradient *gradient)
     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 = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
         if (SP_IS_STOP(ochild)) {
             i++;
             stop = SP_STOP(ochild);
@@ -508,7 +511,7 @@ static void verify_grad(SPGradient *gradient)
 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 = 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 +541,7 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_
     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 = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
             if (SP_IS_STOP(ochild)) {
                 sl = g_slist_append(sl, ochild);
             }
@@ -658,8 +661,8 @@ static void offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb)
             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"));
+            DocumentUndo::maybeDone(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT,
+                                    _("Change gradient stop offset"));
 
             blocked = FALSE;
         }
@@ -733,8 +736,8 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/,  GtkWidget *vb)
     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,
-                      _("Add gradient stop"));
+    DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
+                       _("Add gradient stop"));
 }
 
 static void sp_grd_ed_del_stop(GtkWidget */*widget*/,  GtkWidget *vb)
@@ -764,8 +767,8 @@ 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,
-                          _("Delete gradient stop"));
+        DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
+                           _("Delete gradient stop"));
     }
 
 }
@@ -1030,10 +1033,10 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien
         // 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 = DocumentUndo::getUndoSensitive(document);
+            DocumentUndo::setUndoSensitive(document, false);
             SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL);
-            sp_document_set_undo_sensitive(document, saved);
+            DocumentUndo::setUndoSensitive(document, saved);
         }
     } else { // no gradient, disable everything
         gtk_widget_set_sensitive(widget, FALSE);
@@ -1182,8 +1185,8 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o
     // 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,
-                      _("Change gradient stop color"));
+    DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
+                       _("Change gradient stop color"));
 
     blocked = FALSE;
 
index c25e6aac2f88ed5786b89a239e5d7ad47513f346..15900d340c1e27969a35cb6d1dba2f2abc78710e 100644 (file)
@@ -5,6 +5,7 @@
  * Author:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2002 Lauris Kaplinski
  *
@@ -918,13 +919,13 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
         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 +1106,15 @@ static guchar *load_svg_pixels(gchar const *name,
         /* 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->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
@@ -1135,8 +1136,7 @@ static guchar *load_svg_pixels(gchar const *name,
             ==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(doc->getRoot())->invoke_show(arena, visionkey, SP_ITEM_SHOW_DISPLAY );
 
             // store into the cache
             info = new svg_doc_cache_t;
index a7bed9e94c6461a294bedb0fe0f57b18daebe8e0..1d8acb40a63b426c9c86f426d7838e86a8a438a4 100644 (file)
@@ -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 +785,7 @@ ink_pattern_list_get (SPDocument *source)
         return NULL;
 
     GSList *pl = NULL;
-    GSList const *patterns = sp_document_get_resource_list(source, "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 +876,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
     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);
     }
@@ -894,7 +895,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
 
     // suck in from patterns.svg
     if (patterns_doc) {
-        sp_document_ensure_up_to_date(doc);
+        doc->ensureUpToDate();
         sp_pattern_list_from_doc ( m, doc, patterns_doc, NULL );
     }
 
index ed54857f8159c3e691e0d2ce4931be847a55dafc..a0ec248ca5395ea313459d84852b72e8817e5d93 100644 (file)
@@ -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 +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 +157,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
     SPDocument *document = sp_desktop_document(desktop);
 
-    sp_document_ensure_up_to_date (document);
+    document->ensureUpToDate ();
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     int prefs_bbox = prefs->getInt("/tools/bounding_box");
     SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
@@ -243,7 +245,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
         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,
+        DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT,
                                 _("Transform by toolbar"));
 
         // resume interruptibility
index 3473d8f31c8fbac07673a169a77808525f08f27c..0c31c2f74a562eb46266332c6b1f88afd3c288b8 100644 (file)
@@ -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 +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 +157,8 @@ sp_attribute_widget_changed (GtkEditable *editable)
         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,
-                              _("Set attribute"));
+            DocumentUndo::done(SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE,
+                                _("Set attribute"));
 
         } else if (spaw->src.repr) {
 
@@ -761,8 +764,8 @@ sp_attribute_table_entry_changed ( GtkEditable *editable,
 
                 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,
-                                      _("Set attribute"));
+                    DocumentUndo::done(SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE,
+                                       _("Set attribute"));
 
                 } else if (spat->src.repr) {
 
index 4b565d1a31b38b9464eb99e027069de495007aac..12467041c4f4fb7189a8190d91378d3f5c4d2944 100644 (file)
@@ -581,7 +581,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name )
     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->getResourceList( "iccprofile" );
     while ( current ) {
         SPObject* obj = SP_OBJECT(current->data);
         Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj);
index 7150b07fd4b6fa244120073c52d0d04f27aa117e..75d68d25c58ff351b35ee745833004ba11bc2b9a 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_XMLVIEW_CONTENT_C__
-
 /*
  * Specialization of GtkTextView for the XML tree view
  *
@@ -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 +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 +166,7 @@ sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text)
         text->repr->setContent(data);
         g_free (data);
         text->blocked = FALSE;
-        sp_document_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..ffcbe48f88ed1e5b43579919bedba5816358c091 100644 (file)
@@ -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 +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 +160,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
         return NULL;
 
     // Create a copy repr of the marker with id="sample"
-    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sandbox);
+    Inkscape::XML::Document *xml_doc = sandbox->getReprDoc();
     Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc);
     mrepr->setAttribute("id", "sample");
 
@@ -170,19 +174,19 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
 
 // 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->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) {
@@ -193,7 +197,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
     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 +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));
-          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 +244,8 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
 {
     // 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(sandbox->getRoot())->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY);
 
     for (; marker_list != NULL; marker_list = marker_list->next) {
         Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data);
@@ -280,7 +282,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
         m->append(*i);
     }
 
-    sp_item_invoke_hide(SP_ITEM(sp_document_root(sandbox)), visionkey);
+    SP_ITEM(sandbox->getRoot())->invoke_hide(visionkey);
     nr_object_unref((NRObject *) arena);
 }
 
@@ -342,7 +344,7 @@ gchar const *buffer = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:sodipodi=
 
 "</svg>";
 
-    return sp_document_new_from_mem (buffer, strlen(buffer), FALSE);
+    return SPDocument::createNewDocFromMem (buffer, strlen(buffer), FALSE);
 }
 
 static void
@@ -373,7 +375,7 @@ ink_marker_menu_create_menu(Gtk::Menu *m, gchar const *menu_id, SPDocument *doc,
     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);
     }
@@ -391,7 +393,7 @@ ink_marker_menu_create_menu(Gtk::Menu *m, gchar const *menu_id, SPDocument *doc,
 
     // suck in from markers.svg
     if (markers_doc) {
-        sp_document_ensure_up_to_date(doc);
+        doc->ensureUpToDate();
         sp_marker_list_from_doc(m, doc, markers_doc, NULL, sandbox, menu_id);
     }
 
@@ -498,8 +500,8 @@ sp_marker_select(Gtk::OptionMenu *mnu, Gtk::Container *spw, SPMarkerLoc const wh
     sp_repr_css_attr_unref(css);
     css = 0;
 
-    sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
-                     _("Set markers"));
+    DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+                       _("Set markers"));
 
 };
 
@@ -1200,8 +1202,8 @@ sp_stroke_style_scale_line(Gtk::Container *spw)
     sp_repr_css_attr_unref(css);
     css = 0;
 
-    sp_document_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 +1299,8 @@ sp_stroke_style_any_toggled(Gtk::ToggleButton *tb, Gtk::Container *spw)
         sp_repr_css_attr_unref(css);
         css = 0;
 
-        sp_document_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"));
     }
 }
 
index 3c209a45d455555c0a19f942e563a91f7ffbe80a..935282a3a606a60a5a5db38513aff05dc89ea86c 100644 (file)
@@ -135,8 +135,8 @@ void SwatchSelector::_changedCb(SPColorSelector */*csel*/, void *data)
                 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,
-                                 _("Change swatch color"));
+                DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
+                                   _("Change swatch color"));
             }
         }
     }
index ce71a097ea4211e868d3754f8cfe3782e1e39e29..8a616d0024d5f7b314b52793440144dac33d6c48 100644 (file)
@@ -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);
@@ -1271,7 +1273,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
     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 (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"),
             sp_units_get_pixels(adj->value, *unit));
     }
@@ -2053,8 +2055,8 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
         return;
     }
 
-    bool saved = sp_document_get_undo_sensitive(doc);
-    sp_document_set_undo_sensitive(doc, false);
+    bool saved = DocumentUndo::getUndoSensitive(doc);
+    DocumentUndo::setUndoSensitive(doc, false);
 
     bool v = false;
     SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE"));
@@ -2139,7 +2141,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
     // The snapping preferences are stored in the document, and therefore toggling makes the document dirty
     doc->setModifiedSinceSave();
 
-    sp_document_set_undo_sensitive(doc, saved);
+    DocumentUndo::setUndoSensitive(doc, saved);
 }
 
 void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
@@ -2498,7 +2500,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
 {
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
 
-    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+    if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         // do not remember prefs if this call is initiated by an undo change, because undoing object
         // creation sets bogus values to its attributes before it is deleted
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -2529,8 +2531,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
         }
     }
     if (modmade) {
-        sp_document_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 +2542,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
 {
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
 
-    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+    if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         if (!IS_NAN(adj->value)) {
             Inkscape::Preferences *prefs = Inkscape::Preferences::get();
             prefs->setDouble("/tools/shapes/star/proportion", adj->value);
@@ -2576,8 +2578,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
     }
 
     if (modmade) {
-        sp_document_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 +2590,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
     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 (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setBool( "/tools/shapes/star/isflatsided", flat);
     }
@@ -2620,8 +2622,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
     }
 
     if (modmade) {
-        sp_document_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 +2633,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
 {
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
 
-    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+    if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setDouble("/tools/shapes/star/rounded", (gdouble) adj->value);
     }
@@ -2657,8 +2659,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
         }
     }
     if (modmade) {
-        sp_document_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 +2670,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
 {
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
 
-    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+    if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setDouble("/tools/shapes/star/randomized", (gdouble) adj->value);
     }
@@ -2694,8 +2696,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
         }
     }
     if (modmade) {
-        sp_document_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 +3035,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
     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 (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name, sp_units_get_pixels(adj->value, *unit));
     }
@@ -3062,8 +3064,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
     sp_rtb_sensitivize( tbl );
 
     if (modmade) {
-        sp_document_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 +3432,7 @@ static void box3d_persp_tb_event_attr_changed(Inkscape::XML::Node *repr,
     }
 
     // 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::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 +3516,7 @@ static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, P
     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)"));
+    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 +3711,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
 {
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
 
-    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+    if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setDouble("/tools/shapes/spiral/" + value_name, adj->value);
     }
@@ -3740,8 +3742,8 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
     g_free(namespaced_name);
 
     if (modmade) {
-        sp_document_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 +5305,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
 {
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
 
-    if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+    if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, adj->value);
     }
@@ -5351,8 +5353,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
     sp_arctb_sensitivize( tbl, adj->value, other->value );
 
     if (modmade) {
-        sp_document_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 +5375,7 @@ static void sp_arctb_end_value_changed(GtkAdjustment *adj, GObject *tbl)
 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 (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0);
     }
@@ -5415,8 +5417,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
     }
 
     if (modmade) {
-        sp_document_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 +5748,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
             SP_LPETOOL_CONTEXT(desktop->event_context)->mode = type;
         }
 
-        if (sp_document_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 +6085,7 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
 {
     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 (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
         Inkscape::Preferences *prefs = Inkscape::Preferences::get();
         prefs->setBool( "/tools/eraser/mode", eraserMode );
     }
@@ -6383,8 +6385,8 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb
     g_free (family);
 
     // Save for undo
-    sp_document_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 +6432,8 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje
     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,
-                                   _("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 +6578,8 @@ static void sp_text_style_changed( InkToggleAction* act, GObject *tbl )
     // 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,
-                                   _("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 +6655,8 @@ static void sp_text_script_changed( InkToggleAction* act, GObject *tbl )
     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,
-                                   _("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 +6799,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
     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,
-                                   _("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 +6838,8 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
     }
 
     // Save for undo
-    sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE,
-                                   _("Text: Change line-height"));
+    DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE,
+                             _("Text: Change line-height"));
 
     // If no selected objects, set default.
     SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
@@ -6875,8 +6877,8 @@ static void sp_text_wordspacing_value_changed( GtkAdjustment *adj, GObject *tbl
     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,
-                                   _("Text: Change word-spacing"));
+    DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE,
+                             _("Text: Change word-spacing"));
 
     // If no selected objects, set default.
     SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
@@ -6914,8 +6916,8 @@ static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, GObject *tb
     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,
-                                   _("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 +6961,8 @@ static void sp_text_dx_value_changed( GtkAdjustment *adj, GObject *tbl )
     }
 
     // Save for undo
-    sp_document_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 +6992,8 @@ static void sp_text_dy_value_changed( GtkAdjustment *adj, GObject *tbl )
     }
 
     // Save for undo
-    sp_document_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 +7023,8 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl )
     }
 
     // Save for undo
-    sp_document_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 +7068,8 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject *
     }
 
     sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true);
-    sp_document_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 +7095,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
          items != NULL;
          items = items->next)
     {
-        const gchar* id = SP_OBJECT_ID((SPItem *) items->data);
+        const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
         std::cout << "    " << id << std::endl;
     }
     Glib::ustring selected_text = sp_text_get_selected_text((SP_ACTIVE_DESKTOP)->event_context);
@@ -7118,7 +7120,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
     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 +7878,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
     Inkscape::Selection * selection = sp_desktop_selection(desktop);
     SPDocument *doc = sp_desktop_document(desktop);
 
-    if (!sp_document_get_undo_sensitive(doc)) {
+    if (!DocumentUndo::getUndoSensitive(doc)) {
         return;
     }
 
@@ -7900,7 +7902,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
         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;
@@ -7913,8 +7915,8 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
         prefs->setBool("/tools/connector/orthogonal", is_orthog);
     }
 
-    sp_document_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 +7927,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
     Inkscape::Selection * selection = sp_desktop_selection(desktop);
     SPDocument *doc = sp_desktop_document(desktop);
 
-    if (!sp_document_get_undo_sensitive(doc)) {
+    if (!DocumentUndo::getUndoSensitive(doc)) {
         return;
     }
 
@@ -7948,7 +7950,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
         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;
@@ -7961,8 +7963,8 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
         prefs->setDouble(Glib::ustring("/tools/connector/curvature"), newValue);
     }
 
-    sp_document_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 +7975,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
     SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
     SPDocument *doc = sp_desktop_document(desktop);
 
-    if (!sp_document_get_undo_sensitive(doc)) {
+    if (!DocumentUndo::getUndoSensitive(doc)) {
         return;
     }
 
@@ -8009,8 +8011,8 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
         g_slist_free(items);
     }
 
-    sp_document_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 +8032,7 @@ static void sp_connector_graph_layout(void)
 
     prefs->setInt("/options/clonecompensation/value", saved_compensation);
 
-    sp_document_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*/ )
index 620a88d8c2c500c21c2a3229a5128ebd734d81f0..ce902ba75699e95bae30db68a67094fd8811d47b 100644 (file)
@@ -11,10 +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
+    if(_oldsel && _oldsel->getRepr())
+        _oldsel->getRepr()->removeObserver(*this);
+    if(o && o->getRepr())
+        o->getRepr()->addObserver(*this);
     _oldsel = o;
 }
 
index 3d09dfd1baa52715ee1842602493c71eaae25d80..389d70be0eb1191885c8b5592266cb789e5a63ef 100644 (file)
@@ -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 );
index c3876725d3849c657add39369178cc10fc4f27f5..0655171606f213c6e90592b0ce2945c653d6f9a9 100644 (file)
@@ -201,10 +201,11 @@ Inkscape::XML::calc_abs_doc_base(gchar const *const doc_base)
  */
 void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_base, bool const spns)
 {
-    if (!doc->base)
+    if (!doc->getBase()) {
         return;
+    }
 
-    gchar *const old_abs_base = calc_abs_doc_base(doc->base);
+    gchar *const old_abs_base = calc_abs_doc_base(doc->getBase());
     gchar *const new_abs_base = calc_abs_doc_base(new_base);
 
     /* TODO: Should handle not just image but also:
@@ -227,7 +228,7 @@ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_b
      *
      * 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->getResourceList("image");
     for (GSList const *l = images; l != NULL; l = l->next) {
         Inkscape::XML::Node *ir = SP_OBJECT_REPR(l->data);
 
index b1320a4a399d9eb54fc06671da6cb5b779d6e431..5f7654ba8e7966467077f4d3735582381c65f733 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_REPR_IO_C__
-
 /*
  * Dirty DOM-like  tree
  *
index df1d2cbb8bd5fed5a754d8a612b7cb9522ed2d4a..056236d333379665909bf6a89251a344661eb11f 100644 (file)
@@ -3,18 +3,16 @@
 #include "xml/repr.h"
 #include "xml/node-iterators.h"
 
-static bool
-same_repr(Inkscape::XML::Node &a, Inkscape::XML::Node &b)
+static bool same_repr(Inkscape::XML::Node const &a, Inkscape::XML::Node const &b)
 {
   /* todo: I'm not certain that it's legal to take the address of a reference.  Check the exact wording of the spec on this matter. */
     return &a == &b;
 }
 
-Inkscape::XML::Node *
-LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *b)
+Inkscape::XML::Node const *LCA(Inkscape::XML::Node const *a, Inkscape::XML::Node const *b)
 {
     using Inkscape::Algorithms::longest_common_suffix;
-    Inkscape::XML::Node *ancestor = longest_common_suffix<Inkscape::XML::NodeParentIterator>(
+    Inkscape::XML::Node const *ancestor = longest_common_suffix<Inkscape::XML::NodeConstParentIterator>(
         a, b, NULL, &same_repr
     );
     if ( ancestor && ancestor->type() != Inkscape::XML::DOCUMENT_NODE ) {
@@ -24,22 +22,30 @@ LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *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 *
-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:
index 7d5542f67dcd224be80378d92b217dea63656a58..d560dfa26b6dc5fe8824f6b7a4cdf38b97737931 100644 (file)
 #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
index d310639ba2a15fe63a6924e19dfe22484f57b43f..07a25ca6daeab0fa1fcb996e7d2025279c1d612c 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_REPR_UTIL_C__
-
 /** \file
  * Miscellaneous helpers for reprs.
  */
@@ -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 +353,7 @@ long long int sp_repr_get_int_attribute(Inkscape::XML::Node *repr, char const *k
  *   -1    first object's position is less than the second
  * @todo Rewrite this function's description to be understandable
  */
-int
-sp_repr_compare_position(Inkscape::XML::Node *first, Inkscape::XML::Node *second)
+int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second)
 {
     int p1, p2;
     if (sp_repr_parent(first) == sp_repr_parent(second)) {
@@ -368,7 +366,7 @@ sp_repr_compare_position(Inkscape::XML::Node *first, Inkscape::XML::Node *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 +431,35 @@ sp_repr_lookup_child(Inkscape::XML::Node *repr,
     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.
  */
index 4494d3fe6dc44aa2cd6249a375bac72254157db1..0a384c9c1d707e5a3c489a93c9c7de30660e0f52 100644 (file)
@@ -1,5 +1,3 @@
-#define __SP_REPR_C__
-
 /** \file
  * A few non-inline functions of the C facade to Inkscape::XML::Node.
  */
index 3b8d532fd8a0a4755f0ad38df04352f4ca386a56..bde3e533f07b6b458bc8e6eb80d0d5f0f9220342 100644 (file)
@@ -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 +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 +138,29 @@ double sp_repr_get_double_attribute(Inkscape::XML::Node *repr, gchar const *key,
 /// \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 +170,7 @@ inline Inkscape::XML::Node *sp_repr_document_first_child(Inkscape::XML::Document
     return const_cast<Inkscape::XML::Node *>(doc->firstChild());
 }
 
-#endif
+#endif // SEEN_SP_REPR_H
 /*
   Local Variables:
   mode:c++