From 8867de5daf309e4cdd3fce177b408618490be4f3 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 29 Jun 2010 23:35:42 +0530 Subject: This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp-item and marks the onset of document c++ification as well. Users can check performace increase with [/usr/bin/time -v inkscape_binary_with_commandline_options]. (bzr r9546.1.1) --- src/application/editor.cpp | 6 +- src/arc-context.cpp | 4 +- src/box3d.cpp | 14 +- src/color-profile-test.h | 2 +- src/conn-avoid-ref.cpp | 6 +- src/connector-context.cpp | 18 +- src/desktop-style.cpp | 10 +- src/desktop.cpp | 14 +- src/dialogs/clonetiler.cpp | 13 +- src/dialogs/export.cpp | 8 +- src/dialogs/spellcheck.cpp | 6 +- src/display/nr-filter-image.cpp | 6 +- src/document.cpp | 26 +- src/document.h | 15 +- src/draw-context.cpp | 11 +- src/dyna-draw-context.cpp | 4 +- src/eraser-context.cpp | 2 +- src/extension/internal/cairo-png-out.cpp | 6 +- src/extension/internal/cairo-ps-out.cpp | 6 +- src/extension/internal/cairo-ps-out.h | 1 + src/extension/internal/cairo-render-context.cpp | 6 +- src/extension/internal/cairo-renderer-pdf-out.cpp | 6 +- src/extension/internal/cairo-renderer.cpp | 8 +- src/extension/internal/cairo-renderer.h | 2 +- src/extension/internal/emf-win32-inout.cpp | 2 +- src/extension/internal/emf-win32-print.cpp | 2 +- src/extension/internal/gdkpixbuf-input.cpp | 2 +- src/extension/internal/gimpgrad.cpp | 2 +- src/extension/internal/javafx-out.cpp | 4 +- src/extension/internal/latex-pstricks-out.cpp | 8 +- src/extension/internal/latex-text-renderer.cpp | 6 +- src/extension/internal/odf.cpp | 4 +- src/extension/internal/odf.h | 2 +- src/extension/internal/pdf-input-cairo.cpp | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/internal/pov-out.cpp | 2 +- src/extension/internal/svg.cpp | 6 +- src/extension/internal/wpg-input.cpp | 2 +- src/extension/print.h | 2 +- src/file.cpp | 10 +- src/filter-chemistry.cpp | 8 +- src/flood-context.cpp | 10 +- src/forward.h | 14 +- src/gradient-chemistry.cpp | 4 +- src/gradient-drag.cpp | 4 +- src/graphlayout.cpp | 4 +- src/helper/pixbuf-ops.cpp | 8 +- src/helper/png-write.cpp | 8 +- src/helper/stock-items.cpp | 10 +- src/inkview.cpp | 14 +- src/interface.cpp | 4 +- src/interface.h | 2 +- src/jabber_whiteboard/session-manager.cpp | 2 +- src/knot-holder-entity.cpp | 12 +- src/knotholder.cpp | 6 +- src/live_effects/lpe-mirror_symmetry.cpp | 2 +- src/live_effects/lpegroupbbox.cpp | 2 +- src/live_effects/parameter/path-reference.h | 1 + src/live_effects/parameter/path.cpp | 2 +- src/main.cpp | 6 +- src/marker.cpp | 2 +- src/object-edit.cpp | 4 +- src/object-snapper.cpp | 21 +- src/print.cpp | 22 +- src/rect-context.cpp | 2 +- src/removeoverlap.cpp | 2 +- src/selcue.cpp | 6 +- src/selection-chemistry.cpp | 48 +- src/selection-chemistry.h | 1 + src/selection-describer.cpp | 2 +- src/selection.cpp | 10 +- src/seltrans.cpp | 12 +- src/sp-clippath.cpp | 13 +- src/sp-conn-end-pair.cpp | 2 +- src/sp-ellipse.cpp | 2 +- src/sp-flowtext.cpp | 16 +- src/sp-gradient-test.h | 2 +- src/sp-guide-attachment.h | 1 + src/sp-image.cpp | 6 +- src/sp-item-group.cpp | 24 +- src/sp-item-notify-moveto.cpp | 6 +- src/sp-item-rm-unsatisfied-cns.cpp | 2 +- src/sp-item-transform.cpp | 18 +- src/sp-item-update-cns.cpp | 2 +- src/sp-item.cpp | 508 +++++++++++----------- src/sp-item.h | 143 ++++-- src/sp-line.cpp | 106 ++--- src/sp-line.h | 43 +- src/sp-mask.cpp | 9 +- src/sp-offset.cpp | 4 +- src/sp-path.cpp | 10 +- src/sp-pattern.cpp | 12 +- src/sp-pattern.h | 2 +- src/sp-polyline.cpp | 66 +-- src/sp-polyline.h | 28 +- src/sp-rect.cpp | 12 +- src/sp-shape.cpp | 26 +- src/sp-spiral.cpp | 2 +- src/sp-star.cpp | 2 +- src/sp-style-elem-test.h | 2 +- src/sp-switch.cpp | 2 +- src/sp-text.cpp | 20 +- src/sp-tref-reference.h | 1 + src/sp-tref.cpp | 2 +- src/sp-tspan.cpp | 2 +- src/sp-use-reference.h | 1 + src/sp-use.cpp | 16 +- src/spiral-context.cpp | 2 +- src/splivarot.cpp | 38 +- src/spray-context.cpp | 14 +- src/star-context.cpp | 2 +- src/style-test.h | 2 +- src/svg-view.cpp | 13 +- src/test-helpers.h | 4 +- src/text-chemistry.cpp | 6 +- src/text-context.cpp | 12 +- src/text-editing.cpp | 12 +- src/trace/trace.cpp | 6 +- src/tweak-context.cpp | 24 +- src/ui/clipboard.cpp | 20 +- src/ui/dialog/aboutbox.cpp | 4 +- src/ui/dialog/align-and-distribute.cpp | 19 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 12 +- src/ui/dialog/filedialogimpl-win32.cpp | 12 +- src/ui/dialog/icon-preview.cpp | 7 +- src/ui/dialog/tile.cpp | 18 +- src/ui/dialog/transformation.cpp | 10 +- src/ui/tool/node-tool.cpp | 4 +- src/ui/tool/path-manipulator.cpp | 4 +- src/ui/view/edit-widget.cpp | 14 +- src/ui/widget/imageicon.cpp | 14 +- src/ui/widget/style-subject.cpp | 2 +- src/unclump.cpp | 12 +- src/widgets/desktop-widget.cpp | 14 +- src/widgets/icon.cpp | 9 +- src/widgets/paint-selector.cpp | 2 +- src/widgets/stroke-style.cpp | 12 +- 137 files changed, 1038 insertions(+), 912 deletions(-) (limited to 'src') diff --git a/src/application/editor.cpp b/src/application/editor.cpp index 49010efdc..d2ccccbe3 100644 --- a/src/application/editor.cpp +++ b/src/application/editor.cpp @@ -76,10 +76,10 @@ Editor::init() // gchar const *tmpl = g_build_filename ((INKSCAPE_TEMPLATESDIR), "default.svg", NULL); bool have_default = Inkscape::IO::file_test (tmpl, G_FILE_TEST_IS_REGULAR); - SPDocument *doc = sp_document_new (have_default? tmpl:0, true, true); + SPDocument *doc = SPDocument::createDoc (have_default? tmpl:0, true, true); g_return_val_if_fail (doc != 0, false); Inkscape::UI::View::EditWidget *ew = new Inkscape::UI::View::EditWidget (doc); - sp_document_unref (doc); + doc->doUnref (); _window = ew->getWindow(); return ew != 0; } @@ -129,7 +129,7 @@ Editor::createDesktop (SPDocument* doc) { g_assert (doc != 0); (new Inkscape::UI::View::EditWidget (doc))->present(); - sp_document_unref (doc); + doc->doUnref (); SPDesktop *dt = getActiveDesktop(); reactivateDesktop (dt); return dt; diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 799167a72..ab3389ec6 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -417,7 +417,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state) 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); @@ -441,7 +441,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]; diff --git a/src/box3d.cpp b/src/box3d.cpp index aa2dc55e3..bdbbbfa7e 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -355,16 +355,16 @@ box3d_set_transform(SPItem *item, Geom::Matrix const &xform) 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 +393,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 +417,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(); } @@ -1392,7 +1392,7 @@ box3d_convert_to_guides(SPItem *item) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/3dbox/convertguides", true)) { - sp_item_convert_to_guides(SP_ITEM(box)); + SP_ITEM(box)->convert_to_guides(); return; } diff --git a/src/color-profile-test.h b/src/color-profile-test.h index cdbf76b44..c479f78c0 100644 --- a/src/color-profile-test.h +++ b/src/color-profile-test.h @@ -25,7 +25,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); } } diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 88c84a84c..21df27637 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -387,14 +387,14 @@ 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(); // TODO investigate why this was asking for the active desktop: SPDesktop *desktop = inkscape_active_desktop(); if ( type == ConnPointDefault ) { // For now, just default to the centre of the item - Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); pos = (bbox) ? bbox->midpoint() : Geom::Point(0, 0); } else @@ -504,7 +504,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 hull_points; hull_points = approxItemWithPoints(item, itd_mat); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index b0e192190..82be63de5 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -965,7 +965,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); // 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; @@ -1088,7 +1088,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); 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); } @@ -1104,7 +1104,7 @@ 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); @@ -1182,7 +1182,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, @@ -1204,7 +1204,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); 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); } @@ -1235,7 +1235,7 @@ 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); @@ -1431,7 +1431,7 @@ 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", @@ -1593,7 +1593,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); @@ -1752,7 +1752,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) { diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 26f29d172..19a45a285 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -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. ) ) { @@ -416,7 +416,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); @@ -717,7 +717,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) @@ -935,7 +935,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)) @@ -1381,7 +1381,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 ++; diff --git a/src/desktop.cpp b/src/desktop.cpp index 52f172577..204807e98 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -190,7 +190,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid /* 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); @@ -277,7 +277,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); - NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (sp_document_root (document)), + NRArenaItem *ai = SP_ITEM (sp_document_root (document))->invoke_show ( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); @@ -394,7 +394,7 @@ void SPDesktop::destroy() } if (drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), dkey); + SP_ITEM (sp_document_root (doc()))->invoke_hide (dkey); drawing = NULL; } @@ -552,7 +552,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 { @@ -1075,7 +1075,7 @@ SPDesktop::zoom_drawing() SPItem *docitem = SP_ITEM (sp_document_root (doc())); 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. @@ -1474,7 +1474,7 @@ SPDesktop::setDocument (SPDocument *doc) { if (this->doc() && doc) { namedview->hide(this); - sp_item_invoke_hide (SP_ITEM (sp_document_root (this->doc())), dkey); + SP_ITEM (sp_document_root (this->doc()))->invoke_hide (dkey); } if (_layer_hierarchy) { @@ -1505,7 +1505,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 (sp_document_root (doc))->invoke_show ( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 55884fe4a..550370e90 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -851,7 +851,7 @@ clonetiler_trace_hide_tiled_clones_recursively (SPObject *from) for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) { 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); } } @@ -861,13 +861,12 @@ 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(SP_DOCUMENT_ROOT (trace_doc))->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); + original->invoke_hide(trace_visionkey); clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (trace_doc))); sp_document_root (trace_doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -954,7 +953,7 @@ static void clonetiler_trace_finish () { if (trace_doc) { - sp_item_invoke_hide(SP_ITEM(sp_document_root(trace_doc)), trace_visionkey); + SP_ITEM(sp_document_root(trace_doc))->invoke_hide(trace_visionkey); } if (trace_arena) { ((NRObject *) trace_arena)->unreference(); @@ -1232,7 +1231,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]; diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 696f38b77..463339534 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -780,7 +780,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 (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); if (bbox) { sp_export_set_area (base, bbox->min()[Geom::X], bbox->min()[Geom::Y], @@ -861,7 +861,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 (SP_DOCUMENT_ROOT (doc))->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) { @@ -1127,7 +1127,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, static_cast(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); @@ -1498,7 +1498,7 @@ sp_export_detect_size(GtkObject * base) { case SELECTION_DRAWING: { SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); + Geom::OptRect bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); // std::cout << "Drawing " << bbox2; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) { diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 1645218c6..24890f8eb 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -236,8 +236,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; } @@ -570,7 +570,7 @@ spellcheck_next_word() // draw rect std::vector 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 ++) { diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 4ad6982f3..215fc4d02 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -51,8 +51,8 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { // prep the document sp_document_ensure_up_to_date(document); 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 +100,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); } diff --git a/src/document.cpp b/src/document.cpp index eff6d6e81..0479569f6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -439,7 +439,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, * appears in document list. */ SPDocument * -sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new) +SPDocument::createDoc(gchar const *uri, unsigned int keepalive, bool make_new) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -490,7 +490,7 @@ sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new) } SPDocument * -sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepalive) +SPDocument::createDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -515,18 +515,18 @@ sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepaliv } SPDocument * -sp_document_ref(SPDocument *doc) +SPDocument::doRef() { - g_return_val_if_fail(doc != NULL, NULL); - Inkscape::GC::anchor(doc); - return doc; + //g_return_val_if_fail(doc != NULL, NULL); + Inkscape::GC::anchor(this); + return this; } SPDocument * -sp_document_unref(SPDocument *doc) +SPDocument::doUnref() { - g_return_val_if_fail(doc != NULL, NULL); - Inkscape::GC::release(doc); + //g_return_val_if_fail(doc != NULL, NULL); + Inkscape::GC::release(this); return NULL; } @@ -1126,7 +1126,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); } else { SPItem *child = SP_ITEM(o); - Geom::OptRect box = sp_item_bbox_desktop(child); + Geom::OptRect box = child->getBboxDesktop(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s = g_slist_append(s, child); } @@ -1168,7 +1168,7 @@ sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GS if (!SP_IS_ITEM(o)) continue; SPItem *item = SP_ITEM(o); - NRArenaItem *arenaitem = sp_item_get_arenaitem(item, dkey); + NRArenaItem *arenaitem = item->get_arenaitem(dkey); if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { if (g_slist_find((GSList *) list, item) != NULL) @@ -1219,7 +1219,7 @@ find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gbool } 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 @@ -1252,7 +1252,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) { diff --git a/src/document.h b/src/document.h index e70582006..2f9da7817 100644 --- a/src/document.h +++ b/src/document.h @@ -64,10 +64,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 IDChangedSignal; typedef sigc::signal ResourcesChangedSignal; typedef sigc::signal ModifiedSignal; @@ -180,13 +181,17 @@ public: sigc::connection _desktop_activated_connection; void fitToRect(Geom::Rect const &rect, bool with_margins = false); + static SPDocument *createDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); + static SPDocument *createDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + SPDocument *doRef(); + SPDocument *doUnref(); }; -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_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_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); diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 3049f3a6a..52118eb16 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -438,7 +438,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(); @@ -656,7 +656,7 @@ 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); @@ -694,7 +694,7 @@ 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(); } @@ -836,8 +836,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 @@ -856,6 +856,7 @@ 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); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index bb8e69092..4d8ab2c11 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -599,7 +599,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 @@ -1012,7 +1012,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(); diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 6afa07d77..46efd403a 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -723,7 +723,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(); diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index c81fdd029..d7b7cc862 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -59,8 +59,8 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) /* Create new arena */ SPItem *base = SP_ITEM(sp_document_root(doc)); NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); - NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + unsigned dkey = SPItem::display_key_new(1); + NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ renderer = new CairoRenderer(); @@ -76,7 +76,7 @@ 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; diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 61760e9d9..59daafb7e 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -86,8 +86,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 +110,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); diff --git a/src/extension/internal/cairo-ps-out.h b/src/extension/internal/cairo-ps-out.h index 019b6b810..40c7bf7e3 100644 --- a/src/extension/internal/cairo-ps-out.h +++ b/src/extension/internal/cairo-ps-out.h @@ -16,6 +16,7 @@ #define EXTENSION_INTERNAL_CAIRO_PS_OUT_H #include "extension/implementation/implementation.h" +#include "sp-item.h" #ifdef HAVE_CAIRO_PDF diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 28d1db9a4..5849230bf 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1063,14 +1063,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) ) { 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)); } } @@ -1099,7 +1099,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver 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)) { - sp_item_invoke_hide (SP_ITEM (child), dkey); + SP_ITEM (child)->invoke_hide (dkey); } } break; // do not go further up the chain if children are found diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 808590e04..d7a034291 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -79,8 +79,8 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int /* 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 +102,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); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index ebdb82a69..5b05cd96b 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -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); @@ -449,7 +449,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; @@ -480,7 +480,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 @@ -611,7 +611,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page d.x1 = sp_document_width(doc); d.y1 = sp_document_height(doc); } 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) { diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index d69a60753..094922bbf 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -23,7 +23,7 @@ //#include "libnrtype/font-instance.h" #include "style.h" - +#include "sp-item.h" #include class SPClipPath; diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 9d25f3a7f..0d939427c 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -2366,7 +2366,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::createDocFromMem(d.outsvg->c_str(), d.outsvg->length(), TRUE); delete d.outsvg; delete d.path; diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index d098f6466..21bb85331 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -147,7 +147,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) 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); + sp_item_invoke_bbox(doc_item, &d, doc_item->i2d_affine(), TRUE); } d.x0 *= IN_PER_PX; diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index a1295406c..2e10dae58 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -54,7 +54,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) mime_type = "image/png"; } - doc = sp_document_new(NULL, TRUE, TRUE); + doc = SPDocument::createDoc(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 diff --git a/src/extension/internal/gimpgrad.cpp b/src/extension/internal/gimpgrad.cpp index 5b3e0c16e..d33975f91 100644 --- a/src/extension/internal/gimpgrad.cpp +++ b/src/extension/internal/gimpgrad.cpp @@ -256,7 +256,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::createDocFromMem(outsvg.c_str(), outsvg.length(), TRUE); } error: diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index a4d348940..813a17264 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -493,7 +493,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 +635,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) diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 4a469a750..c2d14f6a5 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -68,14 +68,14 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons /* Create new arena */ mod->base = SP_ITEM (sp_document_root (doc)); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new (1); - mod->root = sp_item_invoke_show (mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new (1); + mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin (doc); - sp_item_invoke_print (mod->base, &context); + (mod->base)->invoke_print (&context); ret = mod->finish (); /* Release arena */ - sp_item_invoke_hide (mod->base, mod->dkey); + (mod->base)->invoke_hide (mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref ((NRObject *) mod->arena); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index bebc21f2f..cd712e477 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -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.); @@ -498,7 +498,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * d = Geom::Rect( Geom::Point(0,0), Geom::Point(sp_document_width(doc), sp_document_height(doc)) ); } 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."); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 5331c072c..4e89ce7b2 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -945,7 +945,7 @@ 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); Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0)); @@ -964,7 +964,7 @@ 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; diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h index 3854ddfe1..08eda3767 100644 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@ -47,7 +47,7 @@ #include #include - +#include "sp-item.h" namespace Inkscape { diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index 937fefb11..e3abc63d4 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -58,7 +58,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::createDocFromMem(output->c_str(), output->length(), TRUE); delete output; g_object_unref(page); diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index ba00fe343..e771d8b41 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -661,7 +661,7 @@ 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); + SPDocument *doc = SPDocument::createDoc(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 diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 16877c370..fc8c1a666 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -300,7 +300,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 ); /* diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index b10aa87ec..c063be46c 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -182,19 +182,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::createDoc(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::createDocFromMem(buffer, strlen(buffer), 1); g_free(buffer); return doc; #else - return sp_document_new (uri, TRUE); + return SPDocument::createDoc(uri, TRUE); #endif } diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index c37d5705b..023bab879 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -86,7 +86,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::createDocFromMem(output.cstr(), strlen(output.cstr()), TRUE); delete input; return doc; } diff --git a/src/extension/print.h b/src/extension/print.h index 8ae71b8e6..bc275b3b5 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -14,7 +14,7 @@ #include "display/nr-arena-forward.h" #include "forward.h" - +#include "sp-item.h" namespace Inkscape { namespace Extension { diff --git a/src/file.cpp b/src/file.cpp index e0ecd5084..352362424 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -118,7 +118,7 @@ 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::createDoc(templName, TRUE, true); g_return_val_if_fail(doc != NULL, NULL); SPDesktop *dt; @@ -128,7 +128,7 @@ sp_file_new(const Glib::ustring &templ) } else { SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); + doc->doUnref(); sp_create_window(dtw, TRUE); dt = static_cast(dtw->view); @@ -250,7 +250,7 @@ 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); @@ -1049,7 +1049,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // 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(); + Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->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 @@ -1063,7 +1063,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } } - sp_document_unref(doc); + doc->doUnref(); sp_document_done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 363663ac3..3d5a795c7 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -319,7 +319,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 +330,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)); } @@ -367,14 +367,14 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, } // 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) { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 612ae1cfc..f8c2e14a0 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -485,10 +485,10 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto 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,7 +774,7 @@ 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); @@ -807,7 +807,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(sp_document_root(document))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -850,7 +850,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(sp_document_root(document))->invoke_hide(dkey); nr_object_unref((NRObject *) arena); diff --git a/src/forward.h b/src/forward.h index d4a98fbff..0388f8f63 100644 --- a/src/forward.h +++ b/src/forward.h @@ -64,15 +64,15 @@ class SPObjectClass; GType sp_object_get_type (); -class SPItem; -class SPItemClass; +//class SPItem; +//class SPItemClass; -#define SP_TYPE_ITEM (sp_item_get_type ()) -#define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) -#define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) -#define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) +//#define SP_TYPE_ITEM (sp_item_get_type ()) +//#define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) +//#define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) +//#define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) -GType sp_item_get_type (); +//GType sp_item_get_type (); class SPGroup; class SPGroupClass; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 979b53f1b..56d4813fb 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -767,7 +767,7 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, Geom 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 @@ -1048,7 +1048,7 @@ sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool 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); } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 227a5f003..6306278c5 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1100,7 +1100,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: @@ -1738,7 +1738,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]); diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index a89af10af..13838d4cf 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -126,7 +126,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 +228,7 @@ void graphlayout(GSList const *const items) { map::iterator i=nodelookup.find(u->getId()); if(i!=nodelookup.end()) { Rectangle* r=rs[i->second]; - Geom::OptRect item_box(sp_item_bbox_desktop(u)); + Geom::OptRect item_box(u->getBboxDesktop()); if(item_box) { Geom::Point const curr(item_box->midpoint()); Geom::Point const dest(r->getCentreX(),r->getCentreY()); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 3be63aa68..ebcee1a64 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -51,7 +51,7 @@ 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 @@ -104,7 +104,7 @@ 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); @@ -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(sp_document_root(doc))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -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(sp_document_root(doc))->invoke_hide (dkey); nr_object_unref((NRObject *) arena); // gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b1c135db0..81c8612fb 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -371,7 +371,7 @@ 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 @@ -461,10 +461,10 @@ 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(sp_document_root(doc))->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, @@ -490,7 +490,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(sp_document_root(doc))->invoke_hide(dkey); /* Free arena */ nr_object_unref((NRObject *) arena); diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 1c184da72..72f97c6da 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -56,7 +56,7 @@ 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::createDoc(markers, FALSE); } g_free(markers); if (doc) { @@ -94,12 +94,12 @@ 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::createDoc(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::createDoc(patterns, FALSE); } g_free(patterns); if (doc) { @@ -137,12 +137,12 @@ 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::createDoc(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::createDoc(gradients, FALSE); } g_free(gradients); if (doc) { diff --git a/src/inkview.cpp b/src/inkview.cpp index c151991dd..1a13e356f 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -273,7 +273,7 @@ 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::createDocFromMem ((const gchar *)gba->data, gba->len, TRUE); gchar *last_filename = jar_file_reader.get_last_filename(); @@ -299,7 +299,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::createDoc (ss.slides[ss.current], TRUE, false); if (!ss.doc) ++ss.current; } @@ -325,7 +325,7 @@ main (int argc, const char **argv) sp_document_ensure_up_to_date (ss.doc); 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)); gtk_widget_show (ss.view); @@ -459,7 +459,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::createDoc (ss->slides[++current], TRUE, false); } sp_svgview_set_document(ss, doc, current); @@ -475,7 +475,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::createDoc (ss->slides[--current], TRUE, false); } sp_svgview_set_document(ss, doc, current); @@ -493,7 +493,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::createDoc (ss->slides[current++], TRUE, false); } sp_svgview_set_document(ss, doc, current - 1); @@ -511,7 +511,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::createDoc (ss->slides[current--], TRUE, false); } sp_svgview_set_document(ss, doc, current + 1); diff --git a/src/interface.cpp b/src/interface.cpp index b33443d1b..4b3126680 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1318,7 +1318,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); @@ -1421,7 +1421,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); diff --git a/src/interface.h b/src/interface.h index 099fdd277..a9cf58471 100644 --- a/src/interface.h +++ b/src/interface.h @@ -17,7 +17,7 @@ #include #include "forward.h" - +#include "sp-item.h" /** * Create a new document window. diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp index a04ab05f0..7a39b6d81 100644 --- a/src/jabber_whiteboard/session-manager.cpp +++ b/src/jabber_whiteboard/session-manager.cpp @@ -393,7 +393,7 @@ makeInkboardDesktop(SPDocument* doc) { SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); + doc->doUnref(); sp_create_window(dtw, TRUE); dt = static_cast(dtw->view); diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 2d0d5eb02..9e3a3babc 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -77,7 +77,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 +89,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 +103,7 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p) Geom::Point KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::ConstraintLine 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; @@ -170,7 +170,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); @@ -220,7 +220,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); } @@ -254,7 +254,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); } diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 314ad807c..af11d5acb 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -83,7 +83,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::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity *e = *i; @@ -163,8 +163,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) for(std::list::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; } } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index a3a0faf37..dabeb5682 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -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()); diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 3820b5ba7..6eac43c43 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -31,7 +31,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(); diff --git a/src/live_effects/parameter/path-reference.h b/src/live_effects/parameter/path-reference.h index 67508e531..53b9ade04 100644 --- a/src/live_effects/parameter/path-reference.h +++ b/src/live_effects/parameter/path-reference.h @@ -10,6 +10,7 @@ */ #include +#include "sp-item.h" #include #include diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index d8d5b0a7c..e662f7d95 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -209,7 +209,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(param_effect->getLPEObj()); r.lpe_key = param_key; diff --git a/src/main.cpp b/src/main.cpp index 9f7bc9ad3..5cb317a44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1201,7 +1201,7 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g 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) { @@ -1234,7 +1234,7 @@ do_query_all_recurse (SPObject *o) { SPItem *item = ((SPItem *) o); if (o->getId() && SP_IS_ITEM(item)) { - Geom::OptRect area = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect area = item->getBounds(item->i2doc_affine()); if (area) { Inkscape::SVGOStringStream os; os << o->getId(); @@ -1329,7 +1329,7 @@ sp_do_export_png(SPDocument *doc) // write object bbox to area sp_document_ensure_up_to_date (doc); Geom::OptRect areaMaybe; - sp_item_invoke_bbox((SPItem *) o_area, areaMaybe, sp_item_i2d_affine((SPItem *) o_area), TRUE); + static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2d_affine(), TRUE); if (areaMaybe) { area = *areaMaybe; } else { diff --git a/src/marker.cpp b/src/marker.cpp index e4c2e0c30..e02276215 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -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); diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 1d81aa7f5..4cd365bb8 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -483,7 +483,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)) { @@ -659,7 +659,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); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index bced0ac44..cbf1dab6f 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -122,11 +122,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, snap_dim, true, sp_item_i2doc_affine(item)); + _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->i2doc_affine()); } obj = SP_OBJECT(item->mask_ref->getObject()); if (obj) { - _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item)); + _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->i2doc_affine()); } } } @@ -138,12 +138,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 @@ -227,7 +226,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, _snapmanager->snapprefs.setSnapIntersectionCS(false); } - sp_item_snappoints(root_item, *_points_to_snap_to, &_snapmanager->snapprefs); + root_item->getSnappoints(*_points_to_snap_to, &_snapmanager->snapprefs); if (_snapmanager->snapprefs.getSnapToItemPath()) { _snapmanager->snapprefs.setSnapIntersectionCS(old_pref); @@ -239,7 +238,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()); } } @@ -351,7 +350,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapCandidatePoint const & 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; } @@ -398,10 +397,10 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapCandidatePoint const & // 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)); } } diff --git a/src/print.cpp b/src/print.cpp index ed9b8d19c..7b582b0d1 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -104,14 +104,14 @@ sp_print_preview_document(SPDocument *doc) /* Create new arena */ mod->base = SP_ITEM(sp_document_root(doc)); 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); @@ -129,9 +129,9 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) // Build arena SPItem *base = SP_ITEM(sp_document_root(doc)); 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); } @@ -165,14 +165,14 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename) /* Create new arena */ mod->base = SP_ITEM(sp_document_root(doc)); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new(1); - mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new(1); + mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin(doc); - sp_item_invoke_print(mod->base, &context); + (mod->base)->invoke_print(&context); ret = mod->finish(); /* Release arena */ - sp_item_invoke_hide(mod->base, mod->dkey); + (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref((NRObject *) mod->arena); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 7ae27c13d..b232a340a 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -471,7 +471,7 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state) 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); diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 975b4becb..a804ceb5f 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -48,7 +48,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); diff --git a/src/selcue.cpp b/src/selcue.cpp index 8756524dd..0b28a8aef 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -84,7 +84,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 +125,7 @@ void Inkscape::SelCue::_newItemBboxes() for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { SPItem *item = (SPItem *) l->data; - Geom::OptRect const b = sp_item_bbox_desktop(item, bbox_type); + Geom::OptRect const b = item->getBboxDesktop(bbox_type); SPCanvasItem* box = NULL; @@ -192,7 +192,7 @@ 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); } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index cc153aa71..8237537c8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -241,7 +241,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); @@ -259,7 +259,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()); @@ -584,7 +584,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 @@ -770,7 +770,7 @@ 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; } @@ -826,7 +826,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)) { @@ -923,7 +923,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)) { @@ -1047,7 +1047,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); } @@ -1383,7 +1383,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons continue; for (SPObject *use = region->firstChild() ; use ; use = SP_OBJECT_NEXT(use)) { if (!SP_IS_USE(use)) continue; - sp_item_write_transform(SP_USE(use), SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate); + SP_USE(use)->doWriteTransform(SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate); } } } else if (transform_clone_with_original) { @@ -1395,7 +1395,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons sp_object_read_attr(SP_OBJECT(item), "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; @@ -1409,25 +1409,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 @@ -1993,7 +1993,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(); @@ -2224,8 +2224,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(); @@ -2284,7 +2284,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,7 +2338,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) { SP_OBJECT(item)->deleteObject(true); @@ -2407,7 +2407,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(); @@ -2531,7 +2531,7 @@ sp_selection_untile(SPDesktop *desktop) sp_document_ensure_up_to_date(doc); 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); } @@ -2744,7 +2744,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; @@ -3128,7 +3128,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); @@ -3205,7 +3205,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) sp_document_ensure_up_to_date(doc); 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; diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 1f975975a..48d1a2d16 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -17,6 +17,7 @@ */ #include "forward.h" +#include "sp-item.h" #include "2geom/forward.h" namespace Inkscape { class Selection; } diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 9321ea0ef..bd8d8e12e 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -182,7 +182,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, diff --git a/src/selection.cpp b/src/selection.cpp index 96c66e0c5..acf6a8e6e 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -374,7 +374,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 +393,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; @@ -436,7 +436,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc std::vector 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 @@ -458,7 +458,7 @@ std::vector Selection::getSnapPointsConvexHull(Sna std::vector 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 pHull; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 05f47d4ab..89799246c 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -265,7 +265,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 +333,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 @@ -444,7 +444,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) { @@ -599,15 +599,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 = ©_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); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 4bbabc965..9cd2b2ca4 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -166,8 +166,7 @@ sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: 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) { @@ -267,7 +266,7 @@ sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { 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); @@ -293,7 +292,7 @@ sp_clippath_hide(SPClipPath *cp, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { - sp_item_invoke_hide(SP_ITEM(child), key); + SP_ITEM(child)->invoke_hide(key); } } @@ -331,13 +330,13 @@ sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform for (i = sp_object_first_child(SP_OBJECT(cp)); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; 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); @@ -400,7 +399,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); } } diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 7f019979a..24c7e7e5c 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -405,7 +405,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; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 88fc59f17..86b6106c5 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -281,7 +281,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectori2d_affine(); // figure out if we have a slice, while guarding against rounding errors bool slice = false; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index b01146d60..5f3517f92 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -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)); @@ -199,7 +199,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)); @@ -351,9 +351,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; } @@ -364,7 +364,7 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) 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)); + Geom::Matrix const ctm (item->i2d_affine()); group->layout.print(ctx, &pbox, &dbox, &bbox, ctm); } @@ -392,7 +392,7 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional 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 +408,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; @@ -742,7 +742,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; } diff --git a/src/sp-gradient-test.h b/src/sp-gradient-test.h index bc188401b..209bc7efb 100644 --- a/src/sp-gradient-test.h +++ b/src/sp-gradient-test.h @@ -25,7 +25,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); } } diff --git a/src/sp-guide-attachment.h b/src/sp-guide-attachment.h index 277b435b6..5e3688b88 100644 --- a/src/sp-guide-attachment.h +++ b/src/sp-guide-attachment.h @@ -2,6 +2,7 @@ #define __SP_GUIDE_ATTACHMENT_H__ #include +#include "sp-item.h" class SPGuideAttachment { public: diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 68bafdeab..367d2e489 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -569,7 +569,7 @@ sp_image_get_type (void) (GInstanceInitFunc) sp_image_init, NULL, /* value_table */ }; - image_type = g_type_register_static (sp_item_get_type (), "SPImage", &image_info, (GTypeFlags)0); + image_type = g_type_register_static (SPItem::getType (), "SPImage", &image_info, (GTypeFlags)0); } return image_type; } @@ -585,7 +585,7 @@ 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; @@ -1352,7 +1352,7 @@ static void sp_image_snappoints(SPItem const *item, std::vectori2d_affine ()); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 588427752..2369ce38a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -331,7 +331,7 @@ static void sp_group_snappoints (SPItem const *item, std::vectorgetSnappoints(p, snapprefs); } } } @@ -353,7 +353,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); @@ -377,7 +377,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 +487,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)) @@ -604,7 +604,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); @@ -618,10 +618,10 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) { SPItemView *v; NRArenaItem *ac; - unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild)); + unsigned position = SP_ITEM(ochild)->pos_in_parent(); for (v = _group->display; v != NULL; v = v->next) { - ac = sp_item_invoke_show (SP_ITEM (ochild), NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); + ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); if (ac) { nr_arena_item_add_child (v->arenaitem, ac, NULL); @@ -709,7 +709,7 @@ 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 +722,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); } @@ -771,7 +771,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 +789,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); } @@ -804,7 +804,7 @@ void CGroup::onOrderChanged (Inkscape::XML::Node *child, Inkscape::XML::Node *, 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); } diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index 628d77956..340aac1ac 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -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 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); diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index 792a9d3bf..e92a573f1 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -15,7 +15,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item) return; } std::vector 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]; diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 23c0bdf33..275d6b046 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -25,9 +25,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 +39,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 +56,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 +68,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); } /* diff --git a/src/sp-item-update-cns.cpp b/src/sp-item-update-cns.cpp index 51da1679d..e1b3989dc 100644 --- a/src/sp-item-update-cns.cpp +++ b/src/sp-item-update-cns.cpp @@ -10,7 +10,7 @@ using std::vector; void sp_item_update_cns(SPItem &item, SPDesktop const &desktop) { std::vector snappoints; - sp_item_snappoints(&item, snappoints, NULL); + item.getSnappoints(snappoints, NULL); /* TODO: Implement the ordering. */ vector found_cns; satisfied_guide_cns(desktop, snappoints, found_cns); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5a2dfb2f0..e5f8eade1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -80,38 +80,40 @@ #define noSP_ITEM_DEBUG_IDLE -static void sp_item_class_init(SPItemClass *klass); -static void sp_item_init(SPItem *item); +//static void sp_item_class_init(SPItemClass *klass); +//static void sp_item_init(SPItem *item); -static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -static void sp_item_release(SPObject *object); -static void sp_item_set(SPObject *object, unsigned key, gchar const *value); -static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); -static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +//static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +//static void sp_item_release(SPObject *object); +//static void sp_item_set(SPObject *object, unsigned key, gchar const *value); +//static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); +//static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static gchar *sp_item_private_description(SPItem *item); -static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); +//static gchar *sp_item_private_description(SPItem *item); +//static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); -static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); +//static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); +//static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); -static SPObjectClass *parent_class; +//static SPObjectClass *parent_class; -static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); -static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); +//static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); +//static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); + +SPObjectClass * SPItemClass::static_parent_class=0; /** * Registers SPItem class and returns its type number. */ GType -sp_item_get_type(void) +SPItem::getType(void) { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPItemClass), NULL, NULL, - (GClassInitFunc) sp_item_class_init, + (GClassInitFunc) SPItemClass::sp_item_class_init, NULL, NULL, sizeof(SPItem), 16, @@ -126,28 +128,28 @@ 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(); } @@ -296,7 +298,7 @@ SPItem::setCenter(Geom::Point object_centre) { // for getBounds() to work sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(this)); - 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 @@ -321,7 +323,7 @@ Geom::Point SPItem::getCenter() const { // for getBounds() to work sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(this)); - 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); } else { @@ -400,8 +402,8 @@ void SPItem::lowerToBottom() { } } -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"); @@ -414,13 +416,13 @@ sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) sp_object_read_attr(object, "inkscape:connector-avoid"); sp_object_read_attr(object, "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; @@ -447,8 +449,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) { @@ -459,8 +461,8 @@ 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; @@ -468,9 +470,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; } @@ -546,16 +548,16 @@ 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; @@ -567,10 +569,10 @@ clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) } 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), NR_ARENA_ITEM_ARENA(v->arenaitem), @@ -583,8 +585,8 @@ clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) } } -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 */ @@ -595,10 +597,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), @@ -611,13 +613,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) { @@ -631,7 +633,7 @@ 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); @@ -655,7 +657,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 { @@ -669,8 +671,8 @@ 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); @@ -725,8 +727,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; @@ -741,21 +743,21 @@ 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); + SP_ITEM(this)->invoke_bbox_full( r, transform, type, TRUE); return r; } void -sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) +SPItem::invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - sp_item_invoke_bbox_full(item, bbox, transform, type, clear); + invoke_bbox_full( bbox, transform, type, clear); } // DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect void -sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) +SPItem::invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - 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,10 +768,10 @@ sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transf * function returns. If this item does not have a boundingbox, this might well be empty. */ void -sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) +SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); if (clear) { bbox = Geom::OptRect(); @@ -782,14 +784,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 (SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href) { - SPObject *filter = SP_OBJECT_STYLE(item)->getFilter(); + if (SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->filter.href) { + SPObject *filter = SP_OBJECT_STYLE(this)->getFilter(); if (filter && SP_IS_FILTER(filter)) { // default filer area per the SVG spec: double x = -0.1; @@ -829,7 +831,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(); @@ -842,9 +844,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 (this->clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); + sp_clippath_get_bbox(SP_CLIPPATH(this->clip_ref->getObject()), &b, transform, flags); nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b); } } @@ -874,10 +876,10 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups, * clones), in turn, call this function in their bbox methods. */ void -sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) +SPItem::invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); g_assert(bbox != NULL); if (clear) { @@ -890,14 +892,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 && this->clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); + sp_clippath_get_bbox(SP_CLIPPATH(this->clip_ref->getObject()), &b, transform, flags); nr_rect_d_intersect (&this_bbox, &this_bbox, &b); } @@ -907,16 +909,16 @@ 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)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); - SPObject *parent = SP_OBJECT_PARENT(item); + SPObject *parent = SP_OBJECT_PARENT(this); g_assert(parent != NULL); g_assert(SP_IS_OBJECT(parent)); - SPObject *object = SP_OBJECT(item); + SPObject *object = SP_OBJECT(this); unsigned pos=0; for ( SPObject *iter = sp_object_first_child(parent) ; iter ; iter = SP_OBJECT_NEXT(iter)) { @@ -933,30 +935,30 @@ unsigned sp_item_pos_in_parent(SPItem *item) } void -sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type) +SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(item != NULL); + //g_assert(SP_IS_ITEM(item)); g_assert(bbox != NULL); - sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE, type); + invoke_bbox( bbox, i2d_affine(), TRUE, type); } -Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type) +Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) { Geom::OptRect rect = Geom::OptRect(); - sp_item_invoke_bbox(item, rect, sp_item_i2d_affine(item), TRUE, type); + invoke_bbox( rect, i2d_affine(), TRUE, type); return rect; } -static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector &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; @@ -970,27 +972,27 @@ static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) +void SPItem::getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { - g_assert (item != NULL); - g_assert (SP_IS_ITEM(item)); + //g_assert (this != NULL); + //g_assert (SP_IS_ITEM(this)); // Get the snappoints of the item - SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item); + SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(this); if (item_class.snappoints) { - item_class.snappoints(item, p, snapprefs); + item_class.snappoints(this, p, snapprefs); } // Get the snappoints at the item's center if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { - p.push_back(Inkscape::SnapCandidatePoint(item->getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER)); + p.push_back(Inkscape::SnapCandidatePoint(getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER)); } // Get the snappoints of clipping paths and mask, if any std::list clips_and_masks; - clips_and_masks.push_back(SP_OBJECT(item->clip_ref->getObject())); - clips_and_masks.push_back(SP_OBJECT(item->mask_ref->getObject())); + clips_and_masks.push_back(SP_OBJECT(clip_ref->getObject())); + clips_and_masks.push_back(SP_OBJECT(mask_ref->getObject())); SPDesktop *desktop = inkscape_active_desktop(); for (std::list::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); o++) { @@ -1000,12 +1002,12 @@ void sp_item_snappoints(SPItem const *item, std::vector 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::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())); } } @@ -1015,25 +1017,25 @@ void sp_item_snappoints(SPItem const *item, std::vectorisHidden()) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) { - if (!item->transform.isIdentity() - || SP_OBJECT_STYLE(item)->opacity.value != SP_SCALE24_MAX) + if (!this->isHidden()) { + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->print) { + if (!this->transform.isIdentity() + || SP_OBJECT_STYLE(this)->opacity.value != SP_SCALE24_MAX) { - sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value)); - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx); + sp_print_bind(ctx, this->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(this)->opacity.value)); + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->print(this, ctx); sp_print_release(ctx); } else { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx); + ((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")); } @@ -1044,25 +1046,25 @@ sp_item_private_description(SPItem */*item*/) * Must be freed by caller. */ gchar * -sp_item_description(SPItem *item) +SPItem::description() { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) { - gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item); - if (s && item->clip_ref->getObject()) { + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { + gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->description(this); + if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; clipped"), s); g_free (s); s = snew; } - if (s && item->mask_ref->getObject()) { + if (s && mask_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; masked"), s); g_free (s); s = snew; } - if (SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href && SP_OBJECT_STYLE(item)->filter.href->getObject()) { - const gchar *label = SP_OBJECT_STYLE(item)->filter.href->getObject()->label(); + if (SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->filter.href && SP_OBJECT_STYLE(this)->filter.href->getObject()) { + const gchar *label = SP_OBJECT_STYLE(this)->filter.href->getObject()->label(); gchar *snew; if (label) { snew = g_strdup_printf (_("%s; filtered (%s)"), s, _(label)); @@ -1086,7 +1088,7 @@ sp_item_description(SPItem *item) * you can use n, n + 1, ..., n + (numkeys - 1) */ unsigned -sp_item_display_key_new(unsigned numkeys) +SPItem::display_key_new(unsigned numkeys) { static unsigned dkey = 0; @@ -1096,31 +1098,31 @@ sp_item_display_key_new(unsigned numkeys) } NRArenaItem * -sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) +SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); g_assert(arena != NULL); g_assert(NR_IS_ARENA(arena)); NRArenaItem *ai = NULL; - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->show) { - ai = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->show(item, arena, key, flags); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) { + ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, arena, key, flags); } if (ai != NULL) { - item->display = sp_item_view_new_prepend(item->display, item, flags, key, ai); - nr_arena_item_set_transform(ai, item->transform); - nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value)); - nr_arena_item_set_visible(ai, !item->isHidden()); - nr_arena_item_set_sensitive(ai, item->sensitive); - if (item->clip_ref->getObject()) { - SPClipPath *cp = item->clip_ref->getObject(); - - if (!item->display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3)); + display = sp_item_view_new_prepend(display, this, flags, key, ai); + nr_arena_item_set_transform(ai, transform); + nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(this)->opacity.value)); + nr_arena_item_set_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); @@ -1129,17 +1131,17 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) // Update bbox, in case the clip uses bbox units NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + invoke_bbox( &bbox, Geom::identity(), TRUE); sp_clippath_set_bbox(SP_CLIPPATH(cp), clip_key, &bbox); SP_OBJECT(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); @@ -1148,13 +1150,13 @@ 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); SP_OBJECT(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); } @@ -1162,30 +1164,30 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) } void -sp_item_invoke_hide(SPItem *item, unsigned key) +SPItem::invoke_hide(unsigned key) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide) { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide(item, key); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) { + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide(this, key); } SPItemView *ref = NULL; - SPItemView *v = item->display; + SPItemView *v = display; while (v != NULL) { SPItemView *next = v->next; if (v->key == key) { - if (item->clip_ref->getObject()) { - sp_clippath_hide(item->clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + if (clip_ref->getObject()) { + sp_clippath_hide(clip_ref->getObject(), 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; } @@ -1202,22 +1204,22 @@ sp_item_invoke_hide(SPItem *item, unsigned key) // Adjusters void -sp_item_adjust_pattern (SPItem *item, Geom::Matrix const &postmul, bool set) +SPItem::adjust_pattern (Geom::Matrix const &postmul, bool set) { - SPStyle *style = SP_OBJECT_STYLE (item); + SPStyle *style = SP_OBJECT_STYLE (this); if (style && (style->fill.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item); + SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (this); 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())) { - SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item); + SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (this); 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); } } @@ -1225,12 +1227,12 @@ sp_item_adjust_pattern (SPItem *item, Geom::Matrix const &postmul, bool set) } void -sp_item_adjust_gradient (SPItem *item, Geom::Matrix const &postmul, bool set) +SPItem::adjust_gradient (Geom::Matrix const &postmul, bool set) { - SPStyle *style = SP_OBJECT_STYLE (item); + SPStyle *style = SP_OBJECT_STYLE (this); if (style && (style->fill.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item); + SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(this); if (SP_IS_GRADIENT (server)) { /** @@ -1242,25 +1244,25 @@ sp_item_adjust_gradient (SPItem *item, Geom::Matrix const &postmul, bool set) * \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())) { - SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item); + SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(this); 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) +SPItem::adjust_stroke (gdouble ex) { - SPStyle *style = SP_OBJECT_STYLE (item); + SPStyle *style = SP_OBJECT_STYLE (this); if (style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) { @@ -1275,7 +1277,7 @@ sp_item_adjust_stroke (SPItem *item, gdouble ex) style->stroke_dash.offset *= ex; } - SP_OBJECT(item)->updateRepr(); + SP_OBJECT(this)->updateRepr(); } } @@ -1302,17 +1304,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) +SPItem::adjust_stroke_width_recursive(double expansion) { - sp_item_adjust_stroke (item, expansion); + adjust_stroke (expansion); // A clone's child is the ghost of its original - we must not touch it, skip recursion - if (item && SP_IS_USE(item)) + if (this && SP_IS_USE(this)) return; - for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) { + for (SPObject *o = SP_OBJECT(this)->children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) - sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion); + SP_ITEM(o)->adjust_stroke_width_recursive(expansion); } } @@ -1336,23 +1338,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) +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 = SP_OBJECT(item)->children; o != NULL; o = o->next) { + if (!(this && (SP_IS_TEXT(this) || SP_IS_USE(this)))) { + for (SPObject *o = SP_OBJECT(this)->children; o != NULL; o = o->next) { 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); } } } @@ -1363,19 +1365,19 @@ sp_item_adjust_paint_recursive (SPItem *item, Geom::Matrix advertized_transform, // before ancestors themselves are adjusted, probably differently (bug 1286535) if (is_pattern) - sp_item_adjust_pattern (item, paint_delta); + adjust_pattern (paint_delta); else - sp_item_adjust_gradient (item, paint_delta); + adjust_gradient (paint_delta); } void -sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool set) +SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set) { - if ( !SP_IS_LPE_ITEM(item) ) + if ( !SP_IS_LPE_ITEM(this) ) return; - SPLPEItem *lpeitem = SP_LPE_ITEM (item); + SPLPEItem *lpeitem = SP_LPE_ITEM (this); if ( sp_lpe_item_has_path_effect(lpeitem) ) { sp_lpe_item_fork_path_effects_if_necessary(lpeitem); @@ -1401,10 +1403,10 @@ sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool s * the repr is updated with the new transform. */ void -sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) +SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); + g_return_if_fail(this != NULL); + g_return_if_fail(SP_IS_ITEM(this)); g_return_if_fail(repr != NULL); // calculate the relative transform, if not given by the adv attribute @@ -1412,7 +1414,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(); @@ -1421,26 +1423,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) @@ -1448,36 +1450,36 @@ 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() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter()) + !clip_ref->getObject() && // the object does not have a clippath + !mask_ref->getObject() && // the object does not have a mask + !(!transform.isTranslation() && SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->getFilter()) // 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. - SP_OBJECT(item)->updateRepr(); + SP_OBJECT(this)->updateRepr(); // send the relative transform with a _transformed_signal - item->_transformed_signal.emit(&advertized_transform, item); + _transformed_signal.emit(&advertized_transform, this); } gint -sp_item_event(SPItem *item, SPEvent *event) +SPItem::emitEvent(SPEvent &event) { - g_return_val_if_fail(item != NULL, FALSE); - g_return_val_if_fail(SP_IS_ITEM(item), FALSE); - g_return_val_if_fail(event != NULL, FALSE); + //g_return_val_if_fail(this != NULL, FALSE); + //g_return_val_if_fail(SP_IS_ITEM(this), FALSE); + //g_return_val_if_fail((&event) != NULL, FALSE); - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->event) - return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->event(item, event); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) + return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event); return FALSE; } @@ -1487,34 +1489,34 @@ sp_item_event(SPItem *item, SPEvent *event) * gradients, patterns as sp_item_write_transform does. */ void -sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform) +SPItem::set_item_transform(Geom::Matrix const &transform_matrix) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); + g_return_if_fail(this != NULL); + g_return_if_fail(SP_IS_ITEM(this)); - if (!matrix_equalp(transform, item->transform, NR_EPSILON)) { - item->transform = transform; + if (!matrix_equalp(transform_matrix, transform, NR_EPSILON)) { + transform = transform_matrix; /* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a transformation. It's apparently not used anywhere else. */ - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B); - sp_item_rm_unsatisfied_cns(*item); + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B); + sp_item_rm_unsatisfied_cns(*this); } } void -sp_item_convert_item_to_guides(SPItem *item) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); +SPItem::convert_item_to_guides() { + g_return_if_fail(this != NULL); + g_return_if_fail(SP_IS_ITEM(this)); /* Use derived method if present ... */ - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides) { - (*((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides)(item); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) { + (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this); return; } /* .. otherwise simply place the guides around the item's bounding box */ - sp_item_convert_to_guides(item); + convert_to_guides(); } @@ -1554,40 +1556,40 @@ 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)); + //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(SP_OBJECT_DOCUMENT(item))) ); + * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(this))) ); return ret; } -void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) +void SPItem::set_i2d_affine(Geom::Matrix const &i2dt) { - g_return_if_fail( item != NULL ); - g_return_if_fail( SP_IS_ITEM(item) ); + //g_return_if_fail( item != NULL ); + //g_return_if_fail( SP_IS_ITEM(item) ); Geom::Matrix dt2p; /* desktop to item parent transform */ - if (SP_OBJECT_PARENT(item)) { - dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse(); + if (SP_OBJECT_PARENT(this)) { + dt2p = static_cast(SP_OBJECT_PARENT(this))->i2d_affine().inverse(); } else { - dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) + dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(this))) * Geom::Scale(1, -1) ); } Geom::Matrix const i2p( i2dt * dt2p ); - sp_item_set_item_transform(item, i2p); + set_item_transform(i2p); } @@ -1595,16 +1597,16 @@ void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa) */ Geom::Matrix -sp_item_dt2i_affine(SPItem const *item) +SPItem::dt2i_affine() const { /* 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; @@ -1623,8 +1625,8 @@ 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; @@ -1646,9 +1648,9 @@ sp_item_view_list_remove(SPItemView *list, SPItemView *view) * with the given key */ NRArenaItem * -sp_item_get_arenaitem(SPItem *item, unsigned key) +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; } @@ -1675,7 +1677,7 @@ sp_item_first_item_child (SPObject *obj) } void -sp_item_convert_to_guides(SPItem *item) { +SPItem::convert_to_guides() { SPDesktop *dt = inkscape_active_desktop(); SPNamedView *nv = sp_desktop_namedview(dt); (void)nv; @@ -1685,7 +1687,7 @@ sp_item_convert_to_guides(SPItem *item) { SPItem::BBoxType bbox_type = (prefs_bbox ==0)? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; - Geom::OptRect bbox = sp_item_bbox_desktop(item, bbox_type); + Geom::OptRect bbox = getBboxDesktop(bbox_type); if (!bbox) { g_warning ("Cannot determine item's bounding box during conversion to guides.\n"); return; diff --git a/src/sp-item.h b/src/sp-item.h index faf64846e..d2c24baf0 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -53,13 +53,17 @@ enum { * Also, this probably goes to SPObject base class. * */ -struct SPEvent { +//struct SPEvent { +class SPEvent { + public: unsigned int type; gpointer data; }; /// SPItemView -struct SPItemView { +//struct SPItemView { +class SPItemView { + public: SPItemView *next; unsigned int flags; unsigned int key; @@ -79,7 +83,9 @@ struct SPItemView { #define SP_ITEM_REFERENCE_FLAGS (1 << 1) /// Contains transformations to document/viewport and the viewport size. -struct SPItemCtx { +//struct SPItemCtx { +class SPItemCtx { + public: SPCtx ctx; /** Item to document transformation */ Geom::Matrix i2doc; @@ -89,8 +95,20 @@ 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 { +//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,7 +178,36 @@ struct SPItem : public SPObject { sigc::connection connectTransformed(sigc::slot slot) { return _transformed_signal.connect(slot); } - + void invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + void invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); + void invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); + void invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); + + unsigned pos_in_parent(); + gchar *description(); + void invoke_print(SPPrintContext *ctx); + static unsigned int display_key_new(unsigned int numkeys); + NRArenaItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); + void invoke_hide(unsigned int key); + void getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs=0) const; + void adjust_pattern(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); + void adjust_gradient(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); + void adjust_stroke(gdouble ex); + void adjust_stroke_width_recursive(gdouble ex); + void adjust_paint_recursive(Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); + void adjust_livepatheffect(Geom::Matrix const &postmul, bool set = false); + void doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); + void set_item_transform(Geom::Matrix const &transform_matrix); + void convert_item_to_guides(); + gint emitEvent (SPEvent &event); + NRArenaItem *get_arenaitem(unsigned int key); + void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); + Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + Geom::Matrix i2doc_affine() const; + Geom::Matrix i2d_affine() const; + void set_i2d_affine(Geom::Matrix const &transform); + Geom::Matrix dt2i_affine() const; + void convert_to_guides(); private: enum EvaluatedStatus { @@ -169,10 +216,30 @@ 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 &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 { +//struct SPItemClass { +class SPItemClass { + public: SPObjectClass parent_class; /** BBox union in given coordinate system */ @@ -201,6 +268,12 @@ struct SPItemClass { /** Emit event, if applicable */ gint (* event) (SPItem *item, SPEvent *event); + + private: + static SPObjectClass *static_parent_class; + static void sp_item_class_init(SPItemClass *klass); + + friend class SPItem; }; /* Flag testing macros */ @@ -209,49 +282,49 @@ struct SPItemClass { /* 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)); +//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); +//unsigned sp_item_pos_in_parent(SPItem *item); -gchar *sp_item_description(SPItem * item); -void sp_item_invoke_print(SPItem *item, SPPrintContext *ctx); +//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); +//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 &p, Inkscape::SnapPreferences const *snapprefs); +//void sp_item_snappoints(SPItem const *item, std::vector &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_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_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_set_item_transform(SPItem *item, Geom::Matrix const &transform); -void sp_item_convert_item_to_guides(SPItem *item); +//void sp_item_convert_item_to_guides(SPItem *item); -gint sp_item_event (SPItem *item, SPEvent *event); +//gint sp_item_event (SPItem *item, SPEvent *event); /* Utility */ -NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); +//NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); -void sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); -Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); +//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); Geom::Matrix i2anc_affine(SPObject const *item, SPObject const *ancestor); Geom::Matrix i2i_affine(SPObject const *src, SPObject const *dest); -Geom::Matrix sp_item_i2doc_affine(SPItem const *item); +//Geom::Matrix sp_item_i2doc_affine(SPItem const *item); /* fixme: - these are evil, but OK */ @@ -261,13 +334,13 @@ 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); +//Geom::Matrix sp_item_i2d_affine(SPItem const *item); +//void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &transform); +//Geom::Matrix sp_item_dt2i_affine(SPItem const *item); int sp_item_repr_compare_position(SPItem *first, SPItem *second); SPItem *sp_item_first_item_child (SPObject *obj); -void sp_item_convert_to_guides(SPItem *item); +//void sp_item_convert_to_guides(SPItem *item); #endif diff --git a/src/sp-line.cpp b/src/sp-line.cpp index d0ce32397..878fceb67 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -25,24 +25,25 @@ #include "document.h" #include "inkscape.h" -static void sp_line_class_init (SPLineClass *klass); -static void sp_line_init (SPLine *line); +//static void sp_line_class_init (SPLineClass *klass); +//static void sp_line_init (SPLine *line); -static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); -static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); -static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +//static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +//static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); +//static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static gchar *sp_line_description (SPItem * item); -static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); +//static gchar *sp_line_description (SPItem * item); +//static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); -static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); -static void sp_line_set_shape (SPShape *shape); -static void sp_line_convert_to_guides(SPItem *item); +//static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); +//static void sp_line_set_shape (SPShape *shape); +//static void sp_line_convert_to_guides(SPItem *item); -static SPShapeClass *parent_class; +//static SPShapeClass *static_parent_class; +SPShapeClass * SPLineClass::static_parent_class=0; GType -sp_line_get_type (void) +SPLine::sp_line_get_type (void) { static GType line_type = 0; @@ -51,7 +52,7 @@ sp_line_get_type (void) sizeof (SPLineClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_line_class_init, + (GClassInitFunc) SPLineClass::sp_line_class_init, NULL, /* klass_finalize */ NULL, /* klass_data */ sizeof (SPLine), @@ -64,29 +65,30 @@ sp_line_get_type (void) 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; + sp_object_class->build = SPLine::sp_line_build; + sp_object_class->set = SPLine::sp_line_set; + sp_object_class->write = SPLine::sp_line_write; SPItemClass *item_class = (SPItemClass *) klass; - item_class->description = sp_line_description; - item_class->set_transform = sp_line_set_transform; - item_class->convert_to_guides = sp_line_convert_to_guides; + item_class->description = SPLine::sp_line_description; + item_class->set_transform = SPLine::sp_line_set_transform; + item_class->convert_to_guides = SPLine::sp_line_convert_to_guides; - sp_object_class->update = sp_line_update; + sp_object_class->update = SPLine::sp_line_update; SPShapeClass *shape_class = (SPShapeClass *) klass; - shape_class->set_shape = sp_line_set_shape; + shape_class->set_shape = SPLine::sp_line_set_shape; } -static void -sp_line_init (SPLine * line) +void +SPLine::sp_line_init (SPLine * line) { line->x1.unset(); line->y1.unset(); @@ -95,11 +97,11 @@ sp_line_init (SPLine * line) } -static void -sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) +void +SPLine::sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) SPLineClass::static_parent_class)->build) { + ((SPObjectClass *) SPLineClass::static_parent_class)->build (object, document, repr); } sp_object_read_attr (object, "x1"); @@ -108,8 +110,8 @@ sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * r sp_object_read_attr (object, "y2"); } -static void -sp_line_set (SPObject *object, unsigned int key, const gchar *value) +void +SPLine::sp_line_set (SPObject *object, unsigned int key, const gchar *value) { SPLine * line = SP_LINE (object); @@ -133,14 +135,14 @@ sp_line_set (SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) SPLineClass::static_parent_class)->set) + ((SPObjectClass *) SPLineClass::static_parent_class)->set (object, key, value); break; } } -static void -sp_line_update (SPObject *object, SPCtx *ctx, guint flags) +void +SPLine::sp_line_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); @@ -159,13 +161,13 @@ sp_line_update (SPObject *object, SPCtx *ctx, guint flags) sp_shape_set_shape ((SPShape *) object); } - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + if (((SPObjectClass *) SPLineClass::static_parent_class)->update) + ((SPObjectClass *) SPLineClass::static_parent_class)->update (object, ctx, flags); } -static Inkscape::XML::Node * -sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPLine::sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPLine *line = SP_LINE (object); @@ -182,25 +184,25 @@ sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML 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; } -static gchar * -sp_line_description(SPItem */*item*/) +gchar * +SPLine::sp_line_description(SPItem */*item*/) { return g_strdup(_("Line")); } -static void -sp_line_convert_to_guides(SPItem *item) +void +SPLine::sp_line_convert_to_guides(SPItem *item) { 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; @@ -208,8 +210,8 @@ sp_line_convert_to_guides(SPItem *item) sp_guide_create(inkscape_active_desktop(), points[0], points[1]); } -static Geom::Matrix -sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) +Geom::Matrix +SPLine::sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) { SPLine *line = SP_LINE (item); Geom::Point points[2]; @@ -225,15 +227,15 @@ sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) 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); return Geom::identity(); } -static void -sp_line_set_shape (SPShape *shape) +void +SPLine::sp_line_set_shape (SPShape *shape) { SPLine *line = SP_LINE (shape); diff --git a/src/sp-line.h b/src/sp-line.h index cc6802b7f..114b0ea7c 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -17,7 +17,7 @@ -#define SP_TYPE_LINE (sp_line_get_type ()) +#define SP_TYPE_LINE (SPLine::sp_line_get_type ()) #define SP_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_LINE, SPLine)) #define SP_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_LINE, SPLineClass)) #define SP_IS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_LINE)) @@ -26,18 +26,43 @@ class SPLine; class SPLineClass; -struct SPLine : public SPShape { - SVGLength x1; - SVGLength y1; - SVGLength x2; - SVGLength y2; +//static void sp_line_class_init (SPLineClass *klass); + +class SPLine : public SPShape { + public: + SVGLength x1; + SVGLength y1; + SVGLength x2; + SVGLength y2; + static GType sp_line_get_type (void); + private: + static void sp_line_init (SPLine *line); + + static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); + static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); + static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + + static gchar *sp_line_description (SPItem * item); + static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); + + static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); + static void sp_line_set_shape (SPShape *shape); + static void sp_line_convert_to_guides(SPItem *item); + + friend class SPLineClass; }; -struct SPLineClass { - SPShapeClass parent_class; +class SPLineClass { + public: + SPShapeClass parent_class; + private: + static SPShapeClass *static_parent_class; + static void sp_line_class_init (SPLineClass *klass); + + friend class SPLine; }; -GType sp_line_get_type (void); +//GType sp_line_get_type (void); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 20cb38297..b0369efe5 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -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) { @@ -289,7 +288,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); } } @@ -313,7 +312,7 @@ sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(mask)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { 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); @@ -339,7 +338,7 @@ sp_mask_hide (SPMask *cp, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)); child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM (child)) { - sp_item_invoke_hide (SP_ITEM (child), key); + SP_ITEM(child)->invoke_hide (key); } } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 556778676..30626695e 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -510,7 +510,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(); @@ -1049,7 +1049,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); } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 54d2a201a..39ed4c657 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -171,7 +171,7 @@ sp_path_convert_to_guides(SPItem *item) std::list > 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) { @@ -392,16 +392,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); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ec0d0d576..56e7956b6 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -327,12 +327,12 @@ sp_pattern_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape:: 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); @@ -524,7 +524,7 @@ 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); @@ -645,7 +645,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); } /** @@ -727,7 +727,7 @@ 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); @@ -741,7 +741,7 @@ sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, G // for each item in pattern, NRArenaItem *cai; // show it on our arena, - cai = sp_item_invoke_show (SP_ITEM (child), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); + cai = SP_ITEM (child)->invoke_show (pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); // add to the group, nr_arena_item_append_child (pp->root, cai); // and connect to the release signal in case the item gets deleted diff --git a/src/sp-pattern.h b/src/sp-pattern.h index f15285e27..be926aabb 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -15,7 +15,7 @@ #include #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)) diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 08f446d61..110fb4d01 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -20,19 +20,21 @@ #include "xml/repr.h" #include "document.h" -static void sp_polyline_class_init (SPPolyLineClass *klass); -static void sp_polyline_init (SPPolyLine *polyline); +//static void sp_polyline_class_init (SPPolyLineClass *klass); +//static void sp_polyline_init (SPPolyLine *polyline); -static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); -static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); -static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +//static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +//static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); +//static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static gchar * sp_polyline_description (SPItem * item); +//static gchar * sp_polyline_description (SPItem * item); -static SPShapeClass *parent_class; +//static SPShapeClass *parent_class; + +SPShapeClass * SPPolyLineClass::static_parent_class=0; GType -sp_polyline_get_type (void) +SPPolyLine::sp_polyline_get_type (void) { static GType polyline_type = 0; @@ -41,7 +43,7 @@ sp_polyline_get_type (void) sizeof (SPPolyLineClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_polyline_class_init, + (GClassInitFunc) SPPolyLineClass::sp_polyline_class_init, NULL, /* klass_finalize */ NULL, /* klass_data */ sizeof (SPPolyLine), @@ -54,8 +56,8 @@ sp_polyline_get_type (void) 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; @@ -65,33 +67,33 @@ sp_polyline_class_init (SPPolyLineClass *klass) sp_object_class = (SPObjectClass *) klass; 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::sp_polyline_build; + sp_object_class->set = SPPolyLine::sp_polyline_set; + sp_object_class->write = SPPolyLine::sp_polyline_write; - item_class->description = sp_polyline_description; + item_class->description = SPPolyLine::sp_polyline_description; } -static void -sp_polyline_init (SPPolyLine * /*polyline*/) +void +SPPolyLine::sp_polyline_init (SPPolyLine * /*polyline*/) { /* Nothing here */ } -static void -sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) +void +SPPolyLine::sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - 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"); } -static void -sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) +void +SPPolyLine::sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) { SPPolyLine *polyline; @@ -144,14 +146,14 @@ sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) break; } default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) + ((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value); break; } } -static Inkscape::XML::Node * -sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPPolyLine::sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPPolyLine *polyline; @@ -165,14 +167,14 @@ sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape: 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; } -static gchar * -sp_polyline_description(SPItem */*item*/) +gchar * +SPPolyLine::sp_polyline_description(SPItem */*item*/) { return g_strdup(_("Polyline")); } diff --git a/src/sp-polyline.h b/src/sp-polyline.h index 3ee18d6a5..b7657288c 100644 --- a/src/sp-polyline.h +++ b/src/sp-polyline.h @@ -5,7 +5,7 @@ -#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)) @@ -14,14 +14,32 @@ class SPPolyLine; class SPPolyLineClass; -struct SPPolyLine : public SPShape { +class SPPolyLine : public SPShape { + public: + static GType sp_polyline_get_type (void); + private: + static void sp_polyline_init (SPPolyLine *polyline); + + 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); + + friend class SPPolyLineClass; + }; -struct SPPolyLineClass { - SPShapeClass parent_class; +class SPPolyLineClass { + public: + SPShapeClass parent_class; + private: + static SPShapeClass *static_parent_class; + static void sp_polyline_class_init (SPPolyLineClass *klass); + + friend class SPPolyLine; }; -GType sp_polyline_get_type (void); diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index bdfae7c99..f4993cdc9 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -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::vectori2d_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 > pts; - Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(rect))); + Geom::Matrix const i2d (SP_ITEM(rect)->i2d_affine()); Geom::Point A1(Geom::Point(rect->x.computed, rect->y.computed) * i2d); Geom::Point A2(Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 3064341b6..4de6aeb80 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -297,7 +297,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) /* 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]) { @@ -609,7 +609,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); } @@ -637,7 +637,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 @@ -664,7 +664,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); } @@ -685,7 +685,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); } } @@ -720,7 +720,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); } @@ -749,7 +749,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; } /** @@ -777,13 +777,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)); + item->getBboxDesktop (&bbox); + Geom::Matrix const i2d(item->i2d_affine()); SPStyle* style = SP_OBJECT_STYLE (item); @@ -899,7 +899,7 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /* 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++) { @@ -1197,10 +1197,10 @@ static void sp_shape_snappoints(SPItem const *item, std::vectori2d_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)); } diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 11e84d9b2..fd44cc4ba 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -533,7 +533,7 @@ static void sp_spiral_snappoints(SPItem const *item, std::vectorgetSnapObjectMidpoints()) { - 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 diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 16c71d030..618d4520e 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -560,7 +560,7 @@ static void sp_star_snappoints(SPItem const *item, std::vectorgetSnapObjectMidpoints()) { - 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)); } } diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 6e24ee28c..6d0b59daa 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -23,7 +23,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); } } diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 37be6f75e..07575c4f0 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -168,7 +168,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; diff --git a/src/sp-text.cpp b/src/sp-text.cpp index bae625f58..8f28ee255 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -249,7 +249,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)); @@ -275,7 +275,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)); @@ -387,7 +387,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 +442,7 @@ static void sp_text_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); } } } @@ -483,13 +483,13 @@ 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 +502,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)); + Geom::Matrix const ctm (item->i2d_affine()); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); } diff --git a/src/sp-tref-reference.h b/src/sp-tref-reference.h index 37a5e21ce..f3c645942 100644 --- a/src/sp-tref-reference.h +++ b/src/sp-tref-reference.h @@ -12,6 +12,7 @@ */ #include +#include "sp-item.h" #include #include diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 83f9ecfa6..382b55740 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -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(""); } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 89a86218e..db2fe6fed 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -578,7 +578,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 diff --git a/src/sp-use-reference.h b/src/sp-use-reference.h index b30819a5b..73d46c8aa 100644 --- a/src/sp-use-reference.h +++ b/src/sp-use-reference.h @@ -10,6 +10,7 @@ */ #include +#include "sp-item.h" #include #include diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 9cd38e4b3..1125550c8 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -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 , 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(_("Clone 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) { @@ -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); } @@ -543,7 +543,7 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) 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); } @@ -736,7 +736,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; } diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 7ce9d4710..2eb8daf89 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -420,7 +420,7 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) 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); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db9f72975..db5ceaa8e 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -451,11 +451,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 +484,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 @@ -620,7 +620,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); } } @@ -1089,7 +1089,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); } @@ -1189,7 +1189,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); } @@ -1321,7 +1321,7 @@ 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")); @@ -1472,11 +1472,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. @@ -1546,7 +1546,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")); @@ -1719,7 +1719,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); @@ -1788,7 +1788,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); @@ -1798,7 +1798,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")); @@ -1878,7 +1878,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) { @@ -1943,7 +1943,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 { @@ -2088,7 +2088,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; } diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 2bdac197f..8c30f5a5a 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -151,9 +151,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 +165,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,7 +479,7 @@ 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) @@ -531,7 +531,7 @@ bool sp_spray_recursive(SPDesktop *desktop, 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,7 +569,7 @@ 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; diff --git a/src/star-context.cpp b/src/star-context.cpp index 63a15545f..69d711722 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -432,7 +432,7 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state) 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); diff --git a/src/style-test.h b/src/style-test.h index a2d5fcf24..0bc47906c 100644 --- a/src/style-test.h +++ b/src/style-test.h @@ -22,7 +22,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); _doc = 0; } } diff --git a/src/svg-view.cpp b/src/svg-view.cpp index bd46dd17a..31b54b36d 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -41,7 +41,7 @@ SPSVGView::~SPSVGView() { if (doc() && _drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey); + SP_ITEM (sp_document_root (doc()))->invoke_hide (_dkey); _drawing = NULL; } } @@ -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 (sp_document_root (doc()))->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 (sp_document_root (document))->invoke_show ( SP_CANVAS_ARENA (_drawing)->arena, _dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/test-helpers.h b/src/test-helpers.h index 8dba0c942..4ec1d4dc1 100644 --- a/src/test-helpers.h +++ b/src/test-helpers.h @@ -32,7 +32,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) ) static_cast(g_object_new(inkscape_get_type(), NULL)); } - SPDocument* tmp = sp_document_new( NULL, TRUE, true ); + SPDocument* tmp = SPDocument::createDoc( NULL, TRUE, true ); if ( tmp ) { fun( suite ); if ( suite ) @@ -41,7 +41,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) ) } else { - sp_document_unref( tmp ); + tmp->doUnref(); } } diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index f574b69fb..166799e38 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -133,7 +133,7 @@ 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); @@ -433,7 +433,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]); @@ -518,7 +518,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); diff --git a/src/text-context.cpp b/src/text-context.cpp index 4f89bd1e1..b37c97311 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -432,7 +432,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); } @@ -498,7 +498,7 @@ 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, @@ -1570,8 +1570,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) { @@ -1612,7 +1612,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); } @@ -1652,7 +1652,7 @@ static void sp_text_context_update_text_selection(SPTextContext *tc) std::vector 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); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 372f5026d..600059303 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -80,7 +80,7 @@ sp_te_input_is_empty (SPObject const *item) 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; @@ -956,7 +956,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; @@ -1008,7 +1008,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; @@ -1112,7 +1112,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) { @@ -1184,7 +1184,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) { @@ -1861,7 +1861,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. ) ) { diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index e2bd0e9f5..0c7f075b9 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -246,7 +246,7 @@ Tracer::sioxProcessImage(SPImage *img, return Glib::RefPtr(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 +264,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); } @@ -549,7 +549,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) { diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 904d0cb23..e77d2d465 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -442,7 +442,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 +455,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 +469,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 +484,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 +497,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 +510,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; @@ -562,7 +562,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 +580,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 +801,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 @@ -940,7 +940,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 +970,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; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 9ce2ac5ba..d92d35ae1 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -335,7 +335,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) } _pasteDocument(desktop, tempdoc, in_place); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return true; } @@ -421,7 +421,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) _userWarn(desktop, _("No style on the clipboard.")); } - sp_document_unref(tempdoc); + tempdoc->doUnref(); return pasted; } @@ -467,7 +467,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { for (GSList *i = const_cast(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 +484,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a } pasted = true; } - sp_document_unref(tempdoc); + tempdoc->doUnref(); return pasted; } @@ -549,7 +549,7 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) *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"); @@ -577,7 +577,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 +615,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); } @@ -847,7 +847,7 @@ 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 @@ -1254,7 +1254,7 @@ void ClipboardManagerImpl::_onClear() void ClipboardManagerImpl::_createInternalClipboard() { if ( _clipboardSPDoc == NULL ) { - _clipboardSPDoc = sp_document_new(NULL, false, true); + _clipboardSPDoc = SPDocument::createDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); _defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(_clipboardSPDoc)); _doc = sp_document_repr_doc(_clipboardSPDoc); @@ -1279,7 +1279,7 @@ void ClipboardManagerImpl::_createInternalClipboard() void ClipboardManagerImpl::_discardInternalClipboard() { if ( _clipboardSPDoc != NULL ) { - sp_document_unref(_clipboardSPDoc); + _clipboardSPDoc->doUnref(); _clipboardSPDoc = NULL; _defs = NULL; _doc = NULL; diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 8d467d53f..7ed00ad19 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -147,7 +147,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::createDoc (about, TRUE); g_free(about); g_return_val_if_fail(doc != NULL, NULL); @@ -162,7 +162,7 @@ Gtk::Widget *build_splash_widget() { double width=sp_document_width(doc); double height=sp_document_height(doc); - sp_document_unref(doc); + doc->doUnref(); sp_svg_view_widget_set_resize(SP_SVG_VIEW_WIDGET(v), FALSE, (int)width, (int)height); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index a75a8d68d..d7e3d1766 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -152,7 +152,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]); @@ -169,8 +169,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = sp_item_bbox_desktop - ( (SPItem *) sp_document_root (sp_desktop_document (desktop)) ); + Geom::OptRect b = static_cast( sp_document_root (sp_desktop_document (desktop)))->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]); @@ -218,7 +217,7 @@ private : { sp_document_ensure_up_to_date(sp_desktop_document (desktop)); 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]); @@ -322,7 +321,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)); } @@ -623,7 +622,7 @@ private : ++it) { sp_document_ensure_up_to_date(sp_desktop_document (desktop)); - Geom::OptRect item_box = sp_item_bbox_desktop (*it); + 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 + @@ -708,7 +707,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional 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]; @@ -751,7 +750,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional 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)); @@ -1108,7 +1107,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::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) { @@ -1125,7 +1124,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::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) { diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 6f83a706f..eb2d33eee 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -123,9 +123,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 +151,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::createDoc (fileName.c_str(), true); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -159,7 +159,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName) setDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } @@ -172,7 +172,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::createDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; @@ -180,7 +180,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) setDocument(doc); - sp_document_unref(doc); + doc->doUnref(); Inkscape::GC::request_early_collection(); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 0f3672f25..8a0c70f7c 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -887,14 +887,14 @@ 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::createDoc (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; } @@ -918,8 +918,8 @@ 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); + static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea, + static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE); NRArena *const arena = NRArena::create(); @@ -949,7 +949,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; } @@ -961,7 +961,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); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 9a46254ab..e74e47ca3 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -378,10 +378,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( SP_DOCUMENT_ROOT(doc) )->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] ); @@ -397,7 +396,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) } updateMagnify(); - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), visionkey); + SP_ITEM(sp_document_root(doc))->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); } diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 6be346582..dfb319f90 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -46,8 +46,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 +86,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? @@ -166,7 +166,7 @@ void TileDialog::Grid_Arrange () 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 +209,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 +316,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,8 +336,8 @@ 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; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 1cab38d98..f74c5d6e0 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -626,7 +626,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.)); } @@ -650,7 +650,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.)); } @@ -694,7 +694,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 @@ -781,7 +781,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]; @@ -835,7 +835,7 @@ 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 { diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 450ca96f0..570d53f05 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -374,7 +374,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 @@ -467,7 +467,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, diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 66f72f379..8e37b2c85 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -119,7 +119,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(); } @@ -988,7 +988,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) { diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 770a9bf87..2c325a5ee 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1219,12 +1219,12 @@ EditWidget::shutdown() switch (response) { case Gtk::RESPONSE_YES: - sp_document_ref(doc); + doc->doRef(); sp_namedview_document_from_window(_desktop); if (sp_file_save_document(*this, doc)) { - sp_document_unref(doc); + doc->doUnref(); } else { // save dialog cancelled or save failed - sp_document_unref(doc); + doc->doUnref(); return TRUE; } break; @@ -1270,11 +1270,11 @@ EditWidget::shutdown() switch (response) { case Gtk::RESPONSE_YES: - sp_document_ref(doc); + doc->doRef(); if (sp_file_save_document(*this, doc)) { - sp_document_unref(doc); + doc->doUnref(); } else { // save dialog cancelled or save failed - sp_document_unref(doc); + doc->doUnref(); return TRUE; } break; @@ -1394,7 +1394,7 @@ EditWidget::updateScrollbars (double scale) Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) ); 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), diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 71ba4428c..79cc8ca42 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -76,7 +76,7 @@ ImageIcon::ImageIcon(const ImageIcon &other) ImageIcon::~ImageIcon() { if (document) - sp_document_unref(document); + document->doUnref(); } @@ -98,11 +98,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 +127,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::createDoc (fileName.c_str(), 0); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -135,7 +135,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) showSvgDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } @@ -148,7 +148,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::createDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; @@ -156,7 +156,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) showSvgDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index a7359242d..ab21ecf32 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -146,7 +146,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(); } diff --git a/src/unclump.cpp b/src/unclump.cpp index 85306698c..1d051bc62 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -31,7 +31,7 @@ unclump_center (SPItem *item) return i->second; } - Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect r = item->getBounds(item->i2d_affine()); if (r) { Geom::Point const c = r->midpoint(); c_cache[item->getId()] = c; @@ -50,7 +50,7 @@ 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; @@ -294,8 +294,8 @@ unclump_push (SPItem *from, SPItem *what, double dist) //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); - 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); } /** @@ -317,8 +317,8 @@ unclump_pull (SPItem *to, SPItem *what, double dist) //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); - 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); } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 36047e81b..dfb22b6d0 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -879,12 +879,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; } @@ -937,14 +937,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; } @@ -1806,7 +1806,7 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) ); 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), diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5d91d3532..e90cc1c46 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -918,7 +918,7 @@ 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 ) @@ -1105,7 +1105,7 @@ 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::createDoc( doc_filename, FALSE )) ) { //g_message("Loaded icon file %s", doc_filename); // prep the document @@ -1113,7 +1113,7 @@ static guchar *load_svg_pixels(gchar const *name, /* 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 +1135,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(SP_DOCUMENT_ROOT(doc))->invoke_show(arena, visionkey, SP_ITEM_SHOW_DISPLAY ); // store into the cache info = new svg_doc_cache_t; diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 8759854a0..55dc80f6f 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -875,7 +875,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::createDoc(patterns_source, FALSE); } g_free(patterns_source); } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index f020b0c3a..a8c0788e6 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -182,7 +182,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, 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) { @@ -242,8 +242,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(SP_DOCUMENT_ROOT (sandbox))->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); for (; marker_list != NULL; marker_list = marker_list->next) { Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data); @@ -280,7 +280,7 @@ 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(sp_document_root(sandbox))->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); } @@ -342,7 +342,7 @@ gchar const *buffer = " Date: Thu, 1 Jul 2010 15:36:56 +0530 Subject: C++fied SPDocument added (bzr r9546.1.2) --- src/application/editor.cpp | 2 +- src/color-profile.cpp | 6 +- src/conn-avoid-ref.cpp | 2 +- src/connector-context.cpp | 10 +- src/desktop.cpp | 18 +-- src/dialogs/clonetiler.cpp | 6 +- src/dialogs/export.cpp | 6 +- src/display/nr-filter-image.cpp | 2 +- src/document-undo.cpp | 2 +- src/document.cpp | 186 +++++++++++----------- src/document.h | 86 ++++++---- src/draw-context.cpp | 2 +- src/eraser-context.cpp | 4 +- src/extension/implementation/script.cpp | 2 +- src/extension/implementation/xslt.cpp | 2 +- src/extension/internal/cairo-png-out.cpp | 2 +- src/extension/internal/cairo-ps-out.cpp | 2 +- src/extension/internal/cairo-renderer-pdf-out.cpp | 2 +- src/extension/internal/cairo-renderer.cpp | 6 +- src/extension/internal/emf-win32-inout.cpp | 4 +- src/extension/internal/emf-win32-print.cpp | 6 +- src/extension/internal/gdkpixbuf-input.cpp | 2 +- src/extension/internal/gimpgrad.cpp | 2 +- src/extension/internal/grid.cpp | 4 +- src/extension/internal/latex-pstricks-out.cpp | 2 +- src/extension/internal/latex-pstricks.cpp | 8 +- src/extension/internal/latex-text-renderer.cpp | 6 +- src/extension/internal/odf.cpp | 4 +- src/extension/internal/pdf-input-cairo.cpp | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 2 +- src/extension/internal/svg.cpp | 6 +- src/extension/internal/win32.cpp | 4 +- src/extension/internal/wpg-input.cpp | 2 +- src/extension/system.cpp | 6 +- src/file.cpp | 12 +- src/filters/componenttransfer-funcnode.cpp | 4 +- src/filters/componenttransfer.cpp | 2 +- src/filters/distantlight.cpp | 4 +- src/filters/pointlight.cpp | 4 +- src/filters/spotlight.cpp | 4 +- src/flood-context.cpp | 6 +- src/gradient-chemistry.cpp | 6 +- src/helper/pixbuf-ops.cpp | 4 +- src/helper/png-write.cpp | 4 +- src/helper/stock-items.cpp | 16 +- src/inkview.cpp | 24 +-- src/interface.cpp | 4 +- src/jabber_whiteboard/session-manager.cpp | 2 +- src/layer-manager.cpp | 6 +- src/lpe-tool-context.cpp | 4 +- src/main.cpp | 12 +- src/object-snapper.cpp | 6 +- src/persp3d.cpp | 6 +- src/print.cpp | 6 +- src/profile-manager.cpp | 4 +- src/select-context.cpp | 4 +- src/selection-chemistry.cpp | 18 +-- src/sp-clippath.cpp | 4 +- src/sp-filter.cpp | 4 +- src/sp-flowtext.cpp | 4 +- src/sp-font.cpp | 4 +- src/sp-gradient.cpp | 4 +- src/sp-guide.cpp | 2 +- src/sp-image.cpp | 4 +- src/sp-item-group.cpp | 6 +- src/sp-item.cpp | 8 +- src/sp-mask.cpp | 4 +- src/sp-object.cpp | 4 +- src/sp-pattern.cpp | 4 +- src/sp-root.cpp | 2 +- src/sp-script.cpp | 4 +- src/sp-shape.cpp | 4 +- src/sp-text.cpp | 4 +- src/svg-view-widget.cpp | 4 +- src/svg-view.cpp | 12 +- src/test-helpers.h | 2 +- src/text-chemistry.cpp | 2 +- src/trace/trace.cpp | 2 +- src/ui/clipboard.cpp | 6 +- src/ui/dialog/aboutbox.cpp | 8 +- src/ui/dialog/align-and-distribute.cpp | 8 +- src/ui/dialog/document-properties.cpp | 16 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 4 +- src/ui/dialog/filedialogimpl-win32.cpp | 8 +- src/ui/dialog/filter-effects-dialog.cpp | 5 +- src/ui/dialog/print.cpp | 8 +- src/ui/dialog/svg-fonts-dialog.cpp | 2 +- src/ui/dialog/swatches.cpp | 10 +- src/ui/dialog/tile.cpp | 2 +- src/ui/tool/node-tool.cpp | 3 +- src/ui/view/edit-widget.cpp | 8 +- src/ui/widget/imageicon.cpp | 4 +- src/ui/widget/page-sizer.cpp | 6 +- src/widgets/desktop-widget.cpp | 10 +- src/widgets/gradient-toolbar.cpp | 2 +- src/widgets/gradient-vector.cpp | 2 +- src/widgets/icon.cpp | 6 +- src/widgets/paint-selector.cpp | 6 +- src/widgets/select-toolbar.cpp | 2 +- src/widgets/sp-color-icc-selector.cpp | 2 +- src/widgets/stroke-style.cpp | 8 +- src/xml/rebase-hrefs.cpp | 2 +- 102 files changed, 410 insertions(+), 386 deletions(-) (limited to 'src') diff --git a/src/application/editor.cpp b/src/application/editor.cpp index d2ccccbe3..b66745968 100644 --- a/src/application/editor.cpp +++ b/src/application/editor.cpp @@ -76,7 +76,7 @@ Editor::init() // gchar const *tmpl = g_build_filename ((INKSCAPE_TEMPLATESDIR), "default.svg", NULL); bool have_default = Inkscape::IO::file_test (tmpl, G_FILE_TEST_IS_REGULAR); - SPDocument *doc = SPDocument::createDoc (have_default? tmpl:0, true, true); + SPDocument *doc = SPDocument::createNewDoc (have_default? tmpl:0, true, true); g_return_val_if_fail (doc != 0, false); Inkscape::UI::View::EditWidget *ew = new Inkscape::UI::View::EditWidget (doc); doc->doUnref (); diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 43709793c..bda4e6e23 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -180,7 +180,7 @@ void ColorProfile::release( SPObject *object ) // Unregister ourselves SPDocument* document = SP_OBJECT_DOCUMENT(object); if ( document ) { - sp_document_remove_resource (SP_OBJECT_DOCUMENT (object), "iccprofile", SP_OBJECT (object)); + SP_OBJECT_DOCUMENT (object)->remove_resource ("iccprofile", SP_OBJECT (object)); } ColorProfile *cprof = COLORPROFILE(object); @@ -254,7 +254,7 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML: // Register if ( document ) { - sp_document_add_resource( document, "iccprofile", object ); + document->add_resource( "iccprofile", object ); } } @@ -475,7 +475,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->get_resource_list("iccprofile"); while ( current && !result ) { if ( IS_COLORPROFILE(current->data) ) { ColorProfile* prof = COLORPROFILE(current->data); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 21df27637..15cd97b28 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -196,7 +196,7 @@ void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 ); item->updateRepr(); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, action); } diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 82be63de5..90b16fddd 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1064,7 +1064,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); cc_connector_rerouting_finish(cc, &p); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); cc->state = SP_CONNECTOR_CONTEXT_IDLE; return TRUE; break; @@ -1108,7 +1108,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) { @@ -1239,7 +1239,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) { @@ -1459,7 +1459,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) } // Process pending updates. cc->newconn->updateRepr(); - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); if (connection) { // Adjust endpoints to shape edge. @@ -1693,7 +1693,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)); + SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); std::set seen; for ( ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end() ;) diff --git a/src/desktop.cpp b/src/desktop.cpp index 204807e98..d5e7974ea 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -185,7 +185,7 @@ 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->ensure_up_to_date (); /* Setup Dialog Manager */ _dlg_mgr = &Inkscape::UI::Dialog::DialogManager::getInstance(); @@ -255,7 +255,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,7 +272,7 @@ 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)); @@ -684,7 +684,7 @@ SPItem * SPDesktop::item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); + return SPDocument::item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); } /** @@ -694,7 +694,7 @@ SPItem * SPDesktop::item_at_point (Geom::Point const p, bool into_groups, SPItem *upto) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_item_at_point (doc(), dkey, p, into_groups, upto); + return doc()->item_at_point ( dkey, p, into_groups, upto); } /** @@ -704,7 +704,7 @@ SPItem * SPDesktop::group_at_point (Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_group_at_point (doc(), dkey, p); + return doc()->group_at_point (dkey, p); } /** @@ -1014,7 +1014,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; @@ -1031,12 +1031,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); } diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 550370e90..8dd59425a 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -870,7 +870,7 @@ clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original) clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (trace_doc))); sp_document_root (trace_doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - sp_document_ensure_up_to_date(trace_doc); + trace_doc->ensure_up_to_date(); trace_zoom = zoom; } @@ -987,7 +987,7 @@ clonetiler_unclump( GtkWidget */*widget*/, void * ) } } - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); + sp_desktop_document(desktop)->ensure_up_to_date(); unclump (to_unclump); @@ -1480,7 +1480,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)->ensure_up_to_date(); // 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 diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 463339534..6513813cc 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -871,7 +871,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; @@ -1513,8 +1513,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; diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 215fc4d02..73082f4c0 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -49,7 +49,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { if (!SVGElem) return 0; // prep the document - sp_document_ensure_up_to_date(document); + document->ensure_up_to_date(); NRArena* arena = NRArena::create(); unsigned const key = SPItem::display_key_new(1); NRArenaItem* ai = SVGElem->invoke_show(arena, key, SP_ITEM_SHOW_DISPLAY); diff --git a/src/document-undo.cpp b/src/document-undo.cpp index ae1c82e71..ee15e480f 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -176,7 +176,7 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev doc->collectOrphans(); - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); sp_document_clear_redo (doc); diff --git a/src/document.cpp b/src/document.cpp index 0479569f6..147c22b3c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -292,7 +292,7 @@ void SPDocument::reset_key (void */*dummy*/) } SPDocument * -sp_document_create(Inkscape::XML::Document *rdoc, +SPDocument::createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, @@ -439,7 +439,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, * appears in document list. */ SPDocument * -SPDocument::createDoc(gchar const *uri, unsigned int keepalive, bool make_new) +SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -481,7 +481,7 @@ SPDocument::createDoc(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); @@ -490,7 +490,7 @@ SPDocument::createDoc(gchar const *uri, unsigned int keepalive, bool make_new) } SPDocument * -SPDocument::createDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) +SPDocument::createNewDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -509,7 +509,7 @@ SPDocument::createDocFromMem(gchar const *buffer, gint length, unsigned int keep 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; } @@ -517,7 +517,7 @@ SPDocument::createDocFromMem(gchar const *buffer, gint length, unsigned int keep SPDocument * SPDocument::doRef() { - //g_return_val_if_fail(doc != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); Inkscape::GC::anchor(this); return this; } @@ -525,18 +525,18 @@ SPDocument::doRef() SPDocument * SPDocument::doUnref() { - //g_return_val_if_fail(doc != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); Inkscape::GC::release(this); return NULL; } -gdouble sp_document_width(SPDocument *document) +gdouble SPDocument::getWidth() { - g_return_val_if_fail(document != NULL, 0.0); - g_return_val_if_fail(document->priv != NULL, 0.0); - g_return_val_if_fail(document->root != NULL, 0.0); + g_return_val_if_fail(this != NULL, 0.0); + g_return_val_if_fail(this->priv != NULL, 0.0); + g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(document->root); + SPRoot *root = SP_ROOT(this->root); if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) return root->viewBox.x1 - root->viewBox.x0; @@ -544,9 +544,9 @@ gdouble sp_document_width(SPDocument *document) } void -sp_document_set_width (SPDocument *document, gdouble width, const SPUnit *unit) +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); @@ -570,9 +570,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); @@ -596,22 +596,22 @@ void sp_document_set_height (SPDocument * document, gdouble height, const SPUnit SP_OBJECT (root)->updateRepr(); } -gdouble sp_document_height(SPDocument *document) +gdouble SPDocument::getHeight() { - g_return_val_if_fail(document != NULL, 0.0); - g_return_val_if_fail(document->priv != NULL, 0.0); - g_return_val_if_fail(document->root != NULL, 0.0); + g_return_val_if_fail(this != NULL, 0.0); + g_return_val_if_fail(this->priv != NULL, 0.0); + g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(document->root); + SPRoot *root = SP_ROOT(this->root); if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) return root->viewBox.y1 - root->viewBox.y0; return root->height.computed; } -Geom::Point sp_document_dimensions(SPDocument *doc) +Geom::Point SPDocument::getDimensions() { - return Geom::Point(sp_document_width(doc), sp_document_height(doc)); + return Geom::Point(getWidth(), getHeight()); } /** @@ -662,7 +662,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 */ @@ -700,8 +700,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()) @@ -774,11 +774,11 @@ 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); + g_return_if_fail(this != NULL); - do_change_uri(document, filename, false); + do_change_uri(this, filename, false); } /** @@ -787,19 +787,19 @@ 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::change_uri_and_hrefs(gchar const *filename) { - g_return_if_fail(document != NULL); + g_return_if_fail(this != NULL); - do_change_uri(document, filename, true); + do_change_uri(this, filename, true); } void -sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height) +SPDocument::resized_signal_emit(gdouble width, gdouble height) { - g_return_if_fail(doc != NULL); + g_return_if_fail(this != NULL); - doc->priv->resized_signal.emit(width, height); + this->priv->resized_signal.emit(width, height); } sigc::connection SPDocument::connectModified(SPDocument::ModifiedSignal::slot_type slot) @@ -959,15 +959,15 @@ Glib::ustring SPDocument::getLanguage() { /* Object modification root handler */ void -sp_document_request_modified(SPDocument *doc) +SPDocument::request_modified() { - 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); } } @@ -1027,7 +1027,7 @@ SPDocument::_updateDocument() * since this typically indicates we're stuck in an update loop. */ gint -sp_document_ensure_up_to_date(SPDocument *doc) +SPDocument::ensure_up_to_date() { // Bring the document up-to-date, specifically via the following: // 1a) Process all document updates. @@ -1036,9 +1036,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--; @@ -1052,19 +1052,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) { + if (modified_id) { /* Remove handler */ - g_source_remove(doc->modified_id); - doc->modified_id = 0; + g_source_remove(modified_id); + modified_id = 0; } - if (doc->rerouting_handler_id) { + if (rerouting_handler_id) { /* Remove handler */ - g_source_remove(doc->rerouting_handler_id); - doc->rerouting_handler_id = 0; + g_source_remove(rerouting_handler_id); + rerouting_handler_id = 0; } return counter>0; } @@ -1156,8 +1156,7 @@ bool item_is_in_group(SPItem *item, SPGroup *group) Returns the bottommost item from the list which is at the point, or NULL if none. */ SPItem* -sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GSList const *list, - Geom::Point const p, bool take_insensitive) +SPDocument::item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const p, bool take_insensitive) { g_return_val_if_fail(group, NULL); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1176,7 +1175,7 @@ sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GS } if (SP_IS_GROUP(o)) { - SPItem *found = sp_document_item_from_list_at_point_bottom(dkey, SP_GROUP(o), list, p, take_insensitive); + SPItem *found = item_from_list_at_point_bottom(dkey, SP_GROUP(o), list, p, take_insensitive); if (found) return found; } @@ -1270,12 +1269,12 @@ find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) * */ -GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box) +GSList *SPDocument::items_in_box(unsigned int dkey, Geom::Rect const &box) { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_items_in_area(NULL, SP_GROUP(document->root), dkey, box, is_within); + return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within); } /* @@ -1285,16 +1284,16 @@ 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::partial_items_in_box(unsigned int dkey, Geom::Rect const &box) { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_items_in_area(NULL, SP_GROUP(document->root), dkey, box, overlaps); + return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps); } GSList * -sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points) +SPDocument::items_at_points(unsigned const key, std::vector points) { GSList *items = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1306,7 +1305,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 = item_at_point(key, points[i], false, NULL); if (item && !g_slist_find(items, item)) items = g_slist_prepend (items, item); @@ -1319,34 +1318,34 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto } SPItem * -sp_document_item_at_point(SPDocument *document, unsigned const key, Geom::Point const p, +SPDocument::item_at_point( unsigned const key, Geom::Point const p, gboolean const into_groups, SPItem *upto) { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_item_at_point(key, SP_GROUP(document->root), p, into_groups, false, upto); + return find_item_at_point(key, SP_GROUP(this->root), p, into_groups, false, upto); } SPItem* -sp_document_group_at_point(SPDocument *document, unsigned int key, Geom::Point const p) +SPDocument::group_at_point(unsigned int key, Geom::Point const p) { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_group_at_point(key, SP_GROUP(document->root), p); + return find_group_at_point(key, SP_GROUP(this->root), p); } /* Resource management */ gboolean -sp_document_add_resource(SPDocument *document, gchar const *key, SPObject *object) +SPDocument::add_resource(gchar const *key, SPObject *object) { GSList *rlist; GQuark q = g_quark_from_string(key); - g_return_val_if_fail(document != NULL, FALSE); + g_return_val_if_fail(this != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(*key != '\0', FALSE); g_return_val_if_fail(object != NULL, FALSE); @@ -1355,23 +1354,23 @@ sp_document_add_resource(SPDocument *document, gchar const *key, SPObject *objec if (SP_OBJECT_IS_CLONED(object)) return FALSE; - rlist = (GSList*)g_hash_table_lookup(document->priv->resources, key); + rlist = (GSList*)g_hash_table_lookup(this->priv->resources, key); g_return_val_if_fail(!g_slist_find(rlist, object), FALSE); rlist = g_slist_prepend(rlist, object); - g_hash_table_insert(document->priv->resources, (gpointer) key, rlist); + g_hash_table_insert(this->priv->resources, (gpointer) key, rlist); - document->priv->resources_changed_signals[q].emit(); + this->priv->resources_changed_signals[q].emit(); return TRUE; } gboolean -sp_document_remove_resource(SPDocument *document, gchar const *key, SPObject *object) +SPDocument::remove_resource(gchar const *key, SPObject *object) { GSList *rlist; GQuark q = g_quark_from_string(key); - g_return_val_if_fail(document != NULL, FALSE); + g_return_val_if_fail(this != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(*key != '\0', FALSE); g_return_val_if_fail(object != NULL, FALSE); @@ -1380,33 +1379,32 @@ sp_document_remove_resource(SPDocument *document, gchar const *key, SPObject *ob if (SP_OBJECT_IS_CLONED(object)) return FALSE; - rlist = (GSList*)g_hash_table_lookup(document->priv->resources, key); + rlist = (GSList*)g_hash_table_lookup(this->priv->resources, key); g_return_val_if_fail(rlist != NULL, FALSE); g_return_val_if_fail(g_slist_find(rlist, object), FALSE); rlist = g_slist_remove(rlist, object); - g_hash_table_insert(document->priv->resources, (gpointer) key, rlist); + g_hash_table_insert(this->priv->resources, (gpointer) key, rlist); - document->priv->resources_changed_signals[q].emit(); + this->priv->resources_changed_signals[q].emit(); return TRUE; } GSList const * -sp_document_get_resource_list(SPDocument *document, gchar const *key) +SPDocument::get_resource_list(gchar const *key) { - g_return_val_if_fail(document != NULL, NULL); + g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); g_return_val_if_fail(*key != '\0', NULL); - return (GSList*)g_hash_table_lookup(document->priv->resources, key); + return (GSList*)g_hash_table_lookup(this->priv->resources, key); } -sigc::connection sp_document_resources_changed_connect(SPDocument *document, - gchar const *key, +sigc::connection SPDocument::resources_changed_connect(gchar const *key, SPDocument::ResourcesChangedSignal::slot_type slot) { 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 */ @@ -1452,9 +1450,9 @@ vacuum_document_recursive(SPObject *obj) } unsigned int -vacuum_document(SPDocument *document) +SPDocument::vacuum_document() { - unsigned int start = objects_in_document(document); + unsigned int start = objects_in_document(this); unsigned int end; unsigned int newend = start; @@ -1463,11 +1461,11 @@ vacuum_document(SPDocument *document) do { end = newend; - vacuum_document_recursive(SP_DOCUMENT_ROOT(document)); - document->collectOrphans(); + vacuum_document_recursive(SP_DOCUMENT_ROOT(this)); + this->collectOrphans(); iterations++; - newend = objects_in_document(document); + newend = objects_in_document(this); } while (iterations < 100 && newend < end); diff --git a/src/document.h b/src/document.h index 2f9da7817..3fa83c779 100644 --- a/src/document.h +++ b/src/document.h @@ -181,10 +181,38 @@ public: sigc::connection _desktop_activated_connection; void fitToRect(Geom::Rect const &rect, bool with_margins = false); - static SPDocument *createDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); - static SPDocument *createDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); + static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + + /* ToDo - Merge createDoc with createNewDoc */ + static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); + SPDocument *doRef(); SPDocument *doUnref(); + gdouble getWidth(); + gdouble getHeight(); + Geom::Point getDimensions(); + void setWidth(gdouble width, const SPUnit *unit); + void setHeight(gdouble height, const SPUnit *unit); + //void setUndoSensitive(bool sensitive); + void request_modified(); + gint ensure_up_to_date(); + gboolean add_resource(const gchar *key, SPObject *object); + gboolean remove_resource(const gchar *key, SPObject *object); + const GSList *get_resource_list(const gchar *key); + sigc::connection resources_changed_connect(const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); + GSList * items_in_box(unsigned int dkey, Geom::Rect const &box); + GSList *partial_items_in_box(unsigned int dkey, Geom::Rect const &box); + static SPItem *item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); + SPItem *item_at_point (unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); + GSList *items_at_points(unsigned const key, std::vector points); + SPItem *group_at_point (unsigned int key, Geom::Point const p); + + void setUri(gchar const *uri); + void change_uri_and_hrefs(gchar const *uri); + void resized_signal_emit(gdouble width, gdouble height); + + unsigned int vacuum_document(); }; //SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); @@ -194,7 +222,7 @@ public: //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); +//SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); /* * Access methods @@ -205,14 +233,14 @@ SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, #define sp_document_root(d) (d->root) #define SP_DOCUMENT_ROOT(d) (d->root) -gdouble sp_document_width(SPDocument *document); -gdouble sp_document_height(SPDocument *document); -Geom::Point sp_document_dimensions(SPDocument *document); +//gdouble sp_document_width(SPDocument *document); +//gdouble sp_document_height(SPDocument *document); +//Geom::Point sp_document_dimensions(SPDocument *document); struct SPUnit; -void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); -void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); +//void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); +//void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); #define SP_DOCUMENT_URI(d) (d->uri) #define SP_DOCUMENT_NAME(d) (d->name) @@ -232,15 +260,15 @@ 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); +//void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); +//void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); +//void sp_document_attr_changed(SPDocument *doc, SPObject *object, const gchar *key, const gchar *oldval, const gchar *newval); +//void sp_document_content_changed(SPDocument *doc, SPObject *object, const gchar *oldcontent, const gchar *newcontent); +//void sp_document_order_changed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *oldref, Inkscape::XML::Node *newref); /* Object modification root handler */ -void sp_document_request_modified(SPDocument *doc); -gint sp_document_ensure_up_to_date(SPDocument *doc); +//void sp_document_request_modified(SPDocument *doc); +//gint sp_document_ensure_up_to_date(SPDocument *doc); /* Save all previous actions to stack, as one undo step */ void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); @@ -255,10 +283,10 @@ gboolean sp_document_undo(SPDocument *document); gboolean sp_document_redo(SPDocument *document); /* Resource management */ -gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); -gboolean sp_document_remove_resource(SPDocument *document, const gchar *key, SPObject *object); -const GSList *sp_document_get_resource_list(SPDocument *document, const gchar *key); -sigc::connection sp_document_resources_changed_connect(SPDocument *document, const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); +//gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); +//gboolean sp_document_remove_resource(SPDocument *document, const gchar *key, SPObject *object); +//const GSList *sp_document_get_resource_list(SPDocument *document, const gchar *key); +//sigc::connection sp_document_resources_changed_connect(SPDocument *document, const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); /* @@ -279,19 +307,19 @@ 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 points); -SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); +//GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); +//GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); +//SPItem *sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); +//SPItem *sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); +//GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); +//SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); -void sp_document_set_uri(SPDocument *document, gchar const *uri); -void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *uri); +//void sp_document_set_uri(SPDocument *document, gchar const *uri); +//void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *uri); -void sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height); +//void sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height); -unsigned int vacuum_document(SPDocument *document); +//unsigned int vacuum_document(SPDocument *document); #endif diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 52118eb16..ea25efc22 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -712,7 +712,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) c->unref(); /* Flush pending updates */ - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); } /** diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 46efd403a..db1aa46d9 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -747,10 +747,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)->partial_items_in_box(desktop->dkey, bounds); } else { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); - toWorkOn = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); + toWorkOn = sp_desktop_document(desktop)->items_at_points(desktop->dkey, r->getPoints()); } toWorkOn = g_slist_remove( toWorkOn, acid ); } else { diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e075feb91..36cc5787b 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -534,7 +534,7 @@ SPDocument *Script::open(Inkscape::Extension::Input *module, if (mydoc != NULL) { g_free(mydoc->base); mydoc->base = NULL; - sp_document_change_uri_and_hrefs(mydoc, filenameArg); + mydoc->change_uri_and_hrefs(filenameArg); } // make sure we don't leak file descriptors from g_file_open_tmp diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index 143d72362..75edacdb7 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -174,7 +174,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); diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index d7b7cc862..14a2f1b17 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -53,7 +53,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) CairoRenderer *renderer; CairoRenderContext *ctx; - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); /* Start */ /* Create new arena */ diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 59daafb7e..76b68bf2c 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -65,7 +65,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->ensure_up_to_date(); SPItem *base = NULL; diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index d7a034291..6536361bd 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -55,7 +55,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->ensure_up_to_date(); /* Start */ diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5b05cd96b..81531b2db 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -608,8 +608,8 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page 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 { base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX); } @@ -631,7 +631,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; diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 0d939427c..aa856e910 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -109,7 +109,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename) gchar *oldoutput; unsigned int ret; - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); mod = Inkscape::Extension::get_print(PRINT_EMF_WIN32); oldconst = mod->get_param_string("destination"); @@ -2366,7 +2366,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl; - SPDocument *doc = SPDocument::createDocFromMem(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; diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 21bb85331..e8e6b3187 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -135,8 +135,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; @@ -232,7 +232,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; } diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 2e10dae58..4983d7eff 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -54,7 +54,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) mime_type = "image/png"; } - doc = SPDocument::createDoc(NULL, TRUE, TRUE); + doc = SPDocument::createNewDoc(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 diff --git a/src/extension/internal/gimpgrad.cpp b/src/extension/internal/gimpgrad.cpp index d33975f91..6b11aa994 100644 --- a/src/extension/internal/gimpgrad.cpp +++ b/src/extension/internal/gimpgrad.cpp @@ -256,7 +256,7 @@ GimpGrad::open (Inkscape::Extension::Input */*module*/, gchar const *filename) fclose(gradient); - return SPDocument::createDocFromMem(outsvg.c_str(), outsvg.length(), TRUE); + return SPDocument::createNewDocFromMem(outsvg.c_str(), outsvg.length(), TRUE); } error: diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 1593ffe79..8132ba1ad 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -87,14 +87,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])); diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index c2d14f6a5..a47419365 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -55,7 +55,7 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons gchar * oldoutput; unsigned int ret; - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); oldconst = mod->get_param_string("destination"); diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 34b7532ce..63e9d3803 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -128,8 +128,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 +139,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()); } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index cd712e477..d944de71a 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -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->ensure_up_to_date(); SPItem *base = NULL; @@ -496,7 +496,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * 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 { base->invoke_bbox( d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX); } @@ -517,7 +517,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; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 4e89ce7b2..aadb9ee17 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -947,7 +947,7 @@ static Geom::Matrix getODFTransform(const SPItem *item) //### Get SVG-to-ODF transform 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; @@ -968,7 +968,7 @@ static Geom::OptRect getODFBoundingBox(const SPItem *item) 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; diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index e3abc63d4..62c6b7f36 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -58,7 +58,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { cairo_destroy(cr); cairo_surface_destroy(surface); - SPDocument * doc = SPDocument::createDocFromMem(output->c_str(), output->length(), TRUE); + SPDocument * doc = SPDocument::createNewDocFromMem(output->c_str(), output->length(), TRUE); delete output; g_object_unref(page); diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index e771d8b41..9826addb6 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -661,7 +661,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { Catalog *catalog = pdf_doc->getCatalog(); Page *page = catalog->getPage(page_num); - SPDocument *doc = SPDocument::createDoc(NULL, TRUE, TRUE); + SPDocument *doc = SPDocument::createNewDoc(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 diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index c063be46c..e80e316cf 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -182,19 +182,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 SPDocument::createDoc(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 = SPDocument::createDocFromMem(buffer, strlen(buffer), 1); + SPDocument * doc = SPDocument::createNewDocFromMem(buffer, strlen(buffer), 1); g_free(buffer); return doc; #else - return SPDocument::createDoc(uri, TRUE); + return SPDocument::createNewDoc(uri, TRUE); #endif } diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp index 21f278858..3522ab247 100644 --- a/src/extension/internal/win32.cpp +++ b/src/extension/internal/win32.cpp @@ -226,8 +226,8 @@ 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); diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 023bab879..02247ffa0 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -86,7 +86,7 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) { //printf("I've got a doc: \n%s", painter.document.c_str()); - SPDocument * doc = SPDocument::createDocFromMem(output.cstr(), strlen(output.cstr()), TRUE); + SPDocument * doc = SPDocument::createNewDocFromMem(output.cstr(), strlen(output.cstr()), TRUE); delete input; return doc; } diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 6ffa7f57f..67720235d 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -111,7 +111,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; } @@ -269,7 +269,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss")); if (official) { /* The document is changing name/uri. */ - sp_document_change_uri_and_hrefs(doc, fileName); + doc->change_uri_and_hrefs(fileName); } // Update attributes: @@ -302,7 +302,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, repr->setAttribute("inkscape:dataloss", saved_dataloss); } sp_document_set_undo_sensitive(doc, saved); - sp_document_change_uri_and_hrefs(doc, saved_uri); + doc->change_uri_and_hrefs(saved_uri); } doc->setModifiedSinceSave(saved_modified); // free used ressources diff --git a/src/file.cpp b/src/file.cpp index 352362424..6b162c799 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -118,7 +118,7 @@ sp_file_new(const Glib::ustring &templ) char *templName = NULL; if (templ.size()>0) templName = (char *)templ.c_str(); - SPDocument *doc = SPDocument::createDoc(templName, TRUE, true); + SPDocument *doc = SPDocument::createNewDoc(templName, TRUE, true); g_return_val_if_fail(doc != NULL, NULL); SPDesktop *dt; @@ -234,9 +234,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->ensure_up_to_date (); desktop->change_document(doc); - sp_document_resized_signal_emit (doc, sp_document_width(doc), sp_document_height(doc)); + doc->resized_signal_emit (doc->getWidth(), doc->getHeight()); } else { if (!Inkscape::NSApplication::Application::getNewGui()) { // create a whole new desktop and window @@ -558,7 +558,7 @@ sp_file_vacuum() { SPDocument *doc = SP_ACTIVE_DOCUMENT; - unsigned int diff = vacuum_document (doc); + unsigned int diff = doc->vacuum_document (); sp_document_done(doc, SP_VERB_FILE_VACUUM, _("Vacuum <defs>")); @@ -1048,13 +1048,13 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // 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); + doc->ensure_up_to_date(); Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer { - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); + sp_desktop_document(desktop)->ensure_up_to_date(); Geom::OptRect sel_bbox = selection->bounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 8edb9cf2d..1dbf07dd5 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -178,7 +178,7 @@ sp_fefuncnode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node //is this necessary? - sp_document_add_resource(document, "fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ? + document->add_resource("fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ? } /** @@ -191,7 +191,7 @@ sp_fefuncnode_release(SPObject *object) if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fefuncnode", SP_OBJECT(object)); + SP_OBJECT_DOCUMENT(object)->remove_resource("fefuncnode", SP_OBJECT(object)); } //TODO: release resources here diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 27e63eaa6..e8a573998 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -100,7 +100,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->add_resource("feComponentTransfer", object); } static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_componenttransfer) diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 41584c4a4..55c51aa0e 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -105,7 +105,7 @@ sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::N sp_object_read_attr(object, "elevation"); //is this necessary? - sp_document_add_resource(document, "fedistantlight", object); + document->add_resource("fedistantlight", object); } /** @@ -118,7 +118,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)->remove_resource("fedistantlight", SP_OBJECT(object)); } //TODO: release resources here diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index ce58cf13e..fed07ecf3 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -109,7 +109,7 @@ sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod sp_object_read_attr(object, "z"); //is this necessary? - sp_document_add_resource(document, "fepointlight", object); + document->add_resource("fepointlight", object); } /** @@ -122,7 +122,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)->remove_resource("fepointlight", SP_OBJECT(object)); } //TODO: release resources here diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 3b518f0b4..613763751 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -124,7 +124,7 @@ sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node sp_object_read_attr(object, "limitingConeAngle"); //is this necessary? - sp_document_add_resource(document, "fespotlight", object); + document->add_resource("fespotlight", object); } /** @@ -137,7 +137,7 @@ sp_fespotlight_release(SPObject *object) if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fespotlight", SP_OBJECT(object)); + SP_OBJECT_DOCUMENT(object)->remove_resource("fespotlight", SP_OBJECT(object)); } //TODO: release resources here diff --git a/src/flood-context.cpp b/src/flood-context.cpp index f8c2e14a0..019cbbb02 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -776,7 +776,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even NRArena *arena = NRArena::create(); unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (document); + document->ensure_up_to_date (); SPItem *document_root = SP_ITEM(SP_DOCUMENT_ROOT(document)); Geom::OptRect bbox = document_root->getBounds(Geom::identity()); @@ -798,7 +798,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)); @@ -905,7 +905,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])); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 56d4813fb..76b29bb09 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -285,7 +285,7 @@ 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)->ensure_up_to_date(); Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine if (!bbox) @@ -345,7 +345,7 @@ sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar const *prop Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr); // calculate the bbox of the item - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); + SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); Geom::Matrix bbox2user; Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine if ( bbox ) { @@ -1040,7 +1040,7 @@ sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool } if (SP_GRADIENT(gradient)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); + SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); 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, diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index ebcee1a64..2b0d5781a 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -106,14 +106,14 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, nr_arena_set_renderoffscreen(arena); unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); 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)); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 81c8612fb..f8321cc03 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -422,10 +422,10 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, return true; } - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); /* 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 diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 72f97c6da..cb2769c8e 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -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 = SPDocument::createDoc(markers, FALSE); + doc = SPDocument::createNewDoc(markers, FALSE); } g_free(markers); if (doc) { - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); } else { edoc = TRUE; } @@ -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 = SPDocument::createDoc(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 = SPDocument::createDoc(patterns, FALSE); + doc = SPDocument::createNewDoc(patterns, FALSE); } g_free(patterns); if (doc) { - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); } else { edoc = TRUE; } @@ -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 = SPDocument::createDoc(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 = SPDocument::createDoc(gradients, FALSE); + doc = SPDocument::createNewDoc(gradients, FALSE); } g_free(gradients); if (doc) { - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); } else { edoc = TRUE; } diff --git a/src/inkview.cpp b/src/inkview.cpp index 1a13e356f..35f150707 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -273,13 +273,13 @@ main (int argc, const char **argv) ss.slides = g_renew (char *, ss.slides, ss.size); } - ss.doc = SPDocument::createDocFromMem ((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 +299,7 @@ main (int argc, const char **argv) ss.slides[ss.length++] = strdup (argv[i]); if (!ss.doc) { - ss.doc = SPDocument::createDoc (ss.slides[ss.current], TRUE, false); + ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false); if (!ss.doc) ++ss.current; } @@ -315,19 +315,19 @@ main (int argc, const char **argv) w = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (w), SP_DOCUMENT_NAME (ss.doc)); gtk_window_set_default_size (GTK_WINDOW (w), - MIN ((int)sp_document_width (ss.doc), (int)gdk_screen_width () - 64), - MIN ((int)sp_document_height (ss.doc), (int)gdk_screen_height () - 64)); + MIN ((int)(ss.doc)->getWidth (), (int)gdk_screen_width () - 64), + MIN ((int)(ss.doc)->getHeight (), (int)gdk_screen_height () - 64)); gtk_window_set_policy (GTK_WINDOW (w), TRUE, TRUE, FALSE); ss.window = w; g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss); g_signal_connect (G_OBJECT (w), "key_press_event", (GCallback) sp_svgview_main_key_press, &ss); - sp_document_ensure_up_to_date (ss.doc); + (ss.doc)->ensure_up_to_date (); ss.view = sp_svg_view_widget_new (ss.doc); (ss.doc)->doUnref (); sp_svg_view_widget_set_resize (SP_SVG_VIEW_WIDGET (ss.view), FALSE, - sp_document_width (ss.doc), sp_document_height (ss.doc)); + (ss.doc)->getWidth (), (ss.doc)->getHeight ()); gtk_widget_show (ss.view); gtk_container_add (GTK_CONTAINER (w), ss.view); @@ -444,7 +444,7 @@ 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->ensure_up_to_date (); reinterpret_cast(SP_VIEW_WIDGET_VIEW (ss->view))->setDocument (doc); ss->doc = doc; ss->current = current; @@ -459,7 +459,7 @@ sp_svgview_show_next (struct SPSlideShow *ss) SPDocument *doc = NULL; int current = ss->current; while (!doc && (current < ss->length - 1)) { - doc = SPDocument::createDoc (ss->slides[++current], TRUE, false); + doc = SPDocument::createNewDoc (ss->slides[++current], TRUE, false); } sp_svgview_set_document(ss, doc, current); @@ -475,7 +475,7 @@ sp_svgview_show_prev (struct SPSlideShow *ss) SPDocument *doc = NULL; int current = ss->current; while (!doc && (current > 0)) { - doc = SPDocument::createDoc (ss->slides[--current], TRUE, false); + doc = SPDocument::createNewDoc (ss->slides[--current], TRUE, false); } sp_svgview_set_document(ss, doc, current); @@ -493,7 +493,7 @@ sp_svgview_goto_first (struct SPSlideShow *ss) while ( !doc && (current < ss->length - 1)) { if (current == ss->current) break; - doc = SPDocument::createDoc (ss->slides[current++], TRUE, false); + doc = SPDocument::createNewDoc (ss->slides[current++], TRUE, false); } sp_svgview_set_document(ss, doc, current - 1); @@ -511,7 +511,7 @@ sp_svgview_goto_last (struct SPSlideShow *ss) while (!doc && (current >= 0)) { if (current == ss->current) break; - doc = SPDocument::createDoc (ss->slides[current--], TRUE, false); + doc = SPDocument::createNewDoc (ss->slides[current--], TRUE, false); } sp_svgview_set_document(ss, doc, current + 1); diff --git a/src/interface.cpp b/src/interface.cpp index 4b3126680..bdec99291 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1363,7 +1363,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->get_resource_list("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( color.descr == grad->getId() ) { @@ -1481,7 +1481,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)->ensure_up_to_date(); Geom::OptRect sel_bbox = selection->bounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp index 7a39b6d81..b46aacaae 100644 --- a/src/jabber_whiteboard/session-manager.cpp +++ b/src/jabber_whiteboard/session-manager.cpp @@ -369,7 +369,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; diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index db7384622..5c96bcee1 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -183,7 +183,7 @@ void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify } std::set currentNames; - GSList const *layers=sp_document_get_resource_list(_document, "layer"); + GSList const *layers=_document->get_resource_list("layer"); SPObject *root=_desktop->currentRoot(); if ( root ) { for ( GSList const *iter=layers ; iter ; iter = iter->next ) { @@ -218,7 +218,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->resources_changed_connect("layer", sigc::mem_fun(*this, &LayerManager::_rebuild)); } _rebuild(); } @@ -248,7 +248,7 @@ void LayerManager::_rebuild() { if (!_document) // http://sourceforge.net/mailarchive/forum.php?thread_name=5747bce9a7ed077c1b4fc9f0f4f8a5e0%40localhost&forum_name=inkscape-devel return; - GSList const *layers = sp_document_get_resource_list(_document, "layer"); + GSList const *layers = _document->get_resource_list("layer"); SPObject *root=_desktop->currentRoot(); if ( root ) { _addOne(root); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 438258cb3..8eafa1711 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -392,8 +392,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); diff --git a/src/main.cpp b/src/main.cpp index 5cb317a44..a25343991 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1020,7 +1020,7 @@ void sp_process_file_list(GSList *fl) g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename); } else { if (sp_vacuum_defs) { - vacuum_document(doc); + doc->vacuum_document(); } if (sp_vacuum_defs && !sp_export_svg) { // save under the name given in the command line @@ -1197,7 +1197,7 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g } if (o) { - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); SPItem *item = ((SPItem *) o); // "true" SVG bbox for scripting @@ -1224,7 +1224,7 @@ do_query_all (SPDocument *doc) o = SP_DOCUMENT_ROOT(doc); if (o) { - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); do_query_all_recurse(o); } } @@ -1327,7 +1327,7 @@ sp_do_export_png(SPDocument *doc) } // write object bbox to area - sp_document_ensure_up_to_date (doc); + doc->ensure_up_to_date (); Geom::OptRect areaMaybe; static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2d_affine(), TRUE); if (areaMaybe) { @@ -1352,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->ensure_up_to_date (); 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 diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index cbf1dab6f..379626683 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -731,7 +731,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); } @@ -748,8 +748,8 @@ Geom::PathVector* Inkscape::ObjectSnapper::_getPathvFromRect(Geom::Rect const re void Inkscape::ObjectSnapper::_getBorderNodes(std::vector *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)); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 6a697ec9b..d9839c556 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -216,10 +216,10 @@ persp3d_create_xml_element (SPDocument *document, Persp3DImpl *dup) {// if dup i 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); diff --git a/src/print.cpp b/src/print.cpp index 7b582b0d1..43f0113a0 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -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->ensure_up_to_date(); mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT); @@ -124,7 +124,7 @@ sp_print_preview_document(SPDocument *doc) void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) { - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); // Build arena SPItem *base = SP_ITEM(sp_document_root(doc)); @@ -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->ensure_up_to_date(); mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_PS); oldconst = mod->get_param_string("destination"); diff --git a/src/profile-manager.cpp b/src/profile-manager.cpp index 1cd965e39..d557fdd39 100644 --- a/src/profile-manager.cpp +++ b/src/profile-manager.cpp @@ -18,7 +18,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->resources_changed_connect( "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) ); } ProfileManager::~ProfileManager() @@ -29,7 +29,7 @@ void ProfileManager::_resourcesChanged() { std::vector newList; if (_doc) { - const GSList *current = sp_document_get_resource_list( _doc, "iccprofile" ); + const GSList *current = _doc->get_resource_list( "iccprofile" ); while ( current ) { newList.push_back(SP_OBJECT(current->data)); current = g_slist_next(current); diff --git a/src/select-context.cpp b/src/select-context.cpp index 028c8634b..db25d3fad 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -614,9 +614,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)->items_in_box(desktop->dkey, *b); } else if (r->getMode() == RUBBERBAND_MODE_TOUCHPATH) { - items = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); + items = sp_desktop_document(desktop)->items_at_points(desktop->dkey, r->getPoints()); } seltrans->resetState(); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 8237537c8..223fcee33 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2265,7 +2265,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) return; } - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX); boost::optional c = selection->center(); if ( !r || !c ) { @@ -2273,7 +2273,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)); @@ -2389,14 +2389,14 @@ sp_selection_tile(SPDesktop *desktop, bool apply) return; } - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); 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)); @@ -2528,7 +2528,7 @@ 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->ensure_up_to_date(); Geom::Matrix transform( i->transform * pat_transform ); i->doWriteTransform(SP_OBJECT_REPR(i), transform); @@ -2640,7 +2640,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->ensure_up_to_date(); selection->bounds(&bbox); if (NR_RECT_DFLS_TEST_EMPTY(&bbox)) { desktop->clearWaitingCursor(); @@ -2855,7 +2855,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->ensure_up_to_date(); GSList *items = g_slist_copy((GSList *) selection->itemList()); @@ -3046,7 +3046,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->ensure_up_to_date(); gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map referenced_objects; @@ -3203,7 +3203,7 @@ 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->ensure_up_to_date(); SPItem const *const root = SP_ITEM(doc->root); Geom::OptRect const bbox(root->getBounds(root->i2d_affine())); if (bbox) { diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 9cd2b2ca4..bae5f5e56 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -107,7 +107,7 @@ sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r sp_object_read_attr(object, "clipPathUnits"); /* Register ourselves */ - sp_document_add_resource(document, "clipPath", object); + document->add_resource("clipPath", object); } static void @@ -115,7 +115,7 @@ sp_clippath_release(SPObject * object) { if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "clipPath", object); + SP_OBJECT_DOCUMENT(object)->remove_resource("clipPath", object); } SPClipPath *cp = SP_CLIPPATH(object); diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 4cbafe50c..1ac8a6733 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -146,7 +146,7 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep sp_object_read_attr(object, "xlink:href"); //is this necessary? - sp_document_add_resource(document, "filter", object); + document->add_resource("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)->remove_resource("filter", SP_OBJECT(object)); } //TODO: release resources here diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 5f3517f92..b18b72968 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -362,8 +362,8 @@ 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)); + 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); diff --git a/src/sp-font.cpp b/src/sp-font.cpp index b2003cf08..96973b657 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -108,7 +108,7 @@ static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML: sp_object_read_attr(object, "vert-origin-y"); sp_object_read_attr(object, "vert-adv-y"); - sp_document_add_resource(document, "font", object); + document->add_resource("font", object); } @@ -150,7 +150,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)->remove_resource("font", object); if (((SPObjectClass *) parent_class)->release) { ((SPObjectClass *) parent_class)->release(object); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 0c0c94784..bc86e2135 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -439,7 +439,7 @@ void SPGradientImpl::build(SPObject *object, SPDocument *document, Inkscape::XML sp_object_read_attr(object, "xlink:href"); /* Register ourselves */ - sp_document_add_resource(document, "gradient", object); + document->add_resource("gradient", object); } /** @@ -455,7 +455,7 @@ void SPGradientImpl::release(SPObject *object) if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "gradient", SP_OBJECT(object)); + SP_OBJECT_DOCUMENT(object)->remove_resource("gradient", SP_OBJECT(object)); } if (gradient->ref) { diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index f5edf7d97..5bf7f664c 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -273,7 +273,7 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { std::list > 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]); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 367d2e489..c1fb9a571 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -646,7 +646,7 @@ sp_image_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep sp_object_read_attr (object, "color-profile"); /* Register */ - sp_document_add_resource (document, "image", object); + document->add_resource ("image", object); } static void @@ -656,7 +656,7 @@ sp_image_release (SPObject *object) if (SP_OBJECT_DOCUMENT (object)) { /* Unregister ourselves */ - sp_document_remove_resource (SP_OBJECT_DOCUMENT (object), "image", SP_OBJECT (object)); + SP_OBJECT_DOCUMENT (object)->remove_resource ("image", SP_OBJECT (object)); } if (image->href) { diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 2369ce38a..c178cfdd4 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -154,7 +154,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)->remove_resource("layer", object); } if (((SPObjectClass *)parent_class)->release) { ((SPObjectClass *)parent_class)->release(object); @@ -535,9 +535,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)->add_resource("layer", this); } else if ( _layer_mode == LAYER ) { - sp_document_remove_resource(SP_OBJECT_DOCUMENT(this), "layer", this); + SP_OBJECT_DOCUMENT(this)->remove_resource("layer", this); } _layer_mode = mode; _updateLayerMode(); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index e5f8eade1..72f318a25 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -296,7 +296,7 @@ SPItem::setExplicitlyHidden(bool const val) { void SPItem::setCenter(Geom::Point object_centre) { // for getBounds() to work - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(this)); + SP_OBJECT_DOCUMENT(this)->ensure_up_to_date(); Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { @@ -321,7 +321,7 @@ bool SPItem::isCenterSet() { Geom::Point SPItem::getCenter() const { // for getBounds() to work - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(this)); + SP_OBJECT_DOCUMENT(this)->ensure_up_to_date(); Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { @@ -1571,7 +1571,7 @@ Geom::Matrix SPItem::i2d_affine() const Geom::Matrix const ret( i2doc_affine() * Geom::Scale(1, -1) - * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(this))) ); + * Geom::Translate(0, SP_OBJECT_DOCUMENT(this)->getHeight()) ); return ret; } @@ -1584,7 +1584,7 @@ void SPItem::set_i2d_affine(Geom::Matrix const &i2dt) if (SP_OBJECT_PARENT(this)) { dt2p = static_cast(SP_OBJECT_PARENT(this))->i2d_affine().inverse(); } else { - dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(this))) + dt2p = ( Geom::Translate(0, -SP_OBJECT_DOCUMENT(this)->getHeight()) * Geom::Scale(1, -1) ); } diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index b0369efe5..e57b5cc47 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -108,7 +108,7 @@ sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr sp_object_read_attr (object, "maskContentUnits"); /* Register ourselves */ - sp_document_add_resource (document, "mask", object); + document->add_resource ("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)->remove_resource ("mask", object); } SPMask *cp = SP_MASK (object); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 420c7b4a6..08d13b2cc 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1312,7 +1312,7 @@ SPObject::requestDisplayUpdate(unsigned int flags) if (parent) { parent->requestDisplayUpdate(SP_OBJECT_CHILD_MODIFIED_FLAG); } else { - sp_document_request_modified(SP_OBJECT_DOCUMENT(this)); + SP_OBJECT_DOCUMENT(this)->request_modified(); } } } @@ -1396,7 +1396,7 @@ SPObject::requestModified(unsigned int flags) if (parent) { parent->requestModified(SP_OBJECT_CHILD_MODIFIED_FLAG); } else { - sp_document_request_modified(SP_OBJECT_DOCUMENT(this)); + SP_OBJECT_DOCUMENT(this)->request_modified(); } } } diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 56e7956b6..b076b5701 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -167,7 +167,7 @@ sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *r sp_object_read_attr (object, "xlink:href"); /* Register ourselves */ - sp_document_add_resource (document, "pattern", object); + document->add_resource ("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)->remove_resource ("pattern", SP_OBJECT (object)); } if (pat->ref) { diff --git a/src/sp-root.cpp b/src/sp-root.cpp index bd935074d..72c0b6de9 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -566,7 +566,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)->resized_signal_emit (root->width.computed, root->height.computed); } } diff --git a/src/sp-script.cpp b/src/sp-script.cpp index ad41b8021..614187013 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -85,14 +85,14 @@ 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"); - sp_document_add_resource(document, "script", object); + document->add_resource("script", object); } static void sp_script_release(SPObject *object) { if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "script", SP_OBJECT(object)); + SP_OBJECT_DOCUMENT(object)->remove_resource("script", SP_OBJECT(object)); } if (((SPObjectClass *) parent_class)->release) diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 4de6aeb80..8e8e22272 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -780,8 +780,8 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) 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)); + dbox.x1 = SP_OBJECT_DOCUMENT (item)->getWidth (); + dbox.y1 = SP_OBJECT_DOCUMENT (item)->getHeight (); item->getBboxDesktop (&bbox); Geom::Matrix const i2d(item->i2d_affine()); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 8f28ee255..46e17a75a 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -506,8 +506,8 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) 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)); + 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); diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index 10d997656..a60c93f0b 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -149,8 +149,8 @@ sp_svg_view_widget_size_request (GtkWidget *widget, GtkRequisition *req) gdouble width, height; svgv = static_cast (v); - width = sp_document_width (v->doc()) * svgv->_hscale; - height = sp_document_height (v->doc()) * svgv->_vscale; + width = (v->doc())->getWidth () * svgv->_hscale; + height = (v->doc())->getHeight () * svgv->_vscale; if (width <= vw->maxwidth) { hpol = GTK_POLICY_NEVER; diff --git a/src/svg-view.cpp b/src/svg-view.cpp index 31b54b36d..6d989a8f5 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -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); } } diff --git a/src/test-helpers.h b/src/test-helpers.h index 4ec1d4dc1..280935900 100644 --- a/src/test-helpers.h +++ b/src/test-helpers.h @@ -32,7 +32,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) ) static_cast(g_object_new(inkscape_get_type(), NULL)); } - SPDocument* tmp = SPDocument::createDoc( NULL, TRUE, true ); + SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true ); if ( tmp ) { fun( suite ); if ( suite ) diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 166799e38..2cc6e30d9 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -139,7 +139,7 @@ text_put_on_path() Inkscape::GC::release(repr); text->deleteObject(); // delete the orignal flowtext - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); + sp_desktop_document(desktop)->ensure_up_to_date(); selection->clear(); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 0c7f075b9..a2b0cd790 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -443,7 +443,7 @@ void Tracer::traceThread() return; } SPDocument *doc = SP_ACTIVE_DOCUMENT; - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); SPImage *img = getSelectedSPImage(); diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index d92d35ae1..aa59a7b23 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -851,7 +851,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); // Update (among other things) all curves in paths, for bounds() to work - sp_document_ensure_up_to_date(target_document); + target_document->ensure_up_to_date(); // move selection either to original position (in_place) or to mouse pointer Geom::OptRect sel_bbox = selection->bounds(); @@ -1200,7 +1200,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); @@ -1254,7 +1254,7 @@ void ClipboardManagerImpl::_onClear() void ClipboardManagerImpl::_createInternalClipboard() { if ( _clipboardSPDoc == NULL ) { - _clipboardSPDoc = SPDocument::createDoc(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); diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 7ed00ad19..8c102b57f 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -147,7 +147,7 @@ Gtk::Widget *build_splash_widget() { // should be in UTF-*8.. char *about=g_build_filename(INKSCAPE_SCREENSDIR, _("about.svg"), NULL); - SPDocument *doc=SPDocument::createDoc (about, TRUE); + SPDocument *doc=SPDocument::createNewDoc (about, TRUE); g_free(about); g_return_val_if_fail(doc != NULL, NULL); @@ -155,12 +155,12 @@ Gtk::Widget *build_splash_widget() { if ( version && SP_IS_TEXT(version) ) { sp_te_set_repr_text_multiline (SP_TEXT (version), Inkscape::version_string); } - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); 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(); doc->doUnref(); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index d7e3d1766..0b47f42ab 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -163,8 +163,8 @@ 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: @@ -215,7 +215,7 @@ private : it != selected.end(); it++) { - sp_document_ensure_up_to_date(sp_desktop_document (desktop)); + sp_desktop_document (desktop)->ensure_up_to_date(); if (!sel_as_group) b = (*it)->getBboxDesktop(); if (b) { @@ -621,7 +621,7 @@ private : it != selected.end(); ++it) { - sp_document_ensure_up_to_date(sp_desktop_document (desktop)); + sp_desktop_document (desktop)->ensure_up_to_date(); Geom::OptRect item_box = (*it)->getBboxDesktop (); if (item_box) { // find new center, staying within bbox diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 33fdf8327..970c609af 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -460,7 +460,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->get_resource_list( "iccprofile" ); if (current) _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); @@ -517,7 +517,7 @@ void DocumentProperties::removeSelectedProfile(){ } } - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" ); + const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "iccprofile" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast(obj); @@ -589,7 +589,7 @@ DocumentProperties::build_cms() _LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release)); cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile)); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "defs" ); + const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "defs" ); if (current) { _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); } @@ -647,7 +647,7 @@ DocumentProperties::build_scripting() #endif // ENABLE_LCMS //TODO: review this observers code: - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); + const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "script" ); if (current) { _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); } @@ -686,7 +686,7 @@ void DocumentProperties::removeExternalScript(){ } } - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); + const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "script" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; @@ -703,7 +703,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->get_resource_list( "script" ); if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); @@ -822,8 +822,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)); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index eb2d33eee..5a9f37bf0 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -151,7 +151,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 = SPDocument::createDoc (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; @@ -172,7 +172,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); - SPDocument *doc = SPDocument::createDocFromMem(xmlBuffer, len, 0); + SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 8a0c70f7c..aabb3c2df 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -887,7 +887,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string, _MAX_PATH, NULL, NULL, NULL); - SPDocument *svgDoc = SPDocument::createDoc (utf8string, true); + SPDocument *svgDoc = SPDocument::createNewDoc (utf8string, true); g_free(utf8string); // Check the document loaded properly @@ -899,8 +899,8 @@ bool FileOpenDialogImplWin32::set_svg_preview() } // 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; @@ -917,7 +917,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() // write object bbox to area Geom::OptRect maybeArea(area); - sp_document_ensure_up_to_date (svgDoc); + svgDoc->ensure_up_to_date (); static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea, static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 1672c4b69..7baf2d71f 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1144,8 +1144,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)->resources_changed_connect("filter",sigc::mem_fun(me, &FilterModifier::update_filters)); me->_dialog.setDesktop(desktop); @@ -1262,7 +1261,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->get_resource_list("filter"); _model->clear(); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 60cab06a2..808386171 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -46,8 +46,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"; @@ -190,8 +190,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); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 998f4e1e1..7f41c4d6b 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -243,7 +243,7 @@ void SvgFontsDialog::update_fonts() { SPDesktop* desktop = this->getDesktop(); SPDocument* document = sp_desktop_document(desktop); - const GSList* fonts = sp_document_get_resource_list(document, "font"); + const GSList* fonts = document->get_resource_list("font"); _model->clear(); for(const GSList *l = fonts; l; l = l->next) { diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 90e9e5f7b..d5d48a528 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -127,7 +127,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->get_resource_list("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { @@ -178,7 +178,7 @@ void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer us if ( doc && (index >= 0) && (static_cast(index) < popupItems.size()) ) { Glib::ustring targetName = popupItems[index]; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); + const GSList *gradients = doc->get_resource_list("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { @@ -306,7 +306,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())->get_resource_list("gradient"); gint index = 0; for (const GSList *curr = gradients; curr; curr = curr->next) { SPGradient* grad = SP_GRADIENT(curr->data); @@ -759,7 +759,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->resources_changed_connect( "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))) ); @@ -797,7 +797,7 @@ static void recalcSwatchContents(SPDocument* doc, { std::vector newList; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); + const GSList *gradients = doc->get_resource_list("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( grad->isSwatch() ) { diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index dfb319f90..546fdd8f0 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -159,7 +159,7 @@ void TileDialog::Grid_Arrange () grid_top = 99999; SPDesktop *desktop = getDesktop(); - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); + sp_desktop_document(desktop)->ensure_up_to_date(); Inkscape::Selection *selection = sp_desktop_selection (desktop); const GSList *items = selection ? selection->itemList() : 0; diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 570d53f05..d10f46313 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -593,8 +593,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)->items_in_box(nt->desktop->dkey, sel); selection->setList(items); g_slist_free(items); } else { diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 2c325a5ee..0248e73d5 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1390,8 +1390,8 @@ EditWidget::updateScrollbars (double scale) /* The desktop region we always show unconditionally */ SPDocument *doc = _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, item->getBboxDesktop()); @@ -1654,12 +1654,12 @@ void EditWidget::onWindowRealize() { - if ( (sp_document_width(_desktop->doc()) < 1.0) || (sp_document_height(_desktop->doc()) < 1.0) ) { + if ( ((_desktop->doc())->getWidth() < 1.0) || ((_desktop->doc())->getHeight() < 1.0) ) { return; } Geom::Rect d( Geom::Point(0, 0), - Geom::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc())) ); + Geom::Point((_desktop->doc())->getWidth(), (_desktop->doc())->getHeight()) ); _desktop->set_display_area(d.min()[Geom::X], d.min()[Geom::Y], d.max()[Geom::X], d.max()[Geom::Y], 10); _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG); diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 79cc8ca42..f5dd3e9fa 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -127,7 +127,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) fileName = Glib::filename_to_utf8(fileName); - SPDocument *doc = SPDocument::createDoc (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; @@ -148,7 +148,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); - SPDocument *doc = SPDocument::createDocFromMem(xmlBuffer, len, 0); + SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 26763cc77..1f70a26fd 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -406,9 +406,9 @@ 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))); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index dfb22b6d0..591ea6253 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -708,8 +708,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; @@ -1540,7 +1540,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())->get_resource_list("image"); for (GSList const *p = imageList; p; p = p->next) { SPImage* image = SP_IMAGE(p->data); sp_image_refresh_if_outdated( image ); @@ -1802,8 +1802,8 @@ 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, item->getBboxDesktop()); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 1d3187985..fe003319f 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -172,7 +172,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->get_resource_list ("gradient"); for (const GSList *i = gradients; i != NULL; i = i->next) { SPGradient *grad = SP_GRADIENT(i->data); if ( grad->hasStops() && !grad->isSolid() ) { diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 454c12001..132aff455 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -249,7 +249,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)->get_resource_list("gradient"); for (const GSList *curr = gradients; curr; curr = curr->next) { SPGradient* grad = SP_GRADIENT(curr->data); if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) { diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index e90cc1c46..570502253 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -924,7 +924,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, 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,11 +1105,11 @@ 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 = SPDocument::createDoc( doc_filename, FALSE )) ) { + (doc = SPDocument::createNewDoc( doc_filename, FALSE )) ) { //g_message("Loaded icon file %s", doc_filename); // prep the document - sp_document_ensure_up_to_date(doc); + doc->ensure_up_to_date(); /* Create new arena */ NRArena *arena = NRArena::create(); /* Create ArenaItem and set transform */ diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 55dc80f6f..aadda9e20 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -784,7 +784,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->get_resource_list("pattern"); for (GSList *l = (GSList *) patterns; l != NULL; l = l->next) { if (SP_PATTERN(l->data) == pattern_getroot(SP_PATTERN(l->data))) { // only if this is a root pattern pl = g_slist_prepend(pl, l->data); @@ -875,7 +875,7 @@ 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 = SPDocument::createDoc(patterns_source, FALSE); + patterns_doc = SPDocument::createNewDoc(patterns_source, FALSE); } g_free(patterns_source); } @@ -894,7 +894,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->ensure_up_to_date(); sp_pattern_list_from_doc ( m, doc, patterns_doc, NULL ); } diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index e2ad61e2d..487e3a274 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -155,7 +155,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->ensure_up_to_date (); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box"); SPItem::BBoxType bbox_type = (prefs_bbox ==0)? diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 6bd1957a8..17324967e 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -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->get_resource_list( "iccprofile" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast(obj); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index a8c0788e6..1843c8edb 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -176,7 +176,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, // object to render; note that the id is the same as that of the menu we're building SPObject *object = sandbox->getObjectById(menu_id); sp_document_root (sandbox)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - sp_document_ensure_up_to_date(sandbox); + sandbox->ensure_up_to_date(); if (object == NULL || !SP_IS_ITEM(object)) return NULL; // sandbox broken? @@ -342,7 +342,7 @@ gchar const *buffer = "ensure_up_to_date(); sp_marker_list_from_doc(m, doc, markers_doc, NULL, sandbox, menu_id); } diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index c3876725d..33978420c 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -227,7 +227,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->get_resource_list("image"); for (GSList const *l = images; l != NULL; l = l->next) { Inkscape::XML::Node *ir = SP_OBJECT_REPR(l->data); -- cgit v1.2.3 From d25a9a072143eafa4a9823b84e977c4b85d45efe Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Fri, 2 Jul 2010 18:05:42 +0530 Subject: New Class SPDocumentUndo created which takes care of c++fying some non SPDocument based methods (bzr r9546.1.3) --- src/arc-context.cpp | 4 +- src/box3d-context.cpp | 14 ++-- src/conn-avoid-ref.cpp | 8 +-- src/connector-context.cpp | 8 +-- src/console-output-undo-observer.cpp | 8 +-- src/console-output-undo-observer.h | 2 +- src/desktop-events.cpp | 8 +-- src/dialogs/clonetiler.cpp | 6 +- src/dialogs/export.cpp | 12 ++-- src/dialogs/item-properties.cpp | 12 ++-- src/dialogs/spellcheck.cpp | 2 +- src/dialogs/text-edit.cpp | 2 +- src/dialogs/xml-tree.cpp | 24 +++---- src/display/canvas-grid.cpp | 2 +- src/document-undo.cpp | 25 +++---- src/document.cpp | 76 ++++++++++----------- src/document.h | 24 ++++--- src/draw-context.cpp | 4 +- src/dropper-context.cpp | 2 +- src/dyna-draw-context.cpp | 2 +- src/eraser-context.cpp | 4 +- src/extension/effect.cpp | 2 +- src/extension/execution-env.cpp | 4 +- src/extension/internal/gdkpixbuf-input.cpp | 6 +- src/extension/internal/pdfinput/pdf-input.cpp | 6 +- src/extension/system.cpp | 18 ++--- src/file.cpp | 4 +- src/flood-context.cpp | 6 +- src/gradient-context.cpp | 12 ++-- src/gradient-drag.cpp | 12 ++-- src/interface.cpp | 16 ++--- src/knot.cpp | 2 +- src/knotholder.cpp | 4 +- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/parameter/path.cpp | 4 +- src/path-chemistry.cpp | 8 +-- src/persp3d.cpp | 4 +- src/rect-context.cpp | 4 +- src/select-context.cpp | 4 +- src/selection-chemistry.cpp | 96 +++++++++++++-------------- src/seltrans.cpp | 14 ++-- src/sp-guide.cpp | 2 +- src/sp-item-group.cpp | 2 +- src/sp-namedview.cpp | 20 +++--- src/spiral-context.cpp | 4 +- src/splivarot.cpp | 14 ++-- src/spray-context.cpp | 6 +- src/star-context.cpp | 4 +- src/text-chemistry.cpp | 12 ++-- src/text-context.cpp | 46 ++++++------- src/trace/trace.cpp | 2 +- src/tweak-context.cpp | 26 ++++---- src/ui/context-menu.cpp | 2 +- src/ui/dialog/align-and-distribute.cpp | 16 ++--- src/ui/dialog/color-item.cpp | 4 +- src/ui/dialog/document-properties.cpp | 10 +-- src/ui/dialog/filter-effects-dialog.cpp | 24 +++---- src/ui/dialog/glyphs.cpp | 4 +- src/ui/dialog/guides.cpp | 4 +- src/ui/dialog/layer-properties.cpp | 4 +- src/ui/dialog/layers.cpp | 4 +- src/ui/dialog/livepatheffect-editor.cpp | 10 +-- src/ui/dialog/session-player.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 30 ++++----- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/tile.cpp | 2 +- src/ui/dialog/transformation.cpp | 10 +-- src/ui/dialog/undo-history.cpp | 10 +-- src/ui/tool/multi-path-manipulator.cpp | 6 +- src/ui/tool/path-manipulator.cpp | 4 +- src/ui/widget/color-picker.cpp | 2 +- src/ui/widget/entity-entry.cpp | 4 +- src/ui/widget/layer-selector.cpp | 4 +- src/ui/widget/licensor.cpp | 2 +- src/ui/widget/object-composite-settings.cpp | 4 +- src/ui/widget/page-sizer.cpp | 2 +- src/ui/widget/registered-widget.cpp | 8 +-- src/ui/widget/registered-widget.h | 8 +-- src/ui/widget/ruler.cpp | 2 +- src/ui/widget/selected-style.cpp | 62 ++++++++--------- src/ui/widget/tolerance-slider.cpp | 6 +- src/vanishing-point.cpp | 6 +- src/verbs.cpp | 24 +++---- src/widgets/fill-style.cpp | 14 ++-- src/widgets/gradient-toolbar.cpp | 2 +- src/widgets/gradient-vector.cpp | 16 ++--- src/widgets/select-toolbar.cpp | 2 +- src/widgets/sp-attribute-widget.cpp | 4 +- src/widgets/sp-xmlview-content.cpp | 2 +- src/widgets/stroke-style.cpp | 6 +- src/widgets/swatch-selector.cpp | 2 +- src/widgets/toolbox.cpp | 90 ++++++++++++------------- 92 files changed, 520 insertions(+), 515 deletions(-) (limited to 'src') diff --git a/src/arc-context.cpp b/src/arc-context.cpp index ab3389ec6..2f70e16f3 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -500,7 +500,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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, _("Create ellipse")); ac->item = NULL; @@ -526,7 +526,7 @@ static void sp_arc_cancel(SPArcContext *ac) sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); + SPDocumentUndo::cancel(sp_desktop_document(desktop)); } diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 5534aa410..88763e183 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -436,42 +436,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, + SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_bracketleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, 180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_parenright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, -180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_parenleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, 180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_braceright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, -180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_braceleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, 180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; @@ -667,7 +667,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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX, _("Create 3D box")); bc->item = NULL; diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 15cd97b28..70e0c3856 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -197,7 +197,7 @@ void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 ); item->updateRepr(); doc->ensure_up_to_date(); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, action); + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, action); } void SPAvoidRef::addConnectionPoint(ConnectionPoint &cp) @@ -589,8 +589,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 = SPDocumentUndo::get_undo_sensitive(document); + SPDocumentUndo::set_undo_sensitive(document, false); bool initialised = false; GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop, @@ -604,7 +604,7 @@ void init_avoided_shape_geometry(SPDesktop *desktop) if (items) { g_slist_free(items); } - sp_document_set_undo_sensitive(document, saved); + SPDocumentUndo::set_undo_sensitive(document, saved); } diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 90b16fddd..ff19c7749 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1152,7 +1152,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) cc_connector_rerouting_finish(cc, NULL); - sp_document_undo(doc); + SPDocumentUndo::undo(doc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, @@ -1303,7 +1303,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, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Reroute connector")); cc_set_active_conn(cc, cc->clickeditem); } @@ -1477,7 +1477,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) c->unref(); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); } @@ -1935,7 +1935,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); + SPDocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); } diff --git a/src/console-output-undo-observer.cpp b/src/console-output-undo-observer.cpp index 84d8af3a8..9369b5db5 100644 --- a/src/console-output-undo-observer.cpp +++ b/src/console-output-undo-observer.cpp @@ -1,6 +1,6 @@ /** * 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 @@ -19,19 +19,19 @@ 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 diff --git a/src/console-output-undo-observer.h b/src/console-output-undo-observer.h index 9b42cf033..f8667d567 100644 --- a/src/console-output-undo-observer.h +++ b/src/console-output-undo-observer.h @@ -1,6 +1,6 @@ /** * 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 diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 810f501d7..2046b9510 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -185,7 +185,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge sp_repr_set_point(repr, "position", from_2geom(event_dt)); SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); Inkscape::GC::release(repr); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create guide")); } desktop->set_coordinate_status(from_2geom(event_dt)); @@ -398,14 +398,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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Move guide")); } else { /* Undo movement of any attached shapes. */ sp_guide_moveto(*guide, guide->point_on_line, false); sp_guide_set_normal(*guide, guide->normal_to_line, false); sp_guide_remove(guide); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Delete guide")); } moved = false; @@ -452,7 +452,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")); + SPDocumentUndo::done(doc, SP_VERB_NONE, _("Delete guide")); ret = TRUE; sp_event_context_discard_delayed_snap_event(desktop->event_context); break; diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 8dd59425a..b1c1cf74a 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -993,7 +993,7 @@ clonetiler_unclump( GtkWidget */*widget*/, void * ) g_slist_free (to_unclump); - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, _("Unclump tiled clones")); } @@ -1046,7 +1046,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, _("Delete tiled clones")); } @@ -1510,7 +1510,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) desktop->clearWaitingCursor(); - sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, _("Create tiled clones")); } diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 6513813cc..649918742 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1243,8 +1243,8 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) bool modified = false; const gchar * temp_string; - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); + bool saved = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); temp_string = repr->attribute("inkscape:export-filename"); if (temp_string == NULL || strcmp(temp_string, filename_ext)) { @@ -1261,7 +1261,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); + SPDocumentUndo::set_undo_sensitive(doc, saved); if (modified) { doc->setModifiedSinceSave(); @@ -1273,8 +1273,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 = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList(); for(; reprlst != NULL; reprlst = reprlst->next) { @@ -1302,7 +1302,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) modified = true; } } - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); if (modified) { doc->setModifiedSinceSave(); diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index abc45b44b..8d2b15e44 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -398,7 +398,7 @@ 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, + SPDocumentUndo::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,7 +417,7 @@ 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, + SPDocumentUndo::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)); @@ -450,7 +450,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) 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, + SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object ID")); } @@ -465,7 +465,7 @@ 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, + SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object label")); } @@ -473,7 +473,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) GtkWidget *w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title")); gchar *title = (gchar *)gtk_entry_get_text(GTK_ENTRY (w)); if (obj->setTitle(title)) - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, + SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object title")); /* Retrieve the description */ @@ -483,7 +483,7 @@ 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, + SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object description")); g_free(desc); diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 24890f8eb..5372a8bb5 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -777,7 +777,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_TEXT, _("Fix spelling")); } } diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index dc71de7c3..ab0de514a 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -661,7 +661,7 @@ 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, + SPDocumentUndo::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); diff --git a/src/dialogs/xml-tree.cpp b/src/dialogs/xml-tree.cpp index c8644fef9..515b49360 100644 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@ -870,10 +870,10 @@ void after_tree_move(GtkCTree */*tree*/, if (GTK_CTREE_ROW(node)->parent == new_parent && GTK_CTREE_ROW(node)->sibling == new_sibling) { - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Drag XML subtree")); } else { - sp_document_cancel(current_document); + SPDocumentUndo::cancel(current_document); } } @@ -1371,7 +1371,7 @@ 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, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Create new element node")); } @@ -1387,7 +1387,7 @@ void cmd_new_text_node(GtkObject */*object*/, gpointer /*data*/) Inkscape::XML::Node *text = xml_doc->createTextNode(""); selected_repr->appendChild(text); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Create new text node")); set_tree_select(text); @@ -1405,7 +1405,7 @@ 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, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Duplicate node")); GtkCTreeNode *node = sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), dup); @@ -1422,7 +1422,7 @@ 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, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, Q_("nodeAsInXMLinHistoryDialog|Delete node")); } @@ -1440,7 +1440,7 @@ void cmd_delete_attr(GtkObject */*object*/, gpointer /*data*/) updated->updateRepr(); } - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Delete attribute")); } @@ -1469,7 +1469,7 @@ void cmd_set_attr(GtkObject */*object*/, gpointer /*data*/) updated->updateRepr(); } - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Change attribute")); /* TODO: actually, the row won't have been created yet. why? */ @@ -1499,7 +1499,7 @@ void cmd_raise_node(GtkObject */*object*/, gpointer /*data*/) parent->changeOrder(selected_repr, ref); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Raise node")); set_tree_select(selected_repr); @@ -1516,7 +1516,7 @@ 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, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Lower node")); set_tree_select(selected_repr); @@ -1546,7 +1546,7 @@ 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, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Indent node")); set_tree_select(repr); set_dt_select(repr); @@ -1567,7 +1567,7 @@ 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, + SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Unindent node")); set_tree_select(repr); set_dt_select(repr); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index a79a6b610..7a21c19b8 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -255,7 +255,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")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid")); } /* diff --git a/src/document-undo.cpp b/src/document-undo.cpp index ee15e480f..280eea243 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -63,6 +63,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" @@ -85,7 +86,7 @@ sp_document_set_undo_sensitive(document, saved); \endverbatim */ void -sp_document_set_undo_sensitive (SPDocument *doc, bool sensitive) +SPDocumentUndo::set_undo_sensitive (SPDocument *doc, bool sensitive) { g_assert (doc != NULL); g_assert (doc->priv != NULL); @@ -112,7 +113,7 @@ 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 SPDocumentUndo::get_undo_sensitive(SPDocument const *document) { g_assert(document != NULL); g_assert(document->priv != NULL); @@ -120,13 +121,13 @@ bool sp_document_get_undo_sensitive(SPDocument const *document) { } void -sp_document_done (SPDocument *doc, const unsigned int event_type, Glib::ustring event_description) +SPDocumentUndo::done (SPDocument *doc, const unsigned int event_type, Glib::ustring event_description) { - sp_document_maybe_done (doc, NULL, event_type, event_description); + maybe_done (doc, NULL, event_type, event_description); } void -sp_document_reset_key (Inkscape::Application */*inkscape*/, SPDesktop */*desktop*/, GtkObject *base) +SPDocumentUndo::reset_key (Inkscape::Application */*inkscape*/, SPDesktop */*desktop*/, GtkObject *base) { SPDocument *doc = (SPDocument *) base; doc->actionkey = NULL; @@ -165,7 +166,7 @@ public: } void -sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type, +SPDocumentUndo::maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type, Glib::ustring event_description) { g_assert (doc != NULL); @@ -178,7 +179,7 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev doc->ensure_up_to_date (); - sp_document_clear_redo (doc); + SPDocumentUndo::clear_redo (doc); Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc)); doc->priv->partial = NULL; @@ -209,7 +210,7 @@ sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int ev } void -sp_document_cancel (SPDocument *doc) +SPDocumentUndo::cancel (SPDocument *doc) { g_assert (doc != NULL); g_assert (doc->priv != NULL); @@ -241,7 +242,7 @@ static void finish_incomplete_transaction(SPDocument &doc) { } gboolean -sp_document_undo (SPDocument *doc) +SPDocumentUndo::undo (SPDocument *doc) { using Inkscape::Debug::EventTracker; using Inkscape::Debug::SimpleEvent; @@ -287,7 +288,7 @@ sp_document_undo (SPDocument *doc) } gboolean -sp_document_redo (SPDocument *doc) +SPDocumentUndo::redo (SPDocument *doc) { using Inkscape::Debug::EventTracker; using Inkscape::Debug::SimpleEvent; @@ -333,7 +334,7 @@ sp_document_redo (SPDocument *doc) } void -sp_document_clear_undo (SPDocument *doc) +SPDocumentUndo::clear_undo (SPDocument *doc) { if (doc->priv->undo) doc->priv->undoStackObservers.notifyClearUndoEvent(); @@ -351,7 +352,7 @@ sp_document_clear_undo (SPDocument *doc) } void -sp_document_clear_redo (SPDocument *doc) +SPDocumentUndo::clear_redo (SPDocument *doc) { if (doc->priv->redo) doc->priv->undoStackObservers.notifyClearRedoEvent(); diff --git a/src/document.cpp b/src/document.cpp index 147c22b3c..e68bc1f94 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -150,8 +150,8 @@ SPDocument::~SPDocument() { priv->partial = NULL; } - sp_document_clear_redo(this); - sp_document_clear_undo(this); + SPDocumentUndo::clear_redo(this); + SPDocumentUndo::clear_undo(this); if (root) { root->releaseReferences(); @@ -200,7 +200,7 @@ SPDocument::~SPDocument() { if (oldSignalsConnected) { g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE), - reinterpret_cast(sp_document_reset_key), + reinterpret_cast(SPDocumentUndo::reset_key), static_cast(this)); } else { _selection_changed_connection.disconnect(); @@ -416,14 +416,14 @@ SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->setCurrentPersp3DImpl(persp_impl); } - sp_document_set_undo_sensitive(document, true); + SPDocumentUndo::set_undo_sensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced if (!Inkscape::NSApplication::Application::getNewGui()) { g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", - G_CALLBACK(sp_document_reset_key), document); + G_CALLBACK(SPDocumentUndo::reset_key), document); g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", - G_CALLBACK(sp_document_reset_key), document); + G_CALLBACK(SPDocumentUndo::reset_key), document); document->oldSignalsConnected = true; } else { document->_selection_changed_connection = Inkscape::NSApplication::Editor::connectSelectionChanged (sigc::mem_fun (*document, &SPDocument::reset_key)); @@ -717,10 +717,10 @@ 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::do_change_uri(gchar const *const filename, bool const rebase) { - g_return_if_fail(document != NULL); + //g_return_if_fail(this != NULL); gchar *new_base; gchar *new_name; @@ -739,32 +739,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 = sp_document_repr_root(this); // Changing uri in the document repr must not be not undoable. - bool const saved = sp_document_get_undo_sensitive(document); - sp_document_set_undo_sensitive(document, false); + bool const saved = SPDocumentUndo::get_undo_sensitive(this); + SPDocumentUndo::set_undo_sensitive(this, false); if (rebase) { - Inkscape::XML::rebase_hrefs(document, new_base, true); + Inkscape::XML::rebase_hrefs(this, new_base, true); } - repr->setAttribute("sodipodi:docname", document->name); - sp_document_set_undo_sensitive(document, saved); + repr->setAttribute("sodipodi:docname", this->name); + SPDocumentUndo::set_undo_sensitive(this, saved); - 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); } /** @@ -776,9 +776,9 @@ do_change_uri(SPDocument *const document, gchar const *const filename, bool cons */ void SPDocument::setUri(gchar const *filename) { - g_return_if_fail(this != NULL); + //g_return_if_fail(this != NULL); - do_change_uri(this, filename, false); + do_change_uri(filename, false); } /** @@ -789,15 +789,15 @@ void SPDocument::setUri(gchar const *filename) */ void SPDocument::change_uri_and_hrefs(gchar const *filename) { - g_return_if_fail(this != NULL); + //g_return_if_fail(this != NULL); - do_change_uri(this, filename, true); + do_change_uri(filename, true); } void SPDocument::resized_signal_emit(gdouble width, gdouble height) { - g_return_if_fail(this != NULL); + //g_return_if_fail(this != NULL); this->priv->resized_signal.emit(width, height); } @@ -1005,12 +1005,12 @@ SPDocument::_updateDocument() SPItemCtx ctx; sp_document_setup_viewport (this, &ctx); - bool saved = sp_document_get_undo_sensitive(this); - sp_document_set_undo_sensitive(this, false); + bool saved = SPDocumentUndo::get_undo_sensitive(this); + SPDocumentUndo::set_undo_sensitive(this, false); this->root->updateDisplay((SPCtx *)&ctx, 0); - sp_document_set_undo_sensitive(this, saved); + SPDocumentUndo::set_undo_sensitive(this, saved); } this->_emitModified(); } @@ -1271,7 +1271,7 @@ find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) GSList *SPDocument::items_in_box(unsigned int dkey, Geom::Rect const &box) { - g_return_val_if_fail(this != NULL, NULL); + //g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(this->priv != NULL, NULL); return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within); @@ -1286,7 +1286,7 @@ GSList *SPDocument::items_in_box(unsigned int dkey, Geom::Rect const &box) GSList *SPDocument::partial_items_in_box(unsigned int dkey, Geom::Rect const &box) { - g_return_val_if_fail(this != NULL, NULL); + //g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(this->priv != NULL, NULL); return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps); @@ -1321,7 +1321,7 @@ SPItem * SPDocument::item_at_point( unsigned const key, Geom::Point const p, gboolean const into_groups, SPItem *upto) { - g_return_val_if_fail(this != NULL, NULL); + //g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(this->priv != NULL, NULL); return find_item_at_point(key, SP_GROUP(this->root), p, into_groups, false, upto); @@ -1330,7 +1330,7 @@ SPDocument::item_at_point( unsigned const key, Geom::Point const p, SPItem* SPDocument::group_at_point(unsigned int key, Geom::Point const p) { - g_return_val_if_fail(this != NULL, NULL); + //g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(this->priv != NULL, NULL); return find_group_at_point(key, SP_GROUP(this->root), p); @@ -1345,7 +1345,7 @@ SPDocument::add_resource(gchar const *key, SPObject *object) GSList *rlist; GQuark q = g_quark_from_string(key); - g_return_val_if_fail(this != NULL, FALSE); + //g_return_val_if_fail(this != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(*key != '\0', FALSE); g_return_val_if_fail(object != NULL, FALSE); @@ -1370,7 +1370,7 @@ SPDocument::remove_resource(gchar const *key, SPObject *object) GSList *rlist; GQuark q = g_quark_from_string(key); - g_return_val_if_fail(this != NULL, FALSE); + //g_return_val_if_fail(this != NULL, FALSE); g_return_val_if_fail(key != NULL, FALSE); g_return_val_if_fail(*key != '\0', FALSE); g_return_val_if_fail(object != NULL, FALSE); @@ -1393,7 +1393,7 @@ SPDocument::remove_resource(gchar const *key, SPObject *object) GSList const * SPDocument::get_resource_list(gchar const *key) { - g_return_val_if_fail(this != NULL, NULL); + //g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); g_return_val_if_fail(*key != '\0', NULL); diff --git a/src/document.h b/src/document.h index 3fa83c779..38f930c31 100644 --- a/src/document.h +++ b/src/document.h @@ -28,6 +28,7 @@ #include "gc-anchored.h" #include #include "verbs.h" +#include "document-undo.h" #include #include @@ -213,6 +214,9 @@ public: void resized_signal_emit(gdouble width, gdouble height); unsigned int vacuum_document(); + + private: + void do_change_uri(gchar const *const filename, bool const rebase); }; //SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); @@ -254,11 +258,11 @@ struct SPUnit; * Undo & redo */ -void sp_document_set_undo_sensitive(SPDocument *document, bool sensitive); -bool sp_document_get_undo_sensitive(SPDocument const *document); +//void sp_document_set_undo_sensitive(SPDocument *document, bool sensitive); +//bool sp_document_get_undo_sensitive(SPDocument const *document); -void sp_document_clear_undo(SPDocument *document); -void sp_document_clear_redo(SPDocument *document); +//void sp_document_clear_undo(SPDocument *document); +//void sp_document_clear_redo(SPDocument *document); //void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); //void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); @@ -271,16 +275,16 @@ void sp_document_clear_redo(SPDocument *document); //gint sp_document_ensure_up_to_date(SPDocument *doc); /* Save all previous actions to stack, as one undo step */ -void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); -void sp_document_maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); -void sp_document_reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); +//void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); +//void sp_document_maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); +//void sp_document_reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); /* Cancel (and revert) current unsaved actions */ -void sp_document_cancel(SPDocument *document); +//void sp_document_cancel(SPDocument *document); /* Undo and redo */ -gboolean sp_document_undo(SPDocument *document); -gboolean sp_document_redo(SPDocument *document); +//gboolean sp_document_undo(SPDocument *document); +//gboolean sp_document_redo(SPDocument *document); /* Resource management */ //gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); diff --git a/src/draw-context.cpp b/src/draw-context.cpp index ea25efc22..a3c3601cc 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -698,7 +698,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) item->updateRepr(); } - sp_document_done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, + SPDocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, _("Draw path")); // When quickly drawing several subpaths with Shift, the next subpath may be finished and @@ -861,7 +861,7 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons sp_desktop_selection(desktop)->set(item); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot")); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot")); + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot")); } /* diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 5415fdc80..513963692 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -350,7 +350,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER, _("Set picked color")); } diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 4d8ab2c11..ab57872cd 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -1040,7 +1040,7 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize, bool subtract) dc->repr = NULL; } - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_CALLIGRAPHIC, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_CALLIGRAPHIC, _("Draw calligraphic stroke")); } diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index db1aa46d9..fdb0813ce 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -826,10 +826,10 @@ set_to_accumulated(SPEraserContext *dc) if ( workDone ) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); } else { - sp_document_cancel(sp_desktop_document(desktop)); + SPDocumentUndo::cancel(sp_desktop_document(desktop)); } } diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index afc0668a9..79bd96a7e 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -258,7 +258,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 diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 7ed389195..d97c8c6de 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -162,14 +162,14 @@ ExecutionEnv::cancel (void) { void ExecutionEnv::undo (void) { - sp_document_cancel(_doc->doc()); + SPDocumentUndo::cancel(_doc->doc()); reselect(); return; } void ExecutionEnv::commit (void) { - sp_document_done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name())); + SPDocumentUndo::done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name())); Effect::set_last_effect(_effect); _effect->get_imp()->commitDocument(); killDocCache(); diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 4983d7eff..69fdbcfd1 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -55,8 +55,8 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) } doc = SPDocument::createNewDoc(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 + bool saved = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); // no need to undo in this temporary document double width = gdk_pixbuf_get_width(pb); double height = gdk_pixbuf_get_height(pb); @@ -103,7 +103,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) Inkscape::GC::release(image_node); fit_canvas_to_drawing(doc); // restore undo, as now this document may be shown to the user if a bitmap was opened - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); } else { printf("GdkPixbuf loader failed\n"); } diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 9826addb6..b50711803 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -662,8 +662,8 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { Page *page = catalog->getPage(page_num); SPDocument *doc = SPDocument::createNewDoc(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 + bool saved = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); // No need to undo in this temporary document // Create builder gchar *docname = g_path_get_basename(uri); @@ -737,7 +737,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { delete dlg; // Restore undo - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); return doc; } diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 67720235d..8cfc58797 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -274,8 +274,8 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, // Update attributes: { - bool const saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); + bool const saved = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); { // also save the extension for next use store_file_extension_in_prefs (omod->get_id(), save_method); @@ -285,7 +285,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, repr->setAttribute("inkscape:dataloss", "true"); } } - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); doc->setModifiedSinceSave(false); } @@ -295,13 +295,13 @@ 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 = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); { store_file_extension_in_prefs (saved_output_extension, save_method); repr->setAttribute("inkscape:dataloss", saved_dataloss); } - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); doc->change_uri_and_hrefs(saved_uri); } doc->setModifiedSinceSave(saved_modified); @@ -317,13 +317,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 = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); { store_file_extension_in_prefs (saved_output_extension, save_method); repr->setAttribute("inkscape:dataloss", saved_dataloss); } - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); doc->setModifiedSinceSave(saved_modified); g_free(saved_output_extension); diff --git a/src/file.cpp b/src/file.cpp index 6b162c799..2344c67f2 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -560,7 +560,7 @@ sp_file_vacuum() unsigned int diff = doc->vacuum_document (); - sp_document_done(doc, SP_VERB_FILE_VACUUM, + SPDocumentUndo::done(doc, SP_VERB_FILE_VACUUM, _("Vacuum <defs>")); SPDesktop *dt = SP_ACTIVE_DESKTOP; @@ -1064,7 +1064,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } doc->doUnref(); - sp_document_done(in_doc, SP_VERB_FILE_IMPORT, + SPDocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); } else { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 019cbbb02..696efd3e3 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -1119,7 +1119,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")); + SPDocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); } static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) @@ -1139,7 +1139,7 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem 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")); + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ret = TRUE; } break; @@ -1278,7 +1278,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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); rc->item = NULL; diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 6d6ea8761..2e6544b63 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -386,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")); + SPDocumentUndo::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; @@ -454,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")); + SPDocumentUndo::done (doc, SP_VERB_CONTEXT_GRADIENT, _("Simplify gradient")); drag->local_change = true; drag->updateDraggers(); drag->selectByCoords(coords); @@ -478,7 +478,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); ec->get_drag()->updateDraggers(); @@ -530,7 +530,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, _("Create default gradient")); } ret = TRUE; @@ -812,7 +812,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, _("Invert gradient")); ret = TRUE; } @@ -924,7 +924,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 diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 6306278c5..5fb490b8b 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -588,7 +588,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (d_new->parent->desktop), SP_VERB_CONTEXT_GRADIENT, _("Merge gradient handles")); return; } @@ -887,7 +887,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (dragger->parent->desktop), SP_VERB_CONTEXT_GRADIENT, _("Move gradient handle")); } @@ -940,7 +940,7 @@ 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, + SPDocumentUndo::done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop")); } } else { @@ -1817,7 +1817,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, + SPDocumentUndo::maybe_done (sp_desktop_document (desktop), "grmoveh", SP_VERB_CONTEXT_GRADIENT, _("Move gradient handle(s)")); return; } @@ -1853,7 +1853,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, + SPDocumentUndo::maybe_done (sp_desktop_document (desktop), "grmovem", SP_VERB_CONTEXT_GRADIENT, _("Move gradient mid stop(s)")); } } @@ -2142,7 +2142,7 @@ GrDrag::deleteSelected (bool just_one) } if (document) { - sp_document_done ( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") ); + SPDocumentUndo::done ( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") ); } } diff --git a/src/interface.cpp b/src/interface.cpp index bdec99291..a535ed1bd 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1249,7 +1249,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 ) { @@ -1289,7 +1289,7 @@ sp_ui_drag_data_received(GtkWidget *widget, if (desktop->event_context && desktop->event_context->get_drag()) { consumed = desktop->event_context->get_drag()->dropColor(item, colorspec, button_dt); if (consumed) { - sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient")); + SPDocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient")); desktop->event_context->get_drag()->updateDraggers(); } } @@ -1297,7 +1297,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")); // } //} @@ -1335,7 +1335,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")); } } @@ -1399,7 +1399,7 @@ sp_ui_drag_data_received(GtkWidget *widget, if (desktop->event_context && desktop->event_context->get_drag()) { consumed = desktop->event_context->get_drag()->dropColor(item, colorspec.c_str(), button_dt); if (consumed) { - sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient")); + SPDocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient")); desktop->event_context->get_drag()->updateDraggers(); } } @@ -1438,7 +1438,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")); } } @@ -1490,7 +1490,7 @@ sp_ui_drag_data_received(GtkWidget *widget, } Inkscape::GC::release(newgroup); - sp_document_done(doc, SP_VERB_NONE, + SPDocumentUndo::done(doc, SP_VERB_NONE, _("Drop SVG")); break; } @@ -1524,7 +1524,7 @@ 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, + SPDocumentUndo::done( doc , SP_VERB_NONE, _("Drop bitmap image")); break; } diff --git a/src/knot.cpp b/src/knot.cpp index 10672e048..95a9ec148 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -427,7 +427,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)); + SPDocumentUndo::undo(sp_desktop_document(knot->desktop)); knot->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Node or handle drag canceled.")); transform_escaped = true; consumed = TRUE; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index af11d5acb..89f57da97 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -146,7 +146,7 @@ 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, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(item), object_verb, _("Change handle")); } @@ -225,7 +225,7 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/) object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; } - sp_document_done(SP_OBJECT_DOCUMENT (object), object_verb, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT (object), object_verb, _("Move handle")); } } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index b8e9b8cf9..a2476a098 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -636,7 +636,7 @@ KnotHolderEntityCrossingSwitcher::knot_click(guint state) //std::cout<<"crossing set to"<crossing_points[s].sign<<".\n"; } lpe->crossing_points_vector.param_set_and_write_new_value(lpe->crossing_points.to_vector()); - sp_document_done(lpe->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, /// @todo Is this the right verb? + SPDocumentUndo::done(lpe->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, /// @todo Is this the right verb? _("Change knot crossing")); // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index e662f7d95..af4f84f59 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -414,7 +414,7 @@ PathParam::on_paste_button_click() Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); paste_param_path(svgd.data()); - sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + SPDocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Paste path parameter")); } @@ -446,7 +446,7 @@ PathParam::on_link_button_click() // check if linking to object to which LPE is applied (maybe delegated to PathReference param_write_to_repr(pathid.c_str()); - sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + SPDocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Link path parameter to path")); } } diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index c44ab5bc6..daa9ae595 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -162,7 +162,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE, _("Combine")); selection->set(repr); @@ -272,7 +272,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) desktop->clearWaitingCursor(); if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART, _("Break apart")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to break apart in the selection.")); @@ -314,7 +314,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, _("Object to path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No objects to convert to path in the selection.")); @@ -627,7 +627,7 @@ sp_selected_path_reverse(SPDesktop *desktop) desktop->clearWaitingCursor(); if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, _("Reverse path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No paths to reverse in the selection.")); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index d9839c556..817bb97d7 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -341,7 +341,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Toggle vanishing point")); } } @@ -352,7 +352,7 @@ persp3d_toggle_VPs (std::list p, Proj::Axis axis) { for (std::list::iterator i = p.begin(); i != p.end(); ++i) { persp3d_toggle_VP((*i), axis, false); } - sp_document_done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Toggle multiple vanishing points")); } diff --git a/src/rect-context.cpp b/src/rect-context.cpp index b232a340a..69a9bc2f0 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -545,7 +545,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, _("Create rectangle")); rc->item = NULL; @@ -571,7 +571,7 @@ static void sp_rect_cancel(SPRectContext *rc) sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); + SPDocumentUndo::cancel(sp_desktop_document(desktop)); } diff --git a/src/select-context.cpp b/src/select-context.cpp index db25d3fad..215436f38 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -222,7 +222,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)); + SPDocumentUndo::undo(sp_desktop_document(desktop)); } sp_object_unref( SP_OBJECT(sc->item), NULL); @@ -230,7 +230,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)); + SPDocumentUndo::undo(sp_desktop_document(desktop)); } sc->item = NULL; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 223fcee33..066b86ddf 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -300,7 +300,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Delete text")); return; } @@ -326,7 +326,7 @@ void sp_selection_delete(SPDesktop *desktop) */ tools_switch( desktop, tools_active( desktop ) ); - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DELETE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DELETE, _("Delete")); } @@ -421,7 +421,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) if ( !suppressDone ) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE, _("Duplicate")); } @@ -446,7 +446,7 @@ void sp_edit_clear_all(SPDesktop *dt) items = g_slist_remove(items, items->data); } - sp_document_done(doc, SP_VERB_EDIT_CLEAR_ALL, + SPDocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, _("Delete all")); } @@ -647,7 +647,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GROUP, _("Group")); selection->set(group); @@ -708,7 +708,7 @@ void sp_selection_ungroup(SPDesktop *desktop) g_slist_free(items); - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_UNGROUP, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); } @@ -843,7 +843,7 @@ sp_selection_raise(SPDesktop *desktop) g_slist_free(rev); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE, //TRANSLATORS: only translate "string" in "context|string". // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS // "Raise" means "to raise an object" in the undo history @@ -881,7 +881,7 @@ void sp_selection_raise_to_top(SPDesktop *desktop) g_slist_free(rl); - sp_document_done(document, SP_VERB_SELECTION_TO_FRONT, + SPDocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, _("Raise to top")); } @@ -944,7 +944,7 @@ sp_selection_lower(SPDesktop *desktop) g_slist_free(rev); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER, _("Lower")); } @@ -991,21 +991,21 @@ void sp_selection_lower_to_bottom(SPDesktop *desktop) g_slist_free(rl); - sp_document_done(document, SP_VERB_SELECTION_TO_BACK, + SPDocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, _("Lower to bottom")); } void sp_undo(SPDesktop *desktop, SPDocument *) { - if (!sp_document_undo(sp_desktop_document(desktop))) + if (!SPDocumentUndo::undo(sp_desktop_document(desktop))) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); } void sp_redo(SPDesktop *desktop, SPDocument *) { - if (!sp_document_redo(sp_desktop_document(desktop))) + if (!SPDocumentUndo::redo(sp_desktop_document(desktop))) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); } @@ -1066,7 +1066,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")); + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste")); } } @@ -1074,7 +1074,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")); + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style")); } } @@ -1083,7 +1083,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, _("Paste live path effect")); } } @@ -1116,7 +1116,7 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) } - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, _("Remove live path effect")); } @@ -1137,7 +1137,7 @@ void sp_selection_remove_filter(SPDesktop *desktop) sp_desktop_set_style(desktop, css); sp_repr_css_attr_unref(css); - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER, _("Remove filter")); } @@ -1146,7 +1146,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE, _("Paste size")); } } @@ -1155,7 +1155,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, _("Paste size separately")); } } @@ -1191,7 +1191,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_NEXT, _("Raise to next layer")); } } else { @@ -1236,7 +1236,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_PREV, _("Lower to previous layer")); } } else { @@ -1452,7 +1452,7 @@ void sp_selection_remove_transform(SPDesktop *desktop) l = l->next; } - sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLATTEN, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLATTEN, _("Remove transform")); } @@ -1554,7 +1554,7 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) sp_item_rotate_rel(item, rot_90); } - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW, ccw ? _("Rotate 90° CCW") : _("Rotate 90° CW")); } @@ -1572,7 +1572,7 @@ 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()), + SPDocumentUndo::maybe_done(sp_desktop_document(selection->desktop()), ( ( angle_degrees > 0 ) ? "selector:rotate:ccw" : "selector:rotate:cw" ), @@ -1619,7 +1619,7 @@ 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()), + SPDocumentUndo::maybe_done(sp_desktop_document(selection->desktop()), ( (angle > 0) ? "selector:rotate:ccw" : "selector:rotate:cw" ), @@ -1649,7 +1649,7 @@ 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()), + SPDocumentUndo::maybe_done(sp_desktop_document(selection->desktop()), ( (grow > 0) ? "selector:scale:larger" : "selector:scale:smaller" ), @@ -1678,7 +1678,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT, _("Scale by whole factor")); } @@ -1693,13 +1693,13 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, _("Move vertically")); } else if (dy == 0) { - sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, _("Move horizontally")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, _("Move")); } } @@ -1719,13 +1719,13 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, _("Move vertically by pixels")); } else if (dy == 0) { - sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, _("Move horizontally by pixels")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, _("Move")); } } @@ -2055,7 +2055,7 @@ sp_selection_clone(SPDesktop *desktop) // TRANSLATORS: only translate "string" in "context|string". // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE, Q_("action|Clone")); selection->setReprList(newsel); @@ -2105,7 +2105,7 @@ sp_selection_relink(SPDesktop *desktop) if (!relinked) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No clones to relink in the selection.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, _("Relink clone")); } } @@ -2172,7 +2172,7 @@ sp_selection_unlink(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No clones to unlink in the selection.")); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, _("Unlink clone")); } @@ -2328,7 +2328,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) g_slist_free(items); - sp_document_done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, + SPDocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, _("Objects to marker")); } @@ -2369,7 +2369,7 @@ 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")); + SPDocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); } void @@ -2472,7 +2472,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) g_slist_free(items); - sp_document_done(doc, SP_VERB_EDIT_TILE, + SPDocumentUndo::done(doc, SP_VERB_EDIT_TILE, _("Objects to pattern")); } @@ -2544,7 +2544,7 @@ sp_selection_untile(SPDesktop *desktop) if (!did) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No pattern fills in the selection.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE, _("Pattern to objects")); selection->setList(new_select); } @@ -2807,7 +2807,7 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) gdk_pixbuf_unref(pb); // Complete undoable transaction - sp_document_done(document, SP_VERB_SELECTION_CREATE_BITMAP, + SPDocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP, _("Create bitmap")); } @@ -3024,9 +3024,9 @@ sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_la g_slist_free(items_to_select); if (apply_clip_path) - sp_document_done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); + SPDocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); else - sp_document_done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); + SPDocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); } void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { @@ -3150,9 +3150,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { g_slist_free(items_to_select); if (apply_clip_path) - sp_document_done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); + SPDocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); else - sp_document_done(doc, SP_VERB_OBJECT_UNSET_MASK, _("Release mask")); + SPDocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_MASK, _("Release mask")); } /** @@ -3189,7 +3189,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION, _("Fit Page to Selection")); } } @@ -3218,7 +3218,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_DRAWING, _("Fit Page to Drawing")); } } @@ -3239,7 +3239,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, _("Fit Page to Selection or Drawing")); } }; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 89799246c..627620a60 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -520,16 +520,16 @@ void Inkscape::SelTrans::ungrab() _items_centers.clear(); if (_current_relative_affine.isTranslation()) { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Move")); } else if (_current_relative_affine.without_translation().isScale()) { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Scale")); } else if (_current_relative_affine.without_translation().isRotation()) { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Rotate")); } else { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Skew")); } @@ -541,7 +541,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Set center")); } @@ -616,7 +616,7 @@ void Inkscape::SelTrans::stamp() Inkscape::GC::release(copy_repr); l = l->next; } - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Stamp")); } @@ -805,7 +805,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, _("Reset center")); } break; diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 5bf7f664c..877e73979 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -284,7 +284,7 @@ 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")); + SPDocumentUndo::done (doc, SP_VERB_NONE, _("Guides Around Page")); } void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler) diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index c178cfdd4..1d38771bc 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -497,7 +497,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) } if (do_done) - sp_document_done (doc, SP_VERB_NONE, _("Ungroup")); + SPDocumentUndo::done (doc, SP_VERB_NONE, _("Ungroup")); } /* diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 44c3bf620..8c750f347 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -204,7 +204,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")); } } @@ -812,8 +812,8 @@ 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 = SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop)); + SPDocumentUndo::set_undo_sensitive(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]); @@ -832,7 +832,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); + SPDocumentUndo::set_undo_sensitive(sp_desktop_document(desktop), saved); } void SPNamedView::hide(SPDesktop const *desktop) @@ -889,10 +889,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 = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); sp_repr_set_boolean(repr, "showguides", v); - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); doc->setModifiedSinceSave(); } @@ -904,10 +904,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 = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible); - sp_document_set_undo_sensitive(doc, saved); + SPDocumentUndo::set_undo_sensitive(doc, saved); /* we don't want the document to get dirty on startup; that's when we call this function with dirty_document = false */ diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 2eb8daf89..3d1cd4b21 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -480,7 +480,7 @@ sp_spiral_finish(SPSpiralContext *sc) sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(sc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, _("Create spiral")); sc->item = NULL; @@ -506,7 +506,7 @@ static void sp_spiral_cancel(SPSpiralContext *sc) sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); + SPDocumentUndo::cancel(sp_desktop_document(desktop)); } /* diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db5ceaa8e..5073382e5 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -419,7 +419,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, description); selection->clear(); @@ -593,7 +593,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); + SPDocumentUndo::done(sp_desktop_document(desktop), verb, description); } delete res; @@ -1216,7 +1216,7 @@ sp_selected_path_outline(SPDesktop *desktop) } if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, _("Convert stroke to path")); } else { // TRANSLATORS: "to outline" means "to convert stroke to path" @@ -1419,7 +1419,7 @@ 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), + SPDocumentUndo::done(sp_desktop_document(desktop), (updating ? SP_VERB_SELECTION_LINKED_OFFSET : SP_VERB_SELECTION_DYNAMIC_OFFSET), (updating ? _("Create linked offset") @@ -1488,7 +1488,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat selection->set(nitem); } - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), (updating ? SP_VERB_SELECTION_LINKED_OFFSET : SP_VERB_SELECTION_DYNAMIC_OFFSET), (updating ? _("Create linked offset") @@ -1733,7 +1733,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } if (did) { - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), (expand ? SP_VERB_SELECTION_OFFSET : SP_VERB_SELECTION_INSET), (expand ? _("Outset path") : _("Inset path"))); } else { @@ -1993,7 +1993,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_SIMPLIFY, _("Simplify")); else desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No paths to simplify in the selection.")); diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8c30f5a5a..ebdf56673 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -877,15 +877,15 @@ case GDK_SCROLL_LEFT: tc->has_dilated = false; switch (tc->mode) { case SPRAY_MODE_COPY: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_SPRAY, _("Spray with copies")); break; case SPRAY_MODE_CLONE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); break; case SPRAY_MODE_SINGLE_PATH: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); break; } diff --git a/src/star-context.cpp b/src/star-context.cpp index 69d711722..2761c573a 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -499,7 +499,7 @@ sp_star_finish (SPStarContext * sc) sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(sc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, _("Create star")); sc->item = NULL; @@ -525,7 +525,7 @@ static void sp_star_cancel(SPStarContext *sc) sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); + SPDocumentUndo::cancel(sp_desktop_document(desktop)); } /* diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 2cc6e30d9..5af97165e 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -188,7 +188,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Put text on path")); g_slist_free(text_reprs); } @@ -225,7 +225,7 @@ text_remove_from_path() if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No texts-on-paths in the selection.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description } @@ -289,7 +289,7 @@ text_remove_all_kerns() if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("Select text(s) to remove kerns from.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Remove manual kerns")); } } @@ -377,7 +377,7 @@ text_flow_into_shape() SP_OBJECT(text)->deleteObject (true); - sp_document_done(doc, SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, _("Flow text into shape")); sp_desktop_selection(desktop)->set(SP_ITEM(root_object)); @@ -473,7 +473,7 @@ text_unflow () g_slist_free (old_objs); g_slist_free (new_objs); - sp_document_done(doc, SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, _("Unflow flowed text")); } @@ -530,7 +530,7 @@ flowtext_to_text() g_slist_free(items); if (did) { - sp_document_done(sp_desktop_document(desktop), + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLOWTEXT_TO_TEXT, _("Convert flowed text to text")); selection->setReprList(reprs); diff --git a/src/text-context.cpp b/src/text-context.cpp index b37c97311..cfde60a0d 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -501,7 +501,7 @@ sp_text_context_setup_text(SPTextContext *tc) text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse(); text_item->updateRepr(); - sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, _("Create text")); } @@ -540,7 +540,7 @@ insert_uni_char(SPTextContext *const tc) tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, u); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, + SPDocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, _("Insert Unicode character")); } } @@ -699,7 +699,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Create flowed text")); } else { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The frame is too small for the current font size. Flowed text not created.")); @@ -839,7 +839,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Insert no-break space")); return TRUE; } @@ -876,7 +876,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Make bold")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@ -894,7 +894,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Make italic")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@ -933,7 +933,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("New line")); return TRUE; } @@ -967,7 +967,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Backspace")); } return TRUE; @@ -998,7 +998,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Delete")); } return TRUE; @@ -1015,7 +1015,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, _("Kern to the left")); } else { if (MOD__CTRL) @@ -1040,7 +1040,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, _("Kern to the right")); } else { if (MOD__CTRL) @@ -1065,7 +1065,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, _("Kern up")); } else { @@ -1091,7 +1091,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, _("Kern down")); } else { @@ -1168,7 +1168,7 @@ 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, + SPDocumentUndo::maybe_done(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); @@ -1189,7 +1189,7 @@ 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, + SPDocumentUndo::maybe_done(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); @@ -1206,7 +1206,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract line spacing")); } else { @@ -1214,7 +1214,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -10); else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -1); - sp_document_maybe_done(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract letter spacing")); } @@ -1233,7 +1233,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand line spacing")); } else { @@ -1241,7 +1241,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 10); else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 1); - sp_document_maybe_done(sp_desktop_document(desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand letter spacing")); } @@ -1371,7 +1371,7 @@ sp_text_paste_inline(SPEventContext *ec) tc->text_sel_start = tc->text_sel_end = sp_te_insert_line(tc->text, tc->text_sel_start); begin = end + 1; } - sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, + SPDocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, _("Paste text")); return true; @@ -1496,7 +1496,7 @@ 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, + SPDocumentUndo::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); @@ -1704,7 +1704,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")); } } @@ -1737,7 +1737,7 @@ 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, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT, _("Type text")); } diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index a2b0cd790..e9bc48372 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -568,7 +568,7 @@ void Tracer::traceThread() } //## inform the document, so we can undo - sp_document_done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap")); + SPDocumentUndo::done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap")); engine = NULL; diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index e77d2d465..cd6ff325a 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -1258,55 +1258,55 @@ 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), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Move tweak")); break; case TWEAK_MODE_MOVE_IN_OUT: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak")); break; case TWEAK_MODE_MOVE_JITTER: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak")); break; case TWEAK_MODE_SCALE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Scale tweak")); break; case TWEAK_MODE_ROTATE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Rotate tweak")); break; case TWEAK_MODE_MORELESS: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak")); break; case TWEAK_MODE_PUSH: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Push path tweak")); break; case TWEAK_MODE_SHRINK_GROW: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak")); break; case TWEAK_MODE_ATTRACT_REPEL: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak")); break; case TWEAK_MODE_ROUGHEN: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak")); break; case TWEAK_MODE_COLORPAINT: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Color paint tweak")); break; case TWEAK_MODE_COLORJITTER: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak")); break; case TWEAK_MODE_BLUR: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), SP_VERB_CONTEXT_TWEAK, _("Blur tweak")); break; } diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 98ad9dc7b..1ffbf1fd0 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -284,7 +284,7 @@ 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, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, _("Create link")); sp_object_attributes_dialog(object, "SPAnchor"); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 0b47f42ab..af1671b04 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -233,7 +233,7 @@ private : prefs->setInt("/options/clonecompensation/value", saved_compensation); if (changed) { - sp_document_done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Align")); } @@ -392,7 +392,7 @@ private : prefs->setInt("/options/clonecompensation/value", saved_compensation); if (changed) { - sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Distribute")); } } @@ -505,7 +505,7 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Remove overlaps")); } }; @@ -536,7 +536,7 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network")); } }; @@ -567,7 +567,7 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Unclump")); } }; @@ -638,7 +638,7 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Randomize positions")); } }; @@ -737,7 +737,7 @@ private : } if (changed) { - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Distribute text baselines")); } @@ -760,7 +760,7 @@ private : } if (changed) { - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Align text baselines")); } } diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index cb6cfbbbe..a8445c66c 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -486,7 +486,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 +720,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() ); + SPDocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() ); } } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 970c609af..2fe353533 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -450,7 +450,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")); + SPDocumentUndo::done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile")); populate_linked_profiles_box(); } @@ -523,7 +523,7 @@ void DocumentProperties::removeSelectedProfile(){ Inkscape::ColorProfile* prof = reinterpret_cast(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")); + SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); } current = g_slist_next(current); } @@ -668,7 +668,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...")); + SPDocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); populate_external_scripts_box(); } @@ -692,7 +692,7 @@ void DocumentProperties::removeExternalScript(){ 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")); + SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); } current = g_slist_next(current); } @@ -985,7 +985,7 @@ DocumentProperties::onRemoveGrid() // delete the grid that corresponds with the selected tab // when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer! found_grid->repr->parent()->removeChild(found_grid->repr); - sp_document_done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); } } diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 7baf2d71f..3a80c4ba8 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1032,7 +1032,7 @@ private: Inkscape::GC::release(repr); } - sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); + SPDocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); update(); } @@ -1215,7 +1215,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")); + SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); if(iter) (*iter)[_columns.label] = text; } @@ -1251,7 +1251,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri } update_selection(sel); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); } } @@ -1327,7 +1327,7 @@ void FilterEffectsDialog::FilterModifier::add_filter() select_filter(filter); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); } void FilterEffectsDialog::FilterModifier::remove_filter() @@ -1338,7 +1338,7 @@ void FilterEffectsDialog::FilterModifier::remove_filter() SPDocument* doc = filter->document; sp_repr_unparent(filter->repr); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); update_filters(); } @@ -1353,7 +1353,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")); + SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter")); update_filters(); } @@ -1543,7 +1543,7 @@ void FilterEffectsDialog::PrimitiveList::remove_selected() sp_repr_unparent(prim->repr); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, + SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter primitive")); update(); @@ -1915,7 +1915,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* // If input is null, delete it if(!in_val) { sp_repr_unparent(o->repr); - sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, + SPDocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; } @@ -2032,7 +2032,7 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtrrequestModified(SP_OBJECT_MODIFIED_FLAG); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); + SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); } // If a connection is dragged towards the top or bottom of the list, the list should scroll to follow. @@ -2263,7 +2263,7 @@ void FilterEffectsDialog::add_primitive() _primitive_list.select(prim); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); + SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); } } @@ -2359,7 +2359,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")); + SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); _primitive_list.update(); } @@ -2411,7 +2411,7 @@ 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, + SPDocumentUndo::maybe_done(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, _("Set filter primitive attribute")); } diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 8ed502aae..8193b4384 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -28,7 +28,7 @@ #include "glyphs.h" #include "desktop.h" -#include "document.h" // for sp_document_done() +#include "document.h" // for SPDocumentUndo::done() #include "libnrtype/font-instance.h" #include "sp-flowtext.h" #include "sp-text.h" @@ -571,7 +571,7 @@ void GlyphsPanel::insertText() } combined += glyphs; sp_te_set_repr_text_multiline(textItem, combined.c_str()); - sp_document_done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); + SPDocumentUndo::done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); } } } diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 3a7964ba2..9c3422167 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -108,7 +108,7 @@ void GuidelinePropertiesDialog::_onApply() sp_guide_moveto(*_guide, newpos, true); - sp_document_done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, _("Set guide properties")); } @@ -121,7 +121,7 @@ void GuidelinePropertiesDialog::_onDelete() { SPDocument *doc = SP_OBJECT_DOCUMENT(_guide); sp_guide_remove(_guide); - sp_document_done(doc, SP_VERB_NONE, + SPDocumentUndo::done(doc, SP_VERB_NONE, _("Delete guide")); } diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index ffa4642e7..80c943e39 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -105,7 +105,7 @@ LayerPropertiesDialog::_apply() g_assert(_strategy != NULL); _strategy->perform(*this); - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, _("Add layer")); _close(); @@ -188,7 +188,7 @@ void LayerPropertiesDialog::Rename::perform(LayerPropertiesDialog &dialog) { (gchar *)name.c_str(), FALSE ); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Rename layer")); // TRANSLATORS: This means "The layer has been renamed" desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Renamed layer")); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index ff3a13ab2..962d78df8 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -468,7 +468,7 @@ 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, + SPDocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, newValue? _("Unhide layer") : _("Hide layer")); } break; @@ -479,7 +479,7 @@ 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, + SPDocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, newValue? _("Lock layer") : _("Unlock layer")); } break; diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 62ed4e639..d05790b3e 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -372,7 +372,7 @@ LivePathEffectEditor::onApply() LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item); - sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, + SPDocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Create and apply path effect")); lpe_list_locked = false; @@ -390,7 +390,7 @@ LivePathEffectEditor::onRemove() if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + SPDocumentUndo::done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Remove path effect") ); effect_list_reload(SP_LPE_ITEM(item)); @@ -406,7 +406,7 @@ void LivePathEffectEditor::onUp() if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + SPDocumentUndo::done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect up") ); effect_list_reload(SP_LPE_ITEM(item)); @@ -422,7 +422,7 @@ void LivePathEffectEditor::onDown() if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + SPDocumentUndo::done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect down") ); effect_list_reload(SP_LPE_ITEM(item)); @@ -461,7 +461,7 @@ 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, + SPDocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, newValue ? _("Activate path effect") : _("Deactivate path effect")); } } diff --git a/src/ui/dialog/session-player.cpp b/src/ui/dialog/session-player.cpp index 0e484c3f2..01560733f 100644 --- a/src/ui/dialog/session-player.cpp +++ b/src/ui/dialog/session-player.cpp @@ -171,7 +171,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()); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 7f41c4d6b..7c6ced5aa 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -117,7 +117,7 @@ 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, + SPDocumentUndo::maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Set SVG Font attribute")); } @@ -163,7 +163,7 @@ 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 += ":"; @@ -171,7 +171,7 @@ void SvgFontsDialog::on_kerning_value_changed(){ //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")); + SPDocumentUndo::maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); //populate_kerning_pairs_box(); kerning_preview.redraw(); @@ -462,7 +462,7 @@ void SvgFontsDialog::add_glyph(){ SPDocument* doc = sp_desktop_document(this->getDesktop()); /* SPGlyph* glyph =*/ new_glyph(doc, get_selected_spfont(), count+1); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); update_glyphs(); } @@ -506,7 +506,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } glyph->repr->setAttribute("d", (char*) sp_svg_write_path (pathv)); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); } @@ -548,7 +548,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ 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")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } @@ -567,7 +567,7 @@ void SvgFontsDialog::reset_missing_glyph_description(){ 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")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@ -582,7 +582,7 @@ void SvgFontsDialog::glyph_name_edit(const Glib::ustring&, const Glib::ustring& glyph->repr->setAttribute("glyph-name", str.c_str()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); update_glyphs(); } @@ -595,7 +595,7 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin glyph->repr->setAttribute("unicode", str.c_str()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); update_glyphs(); } @@ -605,7 +605,7 @@ void SvgFontsDialog::remove_selected_font(){ sp_repr_unparent(font->repr); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); update_fonts(); } @@ -620,7 +620,7 @@ void SvgFontsDialog::remove_selected_glyph(){ sp_repr_unparent(glyph->repr); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); update_glyphs(); } @@ -635,7 +635,7 @@ void SvgFontsDialog::remove_selected_kerning_pair(){ sp_repr_unparent(pair->repr); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); update_glyphs(); } @@ -723,7 +723,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")); + SPDocumentUndo::done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair")); } Gtk::VBox* SvgFontsDialog::kerning_tab(){ @@ -816,7 +816,7 @@ void set_font_family(SPFont* font, char* str){ } } - sp_document_done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); + SPDocumentUndo::done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); } void SvgFontsDialog::add_font(){ @@ -839,7 +839,7 @@ void SvgFontsDialog::add_font(){ update_fonts(); // select_font(font); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); + SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); } SvgFontsDialog::SvgFontsDialog() diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index d5d48a528..62682d623 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -184,7 +184,7 @@ void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer us if ( targetName == grad->getId() ) { grad->repr->setAttribute("osb:paint", "solid"); // TODO make conditional - sp_document_done(doc, SP_VERB_CONTEXT_GRADIENT, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); handleGradientsChange(doc); // work-around for signal not being emitted diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 546fdd8f0..cf29ed77f 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -344,7 +344,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h g_slist_free (current_row); } - sp_document_done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE, _("Arrange in a grid")); } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index f74c5d6e0..62f0f38aa 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -677,7 +677,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) } } - sp_document_done ( sp_desktop_document (selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, + SPDocumentUndo::done ( sp_desktop_document (selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, _("Move")); } @@ -734,7 +734,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, _("Scale")); } @@ -756,7 +756,7 @@ Transformation::applyPageRotate(Inkscape::Selection *selection) } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, _("Rotate")); } @@ -815,7 +815,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, _("Skew")); } @@ -842,7 +842,7 @@ Transformation::applyPageTransform(Inkscape::Selection *selection) sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, _("Edit transformation matrix")); } diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index 8017af803..9e0922072 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -214,7 +214,7 @@ UndoHistory::_onListSelectionChange() _event_log->blockNotifications(); for ( --last ; curr_event != last ; ++curr_event ) { - sp_document_redo(_document); + SPDocumentUndo::redo(_document); } _event_log->blockNotifications(false); @@ -248,7 +248,7 @@ UndoHistory::_onListSelectionChange() while ( selected != last_selected ) { - sp_document_undo(_document); + SPDocumentUndo::undo(_document); if ( last_selected->parent() && last_selected == last_selected->parent()->children().begin() ) @@ -273,7 +273,7 @@ UndoHistory::_onListSelectionChange() while ( selected != last_selected ) { - sp_document_redo(_document); + SPDocumentUndo::redo(_document); if ( !last_selected->children().empty() ) { _event_log->setCurrEventParent(last_selected); @@ -317,10 +317,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); + SPDocumentUndo::redo(_document); for ( --last ; curr_event != last ; ++curr_event ) { - sp_document_redo(_document); + SPDocumentUndo::redo(_document); } _event_log->blockNotifications(false); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 2025a12d7..a455567e8 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -662,9 +662,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); + SPDocumentUndo::maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason); } else { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); } signal_coords_changed.emit(); } @@ -673,7 +673,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); + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); signal_coords_changed.emit(); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 8e37b2c85..dec37cd1c 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1387,13 +1387,13 @@ void PathManipulator::_removeNodesFromSelection() void PathManipulator::_commit(Glib::ustring const &annotation) { writeXML(); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); } void PathManipulator::_commit(Glib::ustring const &annotation, gchar const *key) { writeXML(); - sp_document_maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, + SPDocumentUndo::maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, annotation.data()); } diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index 34cf1d5e3..48dd59685 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -132,7 +132,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, /* TODO: annotate */ "color-picker.cpp:130"); ptr->on_changed (rgba); diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index e9f09f574..cc38de24f 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -96,7 +96,7 @@ EntityLineEntry::on_changed() SPDocument *doc = SP_ACTIVE_DOCUMENT; Glib::ustring text = static_cast(_packable)->get_text(); if (rdf_set_work_entity (doc, _entity, text.c_str())) - sp_document_done (doc, SP_VERB_NONE, + SPDocumentUndo::done (doc, SP_VERB_NONE, /* TODO: annotate */ "entity-entry.cpp:101"); _wr->setUpdating (false); } @@ -141,7 +141,7 @@ EntityMultiLineEntry::on_changed() Gtk::TextView *tv = static_cast(s->get_child()); Glib::ustring text = tv->get_buffer()->get_text(); if (rdf_set_work_entity (doc, _entity, text.c_str())) - sp_document_done (doc, SP_VERB_NONE, + SPDocumentUndo::done (doc, SP_VERB_NONE, /* TODO: annotate */ "entity-entry.cpp:146"); _wr->setUpdating (false); } diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index f25192b2a..da096f25d 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -583,7 +583,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, lock? _("Lock layer") : _("Unlock layer")); } } @@ -591,7 +591,7 @@ void LayerSelector::_lockLayer(bool lock) { void LayerSelector::_hideLayer(bool hide) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setHidden(hide); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, hide? _("Hide layer") : _("Unhide layer")); } } diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index a5f1d89be..a4a789840 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -64,7 +64,7 @@ LicenseItem::on_toggled() _wr.setUpdating (true); rdf_set_license (SP_ACTIVE_DOCUMENT, _lic->details ? _lic : 0); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_NONE, + SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_NONE, /* TODO: annotate */ "licensor.cpp:65"); _wr.setUpdating (false); static_cast(_eep->_packable)->set_text (_lic->uri); diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index bfc291bc0..f5e4657b1 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -168,7 +168,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() SP_OBJECT_STYLE_MODIFIED_FLAG )); } - sp_document_maybe_done (document, _blur_tag.c_str(), _verb_code, + SPDocumentUndo::maybe_done (document, _blur_tag.c_str(), _verb_code, _("Change blur")); // resume interruptibility @@ -208,7 +208,7 @@ ObjectCompositeSettings::_opacityValueChanged() sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, + SPDocumentUndo::maybe_done (sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, _("Change opacity")); // resume interruptibility diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 1f70a26fd..33adc85d0 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -413,7 +413,7 @@ PageSizer::setDim (double w, double h, bool changeList) // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset); - sp_document_done (doc, SP_VERB_NONE, _("Set page size")); + SPDocumentUndo::done (doc, SP_VERB_NONE, _("Set page size")); } if ( w != h ) { diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index db31d08d3..16422f1b2 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -349,14 +349,14 @@ 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 = SPDocumentUndo::get_undo_sensitive (local_doc); + SPDocumentUndo::set_undo_sensitive (local_doc, false); local_repr->setAttribute(_ckey.c_str(), c); sp_repr_set_css_double(local_repr, _akey.c_str(), (rgba & 0xff) / 255.0); - sp_document_set_undo_sensitive (local_doc, saved); + SPDocumentUndo::set_undo_sensitive (local_doc, saved); local_doc->setModifiedSinceSave(); - sp_document_done (local_doc, SP_VERB_NONE, + SPDocumentUndo::done (local_doc, SP_VERB_NONE, /* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed"); _wr->setUpdating (false); diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 7aefbb90e..dec8cd111 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -104,16 +104,16 @@ protected: local_doc = sp_desktop_document(dt); } - bool saved = sp_document_get_undo_sensitive (local_doc); - sp_document_set_undo_sensitive (local_doc, false); + bool saved = SPDocumentUndo::get_undo_sensitive (local_doc); + SPDocumentUndo::set_undo_sensitive (local_doc, false); if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr); - sp_document_set_undo_sensitive (local_doc, saved); + SPDocumentUndo::set_undo_sensitive (local_doc, saved); local_doc->setModifiedSinceSave(); if (write_undo) { local_repr->setAttribute(_key.c_str(), svgstr); - sp_document_done (local_doc, event_type, event_description); + SPDocumentUndo::done (local_doc, event_type, event_description); } } diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index 0afc0da3e..9fac48145 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -152,7 +152,7 @@ Ruler::on_button_release_event(GdkEventButton *evb) sp_repr_set_svg_double(repr, "position", guide_pos_dt); SP_OBJECT_REPR(_dt->namedview)->appendChild(repr); Inkscape::GC::release(repr); - sp_document_done(sp_desktop_document(_dt), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(_dt), SP_VERB_NONE, /* TODO: annotate */ "ruler.cpp:157"); } _dt->set_coordinate_status(event_dt); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a8f9f9c60..9a94113eb 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -464,7 +464,7 @@ 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, + SPDocumentUndo::done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, _("Drop color")); } } @@ -477,7 +477,7 @@ void SelectedStyle::on_fill_remove() { sp_repr_css_set_property (css, "fill", "none"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Remove fill")); } @@ -486,7 +486,7 @@ void SelectedStyle::on_stroke_remove() { sp_repr_css_set_property (css, "stroke", "none"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Remove stroke")); } @@ -495,7 +495,7 @@ void SelectedStyle::on_fill_unset() { sp_repr_css_unset_property (css, "fill"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Unset fill")); } @@ -511,7 +511,7 @@ void SelectedStyle::on_stroke_unset() { sp_repr_css_unset_property (css, "stroke-dasharray"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Unset stroke")); } @@ -520,7 +520,7 @@ void SelectedStyle::on_fill_opaque() { sp_repr_css_set_property (css, "fill-opacity", "1"); sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Make fill opaque")); } @@ -529,7 +529,7 @@ void SelectedStyle::on_stroke_opaque() { sp_repr_css_set_property (css, "stroke-opacity", "1"); sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Make fill opaque")); } @@ -541,7 +541,7 @@ void SelectedStyle::on_fill_lastused() { sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Apply last set color to fill")); } @@ -553,7 +553,7 @@ void SelectedStyle::on_stroke_lastused() { sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Apply last set color to stroke")); } @@ -564,7 +564,7 @@ void SelectedStyle::on_fill_lastselected() { sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Apply last selected color to fill")); } @@ -575,7 +575,7 @@ void SelectedStyle::on_stroke_lastselected() { sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Apply last selected color to stroke")); } @@ -595,7 +595,7 @@ void SelectedStyle::on_fill_invert() { sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Invert fill")); } @@ -615,7 +615,7 @@ void SelectedStyle::on_stroke_invert() { sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Invert stroke")); } @@ -627,7 +627,7 @@ void SelectedStyle::on_fill_white() { sp_repr_css_set_property (css, "fill-opacity", "1"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("White fill")); } @@ -639,7 +639,7 @@ void SelectedStyle::on_stroke_white() { sp_repr_css_set_property (css, "stroke-opacity", "1"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("White stroke")); } @@ -651,7 +651,7 @@ void SelectedStyle::on_fill_black() { sp_repr_css_set_property (css, "fill-opacity", "1.0"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Black fill")); } @@ -663,7 +663,7 @@ void SelectedStyle::on_stroke_black() { sp_repr_css_set_property (css, "stroke-opacity", "1.0"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Black stroke")); } @@ -706,7 +706,7 @@ void SelectedStyle::on_fill_paste() { sp_repr_css_set_property (css, "fill", text.c_str()); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Paste fill")); } } @@ -724,7 +724,7 @@ void SelectedStyle::on_stroke_paste() { sp_repr_css_set_property (css, "stroke", text.c_str()); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Paste stroke")); } } @@ -778,7 +778,7 @@ void SelectedStyle::on_fillstroke_swap() { sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Swap fill and stroke")); } @@ -853,7 +853,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (_desktop), SP_VERB_DIALOG_FILL_STROKE, _("Change opacity")); return true; } @@ -888,7 +888,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES, _("Change stroke width")); } @@ -1147,7 +1147,7 @@ void SelectedStyle::on_opacity_changed () { sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(_desktop), 0); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, _("Change opacity")); // resume interruptibility sp_canvas_end_forced_full_redraws(sp_desktop_canvas(_desktop)); @@ -1274,19 +1274,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, + SPDocumentUndo::maybe_done (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 saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 1) { // lightness - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness"))); double ch = hsl[2]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); } else { // hue - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue"))); double ch = hsl[0]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Ctrl to adjust lightness"), ch - diff, ch, diff); @@ -1315,15 +1315,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, + SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation")); } else if (modifier == 1) { // lightness - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness")); } else { // hue - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue")); } @@ -1397,7 +1397,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, + SPDocumentUndo::maybe_done (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 stroke width: was %.3g, now %.3g (diff %.3g)"), startvalue, startvalue + diff, diff); } @@ -1411,7 +1411,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, + SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); } diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 3a36127f4..84c6a0de2 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -186,11 +186,11 @@ ToleranceSlider::update (double val) _wr->setUpdating (true); SPDocument *doc = sp_desktop_document(dt); - bool saved = sp_document_get_undo_sensitive (doc); - sp_document_set_undo_sensitive (doc, false); + bool saved = SPDocumentUndo::get_undo_sensitive (doc); + SPDocumentUndo::set_undo_sensitive (doc, false); Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt)); repr->setAttribute(_key.c_str(), os.str().c_str()); - sp_document_set_undo_sensitive (doc, saved); + SPDocumentUndo::set_undo_sensitive (doc, saved); doc->setModifiedSinceSave(); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 78ceec467..80f15fc5a 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -119,7 +119,7 @@ vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint stat } // FIXME: Do we need to create a new dragger as well? dragger->updateZOrders (); - sp_document_done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Split vanishing points")); return; } @@ -164,7 +164,7 @@ vp_knot_moved_handler (SPKnot */*knot*/, Geom::Point const *ppointer, guint stat // deleted according to changes in the svg representation, not based on any user input // as is currently the case. - sp_document_done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, + SPDocumentUndo::done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, _("Merge vanishing points")); return; @@ -220,7 +220,7 @@ 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, + SPDocumentUndo::done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, _("3D box: Move vanishing point")); } diff --git a/src/verbs.cpp b/src/verbs.cpp index 24c17aad8..300fe7494 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1098,7 +1098,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_NEXT, _("Switch to next layer")); dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Switched to next layer.")); } else { @@ -1110,7 +1110,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_PREV, _("Switch to previous layer")); dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Switched to previous layer.")); } else { @@ -1176,7 +1176,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) description = _("Lower layer"); break; }; - sp_document_done(sp_desktop_document(dt), verb, description); + SPDocumentUndo::done(sp_desktop_document(dt), verb, description); if (message) { dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message); g_free((void *) message); @@ -1221,7 +1221,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) dt->setCurrentLayer(new_layer); } #endif - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, _("Duplicate layer")); // TRANSLATORS: this means "The layer has been duplicated." @@ -1253,7 +1253,7 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/) dt->setCurrentLayer(survivor); } - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE, _("Delete layer")); // TRANSLATORS: this means "The layer has been deleted." @@ -1268,7 +1268,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")); + SPDocumentUndo::maybe_done(sp_desktop_document(dt), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo")); } break; } @@ -1328,12 +1328,12 @@ 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, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL, _("Flip horizontally")); break; case SP_VERB_OBJECT_FLIP_VERTICAL: sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); - sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL, + SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL, _("Flip vertically")); break; case SP_VERB_OBJECT_SET_MASK: @@ -2162,19 +2162,19 @@ LockAndHideVerb::perform(SPAction *action, void *data, void */*pdata*/) switch (reinterpret_cast(data)) { case SP_VERB_UNLOCK_ALL: unlock_all(dt); - sp_document_done(doc, SP_VERB_UNLOCK_ALL, _("Unlock all objects in the current layer")); + SPDocumentUndo::done(doc, SP_VERB_UNLOCK_ALL, _("Unlock all objects in the current layer")); break; case SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS: unlock_all_in_all_layers(dt); - sp_document_done(doc, SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, _("Unlock all objects in all layers")); + SPDocumentUndo::done(doc, SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, _("Unlock all objects in all layers")); break; case SP_VERB_UNHIDE_ALL: unhide_all(dt); - sp_document_done(doc, SP_VERB_UNHIDE_ALL, _("Unhide all objects in the current layer")); + SPDocumentUndo::done(doc, SP_VERB_UNHIDE_ALL, _("Unhide all objects in the current layer")); break; case SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS: unhide_all_in_all_layers(dt); - sp_document_done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers")); + SPDocumentUndo::done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers")); break; default: return; diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 5a7256d83..e4db09c90 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -332,7 +332,7 @@ void FillNStroke::setFillrule( SPPaintSelector::FillRule mode ) sp_repr_css_attr_unref(css); css = 0; - sp_document_done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE, _("Change fill rule")); } } @@ -417,7 +417,7 @@ void FillNStroke::dragFromPaint() // local change, do not update from selection dragId = g_timeout_add_full(G_PRIORITY_DEFAULT, 100, dragDelayCB, this, 0); psel->setFlatColor( desktop, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" ); - sp_document_maybe_done(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::maybe_done(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, (kind == FILL) ? _("Set fill color") : _("Set stroke color")); break; } @@ -480,7 +480,7 @@ void FillNStroke::updateFromPaint() sp_repr_css_attr_unref(css); css = 0; - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, (kind == FILL) ? _("Remove fill") : _("Remove stroke")); break; } @@ -496,7 +496,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, (kind == FILL) ? _("Set fill color") : _("Set stroke color")); if (kind == FILL) { @@ -583,7 +583,7 @@ void FillNStroke::updateFromPaint() css = 0; } - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke")); } break; @@ -643,7 +643,7 @@ void FillNStroke::updateFromPaint() } // end if - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, (kind == FILL) ? _("Set pattern on fill") : _("Set pattern on stroke")); } // end if @@ -670,7 +670,7 @@ void FillNStroke::updateFromPaint() sp_repr_css_attr_unref(css); css = 0; - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, (kind == FILL) ? _("Unset fill") : _("Unset stroke")); } break; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index fe003319f..a55439908 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -151,7 +151,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, _("Assign gradient to object")); } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 132aff455..d8bbcd788 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -363,7 +363,7 @@ 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, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT, /* TODO: annotate */ "gradient-vector.cpp:350"); } } @@ -666,7 +666,7 @@ 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_done(SP_OBJECT_DOCUMENT(stop), SP_VERB_CONTEXT_GRADIENT, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(stop), SP_VERB_CONTEXT_GRADIENT, _("Change gradient stop offset")); blocked = FALSE; @@ -739,7 +739,7 @@ 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, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); } @@ -770,7 +770,7 @@ static void sp_grd_ed_del_stop(GtkWidget */*widget*/, GtkWidget *vb) SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop)); sp_gradient_vector_widget_load_gradient(vb, gradient); update_stop_list(GTK_WIDGET(mnu), gradient, NULL); - sp_document_done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop")); } @@ -1040,10 +1040,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 = SPDocumentUndo::get_undo_sensitive(document); + SPDocumentUndo::set_undo_sensitive(document, false); SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL); - sp_document_set_undo_sensitive(document, saved); + SPDocumentUndo::set_undo_sensitive(document, saved); } } else { // no gradient, disable everything gtk_widget_set_sensitive(widget, FALSE); @@ -1197,7 +1197,7 @@ 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(alpha)); //SP_OBJECT_REPR(stop)->setAttribute("style", c); - sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, _("Change gradient stop color")); blocked = FALSE; diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 487e3a274..a5bf81821 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -243,7 +243,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, + SPDocumentUndo::maybe_done (document, actionkey, SP_VERB_CONTEXT_SELECT, _("Transform by toolbar")); // resume interruptibility diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index de14fc173..8a46001b1 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -154,7 +154,7 @@ 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, + SPDocumentUndo::done (SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE, _("Set attribute")); } else if (spaw->src.repr) { @@ -761,7 +761,7 @@ 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, + SPDocumentUndo::done (SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE, _("Set attribute")); } else if (spat->src.repr) { diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index 7150b07fd..239f6e6e1 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -165,7 +165,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, + SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_XML_EDITOR, _("Type text in a text node")); } } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 1843c8edb..0d7b95f4c 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -498,7 +498,7 @@ 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, + SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set markers")); }; @@ -1203,7 +1203,7 @@ 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, + SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke style")); spw->set_data("update", GINT_TO_POINTER(FALSE)); @@ -1300,7 +1300,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE, _("Set stroke style")); } } diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp index ce0f8a810..b1329b92a 100644 --- a/src/widgets/swatch-selector.cpp +++ b/src/widgets/swatch-selector.cpp @@ -135,7 +135,7 @@ void SwatchSelector::_changedCb(SPColorSelector */*csel*/, void *data) os << "stop-color:" << c << ";stop-opacity:" << static_cast(alpha) <<";"; SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str()); - sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, + SPDocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, _("Change swatch color")); } } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index c255e087b..29e735536 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1270,7 +1270,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); SPUnit const *unit = tracker->getActiveUnit(); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { + if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), sp_units_get_pixels(adj->value, *unit)); } @@ -2051,8 +2051,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 = SPDocumentUndo::get_undo_sensitive(doc); + SPDocumentUndo::set_undo_sensitive(doc, false); bool v = false; SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE")); @@ -2137,7 +2137,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); + SPDocumentUndo::set_undo_sensitive(doc, saved); } void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) @@ -2491,7 +2491,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 (SPDocumentUndo::get_undo_sensitive(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(); @@ -2522,7 +2522,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu } } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, _("Star: Change number of corners")); } @@ -2533,7 +2533,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { if (!IS_NAN(adj->value)) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/star/proportion", adj->value); @@ -2569,7 +2569,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, _("Star: Change spoke ratio")); } @@ -2581,7 +2581,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool( "/tools/shapes/star/isflatsided", flat); } @@ -2613,7 +2613,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, flat ? _("Make polygon") : _("Make star")); } @@ -2624,7 +2624,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/star/rounded", (gdouble) adj->value); } @@ -2650,7 +2650,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg } } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, _("Star: Change rounding")); } @@ -2661,7 +2661,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/star/randomized", (gdouble) adj->value); } @@ -2687,7 +2687,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl } } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, _("Star: Change randomization")); } @@ -3026,7 +3026,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); SPUnit const *unit = tracker->getActiveUnit(); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { + if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name, sp_units_get_pixels(adj->value, *unit)); } @@ -3055,7 +3055,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, _("Change rectangle")); } @@ -3423,7 +3423,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::maybe_done() 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 @@ -3507,7 +3507,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)")); + SPDocumentUndo::maybe_done(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)")); g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); } @@ -3702,7 +3702,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/spiral/" + value_name, adj->value); } @@ -3733,7 +3733,7 @@ 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, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, _("Change spiral")); } @@ -5296,7 +5296,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, adj->value); } @@ -5344,7 +5344,7 @@ 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, + SPDocumentUndo::maybe_done(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC, _("Arc: Change start/end")); } @@ -5366,7 +5366,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0); } @@ -5408,7 +5408,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, + SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, _("Arc: Change open/closed")); } @@ -5739,7 +5739,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt( "/tools/lpetool/mode", mode ); } @@ -6076,7 +6076,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 (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool( "/tools/eraser/mode", eraserMode ); } @@ -6376,7 +6376,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change font family")); sp_repr_css_attr_unref (css); @@ -6423,7 +6423,7 @@ 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, + SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE, _("Text: Change font size")); // If no selected objects, set default. @@ -6569,7 +6569,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change font style")); sp_repr_css_attr_unref (css); @@ -6646,7 +6646,7 @@ 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, + SPDocumentUndo::maybe_done (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) ); @@ -6790,7 +6790,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change alignment")); sp_repr_css_attr_unref (css); @@ -6829,7 +6829,7 @@ 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, + SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE, _("Text: Change line-height")); // If no selected objects, set default. @@ -6868,7 +6868,7 @@ 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, + SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE, _("Text: Change word-spacing")); // If no selected objects, set default. @@ -6907,7 +6907,7 @@ 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, + SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE, _("Text: Change letter-spacing")); // If no selected objects, set default. @@ -6952,7 +6952,7 @@ 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, + SPDocumentUndo::maybe_done (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) ); @@ -6983,7 +6983,7 @@ 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, + SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE, _("Text: Change dy")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -7014,7 +7014,7 @@ 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, + SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE, _("Text: Change rotate")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -7059,7 +7059,7 @@ 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, + SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, _("Text: Change orientation")); sp_repr_css_attr_unref (css); @@ -7869,7 +7869,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 (!SPDocumentUndo::get_undo_sensitive(doc)) { return; } @@ -7906,7 +7906,7 @@ 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, + SPDocumentUndo::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) ); @@ -7918,7 +7918,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 (!SPDocumentUndo::get_undo_sensitive(doc)) { return; } @@ -7954,7 +7954,7 @@ 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, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Change connector curvature")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -7966,7 +7966,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 (!SPDocumentUndo::get_undo_sensitive(doc)) { return; } @@ -8002,7 +8002,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) g_slist_free(items); } - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, + SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Change connector spacing")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@ -8023,7 +8023,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")); + SPDocumentUndo::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*/ ) -- cgit v1.2.3 From 1aad26aea24f62b63c992118f36b12483f9a5414 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Sat, 3 Jul 2010 22:50:36 +0530 Subject: another c++ification for sp-object.h/cpp and still in progress... (bzr r9546.1.4) --- src/box3d-context.cpp | 2 +- src/box3d.cpp | 10 +- src/conn-avoid-ref.cpp | 2 +- src/desktop-style.cpp | 2 +- src/dialogs/clonetiler.cpp | 8 +- src/dialogs/find.cpp | 2 +- src/dialogs/spellcheck.cpp | 2 +- src/document.cpp | 16 +-- src/extension/internal/cairo-render-context.cpp | 6 +- src/extension/internal/cairo-renderer.cpp | 4 +- src/file.cpp | 6 +- src/filter-chemistry.cpp | 2 +- src/gradient-chemistry.cpp | 4 +- src/gradient-drag.cpp | 2 +- src/helper/pixbuf-ops.cpp | 2 +- src/helper/png-write.cpp | 2 +- src/helper/stock-items.cpp | 6 +- src/id-clash.cpp | 4 +- src/object-snapper.cpp | 2 +- src/persp3d.cpp | 6 +- src/selection-chemistry.cpp | 18 +-- src/sp-clippath.cpp | 10 +- src/sp-defs.cpp | 6 +- src/sp-filter.cpp | 4 +- src/sp-flowdiv.cpp | 24 ++-- src/sp-flowregion.cpp | 20 +-- src/sp-flowtext.cpp | 14 +-- src/sp-gradient.cpp | 16 +-- src/sp-item-group.cpp | 20 +-- src/sp-item.cpp | 8 +- src/sp-lpe-item.cpp | 4 +- src/sp-mask.cpp | 8 +- src/sp-namedview.cpp | 4 +- src/sp-object-group.cpp | 4 +- src/sp-object-repr.cpp | 2 +- src/sp-object.cpp | 158 ++++++++++++------------ src/sp-object.h | 22 ++-- src/sp-pattern.cpp | 12 +- src/sp-root.cpp | 6 +- src/sp-style-elem-test.h | 4 +- src/sp-switch.cpp | 2 +- src/sp-text.cpp | 10 +- src/sp-textpath.h | 2 +- src/sp-tref.cpp | 10 +- src/sp-tspan.cpp | 16 +-- src/sp-use.cpp | 10 +- src/text-chemistry.cpp | 4 +- src/text-editing.cpp | 10 +- src/tweak-context.cpp | 6 +- src/ui/clipboard.cpp | 4 +- src/ui/dialog/find.cpp | 2 +- src/widgets/gradient-vector.cpp | 6 +- src/widgets/stroke-style.cpp | 2 +- 53 files changed, 273 insertions(+), 265 deletions(-) (limited to 'src') diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 88763e183..354fa1234 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -191,7 +191,7 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); bool has_persp = false; - for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = defs->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_PERSP3D(child)) { has_persp = true; break; diff --git a/src/box3d.cpp b/src/box3d.cpp index bdbbbfa7e..7985640cd 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -332,7 +332,7 @@ box3d_position_set (SPBox3D *box) { /* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in box3d_side_position_set() to avoid update conflicts with the parent box) */ - for (SPObject *child = sp_object_first_child(SP_OBJECT (box)); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT (box)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_BOX3D_SIDE(child)) box3d_side_position_set(SP_BOX3D_SIDE(child)); } @@ -350,7 +350,7 @@ 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->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { SPItem *childitem = SP_ITEM(child); @@ -1151,7 +1151,7 @@ box3d_recompute_z_orders (SPBox3D *box) { static std::map box3d_get_sides (SPBox3D *box) { std::map sides; - for (SPObject *side = sp_object_first_child(box); side != NULL; side = SP_OBJECT_NEXT(side)) { + for (SPObject *side = box->first_child(); 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); @@ -1293,7 +1293,7 @@ box3d_extract_boxes_rec(SPObject *obj, std::list &boxes) { if (SP_IS_BOX3D(obj)) { boxes.push_back(SP_BOX3D(obj)); } else if (SP_IS_GROUP(obj)) { - for (SPObject *child = sp_object_first_child(obj); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = obj->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { box3d_extract_boxes_rec(child, boxes); } } @@ -1354,7 +1354,7 @@ box3d_convert_to_group(SPBox3D *box) { Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); Inkscape::XML::Node *repr; - for (SPObject *child = sp_object_first_child(SP_OBJECT(box)); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT(box)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_BOX3D_SIDE(child)) { repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child)); grepr->appendChild(repr); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 70e0c3856..a6ac2387a 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -550,7 +550,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)) ; + for (SPObject *child = SP_OBJECT(from)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child) && !desktop->isLayer(SP_ITEM(child)) && diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 19a45a285..9a8725fac 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -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 = SP_OBJECT(o)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { 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. diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index b1c1cf74a..e25f2602b 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -849,7 +849,7 @@ 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->first_child(); o != NULL; o = SP_OBJECT_NEXT(o)) { if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL)) SP_ITEM(o)->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! clonetiler_trace_hide_tiled_clones_recursively (o); @@ -981,7 +981,7 @@ 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->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (clonetiler_is_a_clone_of (child, obj)) { to_unclump = g_slist_prepend (to_unclump, child); } @@ -1004,7 +1004,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->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (clonetiler_is_a_clone_of (child, obj)) { n ++; } @@ -1033,7 +1033,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->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (clonetiler_is_a_clone_of (child, obj)) { to_delete = g_slist_prepend (to_delete, child); } diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index ed693f6ed..89b389d44 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -292,7 +292,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->first_child(); child; child = SP_OBJECT_NEXT (child)) { 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); diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 5372a8bb5..f95dce0e6 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -203,7 +203,7 @@ all_text_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->first_child(); child; child = SP_OBJECT_NEXT (child)) { 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)) diff --git a/src/document.cpp b/src/document.cpp index e68bc1f94..6b72f0bb8 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -245,7 +245,7 @@ SPDocument::setCurrentPersp3D(Persp3D * const persp) { void SPDocument::getPerspectivesInDefs(std::vector &list) { SPDefs *defs = SP_ROOT(this->root)->defs; - for (SPObject *i = sp_object_first_child(SP_OBJECT(defs)); i != NULL; i = SP_OBJECT_NEXT(i) ) { + for (SPObject *i = SP_OBJECT(defs)->first_child(); i != NULL; i = SP_OBJECT_NEXT(i) ) { if (SP_IS_PERSP3D(i)) list.push_back(SP_PERSP3D(i)); } @@ -1118,7 +1118,7 @@ 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) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (!SP_IS_ITEM(o)) { continue; } @@ -1141,7 +1141,7 @@ 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) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (!SP_IS_ITEM(o)) continue; if (SP_ITEM(o) == item) return true; @@ -1162,7 +1162,7 @@ SPDocument::item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GS Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (!SP_IS_ITEM(o)) continue; @@ -1199,7 +1199,7 @@ find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gbool Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (!SP_IS_ITEM(o)) continue; if (upto && SP_ITEM(o) == upto) @@ -1241,7 +1241,7 @@ find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (!SP_IS_ITEM(o)) continue; if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER) { SPItem *newseen = find_group_at_point(dkey, SP_GROUP(o), p); @@ -1421,7 +1421,7 @@ count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself - for (SPObject *i = sp_object_first_child(obj); i != NULL; i = SP_OBJECT_NEXT(i)) { + for (SPObject *i = obj->first_child(); i != NULL; i = SP_OBJECT_NEXT(i)) { count = count_objects_recursive(i, count); } @@ -1443,7 +1443,7 @@ vacuum_document_recursive(SPObject *obj) def->requestOrphanCollection(); } } else { - for (SPObject *i = sp_object_first_child(obj); i != NULL; i = SP_OBJECT_NEXT(i)) { + for (SPObject *i = obj->first_child(); i != NULL; i = SP_OBJECT_NEXT(i)) { vacuum_document_recursive(i); } } diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 5849230bf..b6b411e0e 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -962,7 +962,7 @@ CairoRenderContext::popState(void) static bool pattern_hasItemChildren (SPPattern *pat) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT(pat)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { return true; } @@ -1068,7 +1068,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT(pat_i)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS); _renderer->renderItem(pattern_ctx, SP_ITEM (child)); @@ -1097,7 +1097,7 @@ 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 = SP_OBJECT(pat_i)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { SP_ITEM (child)->invoke_hide (dkey); } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 81531b2db..3c5cfc7c1 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -671,7 +671,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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { SPItem *item = SP_ITEM(child); @@ -729,7 +729,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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { SPItem *item = SP_ITEM(child); renderItem(ctx, item); diff --git a/src/file.cpp b/src/file.cpp index 2344c67f2..15e5bbe72 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -976,7 +976,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); + for (SPObject *child = SP_DOCUMENT_ROOT(doc)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) items_count++; @@ -1004,7 +1004,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); + for (SPObject *child = SP_DOCUMENT_ROOT(doc)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { @@ -1024,7 +1024,7 @@ 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); + for (SPObject *x = child->first_child(); x != NULL; x = SP_OBJECT_NEXT(x)) { SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(x)->duplicate(xml_in_doc), last_def); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 3d5a795c7..f180dc661 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -50,7 +50,7 @@ count_filter_hrefs(SPObject *o, SPFilter *filter) i ++; } - for (SPObject *child = sp_object_first_child(o); + for (SPObject *child = o->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { i += count_filter_hrefs(child, filter); } diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 76b29bb09..0d99e7fa6 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -155,7 +155,7 @@ count_gradient_hrefs(SPObject *o, SPGradient *gr) i ++; } - for (SPObject *child = sp_object_first_child(o); + for (SPObject *child = o->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { i += count_gradient_hrefs(child, gr); } @@ -718,7 +718,7 @@ sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke) GSList *child_reprs = NULL; GSList *child_objects = NULL; std::vector offsets; - for (SPObject *child = sp_object_first_child(vector); + for (SPObject *child = vector->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { child_reprs = g_slist_prepend (child_reprs, SP_OBJECT_REPR(child)); child_objects = g_slist_prepend (child_objects, child); diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 5fb490b8b..e6dc22cea 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2001,7 +2001,7 @@ GrDrag::deleteSelected (bool just_one) // cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop // manually count the children, don't know if there already exists a function for this... int len = 0; - for ( SPObject *child = sp_object_first_child(stopinfo->vector) ; + for ( SPObject *child = (stopinfo->vector)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 2b0d5781a..b5630edd3 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -56,7 +56,7 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) // recurse if (!g_slist_find(list, o)) { - for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = o->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { hide_other_items_recursively(child, list, dkey); } } diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index f8321cc03..5ccb6c7fa 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -376,7 +376,7 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) // recurse if (!g_slist_find(list, o)) { - for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = o->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { hide_other_items_recursively(child, list, dkey); } } diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index cb2769c8e..6cdb50c35 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -199,7 +199,7 @@ SPObject *get_stock_item(gchar const *urn) SPObject *object = NULL; if (!strcmp(base, "marker")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)); + for (SPObject *child = SP_OBJECT(defs)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { @@ -213,7 +213,7 @@ SPObject *get_stock_item(gchar const *urn) } else if (!strcmp(base,"pattern")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)) ; + for (SPObject *child = SP_OBJECT(defs)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { @@ -227,7 +227,7 @@ SPObject *get_stock_item(gchar const *urn) } else if (!strcmp(base,"gradient")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)); + for (SPObject *child = SP_OBJECT(defs)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 43ce393dd..7572e6a42 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -165,7 +165,7 @@ find_references(SPObject *elem, refmap_type *refmap) } /* recurse */ - for (SPObject *child = sp_object_first_child(elem); + for (SPObject *child = elem->first_child(); child; child = SP_OBJECT_NEXT(child) ) { find_references(child, refmap); @@ -204,7 +204,7 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, } /* recurse */ - for (SPObject *child = sp_object_first_child(elem); + for (SPObject *child = elem->first_child(); child; child = SP_OBJECT_NEXT(child) ) { change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 379626683..00bd10fe2 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -98,7 +98,7 @@ 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->first_child(); o != NULL; o = SP_OBJECT_NEXT(o)) { 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 diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 817bb97d7..4b2e55b9d 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -246,14 +246,14 @@ 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) ) { + for (SPObject *child = defs->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { repr = SP_OBJECT_REPR(child); if (SP_IS_PERSP3D(child)) { return SP_PERSP3D(child); @@ -568,7 +568,7 @@ void persp3d_print_debugging_info_all(SPDocument *document) { SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); Inkscape::XML::Node *repr; - for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = defs->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { repr = SP_OBJECT_REPR(child); if (SP_IS_PERSP3D(child)) { persp3d_print_debugging_info(SP_PERSP3D(child)); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 066b86ddf..7b0f353ab 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -338,7 +338,7 @@ void add_ids_recursive(std::vector &ids, SPObject *obj) ids.push_back(obj->getId()); if (SP_IS_GROUP(obj)) { - for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = obj->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { add_ids_recursive(ids, child); } } @@ -453,7 +453,7 @@ void sp_edit_clear_all(SPDesktop *dt) GSList * get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, GSList const *exclude) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT(from)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child) && !desktop->isLayer(SP_ITEM(child)) && (!onlysensitive || !SP_ITEM(child)->isLocked()) && @@ -782,7 +782,7 @@ prev_sibling(SPObject *child) if (!SP_IS_GROUP(parent)) { return NULL; } - for ( SPObject *i = sp_object_first_child(parent) ; i; i = SP_OBJECT_NEXT(i) ) { + for ( SPObject *i = parent->first_child() ; i; i = SP_OBJECT_NEXT(i) ) { if (i->next == child) return i; } @@ -981,7 +981,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->first_child(); while (!SP_IS_ITEM(pc)) { minpos += 1; pc = pc->next; @@ -1339,7 +1339,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(SP_OBJECT(item)))) )); + bool transform_textpath_with_path = (SP_IS_TEXT_TEXTPATH(item) && selection->includes( sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->first_child())) )); // ...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? @@ -1743,7 +1743,7 @@ 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 children(SPObject *o) { return o->first_child(); } static Iterator siblings_after(SPObject *o) { return SP_OBJECT_NEXT(o); } static void dispose(Iterator /*i*/) {} @@ -2200,7 +2200,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(SP_OBJECT(item)))); + original = sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->first_child())); } 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 @@ -2520,7 +2520,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(SP_OBJECT(pattern)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT(pattern)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc); SPItem *i = SP_ITEM(desktop->currentLayer()->appendChildRepr(copy)); @@ -3099,7 +3099,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for ( std::map::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it).first; // Group containing the clipped paths or masks GSList *items_to_move = NULL; - for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = obj->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { // 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); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index bae5f5e56..a36d9b443 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -187,7 +187,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 = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@ -225,7 +225,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 = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@ -264,7 +264,7 @@ sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key) NRArenaItem *ai = NRArenaGroup::create(arena); cp->display = sp_clippath_view_new_prepend(cp->display, key, ai); - for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { + for (SPObject *child = SP_OBJECT(cp)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { NRArenaItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { @@ -290,7 +290,7 @@ sp_clippath_hide(SPClipPath *cp, 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 = SP_OBJECT(cp)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { SP_ITEM(child)->invoke_hide(key); } @@ -327,7 +327,7 @@ void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { SPObject *i; - for (i = sp_object_first_child(SP_OBJECT(cp)); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; + for (i = SP_OBJECT(cp)->first_child(); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; if (!i) return; SP_ITEM(i)->invoke_bbox_full( bbox, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index aa0cb0be7..76cb2e1d9 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -104,7 +104,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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@ -130,7 +130,7 @@ 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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); } @@ -142,7 +142,7 @@ 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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); } } diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 1ac8a6733..2464b73a5 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -294,7 +294,7 @@ sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::N repr = doc->createElement("svg:filter"); } l = NULL; - for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { crepr = child->updateRepr(doc, NULL, flags); if (crepr) l = g_slist_prepend (l, crepr); } @@ -304,7 +304,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 (child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); } } diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 6d679701f..41df69609 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -127,7 +127,7 @@ sp_flowdiv_update (SPObject *object, SPCtx *ctx, unsigned int 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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -161,7 +161,7 @@ sp_flowdiv_modified (SPObject *object, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -200,7 +200,7 @@ sp_flowdiv_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowDiv"); GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_FLOWTSPAN (child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@ -217,7 +217,7 @@ sp_flowdiv_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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_FLOWTSPAN (child) ) { child->updateRepr(flags); } else if ( SP_IS_FLOWPARA(child) ) { @@ -305,7 +305,7 @@ sp_flowtspan_update (SPObject *object, SPCtx *ctx, unsigned int 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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -339,7 +339,7 @@ sp_flowtspan_modified (SPObject *object, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -371,7 +371,7 @@ sp_flowtspan_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowSpan"); GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_FLOWTSPAN (child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@ -388,7 +388,7 @@ sp_flowtspan_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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_FLOWTSPAN (child) ) { child->updateRepr(flags); } else if ( SP_IS_FLOWPARA (child) ) { @@ -476,7 +476,7 @@ sp_flowpara_update (SPObject *object, SPCtx *ctx, unsigned int 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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -510,7 +510,7 @@ sp_flowpara_modified (SPObject *object, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -544,7 +544,7 @@ sp_flowpara_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape: if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara"); GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_FLOWTSPAN (child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@ -561,7 +561,7 @@ sp_flowpara_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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_FLOWTSPAN (child) ) { child->updateRepr(flags); } else if ( SP_IS_FLOWPARA (child) ) { diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 79007cac7..29ee05f5e 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -162,7 +162,7 @@ sp_flowregion_update (SPObject *object, SPCtx *ctx, unsigned int flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -194,7 +194,7 @@ void SPFlowregion::UpdateComputed(void) delete *it; computed.clear(); - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Shape *shape = NULL; GetDest(child,&shape); computed.push_back(shape); @@ -214,7 +214,7 @@ sp_flowregion_modified (SPObject *object, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -238,7 +238,7 @@ sp_flowregion_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscap } GSList *l = NULL; - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); @@ -251,7 +251,7 @@ 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) ) { + for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; child->updateRepr(flags); } @@ -380,7 +380,7 @@ sp_flowregionexclude_update (SPObject *object, SPCtx *ctx, unsigned int flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -412,7 +412,7 @@ void SPFlowregionExclude::UpdateComputed(void) computed = NULL; } - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { GetDest(child,&computed); } } @@ -430,7 +430,7 @@ sp_flowregionexclude_modified (SPObject *object, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -454,7 +454,7 @@ sp_flowregionexclude_write (SPObject *object, Inkscape::XML::Document *xml_doc, } GSList *l = NULL; - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); } @@ -466,7 +466,7 @@ 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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); } } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index b18b72968..b18d6f182 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -153,7 +153,7 @@ sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned 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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@ -207,7 +207,7 @@ 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 = SP_OBJECT(ft)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_FLOWREGION(o)) { region = o; break; @@ -297,7 +297,7 @@ sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: if ( flags & SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowRoot"); GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { 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); @@ -310,7 +310,7 @@ 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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) ) { child->updateRepr(flags); } @@ -456,7 +456,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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_STRING(child)) { if (*pending_line_break_object) { if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object)) @@ -653,7 +653,7 @@ SPItem *SPFlowtext::get_frame(SPItem *after) SPObject *ft = SP_OBJECT (this); SPObject *region = NULL; - for (SPObject *o = sp_object_first_child(SP_OBJECT(ft)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(ft)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_FLOWREGION(o)) { region = o; break; @@ -665,7 +665,7 @@ SPItem *SPFlowtext::get_frame(SPItem *after) bool past = false; SPItem *frame = NULL; - for (SPObject *o = sp_object_first_child(SP_OBJECT(region)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(region)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_ITEM(o)) { if (after == NULL || past) { frame = SP_ITEM(o); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index bc86e2135..604da3b7c 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -426,7 +426,7 @@ void SPGradientImpl::build(SPObject *object, SPDocument *document, Inkscape::XML (* ((SPObjectClass *) gradient_parent_class)->build)(object, document, repr); SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { + for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { if (SP_IS_STOP(ochild)) { gradient->has_stops = TRUE; break; @@ -585,7 +585,7 @@ void SPGradientImpl::childAdded(SPObject *object, Inkscape::XML::Node *child, In if (((SPObjectClass *) gradient_parent_class)->child_added) (* ((SPObjectClass *) gradient_parent_class)->child_added)(object, child, ref); - SPObject *ochild = sp_object_get_child_by_repr(object, child); + SPObject *ochild = object->get_child_by_repr(child); if ( ochild && SP_IS_STOP(ochild) ) { gr->has_stops = TRUE; } @@ -609,7 +609,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 ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { if (SP_IS_STOP(ochild)) { gr->has_stops = TRUE; break; @@ -640,7 +640,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->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@ -658,7 +658,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 = this->first_child(); ochild && !first; ochild = SP_OBJECT_NEXT(ochild)) { if (SP_IS_STOP(ochild)) { first = SP_STOP(ochild); } @@ -689,7 +689,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->first_child(); child; child = SP_OBJECT_NEXT(child)) { Inkscape::XML::Node *crepr; crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); @@ -985,7 +985,7 @@ bool SPGradient::invalidateVector() void SPGradient::rebuildVector() { gint len = 0; - for ( SPObject *child = sp_object_first_child(SP_OBJECT(this)) ; + for ( SPObject *child = SP_OBJECT(this)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_STOP(child)) { @@ -1009,7 +1009,7 @@ void SPGradient::rebuildVector() } } - for (SPObject *child = sp_object_first_child(SP_OBJECT(this)) ; + for (SPObject *child = SP_OBJECT(this)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_STOP(child)) { diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 1d38771bc..79a673e05 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -237,7 +237,7 @@ sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM repr = xml_doc->createElement("svg:g"); } l = NULL; - for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend (l, crepr); @@ -248,7 +248,7 @@ 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) ) { + for (child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; child->updateRepr(flags); } @@ -326,7 +326,7 @@ sp_group_hide (SPItem *item, unsigned int key) static void sp_group_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - for (SPObject const *o = sp_object_first_child(SP_OBJECT(item)); + for (SPObject const *o = SP_OBJECT(item)->first_child(); o != NULL; o = SP_OBJECT_NEXT(o)) { @@ -368,7 +368,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 = SP_OBJECT(group)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { @@ -512,7 +512,7 @@ sp_item_group_item_list (SPGroup * group) GSList *s = NULL; - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_ITEM (o)) { s = g_slist_prepend (s, o); } @@ -525,7 +525,7 @@ SPObject * sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name) { SPObject *child; - child = (ref) ? SP_OBJECT_NEXT(ref) : sp_object_first_child(SP_OBJECT(group)); + child = (ref) ? SP_OBJECT_NEXT(ref) : SP_OBJECT(group)->first_child(); while ( child && strcmp (SP_OBJECT_REPR(child)->name(), name) ) { child = SP_OBJECT_NEXT(child); } @@ -578,7 +578,7 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) if (this->hasChildren()) { SPObject *o = NULL; - for (o = sp_object_first_child(SP_OBJECT(this)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + for (o = SP_OBJECT(this)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_ITEM (o)) { sp_item_move_rel(static_cast(o), tr); } @@ -612,7 +612,7 @@ 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; @@ -730,7 +730,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 = SP_OBJECT(_group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_ITEM(o)) { len++; } @@ -800,7 +800,7 @@ 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; diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 72f318a25..7f67caee8 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -683,7 +683,7 @@ SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *crepr; GSList *l; l = NULL; - for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend (l, crepr); @@ -694,7 +694,7 @@ SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, l = g_slist_remove (l, l->data); } } else { - for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; child->updateRepr(flags); } @@ -921,7 +921,7 @@ unsigned SPItem::pos_in_parent() SPObject *object = SP_OBJECT(this); unsigned pos=0; - for ( SPObject *iter = sp_object_first_child(parent) ; iter ; iter = SP_OBJECT_NEXT(iter)) { + for ( SPObject *iter = parent->first_child() ; iter ; iter = SP_OBJECT_NEXT(iter)) { if ( iter == object ) { return pos; } @@ -1669,7 +1669,7 @@ sp_item_repr_compare_position(SPItem *first, SPItem *second) SPItem * sp_item_first_item_child (SPObject *obj) { - for ( SPObject *iter = sp_object_first_child(obj) ; iter ; iter = SP_OBJECT_NEXT(iter)) { + for ( SPObject *iter = obj->first_child() ; iter ; iter = SP_OBJECT_NEXT(iter)) { if (SP_IS_ITEM (iter)) return SP_ITEM (iter); } diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 71352ed98..6c49b79c1 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -681,7 +681,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 +692,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)); } diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index e57b5cc47..0c28cd014 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -201,7 +201,7 @@ sp_mask_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 = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -239,7 +239,7 @@ sp_mask_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 = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { g_object_ref (G_OBJECT (child)); l = g_slist_prepend (l, child); } @@ -310,7 +310,7 @@ 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 = SP_OBJECT(mask)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM (child)) { NRArenaItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { @@ -336,7 +336,7 @@ sp_mask_hide (SPMask *cp, unsigned int key) g_return_if_fail (cp != NULL); g_return_if_fail (SP_IS_MASK (cp)); - for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)); child != NULL; child = SP_OBJECT_NEXT(child)) { + for (SPObject *child = SP_OBJECT(cp)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM (child)) { SP_ITEM(child)->invoke_hide (key); } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 8c750f347..52c42866e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -266,7 +266,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: sp_object_read_attr(object, "inkscape:connector-spacing"); /* Construct guideline list */ - for (SPObject *o = sp_object_first_child(SP_OBJECT(og)) ; o != NULL; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(og)->first_child() ; o != NULL; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_GUIDE(o)) { SPGuide * g = SP_GUIDE(o); nv->guides = g_slist_prepend(nv->guides, g); @@ -789,7 +789,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)); + SPObject *iter = SP_DOCUMENT_ROOT(document)->first_child(); for ( ; iter ; iter = SP_OBJECT_NEXT(iter) ) { if (desktop->isLayer(iter)) { layer = iter; diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index 1d5c04339..02ae5d29a 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -112,7 +112,7 @@ sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inksca repr = xml_doc->createElement("svg:g"); } l = NULL; - for ( child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for ( child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend (l, crepr); } @@ -122,7 +122,7 @@ sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inksca l = g_slist_remove (l, l->data); } } else { - for ( child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for ( child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); } } diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 62143e3ab..207d08277 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -107,7 +107,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; } diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 08d13b2cc..edcdd60f5 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -495,7 +495,7 @@ SPObject::appendChildRepr(Inkscape::XML::Node *repr) { */ GSList *SPObject::childList(bool add_ref, Action) { GSList *l = NULL; - for (SPObject *child = sp_object_first_child(this) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = this->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (add_ref) g_object_ref (G_OBJECT (child)); @@ -567,7 +567,7 @@ 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)) { + for (SPObject *child = this->first_child(); child; child = SP_OBJECT_NEXT(child)) { child->_delete_signal.emit(child); child->_sendDeleteSignalRecursive(); } @@ -607,58 +607,58 @@ SPObject::deleteObject(bool propagate, bool propagate_descendants) * also update object's XML space. */ void -sp_object_attach(SPObject *parent, SPObject *object, SPObject *prev) +SPObject::attach(SPObject *object, SPObject *prev) { - g_return_if_fail(parent != NULL); - g_return_if_fail(SP_IS_OBJECT(parent)); + //g_return_if_fail(parent != NULL); + //g_return_if_fail(SP_IS_OBJECT(parent)); g_return_if_fail(object != NULL); g_return_if_fail(SP_IS_OBJECT(object)); g_return_if_fail(!prev || SP_IS_OBJECT(prev)); - g_return_if_fail(!prev || prev->parent == parent); + g_return_if_fail(!prev || prev->parent == this); g_return_if_fail(!object->parent); - sp_object_ref(object, parent); - object->parent = parent; - parent->_updateTotalHRefCount(object->_total_hrefcount); + sp_object_ref(object, this); + object->parent = this; + this->_updateTotalHRefCount(object->_total_hrefcount); SPObject *next; if (prev) { next = prev->next; prev->next = object; } else { - next = parent->children; - parent->children = object; + next = this->children; + this->children = object; } object->next = next; if (!next) { - parent->_last_child = object; + this->_last_child = object; } if (!object->xml_space.set) - object->xml_space.value = parent->xml_space.value; + object->xml_space.value = this->xml_space.value; } /** * In list of object's siblings, move object behind prev. */ void -sp_object_reorder(SPObject *object, SPObject *prev) { - g_return_if_fail(object != NULL); - g_return_if_fail(SP_IS_OBJECT(object)); - g_return_if_fail(object->parent != NULL); - g_return_if_fail(object != prev); +SPObject::reorder(SPObject *prev) { + //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 { @@ -669,14 +669,14 @@ 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; } } @@ -684,17 +684,17 @@ sp_object_reorder(SPObject *object, SPObject *prev) { * Remove object from parent's children, release and unref it. */ void -sp_object_detach(SPObject *parent, SPObject *object) { - g_return_if_fail(parent != NULL); - g_return_if_fail(SP_IS_OBJECT(parent)); +SPObject::detach(SPObject *object) { + //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; @@ -704,32 +704,32 @@ 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::get_child_by_repr(Inkscape::XML::Node *repr) { - g_return_val_if_fail(object != NULL, NULL); - g_return_val_if_fail(SP_IS_OBJECT(object), NULL); + //g_return_val_if_fail(object != NULL, NULL); + //g_return_val_if_fail(SP_IS_OBJECT(object), NULL); g_return_val_if_fail(repr != NULL, NULL); - if (object->_last_child && SP_OBJECT_REPR(object->_last_child) == repr) - return object->_last_child; // optimization for common scenario - for ( SPObject *child = object->children ; child ; child = child->next ) { + if (this->_last_child && SP_OBJECT_REPR(this->_last_child) == repr) + return this->_last_child; // optimization for common scenario + for ( SPObject *child = this->children ; child ; child = child->next ) { if ( SP_OBJECT_REPR(child) == repr ) { return child; } @@ -750,11 +750,11 @@ sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XM return; } SPObject *ochild = SP_OBJECT(g_object_new(type, 0)); - SPObject *prev = ref ? sp_object_get_child_by_repr(object, ref) : NULL; - sp_object_attach(object, ochild, prev); + SPObject *prev = ref ? object->get_child_by_repr(ref) : NULL; + object->attach(ochild, prev); sp_object_unref(ochild, NULL); - sp_object_invoke_build(ochild, object->document, child, SP_OBJECT_IS_CLONED(object)); + ochild->invoke_build(object->document, child, SP_OBJECT_IS_CLONED(object)); } /** @@ -772,7 +772,7 @@ static void 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); } } @@ -788,10 +788,10 @@ static void 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); + object->detach(ochild); } /** @@ -803,10 +803,10 @@ 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) { - 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); } @@ -837,73 +837,73 @@ 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, SP_OBJECT_IS_CLONED(object)); } } -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; + 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 (!SP_OBJECT_IS_CLONED(this)) { + 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); } void SPObject::releaseReferences() { @@ -1606,7 +1606,7 @@ 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) ) { + for ( SPObject *i = parent->first_child(); i; i = SP_OBJECT_NEXT(i) ) { if (SP_OBJECT_NEXT(i) == child) return i; } diff --git a/src/sp-object.h b/src/sp-object.h index 633091668..cb7a5a6ce 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -498,6 +498,14 @@ 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); + SPObject *first_child() { + return firstChild(); + } + void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); private: // Private member functions used in the definitions of setTitle(), @@ -540,16 +548,16 @@ struct SPObjectClass { * 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); +//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) { +/*inline SPObject *sp_object_first_child(SPObject *parent) { return parent->firstChild(); -} -SPObject *sp_object_get_child_by_repr(SPObject *object, Inkscape::XML::Node *repr); +}*/ +//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_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); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index b076b5701..3958da66a 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -323,7 +323,7 @@ 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); @@ -353,8 +353,8 @@ pattern_getchildren (SPPattern *pat) GSList *l = NULL; for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (sp_object_first_child(SP_OBJECT(pat_i))) { // find the first one with children - for (SPObject *child = sp_object_first_child(SP_OBJECT (pat)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + if (SP_OBJECT(pat_i)->first_child()) { // find the first one with children + for (SPObject *child = SP_OBJECT (pat)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { l = g_slist_prepend (l, child); } break; // do not go further up the chain if children are found @@ -535,7 +535,7 @@ SPPattern * pattern_getroot (SPPattern *pat) { for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (sp_object_first_child(SP_OBJECT(pat_i))) { // find the first one with children + if (SP_OBJECT (pat_i)->first_child()) { // find the first one with children return pat_i; } } @@ -621,7 +621,7 @@ NRRect *pattern_viewBox (SPPattern *pat) bool pattern_hasItemChildren (SPPattern *pat) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT (pat)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { return true; } @@ -736,7 +736,7 @@ sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, G pp->_release_connections = new std::map; for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT (pat_i)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { // for each item in pattern, NRArenaItem *cai; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 72c0b6de9..c032654ff 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -165,7 +165,7 @@ sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) (* ((SPObjectClass *) parent_class)->build) (object, document, repr); /* Search for first node */ - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL; o = SP_OBJECT_NEXT(o) ) { + for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL; o = SP_OBJECT_NEXT(o) ) { if (SP_IS_DEFS(o)) { root->defs = SP_DEFS(o); break; @@ -360,7 +360,7 @@ sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML: if (co && SP_IS_DEFS(co)) { SPObject *c; /* We search for first node - it is not beautiful, but works */ - for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) { + for (c = SP_OBJECT(group)->first_child() ; c != NULL; c = SP_OBJECT_NEXT(c) ) { if (SP_IS_DEFS(c)) { root->defs = SP_DEFS(c); break; @@ -379,7 +379,7 @@ static void sp_root_remove_child(SPObject *object, Inkscape::XML::Node *child) if ( root->defs && SP_OBJECT_REPR(root->defs) == child ) { SPObject *iter; /* We search for first remaining node - it is not beautiful, but works */ - for ( iter = sp_object_first_child(object) ; iter ; iter = SP_OBJECT_NEXT(iter) ) { + for ( iter = object->first_child() ; iter ; iter = SP_OBJECT_NEXT(iter) ) { if ( SP_IS_DEFS(iter) && (SPDefs *)iter != root->defs ) { root->defs = (SPDefs *)iter; break; diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 6d0b59daa..38dc1d367 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -108,7 +108,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 +138,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); diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 07575c4f0..2d67b8637 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -72,7 +72,7 @@ CSwitch::~CSwitch() { } SPObject *CSwitch::_evaluateFirst() { - for (SPObject *child = sp_object_first_child(_group) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = _group->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) return child; } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 46e17a75a..7bdd84989 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -225,7 +225,7 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags) /* Create temporary list of children */ GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { sp_object_ref (SP_OBJECT (child), object); l = g_slist_prepend (l, child); } @@ -286,7 +286,7 @@ sp_text_modified (SPObject *object, guint flags) /* Create temporary list of children */ GSList *l = NULL; SPObject *child; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { sp_object_ref (SP_OBJECT (child), object); l = g_slist_prepend (l, child); } @@ -310,7 +310,7 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML if (!repr) repr = xml_doc->createElement("svg:text"); GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; Inkscape::XML::Node *crepr = NULL; if (SP_IS_STRING(child)) { @@ -326,7 +326,7 @@ 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) ) { + for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { 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()); @@ -565,7 +565,7 @@ 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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { 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); diff --git a/src/sp-textpath.h b/src/sp-textpath.h index 193196606..6642587d2 100644 --- a/src/sp-textpath.h +++ b/src/sp-textpath.h @@ -31,7 +31,7 @@ struct SPTextPathClass { GType sp_textpath_get_type(); -#define SP_IS_TEXT_TEXTPATH(obj) (SP_IS_TEXT(obj) && sp_object_first_child(obj) && SP_IS_TEXTPATH(sp_object_first_child(obj))) +#define SP_IS_TEXT_TEXTPATH(obj) (SP_IS_TEXT(obj) && obj->first_child() && SP_IS_TEXTPATH(obj->first_child())) SPItem *sp_textpath_get_path_item(SPTextPath *tp); void sp_textpath_to_text(SPObject *tp); diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 382b55740..850ebbd42 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -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; } @@ -516,7 +516,7 @@ 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; } @@ -527,9 +527,9 @@ sp_tref_update_text(SPTRef *tref) 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); } @@ -633,7 +633,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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { sp_object_ref (SP_OBJECT (child), obj); l = g_slist_prepend (l, child); } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index db2fe6fed..a7391ac98 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -178,7 +178,7 @@ sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { + for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild->updateDisplay(ctx, flags); } @@ -196,7 +196,7 @@ sp_tspan_modified(SPObject *object, unsigned flags) flags &= SP_OBJECT_MODIFIED_CASCADE; SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { + for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild->emitModified(flags); } @@ -242,7 +242,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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@ -259,7 +259,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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { @@ -455,7 +455,7 @@ sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) flags &= SP_OBJECT_MODIFIED_CASCADE; SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { + for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild->updateDisplay(ctx, flags); } @@ -494,7 +494,7 @@ sp_textpath_modified(SPObject *object, unsigned flags) flags &= SP_OBJECT_MODIFIED_CASCADE; SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { + for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild->emitModified(flags); } @@ -526,7 +526,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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@ -543,7 +543,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->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 1125550c8..3770b2324 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -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; } @@ -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; } @@ -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,9 +537,9 @@ 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; diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 5af97165e..9d4c23b25 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -215,7 +215,7 @@ text_remove_from_path() continue; } - SPObject *tp = sp_object_first_child(SP_OBJECT(items->data)); + SPObject *tp = SP_OBJECT(items->data)->first_child(); did = true; @@ -252,7 +252,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->first_child(); i != NULL; i = SP_OBJECT_NEXT(i)) { text_remove_all_kerns_recursively(i); } } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 600059303..2ed5270fd 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -872,8 +872,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 (SP_OBJECT (text)->first_child()); + object = SP_OBJECT (text)->first_child(); is_textpath = true; } else { repr = SP_OBJECT_REPR (text); @@ -1331,7 +1331,7 @@ static void apply_css_recursive(SPObject *o, SPCSSAttr const *css) { sp_repr_css_change(SP_OBJECT_REPR(o), const_cast(css), "style"); - for (SPObject *child = sp_object_first_child(SP_OBJECT(o)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for (SPObject *child = SP_OBJECT(o)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (sp_repr_css_property(const_cast(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. @@ -1418,7 +1418,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; @@ -1430,7 +1430,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); diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index cd6ff325a..775e7aec3 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -425,7 +425,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 = SP_OBJECT(item)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { children = g_slist_prepend(children, child); } @@ -863,7 +863,7 @@ 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); + for (SPObject *child = vector->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { if (!SP_IS_STOP(child)) continue; @@ -923,7 +923,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 = SP_OBJECT(item)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM(child)) { if (sp_tweak_color_recursive (mode, SP_ITEM(child), item_at_point, fill_goal, do_fill, diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index aa59a7b23..e050d69b4 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -702,7 +702,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(SP_OBJECT(item)->first_child())); } // Copy clipping objects if (item->clip_ref->getObject()) { @@ -759,7 +759,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 = SP_OBJECT(pattern)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { if (!SP_IS_ITEM (child)) { continue; } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 837b82291..5068e3bf4 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -348,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->first_child(); child; child = SP_OBJECT_NEXT (child)) { 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); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index d8bbcd788..ffa5b12dd 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -463,7 +463,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 = SP_OBJECT(gradient)->first_child() ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { if (SP_IS_STOP(ochild)) { i++; stop = SP_STOP(ochild); @@ -506,7 +506,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 = SP_OBJECT(gradient)->first_child() ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { if (SP_IS_STOP(ochild)) { if (SP_OBJECT(ochild) == SP_OBJECT(new_stop)) { gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), i); @@ -536,7 +536,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 = SP_OBJECT(gradient)->first_child() ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { if (SP_IS_STOP(ochild)) { sl = g_slist_append(sl, ochild); } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 0d7b95f4c..65732d488 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -221,7 +221,7 @@ ink_marker_list_get (SPDocument *source) GSList *ml = NULL; SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source); - for ( SPObject *child = sp_object_first_child(SP_OBJECT(defs)); + for ( SPObject *child = SP_OBJECT(defs)->first_child(); child != NULL; child = SP_OBJECT_NEXT (child) ) { -- cgit v1.2.3 From 1aaf9a0ee3da28012bf43cfa61e2e5fa933edd2e Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 6 Jul 2010 12:52:32 +0530 Subject: C++ification of SPObject continued along with the onset of XML Privatisation. Users may checkout [grep -Ir XML Tree *] in the source code and all the places where the XML node/Tree is being used shall be reflected. (bzr r9546.1.5) --- src/document.h | 2 + src/extension/internal/grid.cpp | 4 +- src/filter-chemistry.cpp | 3 +- src/filters/blend.cpp | 4 +- src/filters/composite.cpp | 4 +- src/filters/displacementmap.cpp | 4 +- src/flood-context.cpp | 3 +- src/knotholder.cpp | 3 +- src/layer-manager.cpp | 6 ++- src/marker.cpp | 6 ++- src/path-chemistry.cpp | 6 ++- src/sp-anchor.cpp | 16 ++++---- src/sp-clippath.h | 6 ++- src/sp-filter-primitive.cpp | 3 +- src/sp-flowtext.cpp | 6 ++- src/sp-font-face.cpp | 68 +++++++++++++++++---------------- src/sp-font.cpp | 14 ++++--- src/sp-glyph-kerning.cpp | 12 +++--- src/sp-glyph.cpp | 22 ++++++----- src/sp-guide.cpp | 11 ++++-- src/sp-image.cpp | 12 ++++-- src/sp-mask.h | 6 ++- src/sp-missing-glyph.cpp | 13 ++++--- src/sp-object.cpp | 45 ++++++++++++++++------ src/sp-object.h | 19 +++++++-- src/sp-offset.cpp | 35 ++++++++++------- src/sp-paint-server.cpp | 8 +++- src/sp-root.cpp | 3 +- src/sp-string.cpp | 4 +- src/sp-style-elem.cpp | 3 +- src/sp-symbol.cpp | 7 +++- src/sp-text.cpp | 2 +- src/splivarot.cpp | 7 +++- src/style.cpp | 12 ++++-- src/text-editing.cpp | 3 +- src/trace/trace.cpp | 3 +- src/ui/dialog/document-properties.cpp | 8 +++- src/ui/dialog/filter-effects-dialog.cpp | 31 ++++++++++----- src/ui/dialog/svg-fonts-dialog.cpp | 37 ++++++++++++------ src/ui/dialog/swatches.cpp | 10 +++-- src/ui/tool/node-tool.cpp | 7 +++- src/ui/tool/path-manipulator.cpp | 15 +++++--- src/verbs.cpp | 3 +- src/xml/helper-observer.cpp | 10 +++-- 44 files changed, 333 insertions(+), 173 deletions(-) (limited to 'src') diff --git a/src/document.h b/src/document.h index 38f930c31..a91d1e57f 100644 --- a/src/document.h +++ b/src/document.h @@ -162,8 +162,10 @@ sigc::connection connectCommit(CommitSignal::slot_type slot); void setModifiedSinceSave(bool modified = true) { modified_since_save = modified; } + //Inkscape::XML::Document * getRdoc(){ return rdoc; } private: + //Inkscape::XML::Document *rdoc; ///< Our Inkscape::XML::Document SPDocument(SPDocument const &); // no copy void operator=(SPDocument const &); // no assign diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 8132ba1ad..4d07e401d 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -112,7 +112,9 @@ 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(document)->currentLayer()->repr; + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node * current_layer = static_cast(document)->currentLayer()->getRepr(); Inkscape::XML::Node * path = xml_doc->createElement("svg:path"); path->setAttribute("d", path_data.c_str()); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index f180dc661..1f4e91c3b 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -168,7 +168,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->getRepr()->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 5998d7be3..3cec42291 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -213,7 +213,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) { diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 93c692f94..761115850 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -240,7 +240,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) { diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index baa17d785..ea2535f3e 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -218,7 +218,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) { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 696efd3e3..5181809dc 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -417,7 +417,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto std::vector results = pte.traceGrayMap(gray_map); gray_map->destroy(gray_map); - Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->repr; + //XML Tree being used here directly while it shouldn't be...." + Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); long totalNodeCount = 0L; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 89f57da97..6778e9ad8 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -42,7 +42,8 @@ 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"); diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index 5c96bcee1..0ee7f76a9 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -269,13 +269,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(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; diff --git a/src/marker.cpp b/src/marker.cpp index e02276215..979ca3011 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -524,8 +524,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); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index daa9ae595..639c7fa00 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -213,8 +213,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; diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index aabefdfdb..379ddbb7c 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -154,13 +154,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) { diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 02395f3d2..308c3c893 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -61,8 +61,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_clippath = NULL; gchar const * obj_name = NULL; diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index 77325c4b1..7cf0a38bb 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -259,7 +259,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; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index b18d6f182..2d1f61a29 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -241,7 +241,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) { @@ -481,7 +482,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, 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); } diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 1912676d4..20419a8e5 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -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) { diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 96973b657..4f8bbef6e 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -263,12 +263,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) { diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index d62fbb2c2..93996d8bc 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -250,11 +250,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) { diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 0b3b85d3f..203163b29 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -290,16 +290,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) { diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 877e73979..955d4fedc 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -358,7 +358,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 +389,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) @@ -457,8 +459,9 @@ void sp_guide_remove(SPGuide *guide) remove_last(att.item->constraints, SPGuideConstraint(guide, att.snappoint_ix)); } 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()); } /* diff --git a/src/sp-image.cpp b/src/sp-image.cpp index c1fb9a571..33038d73c 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -838,8 +838,12 @@ 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"), + + //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->base); if (pixbuf) { pixbuf = sp_image_pixbuf_force_rgba (pixbuf); @@ -1056,7 +1060,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); diff --git a/src/sp-mask.h b/src/sp-mask.h index 0b995f0ce..ae3b76210 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -63,8 +63,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; diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index 7d5c42763..d15000fcb 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -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) { diff --git a/src/sp-object.cpp b/src/sp-object.cpp index edcdd60f5..f81d5bdb5 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -207,7 +207,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; @@ -294,6 +297,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. * @@ -1007,7 +1019,9 @@ sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) switch (key) { case SP_ATTR_ID: - if ( !SP_OBJECT_IS_CLONED(object) && object->repr->type() == Inkscape::XML::ELEMENT_NODE ) { + + //XML Tree being used here. + if ( !SP_OBJECT_IS_CLONED(object) && object->getRepr()->type() == Inkscape::XML::ELEMENT_NODE ) { SPDocument *document=object->document; SPObject *conflict=NULL; @@ -1108,12 +1122,13 @@ sp_object_read_attr(SPObject *object, gchar const *key) g_assert(SP_IS_OBJECT(object)); g_assert(key != NULL); - g_assert(object->repr != NULL); + //XML Tree being used here. + g_assert(object->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 = object->getRepr()->attribute(key); sp_object_set(object, keyid, value); } @@ -1441,7 +1456,8 @@ sp_object_tagName_get(SPObject const *object, SPException *ex) } /// \todo fixme: Exception if object is NULL? */ - return object->repr->name(); + //XML Tree being used here. + return object->getRepr()->name(); } gchar const * @@ -1453,7 +1469,8 @@ sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex } /// \todo fixme: Exception if object is NULL? */ - return (gchar const *) object->repr->attribute(key); + //XML Tree being used here. + return (gchar const *) object->getRepr()->attribute(key); } void @@ -1463,7 +1480,8 @@ sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, S 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. + object->getRepr()->setAttribute(key, value, false); } void @@ -1473,7 +1491,8 @@ sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex) 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. + object->getRepr()->setAttribute(key, NULL, false); } /* Helper */ @@ -1487,7 +1506,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, ':'); @@ -1551,7 +1571,8 @@ sp_object_get_style_property(SPObject const *object, gchar const *key, gchar con 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 = object->getRepr()->attribute("style"); if (style) { size_t const len = strlen(key); char const *p; @@ -1572,7 +1593,9 @@ 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 = object->getRepr()->attribute(key); if (val && !streq(val, "inherit")) { return val; } diff --git a/src/sp-object.h b/src/sp-object.h index cb7a5a6ce..e1d49b041 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -46,7 +46,7 @@ /* 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) @@ -137,7 +137,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 +155,11 @@ 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 */ + //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 +167,17 @@ public: */ gchar const* getId() const; + /** + * Returns the XML representation of tree + */ + //Inkscape::XML::Node const* getRepr() const; + Inkscape::XML::Node * getRepr(); + + /** + * Returns the XML representation of tree + */ + Inkscape::XML::Node const* getRepr() const; + /** @brief cleans up an SPObject, releasing its references and * requesting that references to it be released */ diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 30626695e..ff915c92f 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -217,37 +217,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")) { + //XML Tree being used directly here while it shouldn't be. + if (object->getRepr()->attribute("inkscape:radius")) { sp_object_read_attr (object, "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"); } - if (object->repr->attribute("inkscape:original")) { + if (object->getRepr()->attribute("inkscape:original")) { sp_object_read_attr (object, "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"); } - if (object->repr->attribute("xlink:href")) { + if (object->getRepr()->attribute("xlink:href")) { sp_object_read_attr(object, "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"); } @@ -454,7 +459,8 @@ sp_offset_set_shape(SPShape *shape) // just put the source shape as the offseted one, no one will notice // it's also useless to compute the offset with a 0 radius - const char *res_d = SP_OBJECT(shape)->repr->attribute("inkscape:original"); + //XML Tree being used directly here while it shouldn't be. + const char *res_d = SP_OBJECT(shape)->getRepr()->attribute("inkscape:original"); if ( res_d ) { Geom::PathVector pv = sp_svg_read_pathv(res_d); SPCurve *c = new SPCurve(pv); @@ -1145,7 +1151,8 @@ 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); } diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index 5858f9a0e..fa2cc4fda 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -160,7 +160,9 @@ bool SPPaintServer::isSwatch() const bool swatch = false; if (SP_IS_GRADIENT(this)) { SPGradient *grad = SP_GRADIENT(this); - swatch = grad->hasStops() && repr->attribute("osb:paint"); + + //XML Tree being used directly here while it shouldn't be. + swatch = grad->hasStops() && getRepr()->attribute("osb:paint"); } return swatch; } @@ -171,7 +173,9 @@ bool SPPaintServer::isSolid() const if (SP_IS_GRADIENT(this)) { SPGradient *grad = SP_GRADIENT(this); if ( grad->hasStops() && (grad->getStopCount() == 0) ) { - gchar const * attr = repr->attribute("osb:paint"); + + //XML Tree being used directly here while it shouldn't be. + gchar const * attr = getRepr()->attribute("osb:paint"); if (attr && !strcmp(attr, "solid")) { solid = true; } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index c032654ff..e73e83a7f 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -146,7 +146,8 @@ 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); } diff --git a/src/sp-string.cpp b/src/sp-string.cpp index 871338ad5..8cf8d3291 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -116,7 +116,9 @@ 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) ) { diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index 46c311920..bb4ccb2e1 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -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(text->str), text->len, CR_UTF_8, FALSE); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 41004db6e..0dab82bc9 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -393,8 +393,11 @@ 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) ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 7bdd84989..e3e919796 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -570,7 +570,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio 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); } } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 5073382e5..d9ac792b3 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1323,7 +1323,8 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat 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(); @@ -1451,7 +1452,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); diff --git a/src/style.cpp b/src/style.cpp index 2b5804671..13967ec0c 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -1019,7 +1019,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); @@ -1029,7 +1031,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) { @@ -1288,9 +1292,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. diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 2ed5270fd..a307e5e27 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1497,7 +1497,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); diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index e9bc48372..cff464e9f 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -482,7 +482,8 @@ void Tracer::traceThread() } //### Get pointers to the 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() diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 2fe353533..4e1ddda2e 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -522,7 +522,9 @@ void DocumentProperties::removeSelectedProfile(){ SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast(obj); if (!name.compare(prof->name)){ - sp_repr_unparent(obj->repr); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(obj->getRepr()); SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); } current = g_slist_next(current); @@ -691,7 +693,9 @@ void DocumentProperties::removeExternalScript(){ SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; if (name == script->xlinkhref){ - sp_repr_unparent(obj->repr); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(obj->getRepr()); SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); } current = g_slist_next(current); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 3a80c4ba8..07b8a4159 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1023,12 +1023,14 @@ 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::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); - prim->repr->appendChild(repr); + Inkscape::XML::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); + //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); Inkscape::GC::release(repr); } @@ -1336,7 +1338,9 @@ void FilterEffectsDialog::FilterModifier::remove_filter() if(filter) { SPDocument* doc = filter->document; - sp_repr_unparent(filter->repr); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(filter->getRepr()); SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); @@ -1488,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(); @@ -1541,7 +1547,8 @@ 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()); SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter primitive")); @@ -1914,7 +1921,9 @@ 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); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(o->getRepr()); SPDocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; @@ -1929,7 +1938,9 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); 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); @@ -2467,7 +2478,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(); } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 7c6ced5aa..9f9f91bd1 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -170,7 +170,9 @@ void SvgFontsDialog::on_kerning_value_changed(){ 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()); + + //XML Tree being directly used here while it shouldn't be. + this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str()); SPDocumentUndo::maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); //populate_kerning_pairs_box(); @@ -505,7 +507,8 @@ 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)); + //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); @@ -547,7 +550,9 @@ 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)); + + //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } @@ -566,7 +571,8 @@ 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"); + //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@ -579,7 +585,8 @@ 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()); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); @@ -592,7 +599,8 @@ 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()); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); @@ -603,7 +611,8 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin void SvgFontsDialog::remove_selected_font(){ SPFont* font = get_selected_spfont(); - 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()); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); @@ -617,7 +626,9 @@ 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()); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); @@ -632,7 +643,9 @@ 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()); SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); @@ -812,7 +825,8 @@ 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); } } @@ -832,7 +846,8 @@ 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()); } } diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 62682d623..6cef5bedd 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -182,7 +182,8 @@ void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer us for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { - grad->repr->setAttribute("osb:paint", "solid"); // TODO make conditional + //XML Tree being used directly here while it shouldn't be + grad->getRepr()->setAttribute("osb:paint", "solid"); // TODO make conditional SPDocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); @@ -948,7 +949,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; } @@ -979,7 +981,9 @@ 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; } diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index d10f46313..0b6d2168f 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -359,7 +359,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(obj); r.edit_transform = Geom::identity(); // TODO wrong? @@ -408,8 +409,10 @@ void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel) bool something_set = false; for (std::set::iterator i = shapes.begin(); i != shapes.end(); ++i) { ShapeRecord const &r = *i; + + //XML Tree being used directly here while it shouldn't be. if (SP_IS_SHAPE(r.item) || - (SP_IS_PATH(r.item) && r.item->repr->attribute("inkscape:original-d") != NULL)) + (SP_IS_PATH(r.item) && r.item->getRepr()->attribute("inkscape:original-d") != NULL)) { nt->shape_editor->set_item(r.item, SH_KNOTHOLDER); something_set = true; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index dec37cd1c..ba82b810b 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -108,7 +108,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) @@ -1069,7 +1069,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, @@ -1244,7 +1246,8 @@ 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); @@ -1262,8 +1265,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) diff --git a/src/verbs.cpp b/src/verbs.cpp index 300fe7494..5c35c1e51 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1207,7 +1207,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); diff --git a/src/xml/helper-observer.cpp b/src/xml/helper-observer.cpp index 620a88d8c..976a8a7ec 100644 --- a/src/xml/helper-observer.cpp +++ b/src/xml/helper-observer.cpp @@ -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; } -- cgit v1.2.3 From 6cc35b45eab6422a6b6f67d621aa259a0a73786f Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Mon, 12 Jul 2010 22:06:46 +0530 Subject: SPObject c++ification finalized along with the beginning of XML Privatisation tweaks (bzr r9546.1.6) --- src/box3d-side.cpp | 10 +- src/box3d-side.h | 1 + src/box3d.cpp | 51 ++++---- src/box3d.h | 6 +- src/color-profile-test.h | 10 +- src/color-profile.cpp | 8 +- src/conn-avoid-ref.cpp | 2 +- src/connector-context.cpp | 22 ++-- src/dialogs/item-properties.cpp | 2 +- src/document-subset.cpp | 4 +- src/filters/blend.cpp | 8 +- src/filters/colormatrix.cpp | 4 +- src/filters/componenttransfer-funcnode.cpp | 18 +-- src/filters/composite.cpp | 12 +- src/filters/convolvematrix.cpp | 18 +-- src/filters/diffuselighting.cpp | 16 +-- src/filters/displacementmap.cpp | 8 +- src/filters/distantlight.cpp | 8 +- src/filters/flood.cpp | 4 +- src/filters/image.cpp | 10 +- src/filters/mergenode.cpp | 2 +- src/filters/morphology.cpp | 4 +- src/filters/offset.cpp | 8 +- src/filters/pointlight.cpp | 12 +- src/filters/specularlighting.cpp | 20 +-- src/filters/spotlight.cpp | 32 ++--- src/filters/turbulence.cpp | 10 +- src/forward.h | 13 +- src/interface.cpp | 2 +- src/live_effects/lpeobject.cpp | 2 +- src/marker.cpp | 16 +-- src/persp3d.cpp | 8 +- src/selection-chemistry.cpp | 4 +- src/sp-anchor.cpp | 16 +-- src/sp-animation.cpp | 42 +++---- src/sp-clippath.cpp | 2 +- src/sp-conn-end-pair.cpp | 12 +- src/sp-ellipse.cpp | 28 ++--- src/sp-filter-primitive.cpp | 8 +- src/sp-filter.cpp | 16 +-- src/sp-flowtext.cpp | 2 +- src/sp-font-face.cpp | 132 +++++++++---------- src/sp-font.cpp | 24 ++-- src/sp-gaussian-blur.cpp | 4 +- src/sp-glyph-kerning.cpp | 18 +-- src/sp-glyph.cpp | 40 +++--- src/sp-gradient-test.h | 10 +- src/sp-gradient.cpp | 46 +++---- src/sp-guide.cpp | 4 +- src/sp-image.cpp | 14 +-- src/sp-item-group.cpp | 2 +- src/sp-item.cpp | 24 ++-- src/sp-line.cpp | 8 +- src/sp-lpe-item.cpp | 2 +- src/sp-mask.cpp | 4 +- src/sp-missing-glyph.cpp | 10 +- src/sp-namedview.cpp | 96 +++++++------- src/sp-object-repr.h | 4 +- src/sp-object.cpp | 196 ++++++++++++++++------------- src/sp-object.h | 80 ++++++++++-- src/sp-offset.cpp | 12 +- src/sp-path.cpp | 16 +-- src/sp-pattern.cpp | 18 +-- src/sp-polygon.cpp | 2 +- src/sp-polyline.cpp | 2 +- src/sp-rect.cpp | 12 +- src/sp-root.cpp | 18 +-- src/sp-script.cpp | 2 +- src/sp-skeleton.cpp | 24 ++-- src/sp-spiral.cpp | 14 +-- src/sp-star.cpp | 20 +-- src/sp-style-elem-test.h | 10 +- src/sp-style-elem.cpp | 4 +- src/sp-symbol.cpp | 4 +- src/sp-text.cpp | 12 +- src/sp-tref.cpp | 12 +- src/sp-tspan.cpp | 26 ++-- src/sp-use.cpp | 12 +- src/ui/context-menu.h | 2 +- src/uri-references.h | 1 + src/widgets/desktop-widget.h | 1 + src/widgets/toolbox.cpp | 4 +- 82 files changed, 762 insertions(+), 665 deletions(-) (limited to 'src') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 69bae53d9..be6d47db7 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -99,7 +99,7 @@ box3d_side_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, "inkscape:box3dsidetype"); + object->readAttr( "inkscape:box3dsidetype"); } static Inkscape::XML::Node * @@ -185,6 +185,14 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) if (((SPObjectClass *) parent_class)->update) ((SPObjectClass *) parent_class)->update (object, ctx, flags); } +/* + * 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) { diff --git a/src/box3d-side.h b/src/box3d-side.h index d40e64b75..ba1431fab 100644 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@ -31,6 +31,7 @@ struct Box3DSide : public SPPolygon { Box3D::Axis dir1; Box3D::Axis dir2; Box3D::FrontOrRear front_or_rear; + long long int getFaceId(); }; struct Box3DSideClass { diff --git a/src/box3d.cpp b/src/box3d.cpp index 7985640cd..1facf2c0c 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -132,9 +132,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"); } /** @@ -268,7 +268,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 +290,13 @@ 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); + //Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(doc->getCurrentPersp3D()); + //const gchar *persp_id = persp_repr->attribute("id"); + //gchar *href = g_strdup_printf("#%s", persp_id); + Glib::ustring href = "#"; + href += doc->getCurrentPersp3D()->getId(); + repr->setAttribute("inkscape:perspectiveID", href.c_str()); + //g_free(href); } } @@ -1152,9 +1154,11 @@ static std::map box3d_get_sides (SPBox3D *box) { std::map sides; for (SPObject *side = box->first_child(); 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); + + 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; @@ -1328,9 +1332,12 @@ 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); + //gchar *href = g_strdup_printf("#%s", SP_OBJECT_REPR(new_persp)->attribute("id")); + Glib::ustring href = "#"; + href += new_persp->getId(); + //SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", href.c_str()); + static_cast(box)->setAttribute("inkscape:perspectiveID", href.c_str()); + //g_free(href); } /* Converts the 3D box to an ordinary SPGroup, adds it to the XML tree at the same position as @@ -1341,14 +1348,14 @@ box3d_convert_to_group(SPBox3D *box) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); // remember position of the box - int pos = SP_OBJECT_REPR(box)->position(); + int pos = static_cast(box)->getPosition(); // remember important attributes - Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box); - gchar const *id = repr_source->attribute("id"); - gchar const *style = repr_source->attribute("style"); - gchar const *mask = repr_source->attribute("mask"); - gchar const *clip_path = repr_source->attribute("clip-path"); + //Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box); + gchar const *id = static_cast(box)->getAttribute("id"); + gchar const *style = static_cast(box)->getAttribute("style"); + gchar const *mask = static_cast(box)->getAttribute("mask"); + gchar const *clip_path = static_cast(box)->getAttribute("clip-path"); // create a new group and add the sides (converted to ordinary paths) as its children Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); @@ -1365,7 +1372,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) diff --git a/src/box3d.h b/src/box3d.h index 9f2e1d78e..182a312e1 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -29,7 +29,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; @@ -46,7 +47,8 @@ struct SPBox3D : public SPGroup { gint my_counter; // for debugging only }; -struct SPBox3DClass { +class SPBox3DClass { + public: SPGroupClass parent_class; }; diff --git a/src/color-profile-test.h b/src/color-profile-test.h index c479f78c0..4da3c579a 100644 --- a/src/color-profile-test.h +++ b/src/color-profile-test.h @@ -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); diff --git a/src/color-profile.cpp b/src/color-profile.cpp index bda4e6e23..ee4118e4f 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -247,10 +247,10 @@ 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 ) { diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index a6ac2387a..ed2aceb82 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -194,7 +194,7 @@ 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 ); + SP_OBJECT(item)->setAttribute( "inkscape:connection-points", value, 0 ); item->updateRepr(); doc->ensure_up_to_date(); SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, action); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index ff19c7749..a419af44a 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1286,15 +1286,15 @@ 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, + (cc->clickeditem)->setAttribute( "inkscape:connection-start", shape_label, false); - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-start-point", cpid, false); } else { - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-end", shape_label, false); - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-end-point", cpid, false); } g_free(shape_label); @@ -1434,26 +1434,26 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); bool connection = false; - sp_object_setAttribute(cc->newconn, "inkscape:connector-type", + (cc->newconn)->setAttribute( "inkscape:connector-type", cc->isOrthogonal ? "orthogonal" : "polyline", false); - sp_object_setAttribute(cc->newconn, "inkscape:connector-curvature", + (cc->newconn)->setAttribute( "inkscape:connector-curvature", Glib::Ascii::dtostr(cc->curvature).c_str(), false); if (cc->shref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-start", + (cc->newconn)->setAttribute( "inkscape:connection-start", cc->shref, false); if (cc->scpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-start-point", + (cc->newconn)->setAttribute( "inkscape:connection-start-point", cc->scpid, false); connection = true; } if (cc->ehref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-end", + (cc->newconn)->setAttribute( "inkscape:connection-end", cc->ehref, false); if (cc->ecpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-end-point", + (cc->newconn)->setAttribute( "inkscape:connection-end-point", cc->ecpid, false); connection = true; } @@ -1917,7 +1917,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", + item->setAttribute("inkscape:connector-avoid", value, false); item->avoidRef->handleSettingChange(); changes++; diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 8d2b15e44..d96b364ef 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -449,7 +449,7 @@ 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_OBJECT (item)->setAttribute ("id", id, &ex); SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object ID")); } diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 1988865d1..a25205db9 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -60,7 +60,7 @@ struct DocumentSubset::Relations : public GC::Managed, while ( first != last ) { Siblings::const_iterator mid = first + ( last - first + 1 ) / 2; - int pos = sp_object_compare_position(*mid, obj); + int pos = sp_object_compare_position(*mid,obj); if ( pos < 0 ) { first = mid; } else if ( pos > 0 ) { @@ -76,7 +76,7 @@ struct DocumentSubset::Relations : public GC::Managed, if ( first == last ) { // compare to the single possiblity left - int pos = sp_object_compare_position(*last, obj); + int pos = sp_object_compare_position(*last,obj); if ( pos < 0 ) { last++; } diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 3cec42291..f297ac199 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -103,8 +103,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 +202,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 diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index 3f60ea05c..1b189ef37 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -98,8 +98,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"); } /** diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 1dbf07dd5..a45716e08 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -168,13 +168,13 @@ 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? @@ -296,8 +296,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) { diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 761115850..ae5be1a81 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -101,14 +101,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. */ diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index 6440f340a..2f91c9db5 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -110,15 +110,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"); } /** diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index bdc569083..5681bddc1 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -118,10 +118,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 +224,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) { diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index ea2535f3e..ded7aab45 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -97,10 +97,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. */ diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 55c51aa0e..3a56f682b 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -101,8 +101,8 @@ 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? document->add_resource("fedistantlight", object); @@ -189,8 +189,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) { diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp index 221b0daf2..f5179cb41 100644 --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@ -96,8 +96,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"); } /** diff --git a/src/filters/image.cpp b/src/filters/image.cpp index eb6dfc22a..1180799f4 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -100,11 +100,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"); } diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 8a4e0dd0a..c135c06fb 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -84,7 +84,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"); } /** diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index 1530dae8c..2724dc5b6 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -97,8 +97,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"); } /** diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index 61ea45ff2..64f6661fe 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -96,8 +96,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 +151,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) { diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index fed07ecf3..55513ccb8 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -104,9 +104,9 @@ 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? document->add_resource("fepointlight", object); @@ -211,9 +211,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) { diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 03a0c7f96..fcc6c697a 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -120,11 +120,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 +250,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) { diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 613763751..6e0c0cbd0 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -114,14 +114,14 @@ 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? document->add_resource("fespotlight", object); @@ -309,14 +309,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) { diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index eed056ecc..8c2d0387e 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -100,11 +100,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"); } /** diff --git a/src/forward.h b/src/forward.h index 0388f8f63..41365611a 100644 --- a/src/forward.h +++ b/src/forward.h @@ -54,15 +54,14 @@ GType sp_document_get_type (); /* Objects */ -class SPObject; -class SPObjectClass; +//class SPObject; +//class SPObjectClass; -#define SP_TYPE_OBJECT (sp_object_get_type ()) -#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) -#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) -#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) +//#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) +//#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) +//#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) -GType sp_object_get_type (); +//GType sp_object_get_type (); //class SPItem; //class SPItemClass; diff --git a/src/interface.cpp b/src/interface.cpp index a535ed1bd..4b95e8de6 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1231,7 +1231,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 ); diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index aa916318d..a77b9817a 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -104,7 +104,7 @@ 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); diff --git a/src/marker.cpp b/src/marker.cpp index 979ca3011..376b4fa28 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -141,14 +141,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); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 4b2e55b9d..60bfa765a 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -116,10 +116,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); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7b0f353ab..8b4db3e25 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1374,7 +1374,7 @@ 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(SP_OBJECT(item), "transform"); + SP_OBJECT(item)->readAttr( "transform"); } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the so that the flow remains // the same (even though the output itself gets transformed) @@ -1392,7 +1392,7 @@ 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(SP_OBJECT(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(SP_OBJECT_PARENT(item))->i2d_affine(); diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index 379ddbb7c..9a5e8b1c1 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -89,14 +89,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) diff --git a/src/sp-animation.cpp b/src/sp-animation.cpp index 2d9f2e941..85fa615de 100644 --- a/src/sp-animation.cpp +++ b/src/sp-animation.cpp @@ -89,18 +89,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 +176,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 diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index a36d9b443..63e617551 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -104,7 +104,7 @@ sp_clippath_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, "clipPathUnits"); + object->readAttr( "clipPathUnits"); /* Register ourselves */ document->add_resource("clipPath", object); diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 24c7e7e5c..21ecf6b43 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -79,12 +79,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"); } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 86b6106c5..b5f0bdab6 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -433,10 +433,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 * @@ -581,9 +581,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 * @@ -706,14 +706,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"); } /* diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index 7cf0a38bb..4ce0e133d 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -99,8 +99,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 +164,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) { diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 2464b73a5..e65a7be05 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -136,14 +136,14 @@ 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? document->add_resource("filter", object); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 2d1f61a29..4c3cc8a6c 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -230,7 +230,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 diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 20419a8e5..a5894f83a 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -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) { diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 4f8bbef6e..a1a2c425f 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -101,12 +101,12 @@ 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"); document->add_resource("font", object); } @@ -232,12 +232,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) { diff --git a/src/sp-gaussian-blur.cpp b/src/sp-gaussian-blur.cpp index e6eab5032..7182e5ce9 100644 --- a/src/sp-gaussian-blur.cpp +++ b/src/sp-gaussian-blur.cpp @@ -100,7 +100,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 +143,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) { diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index 93996d8bc..2efdedf7a 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -110,11 +110,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 +216,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) { diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 203163b29..a2a5c7fcd 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -90,16 +90,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 +250,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) { diff --git a/src/sp-gradient-test.h b/src/sp-gradient-test.h index 209bc7efb..62c0ac8c2 100644 --- a/src/sp-gradient-test.h +++ b/src/sp-gradient-test.h @@ -56,13 +56,13 @@ public: SPGradient *gr = static_cast(g_object_new(SP_TYPE_GRADIENT, NULL)); SP_OBJECT(gr)->document = _doc; - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)"); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)"); TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Matrix(Geom::Translate(5, 8)) ); - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, ""); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, ""); TS_ASSERT_EQUALS( gr->gradientTransform, Geom::identity() ); - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "rotate(90)"); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "rotate(90)"); TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Matrix(rotate_degrees(90)) ); g_object_unref(gr); @@ -74,7 +74,7 @@ public: SPGradient *gr = static_cast(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 +136,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 ); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 604da3b7c..56ddd09d9 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -141,10 +141,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"); } /** @@ -168,7 +168,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 +177,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 +186,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 { @@ -200,7 +200,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; } @@ -299,7 +299,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); } @@ -319,7 +319,7 @@ static SPColor sp_stop_get_color(SPStop const *const stop) { if (stop->currentColor) { - char const *str = sp_object_get_style_property(stop, "color", NULL); + char const *str = stop->getStyleProperty( "color", NULL); guint32 const dfl = 0; /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial * value depends on user agent, and don't give any further restrictions that I can @@ -433,10 +433,10 @@ void SPGradientImpl::build(SPObject *object, SPDocument *document, Inkscape::XML } } - 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"); + object->readAttr( "gradientUnits"); + object->readAttr( "gradientTransform"); + object->readAttr( "spreadMethod"); + object->readAttr( "xlink:href"); /* Register ourselves */ document->add_resource("gradient", object); @@ -1492,10 +1492,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"); } /** @@ -1769,11 +1769,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"); } /** diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 955d4fedc..e43c3056d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -158,8 +158,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) diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 33038d73c..ae7ac6fa3 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -637,13 +637,13 @@ 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 */ document->add_resource ("image", object); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 79a673e05..5b15ca326 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -145,7 +145,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); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 7f67caee8..ae77f9d84 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -405,16 +405,16 @@ void SPItem::lowerToBottom() { 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 *) (SPItemClass::static_parent_class))->build) { (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr); @@ -1405,8 +1405,8 @@ SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set) void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) { - g_return_if_fail(this != NULL); - g_return_if_fail(SP_IS_ITEM(this)); + //g_return_if_fail(this != NULL); + //g_return_if_fail(SP_IS_ITEM(this)); g_return_if_fail(repr != NULL); // calculate the relative transform, if not given by the adv attribute diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 878fceb67..6d3d2aea7 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -104,10 +104,10 @@ SPLine::sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML:: ((SPObjectClass *) SPLineClass::static_parent_class)->build (object, document, repr); } - sp_object_read_attr (object, "x1"); - sp_object_read_attr (object, "y1"); - sp_object_read_attr (object, "x2"); - sp_object_read_attr (object, "y2"); + object->readAttr( "x1"); + object->readAttr( "y1"); + object->readAttr( "x2"); + object->readAttr( "y2"); } void diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 6c49b79c1..655c4b27e 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -137,7 +137,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); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 0c28cd014..26ddfa009 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -104,8 +104,8 @@ 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 */ document->add_resource ("mask", object); diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index d15000fcb..9833a6995 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -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) diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 52c42866e..7c974802e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -217,53 +217,53 @@ 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, "viewonly"); - sp_object_read_attr(object, "showguides"); - sp_object_read_attr(object, "showgrid"); - sp_object_read_attr(object, "gridtolerance"); - sp_object_read_attr(object, "guidetolerance"); - sp_object_read_attr(object, "objecttolerance"); - sp_object_read_attr(object, "guidecolor"); - sp_object_read_attr(object, "guideopacity"); - sp_object_read_attr(object, "guidehicolor"); - sp_object_read_attr(object, "guidehiopacity"); - sp_object_read_attr(object, "showborder"); - sp_object_read_attr(object, "inkscape:showpageshadow"); - sp_object_read_attr(object, "borderlayer"); - sp_object_read_attr(object, "bordercolor"); - sp_object_read_attr(object, "borderopacity"); - sp_object_read_attr(object, "pagecolor"); - sp_object_read_attr(object, "inkscape:pageopacity"); - sp_object_read_attr(object, "inkscape:pageshadow"); - sp_object_read_attr(object, "inkscape:zoom"); - sp_object_read_attr(object, "inkscape:cx"); - sp_object_read_attr(object, "inkscape:cy"); - sp_object_read_attr(object, "inkscape:window-width"); - sp_object_read_attr(object, "inkscape:window-height"); - sp_object_read_attr(object, "inkscape:window-x"); - sp_object_read_attr(object, "inkscape:window-y"); - sp_object_read_attr(object, "inkscape:window-maximized"); - sp_object_read_attr(object, "inkscape:snap-global"); - sp_object_read_attr(object, "inkscape:snap-bbox"); - sp_object_read_attr(object, "inkscape:snap-nodes"); - sp_object_read_attr(object, "inkscape:snap-from-guide"); - sp_object_read_attr(object, "inkscape:snap-center"); - sp_object_read_attr(object, "inkscape:snap-smooth-nodes"); - sp_object_read_attr(object, "inkscape:snap-midpoints"); - sp_object_read_attr(object, "inkscape:snap-object-midpoints"); - sp_object_read_attr(object, "inkscape:snap-bbox-edge-midpoints"); - sp_object_read_attr(object, "inkscape:snap-bbox-midpoints"); - sp_object_read_attr(object, "inkscape:snap-to-guides"); - sp_object_read_attr(object, "inkscape:snap-grids"); - sp_object_read_attr(object, "inkscape:snap-intersection-paths"); - sp_object_read_attr(object, "inkscape:object-paths"); - sp_object_read_attr(object, "inkscape:object-nodes"); - sp_object_read_attr(object, "inkscape:bbox-paths"); - sp_object_read_attr(object, "inkscape:bbox-nodes"); - sp_object_read_attr(object, "inkscape:snap-page"); - sp_object_read_attr(object, "inkscape:current-layer"); - sp_object_read_attr(object, "inkscape:connector-spacing"); + object->readAttr( "inkscape:document-units"); + object->readAttr( "viewonly"); + object->readAttr( "showguides"); + object->readAttr( "showgrid"); + object->readAttr( "gridtolerance"); + object->readAttr( "guidetolerance"); + object->readAttr( "objecttolerance"); + object->readAttr( "guidecolor"); + object->readAttr( "guideopacity"); + object->readAttr( "guidehicolor"); + object->readAttr( "guidehiopacity"); + object->readAttr( "showborder"); + object->readAttr( "inkscape:showpageshadow"); + object->readAttr( "borderlayer"); + object->readAttr( "bordercolor"); + object->readAttr( "borderopacity"); + object->readAttr( "pagecolor"); + object->readAttr( "inkscape:pageopacity"); + object->readAttr( "inkscape:pageshadow"); + object->readAttr( "inkscape:zoom"); + object->readAttr( "inkscape:cx"); + object->readAttr( "inkscape:cy"); + object->readAttr( "inkscape:window-width"); + object->readAttr( "inkscape:window-height"); + object->readAttr( "inkscape:window-x"); + object->readAttr( "inkscape:window-y"); + object->readAttr( "inkscape:window-maximized"); + object->readAttr( "inkscape:snap-global"); + object->readAttr( "inkscape:snap-bbox"); + object->readAttr( "inkscape:snap-nodes"); + object->readAttr( "inkscape:snap-from-guide"); + object->readAttr( "inkscape:snap-center"); + object->readAttr( "inkscape:snap-smooth-nodes"); + object->readAttr( "inkscape:snap-midpoints"); + object->readAttr( "inkscape:snap-object-midpoints"); + object->readAttr( "inkscape:snap-bbox-edge-midpoints"); + object->readAttr( "inkscape:snap-bbox-midpoints"); + object->readAttr( "inkscape:snap-to-guides"); + object->readAttr( "inkscape:snap-grids"); + object->readAttr( "inkscape:snap-intersection-paths"); + object->readAttr( "inkscape:object-paths"); + object->readAttr( "inkscape:object-nodes"); + object->readAttr( "inkscape:bbox-paths"); + object->readAttr( "inkscape:bbox-nodes"); + object->readAttr( "inkscape:snap-page"); + object->readAttr( "inkscape:current-layer"); + object->readAttr( "inkscape:connector-spacing"); /* Construct guideline list */ for (SPObject *o = SP_OBJECT(og)->first_child() ; o != NULL; o = SP_OBJECT_NEXT(o) ) { @@ -920,7 +920,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() diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h index f3a80f83c..d1501fe3e 100644 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@ -13,7 +13,7 @@ */ #include "forward.h" - +#include "sp-object.h" namespace Inkscape { namespace XML { class Node; @@ -21,7 +21,7 @@ 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); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index f81d5bdb5..f23f374d4 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -75,7 +75,7 @@ using std::strstr; # define debug(f, a...) /**/ #endif -static void sp_object_class_init(SPObjectClass *klass); +/*static void sp_object_class_init(SPObjectClass *klass); static void sp_object_init(SPObject *object); static void sp_object_finalize(GObject *object); @@ -89,9 +89,9 @@ static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XM static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -/* Real handlers of repr signals */ +* Real handlers of repr signals */ -static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); +/*static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); @@ -100,16 +100,16 @@ static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XM static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); -static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); +static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid);*/ guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { - sp_object_repr_child_added, - sp_object_repr_child_removed, - sp_object_repr_attr_changed, - sp_object_repr_content_changed, - sp_object_repr_order_changed + SPObject::sp_object_repr_child_added, + SPObject::sp_object_repr_child_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 @@ -143,20 +143,22 @@ public: }; -static GObjectClass *parent_class; +//static GObjectClass *parent_class; + +GObjectClass * SPObjectClass::static_parent_class = 0; /** * Registers the SPObject class with Gdk and returns its type number. */ GType -sp_object_get_type(void) +SPObject::sp_object_get_type() { 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, @@ -171,34 +173,34 @@ 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)); @@ -234,8 +236,8 @@ 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; @@ -249,8 +251,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(); @@ -754,8 +756,8 @@ SPObject::get_child_by_repr(Inkscape::XML::Node *repr) * 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) { @@ -780,7 +782,7 @@ 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) { @@ -796,8 +798,8 @@ 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 = object->get_child_by_repr(child); @@ -812,7 +814,7 @@ 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 = object->get_child_by_repr(child); @@ -833,15 +835,15 @@ 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); @@ -918,6 +920,23 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns 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::releaseReferences() { g_assert(this->document); g_assert(this->repr); @@ -966,14 +985,14 @@ SPObject *SPObject::getNext() SPObject *SPObject::getPrev() { - return sp_object_prev(this); + return this->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); @@ -984,8 +1003,8 @@ sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *c /** * 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); @@ -999,8 +1018,8 @@ 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); @@ -1012,8 +1031,8 @@ 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); @@ -1102,13 +1121,13 @@ 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) +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); } } @@ -1116,33 +1135,33 @@ sp_object_set(SPObject *object, unsigned int key, gchar const *value) * Read value of key attribute from XML node into object. */ void -sp_object_read_attr(SPObject *object, gchar const *key) +SPObject::readAttr(gchar const *key) { - g_assert(object != NULL); - g_assert(SP_IS_OBJECT(object)); + //g_assert(object != NULL); + //g_assert(SP_IS_OBJECT(object)); g_assert(key != NULL); //XML Tree being used here. - g_assert(object->getRepr() != NULL); + 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->getRepr()->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 @@ -1154,8 +1173,8 @@ 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); @@ -1182,8 +1201,8 @@ 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); @@ -1448,8 +1467,9 @@ SPObject::emitModified(unsigned int flags) } gchar const * -sp_object_tagName_get(SPObject const *object, SPException *ex) +SPObject::getTagName(SPException *ex) const { + g_assert(repr != NULL); /* If exception is not clear, return */ if (!SP_EXCEPTION_IS_OK(ex)) { return NULL; @@ -1457,12 +1477,13 @@ sp_object_tagName_get(SPObject const *object, SPException *ex) /// \todo fixme: Exception if object is NULL? */ //XML Tree being used here. - return object->getRepr()->name(); + return getRepr()->name(); } gchar const * -sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex) +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; @@ -1470,35 +1491,36 @@ sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex /// \todo fixme: Exception if object is NULL? */ //XML Tree being used here. - return (gchar const *) object->getRepr()->attribute(key); + return (gchar const *) getRepr()->attribute(key); } void -sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex) +SPObject::setAttribute(gchar const *key, gchar const *value, SPException *ex) { + 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? */ //XML Tree being used here. - object->getRepr()->setAttribute(key, value, false); + getRepr()->setAttribute(key, value, false); } void -sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex) +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? */ //XML Tree being used here. - object->getRepr()->setAttribute(key, NULL, false); + getRepr()->setAttribute(key, NULL, false); } /* 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; @@ -1565,14 +1587,14 @@ sp_object_get_unique_id(SPObject *object, gchar const *id) * responsible for ascending the repr tree as necessary. */ gchar const * -sp_object_get_style_property(SPObject const *object, gchar const *key, gchar const *def) +SPObject::getStyleProperty(gchar const *key, gchar const *def) const { - 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); //XML Tree being used here. - gchar const *style = object->getRepr()->attribute("style"); + gchar const *style = getRepr()->attribute("style"); if (style) { size_t const len = strlen(key); char const *p; @@ -1595,12 +1617,12 @@ sp_object_get_style_property(SPObject const *object, gchar const *key, gchar con } //XML Tree being used here. - gchar const *val = object->getRepr()->attribute(key); + 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; @@ -1626,11 +1648,11 @@ SPObject::_requireSVGVersion(Inkscape::Version version) { * Returns previous object in sibling list or NULL. */ SPObject * -sp_object_prev(SPObject *child) +SPObject::prev() { - SPObject *parent = SP_OBJECT_PARENT(child); + SPObject *parent = SP_OBJECT_PARENT(this); for ( SPObject *i = parent->first_child(); i; i = SP_OBJECT_NEXT(i) ) { - if (SP_OBJECT_NEXT(i) == child) + if (SP_OBJECT_NEXT(i) == this) return i; } return NULL; diff --git a/src/sp-object.h b/src/sp-object.h index e1d49b041..61c69c3aa 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -15,6 +15,14 @@ /* 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) @@ -50,11 +58,10 @@ #define SP_OBJECT_DOCUMENT(o) (((SPObject *) (o))->document) #define SP_OBJECT_PARENT(o) (((SPObject *) (o))->parent) #define SP_OBJECT_NEXT(o) (((SPObject *) (o))->next) -#define SP_OBJECT_PREV(o) (sp_object_prev((SPObject *) (o))) +#define SP_OBJECT_PREV(o) (((SPObject *) (o))->prev()) #define SP_OBJECT_HREFCOUNT(o) (((SPObject *) (o))->hrefcount) #define SP_OBJECT_STYLE(o) (((SPObject *) (o))->style) - #include #include #include @@ -171,12 +178,14 @@ public: * Returns the XML representation of tree */ //Inkscape::XML::Node const* getRepr() const; +//protected: Inkscape::XML::Node * getRepr(); /** * Returns the XML representation of tree */ Inkscape::XML::Node const* getRepr() const; +public: /** @brief cleans up an SPObject, releasing its references and * requesting that references to it be released @@ -519,6 +528,17 @@ public: return firstChild(); } void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); + long long int getIntAttribute(char const *key, long long int def); + unsigned getPosition(); + gchar const * getAttribute(gchar const *name,SPException *ex=0) const; + void appendChild(Inkscape::XML::Node *child); + void setKeyValue(unsigned int key, gchar const *value); + void setAttribute(gchar const *key, gchar const *value, SPException *ex=0); + void readAttr(gchar const *key); + gchar const *getTagName(SPException *ex) const; + void removeAttribute(gchar const *key, SPException *ex=0); + gchar const *getStyleProperty(gchar const *key, gchar const *def) const; + SPObject *prev(); private: // Private member functions used in the definitions of setTitle(), @@ -528,11 +548,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); @@ -554,6 +604,12 @@ 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); + + private: + static GObjectClass *static_parent_class; + static void sp_object_class_init(SPObjectClass *klass); + + friend class SPObject; }; @@ -572,25 +628,25 @@ struct SPObjectClass { //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_set(SPObject *object, unsigned int key, gchar const *value); -void sp_object_read_attr(SPObject *object, gchar const *key); +//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); +//gchar const *sp_object_tagName_get(SPObject const *object, SPException *ex); +//gchar const *sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex); +//void sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex); +//void sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex); /* Style */ -gchar const *sp_object_get_style_property(SPObject const *object, - gchar const *key, gchar const *def); +//gchar const *sp_object_get_style_property(SPObject const *object, +// gchar const *key, gchar const *def); int sp_object_compare_position(SPObject const *first, SPObject const *second); -SPObject *sp_object_prev(SPObject *child); +//SPObject *sp_object_prev(SPObject *child); #endif // SP_OBJECT_H_SEEN diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index ff915c92f..fdff5d7b6 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -219,7 +219,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep //XML Tree being used directly here while it shouldn't be. if (object->getRepr()->attribute("inkscape:radius")) { - sp_object_read_attr (object, "inkscape:radius"); + object->readAttr( "inkscape:radius"); } else { @@ -229,19 +229,19 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep 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->getRepr()->attribute("inkscape:original")) { - sp_object_read_attr (object, "inkscape:original"); + object->readAttr( "inkscape:original"); } else { 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->getRepr()->attribute("xlink:href")) { - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "xlink:href"); } else { gchar const *oldA = object->getRepr()->attribute("inkscape:href"); if (oldA) { @@ -254,7 +254,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep free(nA); object->getRepr()->setAttribute("inkscape:href",NULL); } - sp_object_read_attr (object, "xlink:href"); + object->readAttr( "xlink:href"); } } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 39ed4c657..5a0ff7c08 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -214,10 +214,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 +225,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"), ""); } } diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 3958da66a..779edc3e8 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -156,15 +156,15 @@ 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 */ document->add_resource ("pattern", object); diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 014c68c9b..b947e45ec 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -84,7 +84,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"); } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 110fb4d01..b5eb81a11 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -89,7 +89,7 @@ SPPolyLine::sp_polyline_build (SPObject * object, SPDocument * document, Inkscap 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"); } void diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index f4993cdc9..4e417f35b 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -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 diff --git a/src/sp-root.cpp b/src/sp-root.cpp index e73e83a7f..ad43bb3db 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -151,16 +151,16 @@ sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) 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); diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 614187013..6cf120a65 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -83,7 +83,7 @@ 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"); document->add_resource("script", object); } diff --git a/src/sp-skeleton.cpp b/src/sp-skeleton.cpp index ec6c9b437..f67341826 100644 --- a/src/sp-skeleton.cpp +++ b/src/sp-skeleton.cpp @@ -110,18 +110,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"); */ } diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index fd44cc4ba..3acc34d2a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -129,13 +129,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"); } /** diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 618d4520e..0d74cf780 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -118,16 +118,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 * diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 38dc1d367..9b096c861 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -56,16 +56,16 @@ public: SPStyleElem *style_elem = static_cast(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); SP_OBJECT(style_elem)->document = _doc; - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "something unrecognized"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "something unrecognized"); TS_ASSERT( !style_elem->is_css ); - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/css"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css"); TS_ASSERT( style_elem->is_css ); - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "atext/css"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "atext/css"); TS_ASSERT( !style_elem->is_css ); - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/cssx"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/cssx"); TS_ASSERT( !style_elem->is_css ); g_object_unref(style_elem); @@ -82,7 +82,7 @@ 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); { diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index bb4ccb2e1..68d8e8870 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -390,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 diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 0dab82bc9..262cfa6a0 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -110,8 +110,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); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index e3e919796..dcf9160ff 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -149,16 +149,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 diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 850ebbd42..ef9c89486 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -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"); } /** diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index a7391ac98..8cddc6e5e 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -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); @@ -392,13 +392,13 @@ sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { //SPTextPath *textpath = SP_TEXTPATH(object); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - sp_object_read_attr(object, "startOffset"); - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "dx"); + object->readAttr( "dy"); + object->readAttr( "rotate"); + object->readAttr( "startOffset"); + object->readAttr( "xlink:href"); bool no_content=true; for (Inkscape::XML::Node* rch = repr->firstChild() ; rch != NULL; rch = rch->next()) { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 3770b2324..075c7f804 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -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, @@ -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; diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index 571698fd2..46a1e8941 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -13,7 +13,7 @@ #include #include "forward.h" - +#include "sp-object.h" /* Append object-specific part to context menu */ void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu); diff --git a/src/uri-references.h b/src/uri-references.h index a98c84153..e6399bfd9 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -18,6 +18,7 @@ #include "bad-uri-exception.h" #include "forward.h" +#include "sp-object.h" namespace Inkscape { diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 33f2a6ae7..6aa2a1ed5 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -17,6 +17,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" diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 29e735536..6da23a696 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -7893,7 +7893,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; @@ -7941,7 +7941,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; -- cgit v1.2.3 From cde0571b44ec5b108907bda85971c49f3ceb1de8 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Wed, 14 Jul 2010 23:40:35 +0530 Subject: SPShape c++ified to the extent it was possible and more changes done for XML privatisation. Major changes yet to come. (bzr r9546.1.7) --- src/box3d-context.cpp | 36 ++++++- src/box3d-side.cpp | 21 ++-- src/box3d-side.h | 2 +- src/conn-avoid-ref.cpp | 2 +- src/extension/internal/odf.cpp | 2 +- src/knotholder.cpp | 4 +- src/live_effects/effect.cpp | 2 +- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/parameter/path.cpp | 2 +- src/lpe-tool-context.cpp | 4 +- src/path-chemistry.cpp | 2 +- src/sp-conn-end.cpp | 2 +- src/sp-ellipse.cpp | 10 +- src/sp-flowregion.cpp | 2 +- src/sp-item-group.cpp | 4 +- src/sp-line.cpp | 4 +- src/sp-offset.cpp | 16 +-- src/sp-path.cpp | 10 +- src/sp-polygon.cpp | 4 +- src/sp-polyline.cpp | 2 +- src/sp-rect.cpp | 6 +- src/sp-shape.cpp | 192 ++++++++++++++++++------------------ src/sp-shape.h | 68 ++++++++++--- src/sp-spiral.cpp | 8 +- src/sp-star.cpp | 8 +- src/sp-use-reference.cpp | 2 +- src/spiral-context.cpp | 2 +- src/splivarot.cpp | 16 +-- src/star-context.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 2 +- 30 files changed, 257 insertions(+), 182 deletions(-) (limited to 'src') diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 354fa1234..e48f7e17d 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -573,7 +573,8 @@ 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 = SP_EVENT_CONTEXT(&bc)->desktop; + SPDesktop *desktop = bc.desktop; if (!bc.item) { @@ -582,7 +583,12 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) } /* Create object */ - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc)); + + /* Remove convoluted code. */ + //Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc)); + + /*To be removed for directly accessing the XML Document*/ + Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc; Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); repr->setAttribute("sodipodi:type", "inkscape:box3d"); @@ -598,7 +604,8 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) repr_side->setAttribute("sodipodi:type", "inkscape:box3dside"); repr->addChild(repr_side, NULL); - Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side)); + //Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side)); + Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side)); guint desc = Box3D::int_to_face(i); @@ -609,7 +616,28 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8); /* Set style */ - box3d_side_apply_style(side); + /* Removed the faulty usage */ + //box3d_side_apply_style(side); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + 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)); + sp_desktop_apply_style_tool (desktop, side->getRepr(), pstring->str, false); + } + SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description } diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index be6d47db7..9059e9705 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -117,7 +117,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); + ((SPShape *) object)->setShape (); /* Duplicate the path */ SPCurve const *curve = ((SPShape *) object)->curve; @@ -179,7 +179,7 @@ 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); + ((SPShape *) object)->setShape (); } if (((SPObjectClass *) parent_class)->update) @@ -251,19 +251,24 @@ box3d_side_set_shape (SPShape *shape) /* Reset the shape'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ - sp_shape_set_curve_insync (shape, c, TRUE); + shape->setCurveInsync( c, TRUE); if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) { SPCurve *c_lpe = c->copy(); bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe); if (success) { - sp_shape_set_curve_insync (shape, c_lpe, TRUE); + shape->setCurveInsync( c_lpe, TRUE); } c_lpe->unref(); } c->unref(); } -void +/* removed to be merged into box3d-context function sp_box3d_drag + * so as to remove the faulty mehcanism of accessing a parent's/base + * level class members from a derived subclass. + */ + +/*void box3d_side_apply_style (Box3DSide *side) { Inkscape::XML::Node *repr_face = SP_OBJECT_REPR(SP_OBJECT(side)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -276,15 +281,15 @@ box3d_side_apply_style (Box3DSide *side) { SPDesktop *desktop = inkscape_active_desktop(); bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false); if (use_current && !cur_style.empty()) { - /* use last used style */ + // use last used style repr_face->setAttribute("style", cur_style.data()); } else { - /* use default style */ + // use default style GString *pstring = g_string_new(""); g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side)); sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false); } -} +}*/ gchar * box3d_side_axes_string(Box3DSide *side) diff --git a/src/box3d-side.h b/src/box3d-side.h index ba1431fab..6014ddaae 100644 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@ -41,7 +41,7 @@ struct Box3DSideClass { GType box3d_side_get_type (void); void box3d_side_position_set (Box3DSide *side); // FIXME: Replace this by box3d_side_set_shape?? -void box3d_side_apply_style (Box3DSide *side); +//void box3d_side_apply_style (Box3DSide *side); gchar *box3d_side_axes_string(Box3DSide *side); Persp3D *box3d_side_perspective(Box3DSide *side); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index ed2aceb82..fd37fceed 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -484,7 +484,7 @@ static std::vector 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) { diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index aadb9ee17..bf8a70a14 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -2002,7 +2002,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)) { diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 6778e9ad8..23d610ad0 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -122,7 +122,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(); @@ -171,7 +171,7 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) } if (SP_IS_SHAPE (item)) { - sp_shape_set_shape(SP_SHAPE (item)); + SP_SHAPE (item)->setShape(); } this->update_knots(); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 6266fade0..2cc26e4e1 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -518,7 +518,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()); } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index a2476a098..d43213fe9 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -498,7 +498,7 @@ void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &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(); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index af4f84f59..bdbe126e2 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -366,7 +366,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(); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 8eafa1711..1459cb460 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -472,7 +472,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 > pwd2 = paths_to_pw(curve->get_pathvector()); canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), ""); if (!show) @@ -514,7 +514,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc) std::map::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 > pwd2 = Geom::paths_to_pw(curve->get_pathvector()); SPUnitId unitid = static_cast(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); SPUnit unit = sp_unit_get_by_id(unitid); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 639c7fa00..12913fd85 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -534,7 +534,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) diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 3ad6954a2..07dd852f2 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -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) diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index b5f0bdab6..7eb473d03 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -153,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); + ((SPShape *) object)->setShape(); } if (((SPObjectClass *) ge_parent_class)->update) @@ -190,7 +190,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; @@ -257,12 +257,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(); } @@ -855,7 +855,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) diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 29ee05f5e..cff7a5db7 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -520,7 +520,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 (); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 5b15ca326..56b9dbc21 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -858,12 +858,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); diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 6d3d2aea7..b29e51b5a 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -158,7 +158,7 @@ SPLine::sp_line_update (SPObject *object, SPCtx *ctx, guint flags) line->y1.update(em, ex, h); line->y2.update(em, ex, h); - sp_shape_set_shape ((SPShape *) object); + ((SPShape *) object)->setShape (); } if (((SPObjectClass *) SPLineClass::static_parent_class)->update) @@ -244,7 +244,7 @@ SPLine::sp_line_set_shape (SPShape *shape) 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(); } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index fdff5d7b6..449d7d44d 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -283,7 +283,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)); } @@ -410,7 +410,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; @@ -465,7 +465,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(); } return; @@ -714,7 +714,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); @@ -954,11 +954,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; } @@ -1082,7 +1082,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 @@ -1100,7 +1100,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; } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 5a0ff7c08..d98647b11 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -279,11 +279,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; @@ -425,7 +425,7 @@ g_message("sp_path_update_patheffect"); SPCurve *curve = path->original_curve->copy(); /* if a path does not have an lpeitem applied, then reset the curve to the original_curve. * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ - sp_shape_set_curve_insync(shape, curve, TRUE); + shape->setCurveInsync(curve, TRUE); bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM(shape), curve); if (success && write) { @@ -446,7 +446,7 @@ 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 +505,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(); } } diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index b947e45ec..d5e10e10f 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -116,7 +116,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 +209,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; } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index b5eb81a11..5bf40352d 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -141,7 +141,7 @@ SPPolyLine::sp_polyline_set (SPObject *object, unsigned int key, const gchar *va } } - sp_shape_set_curve (SP_SHAPE (polyline), curve, TRUE); + (SP_SHAPE (polyline))->setCurve (curve, TRUE); curve->unref(); break; } diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 4e417f35b..5b75269dc 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -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(); } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 8e8e22272..3b3e1108b 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -54,7 +54,7 @@ #define noSHAPE_VERBOSE -static void sp_shape_class_init (SPShapeClass *klass); +/*static void sp_shape_class_init (SPShapeClass *klass); static void sp_shape_init (SPShape *shape); static void sp_shape_finalize (GObject *object); @@ -66,28 +66,30 @@ static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); static void sp_shape_modified (SPObject *object, unsigned int flags); static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); +static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);*/ void sp_shape_print (SPItem * item, SPPrintContext * ctx); -static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +/*static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_shape_hide (SPItem *item, unsigned int key); static void sp_shape_snappoints (SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai); -static SPLPEItemClass *parent_class; +static SPLPEItemClass *parent_class;*/ + +SPLPEItemClass * SPShapeClass::parent_class=0; /** * Registers the SPShape class with Gdk and returns its type number. */ GType -sp_shape_get_type (void) +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, @@ -103,8 +105,8 @@ 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); @@ -113,20 +115,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; @@ -135,8 +137,8 @@ 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(); @@ -146,8 +148,8 @@ 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; @@ -158,8 +160,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); } } @@ -170,11 +172,11 @@ 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++) { @@ -192,8 +194,8 @@ 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; @@ -217,26 +219,26 @@ 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; @@ -246,14 +248,14 @@ 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 @@ -293,7 +295,7 @@ 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) { @@ -303,7 +305,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) 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)); } } } @@ -402,8 +404,8 @@ 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; @@ -511,13 +513,13 @@ 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) { @@ -531,7 +533,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) { @@ -585,7 +587,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)) { + if (shape->hasMarkers ()) { /** \todo make code prettier! */ Geom::PathVector const & pathv = shape->curve->get_pathvector(); // START marker @@ -871,8 +873,8 @@ 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); @@ -895,7 +897,7 @@ 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) { @@ -906,7 +908,7 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int 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)); } } @@ -920,8 +922,8 @@ 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; @@ -940,8 +942,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); } } @@ -950,18 +952,18 @@ sp_shape_hide (SPItem *item, unsigned int key) * \return TRUE if the shape has any markers, or FALSE if not. */ int -sp_shape_has_markers (SPShape const *shape) +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]) ); } @@ -972,9 +974,9 @@ sp_shape_has_markers (SPShape const *shape) * \return Number of markers that the shape has of this type. */ int -sp_shape_number_of_markers (SPShape *shape, int type) +SPShape::numberOfMarkers (int type) { - Geom::PathVector const & pathv = shape->curve->get_pathvector(); + Geom::PathVector const & pathv = this->curve->get_pathvector(); if (pathv.size() == 0) { return 0; } @@ -982,7 +984,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; @@ -994,11 +996,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; @@ -1012,7 +1014,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: @@ -1113,13 +1115,13 @@ 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) +SPShape::setShape () { - g_return_if_fail (shape != NULL); - g_return_if_fail (SP_IS_SHAPE (shape)); + //g_return_if_fail (shape != NULL); + //g_return_if_fail (SP_IS_SHAPE (shape)); - if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape) { - SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape (shape); + if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape) { + SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape (this); } } @@ -1130,29 +1132,29 @@ sp_shape_set_shape (SPShape *shape) * This routine also triggers a request to update the display. */ void -sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner) +SPShape::setCurve (SPCurve *curve, unsigned int owner) { - if (shape->curve) { - shape->curve = shape->curve->unref(); + if (this->curve) { + this->curve = this->curve->unref(); } if (curve) { if (owner) { - shape->curve = curve->ref(); + this->curve = curve->ref(); } else { - shape->curve = curve->copy(); + this->curve = curve->copy(); } } - SP_OBJECT(shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + SP_OBJECT(this)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ SPCurve * -sp_shape_get_curve (SPShape *shape) +SPShape::getCurve () { - if (shape->curve) { - return shape->curve->copy(); + if (this->curve) { + return this->curve->copy(); } return NULL; } @@ -1161,16 +1163,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) +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(); } } } @@ -1178,7 +1180,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 &p, Inkscape::SnapPreferences const *snapprefs) +void SPShape::sp_shape_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) { g_assert(item != NULL); g_assert(SP_IS_SHAPE(item)); diff --git a/src/sp-shape.h b/src/sp-shape.h index 4b1ded236..0a3b3e37f 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -21,7 +21,7 @@ #include -#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)) @@ -31,38 +31,78 @@ struct SPDesktop; -struct SPShape : public SPLPEItem { - SPCurve *curve; +//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); + private: + static void sp_shape_init (SPShape *shape); + static void sp_shape_finalize (GObject *object); + + static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); + static void sp_shape_release (SPObject *object); + + static void sp_shape_set(SPObject *object, unsigned key, gchar const *value); + static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); + static void sp_shape_modified (SPObject *object, unsigned int flags); + static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + + static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); + static 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 &p, Inkscape::SnapPreferences const *snapprefs); + + static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai); + + + + friend class SPShapeClass; }; -struct SPShapeClass { +//struct 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; }; -GType sp_shape_get_type (void); +//GType sp_shape_get_type (void); -void sp_shape_set_shape (SPShape *shape); +//void sp_shape_set_shape (SPShape *shape); /* Return duplicate of curve or NULL */ -SPCurve *sp_shape_get_curve (SPShape *shape); +//SPCurve *sp_shape_get_curve (SPShape *shape); // sets a curve, updates display -void sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner); +//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); +//void sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner); // markers API void sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value); -int sp_shape_has_markers (SPShape const *shape); -int sp_shape_number_of_markers (SPShape* Shape, int type); +//int sp_shape_has_markers (SPShape const *shape); +//int sp_shape_number_of_markers (SPShape* Shape, int type); Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2); Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 3acc34d2a..499500c44 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -287,7 +287,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 +427,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 +470,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(); } diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 0d74cf780..b956019d4 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -270,7 +270,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 +439,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 +509,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(); } diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp index 914e416b3..a05dc0e93 100644 --- a/src/sp-use-reference.cpp +++ b/src/sp-use-reference.cpp @@ -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; } diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 3d1cd4b21..13407b80b 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -474,7 +474,7 @@ 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); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index d9ac792b3..b2fe45e19 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -667,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(); } @@ -782,7 +782,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(); @@ -891,7 +891,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; } @@ -1075,7 +1075,7 @@ 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::Node *g_repr = xml_doc->createElement("svg:g"); @@ -1308,7 +1308,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; } @@ -1537,7 +1537,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; } @@ -1779,7 +1779,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; } @@ -2112,7 +2112,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)) diff --git a/src/star-context.cpp b/src/star-context.cpp index 2761c573a..61646ceee 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -492,7 +492,7 @@ 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); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index ba82b810b..f102be1f7 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1250,7 +1250,7 @@ void PathManipulator::_setGeometry() 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); } } -- cgit v1.2.3 From 150ac8ed3274e060e3349b5c0901ec8c7c7e3d4e Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Sat, 17 Jul 2010 12:48:31 +0530 Subject: More in XML privatisation with new create3DBox function and other supplements to efficiently hide information. (bzr r9546.1.8) --- src/box3d-context.cpp | 36 ++++++++++++++++++++---------------- src/box3d-side.cpp | 12 ++++++++++++ src/box3d-side.h | 1 + src/box3d.cpp | 12 ++++++++++++ src/box3d.h | 1 + src/desktop.cpp | 22 ++++++++++++++++++++++ src/desktop.h | 2 ++ 7 files changed, 70 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index e48f7e17d..99cf28963 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -588,25 +588,28 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) //Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc)); /*To be removed for directly accessing the XML Document*/ - Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc; - Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); - repr->setAttribute("sodipodi:type", "inkscape:box3d"); - + //Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc; + //Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); + //repr->setAttribute("sodipodi:type", "inkscape:box3d"); + SPBox3D *box3d = 0; + box3d = SPBox3D::createBox3D((SPItem *)desktop->currentLayer()); /* Set style */ - sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/3dbox", false); - - bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); - Inkscape::GC::release(repr); - Inkscape::XML::Node *repr_side; + 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); + //repr_side = xml_doc->createElement("svg:path"); + //repr_side->setAttribute("sodipodi:type", "inkscape:box3dside"); + //repr->addChild(repr_side, NULL); //Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side)); - Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side)); - + //Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side)); + Box3DSide *side = Box3DSide::createBox3DSide(box3d); + guint desc = Box3D::int_to_face(i); Box3D::Axis plane = (Box3D::Axis) (desc & 0x7); @@ -635,11 +638,12 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) // 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, side->getRepr(), pstring->str, false); + desktop->applyCurrentOrToolStyle (side, pstring->str, false); } - SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description + //SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description + side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description } box3d_set_z_orders(SP_BOX3D(bc.item)); diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 9059e9705..d6f1f6b42 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -185,6 +185,18 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) if (((SPObjectClass *) parent_class)->update) ((SPObjectClass *) parent_class)->update (object, ctx, flags); } + +/* Create a new Box3DSide and append it to the parent box */ +Box3DSide * Box3DSide::createBox3DSide(SPBox3D *box) +{ + Box3DSide *box3d_side = 0; + Inkscape::XML::Document *xml_doc = box->document->rdoc; + Inkscape::XML::Node *repr_side = xml_doc->createElement("svg:path"); + repr_side->setAttribute("sodipodi:type", "inkscape:box3dside"); + box3d_side = (Box3DSide *)box->appendChildRepr(repr_side); + return box3d_side; +} + /* * Function which return the type attribute for Box3D. * Acts as a replacement for directly accessing the XML Tree directly. diff --git a/src/box3d-side.h b/src/box3d-side.h index 6014ddaae..29a4a6b00 100644 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@ -32,6 +32,7 @@ struct Box3DSide : public SPPolygon { Box3D::Axis dir2; Box3D::FrontOrRear front_or_rear; long long int getFaceId(); + static Box3DSide * createBox3DSide(SPBox3D *box); }; struct Box3DSideClass { diff --git a/src/box3d.cpp b/src/box3d.cpp index 1facf2c0c..250c1f500 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -511,6 +511,18 @@ 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); } +/*create a SPBox3D and append it to the parent*/ + +SPBox3D * SPBox3D::createBox3D(SPItem * parent) +{ + SPBox3D *box3d = 0; + Inkscape::XML::Document *xml_doc = parent->document->rdoc; + Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); + repr->setAttribute("sodipodi:type", "inkscape:box3d"); + box3d = (SPBox3D *)parent->appendChildRepr(repr); + return box3d; +} + 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)); diff --git a/src/box3d.h b/src/box3d.h index 182a312e1..e313f4285 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -45,6 +45,7 @@ class SPBox3D : public SPGroup { Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging gint my_counter; // for debugging only + static SPBox3D * createBox3D(SPItem * parent); }; class SPBox3DClass { diff --git a/src/desktop.cpp b/src/desktop.cpp index d5e7974ea..3f9fc7806 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -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" @@ -960,6 +961,27 @@ 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) { + sp_repr_css_set(obj->getRepr(), css_current, "style"); + } else { + SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style"); + sp_repr_css_set(obj->getRepr(), 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. */ diff --git a/src/desktop.h b/src/desktop.h index 00f6cfdd5..59ba3f957 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -324,6 +324,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; -- cgit v1.2.3 From 2290edeee46e7100363de0ac280ed79b0c5eb2d7 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Sun, 18 Jul 2010 08:55:41 +0530 Subject: I didn't see it but there was an important file missing namely document-undo.h (bzr r9546.1.9) --- src/document-undo.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/document-undo.h (limited to 'src') diff --git a/src/document-undo.h b/src/document-undo.h new file mode 100644 index 000000000..9fc49b112 --- /dev/null +++ b/src/document-undo.h @@ -0,0 +1,14 @@ +class SPDocumentUndo +{ + public: + static void set_undo_sensitive(SPDocument *doc, bool sensitive); + static bool get_undo_sensitive(SPDocument const *document); + static void clear_undo(SPDocument *document); + static void clear_redo(SPDocument *document); + static void done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); + static void maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); + static void reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); + static void cancel(SPDocument *document); + static gboolean undo(SPDocument *document); + static gboolean redo(SPDocument *document); +}; -- cgit v1.2.3 From 88fc01afa8ea80d5105961d9103cc8f33582e7fb Mon Sep 17 00:00:00 2001 From: Abhishek Sharma public Date: Tue, 20 Jul 2010 16:14:23 +0530 Subject: More on c++ification and some XML privatisation (bzr r9546.1.10) --- src/box3d-side.cpp | 6 ++- src/conditions.cpp | 5 +- src/conn-avoid-ref.cpp | 3 +- src/desktop.h | 3 +- src/forward.h | 8 +-- src/selection-chemistry.cpp | 2 +- src/sp-clippath.cpp | 121 ++++++++++++++++++++++---------------------- src/sp-clippath.h | 41 ++++++++++++--- src/sp-item.cpp | 18 +++---- 9 files changed, 120 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index d6f1f6b42..6838008bb 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -346,8 +346,10 @@ box3d_side_convert_to_path(Box3DSide *side) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); - repr->setAttribute("d", SP_OBJECT_REPR(side)->attribute("d")); - repr->setAttribute("style", SP_OBJECT_REPR(side)->attribute("style")); + //repr->setAttribute("d", SP_OBJECT_REPR(side)->attribute("d")); + repr->setAttribute("d", side->getAttribute("d")); + //repr->setAttribute("style", SP_OBJECT_REPR(side)->attribute("style")); + repr->setAttribute("style", side->getAttribute("style")); return repr; } diff --git a/src/conditions.cpp b/src/conditions.cpp index 4a18a6913..7087abac2 100644 --- a/src/conditions.cpp +++ b/src/conditions.cpp @@ -41,10 +41,11 @@ static Condition _condition_handlers[] = { /* function which evaluates if item should be displayed */ bool sp_item_evaluate(SPItem const *item) { - Inkscape::XML::Node *grepr = SP_OBJECT_REPR (item); + //Inkscape::XML::Node *grepr = SP_OBJECT_REPR (item); for ( unsigned int i = 0 ; i < sizeof(_condition_handlers)/sizeof(_condition_handlers[0]) ; i++ ) { - gchar const *value = grepr->attribute(_condition_handlers[i].attribute); + //gchar const *value = grepr->attribute(_condition_handlers[i].attribute); + gchar const *value = item->getAttribute(_condition_handlers[i].attribute); if ( NULL == value ) continue; diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index fd37fceed..3e8359c57 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -314,7 +314,8 @@ void SPAvoidRef::handleSettingChange(void) _transformed_connection = item->connectTransformed( sigc::ptr_fun(&avoid_item_move)); - const char *id = SP_OBJECT_REPR(item)->attribute("id"); + //const char *id = SP_OBJECT_REPR(item)->attribute("id"); + const char *id = item->getAttribute("id"); g_assert(id != NULL); // Get a unique ID for the item. diff --git a/src/desktop.h b/src/desktop.h index 59ba3f957..160a33558 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -84,8 +84,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; diff --git a/src/forward.h b/src/forward.h index 41365611a..e090b68b7 100644 --- a/src/forward.h +++ b/src/forward.h @@ -46,11 +46,11 @@ GType sp_event_context_get_type (); class SPDocument; class SPDocumentClass; -#define SP_TYPE_DOCUMENT (sp_document_get_type ()) -#define SP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DOCUMENT, SPDocument)) -#define SP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DOCUMENT)) +//#define SP_TYPE_DOCUMENT (sp_document_get_type ()) +//#define SP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DOCUMENT, SPDocument)) +//#define SP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DOCUMENT)) -GType sp_document_get_type (); +//GType sp_document_get_type (); /* Objects */ diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 8b4db3e25..7c93c5f07 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2970,7 +2970,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); } diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 63e617551..d074ef197 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -37,7 +37,7 @@ struct SPClipPathView { NRRect bbox; }; -static void sp_clippath_class_init(SPClipPathClass *klass); +/*static void sp_clippath_class_init(SPClipPathClass *klass); static void sp_clippath_init(SPClipPath *clippath); static void sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@ -46,22 +46,23 @@ static void sp_clippath_set(SPObject *object, unsigned int key, gchar const *val static void sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); static void sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_clippath_modified(SPObject *object, guint flags); -static Inkscape::XML::Node *sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static Inkscape::XML::Node *sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);*/ SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, NRArenaItem *arenaitem); SPClipPathView *sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); -static SPObjectGroupClass *parent_class; +//static SPObjectGroupClass *parent_class; +SPObjectGroupClass * SPClipPathClass::static_parent_class = 0; GType -sp_clippath_get_type(void) +SPClipPath::sp_clippath_get_type(void) { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPClipPathClass), NULL, NULL, - (GClassInitFunc) sp_clippath_class_init, + (GClassInitFunc) SPClipPathClass::sp_clippath_class_init, NULL, NULL, sizeof(SPClipPath), 16, @@ -73,24 +74,24 @@ sp_clippath_get_type(void) 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::sp_clippath_build; + sp_object_class->release = SPClipPath::sp_clippath_release; + sp_object_class->set = SPClipPath::sp_clippath_set; + sp_object_class->child_added = SPClipPath::sp_clippath_child_added; + sp_object_class->update = SPClipPath::sp_clippath_update; + sp_object_class->modified = SPClipPath::sp_clippath_modified; + sp_object_class->write = SPClipPath::sp_clippath_write; } -static void -sp_clippath_init(SPClipPath *cp) +void +SPClipPath::sp_clippath_init(SPClipPath *cp) { cp->clipPathUnits_set = FALSE; cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; @@ -98,11 +99,11 @@ sp_clippath_init(SPClipPath *cp) cp->display = NULL; } -static void -sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +void +SPClipPath::sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - 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); object->readAttr( "clipPathUnits"); @@ -110,8 +111,8 @@ sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r document->add_resource("clipPath", object); } -static void -sp_clippath_release(SPObject * object) +void +SPClipPath::sp_clippath_release(SPObject * object) { if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ @@ -124,13 +125,13 @@ 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::sp_clippath_set(SPObject *object, unsigned int key, gchar const *value) { SPClipPath *cp = SP_CLIPPATH(object); @@ -149,17 +150,17 @@ 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); + if (((SPObjectClass *) SPClipPathClass::static_parent_class)->set) + ((SPObjectClass *) SPClipPathClass::static_parent_class)->set(object, key, value); break; } } -static void -sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +void +SPClipPath::sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { /* 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); @@ -176,8 +177,8 @@ sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: } } -static void -sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) +void +SPClipPath::sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -214,8 +215,8 @@ sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void -sp_clippath_modified(SPObject *object, guint flags) +void +SPClipPath::sp_clippath_modified(SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -240,31 +241,31 @@ 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::sp_clippath_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) +SPClipPath::sp_clippath_show(NRArena *arena, unsigned int key) { - g_return_val_if_fail(cp != NULL, NULL); - g_return_val_if_fail(SP_IS_CLIPPATH(cp), NULL); + //g_return_val_if_fail(cp != NULL, NULL); + //g_return_val_if_fail(SP_IS_CLIPPATH(cp), NULL); g_return_val_if_fail(arena != NULL, NULL); g_return_val_if_fail(NR_IS_ARENA(arena), NULL); NRArenaItem *ai = NRArenaGroup::create(arena); - cp->display = sp_clippath_view_new_prepend(cp->display, key, ai); + this->display = sp_clippath_view_new_prepend(this->display, key, ai); - for (SPObject *child = SP_OBJECT(cp)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { + for (SPObject *child = this->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { NRArenaItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { @@ -274,10 +275,10 @@ 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 (this->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { + Geom::Matrix t(Geom::Scale(this->display->bbox.x1 - this->display->bbox.x0, this->display->bbox.y1 - this->display->bbox.y0)); + t[4] = this->display->bbox.x0; + t[5] = this->display->bbox.y0; nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), &t); } @@ -285,21 +286,21 @@ sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key) } void -sp_clippath_hide(SPClipPath *cp, unsigned int key) +SPClipPath::sp_clippath_hide(unsigned int key) { - g_return_if_fail(cp != NULL); - g_return_if_fail(SP_IS_CLIPPATH(cp)); + //g_return_if_fail(cp != NULL); + //g_return_if_fail(SP_IS_CLIPPATH(cp)); - for (SPObject *child = SP_OBJECT(cp)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { + for (SPObject *child = this->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { SP_ITEM(child)->invoke_hide(key); } } - for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { + for (SPClipPathView *v = this->display; v != NULL; v = v->next) { if (v->key == key) { /* We simply unref and let item to manage this in handler */ - cp->display = sp_clippath_view_list_remove(cp->display, v); + this->display = sp_clippath_view_list_remove(this->display, v); return; } } @@ -308,9 +309,9 @@ sp_clippath_hide(SPClipPath *cp, unsigned int key) } void -sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox) +SPClipPath::sp_clippath_set_bbox(unsigned int key, NRRect *bbox) { - for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { + for (SPClipPathView *v = this->display; v != NULL; v = v->next) { 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,10 +325,10 @@ 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*/) +SPClipPath::sp_clippath_get_bbox(NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { SPObject *i; - for (i = SP_OBJECT(cp)->first_child(); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; + for (i = this->first_child(); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; if (!i) return; SP_ITEM(i)->invoke_bbox_full( bbox, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); @@ -380,7 +381,7 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view) // Create a mask element (using passed elements), add it to const gchar * -sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform) +SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform) { Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 308c3c893..239dca049 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -13,7 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#define SP_TYPE_CLIPPATH (sp_clippath_get_type ()) +#define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type ()) #define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CLIPPATH, SPClipPath)) #define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CLIPPATH, SPClipPathClass)) #define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CLIPPATH)) @@ -27,20 +27,47 @@ class SPClipPathView; #include "uri-references.h" #include "xml/node.h" -struct SPClipPath : public SPObjectGroup { +class SPClipPath : public SPObjectGroup { + public: class Reference; unsigned int clipPathUnits_set : 1; unsigned int clipPathUnits : 1; SPClipPathView *display; + static const gchar *create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); + static GType sp_clippath_get_type (void); + + NRArenaItem *sp_clippath_show(NRArena *arena, unsigned int key); + void sp_clippath_hide(unsigned int key); + + void sp_clippath_set_bbox(unsigned int key, NRRect *bbox); + void sp_clippath_get_bbox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); + private: + static void sp_clippath_init(SPClipPath *clippath); + + 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); + + friend class SPClipPathClass; }; -struct SPClipPathClass { +class SPClipPathClass { + public: SPObjectGroupClass parent_class; + private: + static void sp_clippath_class_init(SPClipPathClass *klass); + static SPObjectGroupClass *static_parent_class; + + friend class SPClipPath; }; -GType sp_clippath_get_type (void); +//GType sp_clippath_get_type (void); class SPClipPathReference : public Inkscape::URIReference { public: @@ -87,12 +114,12 @@ protected: } }; -NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key); +/*NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key); void sp_clippath_hide(SPClipPath *cp, unsigned int key); void sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox); -void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); +void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);*/ -const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); +//const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); #endif diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ae77f9d84..fc605516d 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -563,7 +563,7 @@ SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) SPItemView *v; /* Hide clippath */ for (v = item->display; v != NULL; v = v->next) { - sp_clippath_hide(SP_CLIPPATH(old_clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + SP_CLIPPATH(old_clip)->sp_clippath_hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, NULL); } } @@ -574,12 +574,12 @@ SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) if (!v->arenaitem->key) { NR_ARENA_ITEM_SET_KEY(v->arenaitem, SPItem::display_key_new(3)); } - NRArenaItem *ai = sp_clippath_show(SP_CLIPPATH(clip), + NRArenaItem *ai = SP_CLIPPATH(clip)->sp_clippath_show( NR_ARENA_ITEM_ARENA(v->arenaitem), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, ai); nr_arena_item_unref(ai); - sp_clippath_set_bbox(SP_CLIPPATH(clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + SP_CLIPPATH(clip)->sp_clippath_set_bbox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); SP_OBJECT(clip)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -636,7 +636,7 @@ SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) item->invoke_bbox( &bbox, Geom::identity(), TRUE); if (clip_path) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_clippath_set_bbox(clip_path, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + clip_path->sp_clippath_set_bbox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); } } if (mask) { @@ -846,7 +846,7 @@ SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, un } if (this->clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(this->clip_ref->getObject()), &b, transform, flags); + SP_CLIPPATH(this->clip_ref->getObject())->sp_clippath_get_bbox(&b, transform, flags); nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b); } } @@ -899,7 +899,7 @@ SPItem::invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned // unless this is geometric bbox, crop the bbox by clip path, if any if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && this->clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(this->clip_ref->getObject()), &b, transform, flags); + SP_CLIPPATH(this->clip_ref->getObject())->sp_clippath_get_bbox(&b, transform, flags); nr_rect_d_intersect (&this_bbox, &this_bbox, &b); } @@ -1125,14 +1125,14 @@ SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) int clip_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); // Show and set clip - NRArenaItem *ac = sp_clippath_show(cp, arena, clip_key); + NRArenaItem *ac = cp->sp_clippath_show(arena, clip_key); nr_arena_item_set_clip(ai, ac); nr_arena_item_unref(ac); // Update bbox, in case the clip uses bbox units NRRect bbox; invoke_bbox( &bbox, Geom::identity(), TRUE); - sp_clippath_set_bbox(SP_CLIPPATH(cp), clip_key, &bbox); + SP_CLIPPATH(cp)->sp_clippath_set_bbox(clip_key, &bbox); SP_OBJECT(cp)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } if (mask_ref->getObject()) { @@ -1179,7 +1179,7 @@ SPItem::invoke_hide(unsigned key) SPItemView *next = v->next; if (v->key == key) { if (clip_ref->getObject()) { - sp_clippath_hide(clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + (clip_ref->getObject())->sp_clippath_hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, NULL); } if (mask_ref->getObject()) { -- cgit v1.2.3 From 7396564ea83c67c0e40a8b0aa453a13ddf21e0e0 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma public Date: Sat, 24 Jul 2010 20:58:27 +0530 Subject: Yet mor in c++ification (bzr r9546.1.11) --- src/filter-chemistry.cpp | 15 ++++++--- src/flood-context.cpp | 10 +++--- src/satisfied-guide-cns.cpp | 2 +- src/sp-defs.cpp | 39 ++++++++++++------------ src/sp-defs.h | 28 ++++++++++++++--- src/sp-guide.cpp | 43 +++++++++++++------------- src/sp-guide.h | 24 ++++++++++----- src/sp-item-rm-unsatisfied-cns.cpp | 2 +- src/sp-line.cpp | 2 +- src/sp-namedview.cpp | 13 ++++---- src/sp-object-group.cpp | 62 ++++++++++++++++++++------------------ src/sp-object-group.h | 29 +++++++++++++++--- src/sp-object.cpp | 7 +++++ src/sp-object.h | 1 + 14 files changed, 170 insertions(+), 107 deletions(-) (limited to 'src') diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 1f4e91c3b..9e0ee8383 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -101,7 +101,8 @@ SPFilter *new_filter(SPDocument *document) repr = xml_doc->createElement("svg:filter"); // Append the new filter node to defs - SP_OBJECT_REPR(defs)->appendChild(repr); + //SP_OBJECT_REPR(defs)->appendChild(repr); + defs->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@ -169,7 +170,8 @@ filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveT //set primitive as child of filter node // XML tree being used directly while/where it shouldn't be... - filter->getRepr()->appendChild(repr); + //filter->getRepr()->appendChild(repr); + filter->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@ -218,7 +220,8 @@ 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); + //SP_OBJECT_REPR(defs)->appendChild(repr); + defs->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@ -254,7 +257,8 @@ 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); + //SP_OBJECT_REPR(defs)->appendChild(repr); + defs->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@ -361,7 +365,8 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, Inkscape::XML::Node *repr; repr = SP_OBJECT_REPR(item->style->getFilter())->duplicate(xml_doc); SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); - SP_OBJECT_REPR(defs)->appendChild(repr); + //SP_OBJECT_REPR(defs)->appendChild(repr); + defs->appendChild(repr); filter = SP_FILTER( document->getObjectByRepr(repr) ); Inkscape::GC::release(repr); diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 5181809dc..b9aaf902e 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -418,7 +418,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto gray_map->destroy(gray_map); //XML Tree being used here directly while it shouldn't be...." - Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); + //Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); long totalNodeCount = 0L; @@ -482,7 +482,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto g_free(str); } - layer_repr->addChild(pathRepr, NULL); + //layer_repr->addChild(pathRepr, NULL); + desktop->currentLayer()->addChild(pathRepr,NULL); SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { @@ -1137,9 +1138,10 @@ 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); + //Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); /* Set style */ - sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); + //sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); + desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false); SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ret = TRUE; } diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp index dcf635989..f7f2bd7da 100644 --- a/src/satisfied-guide-cns.cpp +++ b/src/satisfied-guide-cns.cpp @@ -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)); } } diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 76cb2e1d9..b523322e1 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -20,7 +20,7 @@ #include "xml/repr.h" #include "document.h" -static void sp_defs_class_init(SPDefsClass *dc); +/*static void sp_defs_class_init(SPDefsClass *dc); static void sp_defs_init(SPDefs *defs); static void sp_defs_release(SPObject *object); @@ -28,9 +28,10 @@ static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_defs_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static SPObjectClass *parent_class; +static SPObjectClass *parent_class;*/ +SPObjectClass * SPDefsClass::static_parent_class = 0; -GType sp_defs_get_type(void) +GType SPDefs::sp_defs_get_type(void) { static GType defs_type = 0; @@ -39,7 +40,7 @@ GType sp_defs_get_type(void) sizeof(SPDefsClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_defs_class_init, + (GClassInitFunc) SPDefsClass::sp_defs_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof(SPDefs), @@ -53,30 +54,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::sp_defs_release; + sp_object_class->update = SPDefs::sp_defs_update; + sp_object_class->modified = SPDefs::sp_defs_modified; + sp_object_class->write = SPDefs::sp_defs_write; } -static void sp_defs_init(SPDefs */*defs*/) +void SPDefs::sp_defs_init(SPDefs */*defs*/) { } -static void sp_defs_release(SPObject *object) +void SPDefs::sp_defs_release(SPObject *object) { - if (((SPObjectClass *) (parent_class))->release) { - ((SPObjectClass *) (parent_class))->release(object); + if (((SPObjectClass *) (SPDefsClass::static_parent_class))->release) { + ((SPObjectClass *) (SPDefsClass::static_parent_class))->release(object); } } -static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags) +void SPDefs::sp_defs_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -95,7 +96,7 @@ static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void sp_defs_modified(SPObject *object, guint flags) +void SPDefs::sp_defs_modified(SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -121,7 +122,7 @@ static void sp_defs_modified(SPObject *object, guint flags) } } -static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * SPDefs::sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { @@ -147,8 +148,8 @@ static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Docum } } - if (((SPObjectClass *) (parent_class))->write) { - (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags); + if (((SPObjectClass *) (SPDefsClass::static_parent_class))->write) { + (* ((SPObjectClass *) (SPDefsClass::static_parent_class))->write)(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-defs.h b/src/sp-defs.h index 4b6f7a5b7..c88aef81e 100644 --- a/src/sp-defs.h +++ b/src/sp-defs.h @@ -14,20 +14,38 @@ #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 sp_defs_init(SPDefs *defs); + static void sp_defs_release(SPObject *object); + static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags); + static void sp_defs_modified(SPObject *object, guint flags); + static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + + friend class SPDefsClass; }; -struct SPDefsClass { - SPObjectClass parent_class; +class SPDefsClass { + public: + SPObjectClass parent_class; + + private: + static void sp_defs_class_init(SPDefsClass *dc); + static SPObjectClass *static_parent_class; + + friend class SPDefs; }; -GType sp_defs_get_type(void); +//GType sp_defs_get_type(void); #endif /* !SEEN_SP_DEFS_H */ diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index e43c3056d..21b350486 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -242,7 +242,7 @@ 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) { +SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { SPDocument *doc=sp_desktop_document(desktop); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); @@ -253,7 +253,8 @@ 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); + //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 > &pts) { for (std::list >::iterator i = pts.begin(); i != pts.end(); ++i) { - sp_guide_create(dt, (*i).first, (*i).second); + SPGuide::createSPGuide(dt, (*i).first, (*i).second); } } @@ -287,27 +288,27 @@ sp_guide_create_guides_around_page(SPDesktop *dt) { SPDocumentUndo::done (doc, SP_VERB_NONE, _("Guides Around Page")); } -void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler) +void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { - SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line); - sp_guideline_set_color(SP_GUIDELINE(item), guide->color); + SPCanvasItem *item = sp_guideline_new(group, this->point_on_line, this->normal_to_line); + sp_guideline_set_color(SP_GUIDELINE(item), this->color); - g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide); + g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); - guide->views = g_slist_prepend(guide->views, item); + this->views = g_slist_prepend(this->views, item); } -void sp_guide_hide(SPGuide *guide, SPCanvas *canvas) +void SPGuide::hideSPGuide(SPCanvas *canvas) { - g_assert(guide != NULL); - g_assert(SP_IS_GUIDE(guide)); + //g_assert(guide != NULL); + //g_assert(SP_IS_GUIDE(guide)); g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); - for (GSList *l = guide->views; l != NULL; l = l->next) { + for (GSList *l = this->views; l != NULL; l = l->next) { if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { sp_guideline_delete(SP_GUIDELINE(l->data)); - guide->views = g_slist_remove(guide->views, l->data); + this->views = g_slist_remove(this->views, l->data); return; } } @@ -315,14 +316,14 @@ 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(guide != NULL); + //g_assert(SP_IS_GUIDE(guide)); g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); - for (GSList *l = guide->views; l != NULL; l = l->next) { + for (GSList *l = this->views; l != NULL; l = l->next) { if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive); return; @@ -332,14 +333,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 - this->point_on_line); } -double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt) +double SPGuide::getDistanceFrom(Geom::Point const &pt) const { - return Geom::dot(pt - guide->point_on_line, guide->normal_to_line); + return Geom::dot(pt - this->point_on_line, this->normal_to_line); } /** diff --git a/src/sp-guide.h b/src/sp-guide.h index 6bf541cd1..b5914e890 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -25,7 +25,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; @@ -37,24 +38,31 @@ struct SPGuide : public SPObject { 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 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); +//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 > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); -void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler); -void sp_guide_hide(SPGuide *guide, SPCanvas *canvas); -void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive); +//void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler); +//void sp_guide_hide(SPGuide *guide, SPCanvas *canvas); +//void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive); -Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt); -double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt); +//Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt); +//double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt); void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit); void sp_guide_remove(SPGuide *guide); diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index e92a573f1..a7f29fb80 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -21,7 +21,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item) 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::iterator const ei(&item.constraints[i]); diff --git a/src/sp-line.cpp b/src/sp-line.cpp index b29e51b5a..b71616c5b 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -207,7 +207,7 @@ SPLine::sp_line_convert_to_guides(SPItem *item) 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]); } Geom::Matrix diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 7c974802e..c4ce6355b 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -642,10 +642,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(l->data)->guides, (GCallback) sp_dt_guide_event); + g->SPGuide::showSPGuide(static_cast(l->data)->guides, (GCallback) sp_dt_guide_event); if (static_cast(l->data)->guides_active) - sp_guide_sensitize(g, - sp_desktop_canvas(static_cast (l->data)), + g->sensitize(sp_desktop_canvas(static_cast (l->data)), TRUE); sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides); } @@ -703,9 +702,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); } @@ -841,7 +840,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); @@ -855,7 +854,7 @@ void SPNamedView::activateGuides(gpointer desktop, gboolean active) SPDesktop *dt = static_cast(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); } } diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index 02ae5d29a..d0e5c01a7 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -16,18 +16,20 @@ #include "xml/repr.h" #include "document.h" -static void sp_objectgroup_class_init (SPObjectGroupClass *klass); +/*static void sp_objectgroup_class_init (SPObjectGroupClass *klass); static void sp_objectgroup_init (SPObjectGroup *objectgroup); static void sp_objectgroup_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref); static void sp_objectgroup_remove_child (SPObject * object, Inkscape::XML::Node * child); static void sp_objectgroup_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref); -static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);*/ -static SPObjectClass *parent_class; +//static SPObjectClass *parent_class; + +SPObjectClass * SPObjectGroupClass::static_parent_class = 0; GType -sp_objectgroup_get_type (void) +SPObjectGroup::sp_objectgroup_get_type (void) { static GType objectgroup_type = 0; if (!objectgroup_type) { @@ -35,7 +37,7 @@ sp_objectgroup_get_type (void) sizeof (SPObjectGroupClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_objectgroup_class_init, + (GClassInitFunc) SPObjectGroupClass::sp_objectgroup_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (SPObjectGroup), @@ -48,8 +50,8 @@ sp_objectgroup_get_type (void) 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; @@ -57,48 +59,48 @@ sp_objectgroup_class_init (SPObjectGroupClass *klass) object_class = (GObjectClass *) klass; 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->child_added = sp_objectgroup_child_added; - sp_object_class->remove_child = sp_objectgroup_remove_child; - sp_object_class->order_changed = sp_objectgroup_order_changed; - sp_object_class->write = sp_objectgroup_write; + sp_object_class->child_added = SPObjectGroup::sp_objectgroup_child_added; + sp_object_class->remove_child = SPObjectGroup::sp_objectgroup_remove_child; + sp_object_class->order_changed = SPObjectGroup::sp_objectgroup_order_changed; + sp_object_class->write = SPObjectGroup::sp_objectgroup_write; } -static void -sp_objectgroup_init (SPObjectGroup */*objectgroup*/) +void +SPObjectGroup::sp_objectgroup_init (SPObjectGroup */*objectgroup*/) { } -static void -sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +void +SPObjectGroup::sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - 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); } -static void -sp_objectgroup_remove_child (SPObject *object, Inkscape::XML::Node *child) +void +SPObjectGroup::sp_objectgroup_remove_child (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); } -static void -sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) +void +SPObjectGroup::sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { - 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); } -static Inkscape::XML::Node * -sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPObjectGroup::sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPObjectGroup *group; SPObject *child; @@ -127,8 +129,8 @@ sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inksca } } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write) + ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write (object, xml_doc, repr, flags); return repr; } diff --git a/src/sp-object-group.h b/src/sp-object-group.h index 5d67df6fe..7d35cfc17 100644 --- a/src/sp-object-group.h +++ b/src/sp-object-group.h @@ -15,19 +15,38 @@ #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 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); + + friend class SPObjectGroupClass; }; -struct SPObjectGroupClass { - SPObjectClass parent_class; +class SPObjectGroupClass { + public: + SPObjectClass parent_class; + + private: + static void sp_objectgroup_class_init (SPObjectGroupClass *klass); + static SPObjectClass *static_parent_class; + + friend class SPObjectGroup; }; -GType sp_objectgroup_get_type (void); +//GType sp_objectgroup_get_type (void); #endif diff --git a/src/sp-object.cpp b/src/sp-object.cpp index f23f374d4..80f39db4a 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -937,6 +937,13 @@ void SPObject::appendChild(Inkscape::XML::Node *child) { 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() { g_assert(this->document); g_assert(this->repr); diff --git a/src/sp-object.h b/src/sp-object.h index 61c69c3aa..4856bdd06 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -532,6 +532,7 @@ public: 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); -- cgit v1.2.3 From e5dec7d5f087114818646072164234aa999e6d72 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma public Date: Wed, 11 Aug 2010 20:19:55 +0530 Subject: XML Privatisation Stuff after a long time (bzr r9546.1.12) --- src/desktop-events.cpp | 11 ++++++--- src/desktop-style.cpp | 5 ++-- src/desktop.cpp | 19 +++++++++------ src/document.cpp | 35 ++++++++++++++++++--------- src/selection-chemistry.cpp | 4 +-- src/sp-namedview.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++ src/sp-namedview.h | 10 ++++++++ src/sp-object.cpp | 18 ++++++++++++++ src/sp-object.h | 4 +++ 9 files changed, 138 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 2046b9510..9e97aa432 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -75,7 +75,7 @@ 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); + //Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview); gdk_window_get_pointer(GTK_WIDGET(dtw->canvas)->window, &wx, &wy, NULL); Geom::Point const event_win(wx, wy); @@ -92,8 +92,10 @@ 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); + /*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 @@ -183,7 +185,8 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); sp_repr_set_point(repr, "orientation", normal); sp_repr_set_point(repr, "position", from_2geom(event_dt)); - SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); + //SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); + desktop->namedview->appendChild(repr); Inkscape::GC::release(repr); SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create guide")); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 9a8725fac..049b5fcf8 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -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")) + && /*!SP_OBJECT_REPR(o)->attribute("style")*/ !o->getAttribute("style")) && !(SP_IS_FLOWREGION(o) || SP_IS_FLOWREGIONEXCLUDE(o) || @@ -129,7 +129,8 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines) } } - sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style"); + //sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style"); + o->changeCSS(css_set,"style"); sp_repr_css_attr_unref(css_set); } diff --git a/src/desktop.cpp b/src/desktop.cpp index 3f9fc7806..e7ef2897e 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -970,10 +970,12 @@ void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool(tool_path + "/usecurrent") && css_current) { - sp_repr_css_set(obj->getRepr(), css_current, "style"); + //sp_repr_css_set(obj->getRepr(), css_current, "style"); + obj->setCSS(css_current,"style"); } else { SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style"); - sp_repr_css_set(obj->getRepr(), css, "style"); + //sp_repr_css_set(obj->getRepr(), css, "style"); + obj->setCSS(css,"style"); sp_repr_css_attr_unref(css); } if (css_current) { @@ -1432,8 +1434,9 @@ void SPDesktop::toggleGrids() } } else { //there is no grid present at the moment. add a rectangular grid and make it visible - Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); + //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); + //Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); + namedview->writeNewGrid(sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); showGrids(true); } } @@ -1451,9 +1454,11 @@ 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->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); } //---------------------------------------------------------------------- diff --git a/src/document.cpp b/src/document.cpp index 6b72f0bb8..702c58d5d 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -627,18 +627,21 @@ Geom::Point SPDocument::getDimensions() * 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, +//static double getMarginLength(/*Inkscape::XML::Node * const nv_repr*/ +/* gchar const * const key, SPUnit const * const margin_units, SPUnit const * const return_units, double const width, double const height, - bool const use_width) -{ - double value; - if (!sp_repr_get_double (nv_repr, key, &value)) { + bool const use_width)*/ +//{ + // double value; + /*if (!sp_repr_get_double (nv_repr, key, &value)) { return 0.0; - } + }*/ +/* if(!this->storeAsDouble(key,&value)) { + return 0.0; + } if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) { return (use_width)? width * value : height * value; } @@ -646,7 +649,7 @@ static double getMarginLength(Inkscape::XML::Node * const nv_repr, return 0.0; } return value; -} +}*/ /** * Given a Geom::Rect that may, for example, correspond to the bbox of an object, @@ -674,9 +677,10 @@ 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"); + //Inkscape::XML::Node *nv_repr = SP_OBJECT_REPR (nv); + if (nv != NULL) { + //gchar const * const units_abbr = nv_repr->attribute("units"); + gchar const * const units_abbr = nv->getAttribute("units"); SPUnit const *margin_units = NULL; if (units_abbr != NULL) { margin_units = sp_unit_get_by_abbreviation(units_abbr); @@ -684,6 +688,7 @@ 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", @@ -691,7 +696,13 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) margin_right = getMarginLength(nv_repr, "fit-margin-right", margin_units, &px, w, h, true); margin_bottom = getMarginLength(nv_repr, "fit-margin-bottom", - margin_units, &px, w, h, false); + margin_units, &px, w, h, false);*/ + margin_top = nv->getMarginLength("fit-margin-top",margin_units, &px, w, h, false); + margin_top = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true); + margin_top = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true); + margin_top = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false); + + } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7c93c5f07..f7123da47 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1751,7 +1751,7 @@ struct Forward { static Iterator next(Iterator i) { return SP_OBJECT_NEXT(i); } }; -struct Reverse { +struct ReverseSelect { typedef GSList *Iterator; static Iterator children(SPObject *o) { @@ -1830,7 +1830,7 @@ sp_selection_item_prev(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + SPItem *item=next_item_from_list(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index c4ce6355b..61685b321 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -726,6 +726,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(gridtype)); +} + /* * Restores window geometry from the document settings or defaults in prefs */ @@ -774,6 +780,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; @@ -984,6 +1001,48 @@ 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. */ diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 048096d8c..337a67deb 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -23,6 +23,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; @@ -80,6 +82,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 { diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 80f39db4a..88d24bffd 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -503,6 +503,18 @@ SPObject::appendChildRepr(Inkscape::XML::Node *repr) { } } +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); +} + /** * Retrieves the children as a GSList object, optionally ref'ing the children * in the process, if add_ref is specified. @@ -1524,6 +1536,12 @@ SPObject::removeAttribute(gchar const *key, SPException *ex) 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 */ gchar * diff --git a/src/sp-object.h b/src/sp-object.h index 4856bdd06..b7b3f9cc4 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -70,6 +70,7 @@ class SPObjectClass; #include "forward.h" #include "version.h" #include "util/forward-pointer-iterator.h" +#include "desktop-style.h" namespace Inkscape { namespace XML { @@ -540,6 +541,9 @@ public: void removeAttribute(gchar const *key, SPException *ex=0); gchar const *getStyleProperty(gchar const *key, gchar const *def) const; SPObject *prev(); + void setCSS(SPCSSAttr *css, gchar const *attr); + void changeCSS(SPCSSAttr *css, gchar const *attr); + bool storeAsDouble( gchar const *key, double *val ) const; private: // Private member functions used in the definitions of setTitle(), -- cgit v1.2.3 From 392bac7bb9c21cef030f8ef6b49c044c32b88129 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma public Date: Thu, 12 Aug 2010 13:23:35 +0530 Subject: Naming Correction (bzr r9546.1.13) --- src/selection-chemistry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f7123da47..bd2d2768c 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1751,7 +1751,7 @@ struct Forward { static Iterator next(Iterator i) { return SP_OBJECT_NEXT(i); } }; -struct ReverseSelect { +struct ListReverse { typedef GSList *Iterator; static Iterator children(SPObject *o) { @@ -1830,7 +1830,7 @@ sp_selection_item_prev(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + SPItem *item=next_item_from_list(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); -- cgit v1.2.3