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/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 +- 13 files changed, 69 insertions(+), 71 deletions(-) (limited to 'src/ui') 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(); } -- cgit v1.2.3 From 121815791be2d24cb745663520b111ee914fbc09 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Thu, 1 Jul 2010 15:36:56 +0530 Subject: C++fied SPDocument added (bzr r9546.1.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 +++--- 15 files changed, 48 insertions(+), 50 deletions(-) (limited to 'src/ui') 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))); -- 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/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 +-- 29 files changed, 126 insertions(+), 126 deletions(-) (limited to 'src/ui') 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(); -- 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/ui/clipboard.cpp | 4 ++-- src/ui/dialog/find.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui') 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); -- 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/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 ++++++++----- 6 files changed, 76 insertions(+), 32 deletions(-) (limited to 'src/ui') 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) -- 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/ui/context-menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') 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); -- 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/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') 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