diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2010-12-12 08:40:34 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2010-12-12 08:40:34 +0000 |
| commit | aadfea4113abc6863d7ab03d21b973802c41c503 (patch) | |
| tree | 3f890c0c112433fd850d59558208addf1baa85da /src/ui | |
| parent | Pot and Dutch translation update (diff) | |
| parent | A simple layout document as to what, why and how is cppification. (diff) | |
| download | inkscape-aadfea4113abc6863d7ab03d21b973802c41c503.tar.gz inkscape-aadfea4113abc6863d7ab03d21b973802c41c503.zip | |
Merge and cleanup of GSoC C++-ification project.
(bzr r9945.1.1)
Diffstat (limited to 'src/ui')
41 files changed, 478 insertions, 390 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 90a9ba0f5..d405afb8f 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -5,6 +5,7 @@ * Krzysztof Kosiński <tweenk@o2.pl> * Jon A. Cruz <jon@joncruz.org> * Incorporates some code from selection-chemistry.cpp, see that file for more credits. + * Abhishek Sharma * * Copyright (C) 2008 authors * Copyright (C) 2010 Jon A. Cruz @@ -335,7 +336,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) } _pasteDocument(desktop, tempdoc, in_place); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return true; } @@ -350,8 +351,7 @@ const gchar *ClipboardManagerImpl::getFirstObjectID() return NULL; } - Inkscape::XML::Node - *root = sp_document_repr_root(tempdoc); + Inkscape::XML::Node *root = tempdoc->getReprRoot(); if (!root) { return NULL; @@ -405,9 +405,8 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) } } - Inkscape::XML::Node - *root = sp_document_repr_root(tempdoc), - *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); + Inkscape::XML::Node *root = tempdoc->getReprRoot(); + Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); bool pasted = false; @@ -421,7 +420,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) _userWarn(desktop, _("No style on the clipboard.")); } - sp_document_unref(tempdoc); + tempdoc->doUnref(); return pasted; } @@ -455,7 +454,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a } // retrieve size ifomration from the clipboard - Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); + Inkscape::XML::Node *root = tempdoc->getReprRoot(); Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); bool pasted = false; if (clipnode) { @@ -467,7 +466,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) { SPItem *item = SP_ITEM(i->data); - Geom::OptRect obj_size = sp_item_bbox_desktop(item); + Geom::OptRect obj_size = item->getBboxDesktop(); if ( !obj_size ) { continue; } @@ -484,7 +483,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a } pasted = true; } - sp_document_unref(tempdoc); + tempdoc->doUnref(); return pasted; } @@ -509,7 +508,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) SPDocument *tempdoc = _retrieveClipboard("image/x-inkscape-svg"); if ( tempdoc ) { - Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); + Inkscape::XML::Node *root = tempdoc->getReprRoot(); Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); if ( clipnode ) { gchar const *effectstack = clipnode->attribute("inkscape:path-effect"); @@ -544,12 +543,11 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) _userWarn(desktop, _("Nothing on the clipboard.")); return ""; } - Inkscape::XML::Node - *root = sp_document_repr_root(tempdoc), - *path = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth + Inkscape::XML::Node *root = tempdoc->getReprRoot(); + Inkscape::XML::Node *path = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth if ( path == NULL ) { _userWarn(desktop, _("Clipboard does not contain a path.")); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return ""; } gchar const *svgd = path->attribute("d"); @@ -568,7 +566,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) _userWarn(desktop, _("Nothing on the clipboard.")); return ""; } - Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); + Inkscape::XML::Node *root = tempdoc->getReprRoot(); Inkscape::XML::Node *repr = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth if ( repr == NULL ) { @@ -577,7 +575,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) if ( repr == NULL ) { _userWarn(desktop, _("Clipboard does not contain a path.")); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return ""; } gchar const *svgd = repr->attribute("id"); @@ -615,7 +613,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // write the complete accumulated transform passed to us // (we're dealing with unattached representations, so we write to their attributes // instead of using sp_item_set_transform) - gchar *transform_str = sp_svg_transform_write(sp_item_i2doc_affine(SP_ITEM(i->data))); + gchar *transform_str = sp_svg_transform_write(SP_ITEM(i->data)->i2doc_affine()); obj_copy->setAttribute("transform", transform_str); g_free(transform_str); } @@ -702,7 +700,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } // Copy text paths if (SP_IS_TEXT_TEXTPATH(item)) { - _copyTextPath(SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item)))); + _copyTextPath(SP_TEXTPATH(item->firstChild())); } // Copy clipping objects if (item->clip_ref->getObject()) { @@ -759,7 +757,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) _copyNode(SP_OBJECT_REPR(pattern), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) { if (!SP_IS_ITEM (child)) { continue; } @@ -814,10 +812,9 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node, void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) { SPDocument *target_document = sp_desktop_document(desktop); - Inkscape::XML::Node - *root = sp_document_repr_root(clipdoc), - *target_parent = SP_OBJECT_REPR(desktop->currentLayer()); - Inkscape::XML::Document *target_xmldoc = sp_document_repr_doc(target_document); + Inkscape::XML::Node *root = clipdoc->getReprRoot(); + Inkscape::XML::Node *target_parent = SP_OBJECT_REPR(desktop->currentLayer()); + Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); // copy definitions _pasteDefs(desktop, clipdoc); @@ -847,11 +844,11 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo selection->setReprList(pasted_objects); // invers apply parent transform - Geom::Matrix doc2parent = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + Geom::Matrix doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); // Update (among other things) all curves in paths, for bounds() to work - sp_document_ensure_up_to_date(target_document); + target_document->ensureUpToDate(); // move selection either to original position (in_place) or to mouse pointer Geom::OptRect sel_bbox = selection->bounds(); @@ -894,11 +891,10 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) { // boilerplate vars copied from _pasteDocument SPDocument *target_document = sp_desktop_document(desktop); - Inkscape::XML::Node - *root = sp_document_repr_root(clipdoc), - *defs = sp_repr_lookup_name(root, "svg:defs", 1), - *target_defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(target_document)); - Inkscape::XML::Document *target_xmldoc = sp_document_repr_doc(target_document); + Inkscape::XML::Node *root = clipdoc->getReprRoot(); + Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); + Inkscape::XML::Node *target_defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(target_document)); + Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); prevent_id_clashes(clipdoc, target_document); @@ -1201,7 +1197,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) guint32 bgcolor = 0x00000000; Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed); - Geom::Rect area = Geom::Rect(origin, origin + sp_document_dimensions(_clipboardSPDoc)); + Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); unsigned long int height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5); @@ -1255,11 +1251,11 @@ void ClipboardManagerImpl::_onClear() void ClipboardManagerImpl::_createInternalClipboard() { if ( _clipboardSPDoc == NULL ) { - _clipboardSPDoc = sp_document_new(NULL, false, true); + _clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); _defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(_clipboardSPDoc)); - _doc = sp_document_repr_doc(_clipboardSPDoc); - _root = sp_document_repr_root(_clipboardSPDoc); + _doc = _clipboardSPDoc->getReprDoc(); + _root = _clipboardSPDoc->getReprRoot(); _clipnode = _doc->createElement("inkscape:clipboard"); _root->appendChild(_clipnode); @@ -1280,7 +1276,7 @@ void ClipboardManagerImpl::_createInternalClipboard() void ClipboardManagerImpl::_discardInternalClipboard() { if ( _clipboardSPDoc != NULL ) { - sp_document_unref(_clipboardSPDoc); + _clipboardSPDoc->doUnref(); _clipboardSPDoc = NULL; _defs = NULL; _doc = NULL; diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 262fdcf32..c544d1999 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -1,10 +1,10 @@ -#define __CONTEXT_MENU_C__ - /* * Unser-interface related object extension * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * This code is in public domain */ @@ -21,6 +21,8 @@ #include "preferences.h" #include "ui/dialog/dialog-manager.h" +using Inkscape::DocumentUndo; + static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu); /* Append object-specific part to context menu */ @@ -274,7 +276,7 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item)); SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr); @@ -289,8 +291,8 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) Inkscape::GC::release(repr); Inkscape::GC::release(child); - sp_document_done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, - _("Create link")); + DocumentUndo::done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, + _("Create link")); sp_object_attributes_dialog(object, "SPAnchor"); diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index c66cd4e96..36846edc3 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -1,11 +1,12 @@ -#ifndef __CONTEXT_MENU_H__ -#define __CONTEXT_MENU_H__ +#ifndef SEEN_CONTEXT_MENU_H +#define SEEN_CONTEXT_MENU_H /* * Unser-interface related object extension * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> + * Abhishek Sharma * * This code is in public domain */ @@ -13,7 +14,7 @@ #include <gtk/gtkmenu.h> #include "forward.h" - +#include "sp-object.h" /* Append object-specific part to context menu */ void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu); diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 8d467d53f..8db5e7c0b 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -6,6 +6,7 @@ * MenTaLguY <mental@rydia.net> * Kees Cook <kees@outflux.net> * Jon Phillips <jon@rejon.org> + * Abhishek Sharma * * Copyright (C) 2004 Derek P. Moore * Copyright 2004 Kees Cook @@ -147,7 +148,7 @@ Gtk::Widget *build_splash_widget() { // should be in UTF-*8.. char *about=g_build_filename(INKSCAPE_SCREENSDIR, _("about.svg"), NULL); - SPDocument *doc=sp_document_new (about, TRUE); + SPDocument *doc=SPDocument::createNewDoc (about, TRUE); g_free(about); g_return_val_if_fail(doc != NULL, NULL); @@ -155,14 +156,14 @@ Gtk::Widget *build_splash_widget() { if ( version && SP_IS_TEXT(version) ) { sp_te_set_repr_text_multiline (SP_TEXT (version), Inkscape::version_string); } - sp_document_ensure_up_to_date(doc); + doc->ensureUpToDate(); GtkWidget *v=sp_svg_view_widget_new(doc); - double width=sp_document_width(doc); - double height=sp_document_height(doc); + double width=doc->getWidth(); + double height=doc->getHeight(); - sp_document_unref(doc); + doc->doUnref(); sp_svg_view_widget_set_resize(SP_SVG_VIEW_WIDGET(v), FALSE, (int)width, (int)height); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index ba8cc939b..48f0fbf22 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -7,6 +7,8 @@ * Frank Felfe <innerspace@iname.com> * Lauris Kaplinski <lauris@kaplinski.com> * Tim Dwyer <tgdwyer@gmail.com> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 1999-2004, 2005 Authors * @@ -152,7 +154,7 @@ private : selected.erase(master); /*}*/ //Compute the anchor point - Geom::OptRect b = sp_item_bbox_desktop (thing); + Geom::OptRect b = thing->getBboxDesktop (); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -163,14 +165,13 @@ private : } case AlignAndDistribute::PAGE: - mp = Geom::Point(a.mx1 * sp_document_width(sp_desktop_document(desktop)), - a.my1 * sp_document_height(sp_desktop_document(desktop))); + mp = Geom::Point(a.mx1 * sp_desktop_document(desktop)->getWidth(), + a.my1 * sp_desktop_document(desktop)->getHeight()); break; case AlignAndDistribute::DRAWING: { - Geom::OptRect b = sp_item_bbox_desktop - ( (SPItem *) sp_document_root (sp_desktop_document (desktop)) ); + Geom::OptRect b = static_cast<SPItem *>( sp_desktop_document(desktop)->getRoot() )->getBboxDesktop(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -216,9 +217,9 @@ private : it != selected.end(); it++) { - sp_document_ensure_up_to_date(sp_desktop_document (desktop)); + sp_desktop_document (desktop)->ensureUpToDate(); if (!sel_as_group) - b = sp_item_bbox_desktop (*it); + b = (*it)->getBboxDesktop(); if (b) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); @@ -234,8 +235,8 @@ private : prefs->setInt("/options/clonecompensation/value", saved_compensation); if (changed) { - sp_document_done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Align")); + DocumentUndo::done( sp_desktop_document(desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Align")); } @@ -322,7 +323,7 @@ private : it != selected.end(); ++it) { - Geom::OptRect bbox = sp_item_bbox_desktop(*it); + Geom::OptRect bbox = (*it)->getBboxDesktop(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd)); } @@ -393,8 +394,8 @@ private : prefs->setInt("/options/clonecompensation/value", saved_compensation); if (changed) { - sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Distribute")); + DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Distribute")); } } guint _index; @@ -504,8 +505,8 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Remove overlaps")); + DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Remove overlaps")); } }; @@ -535,8 +536,8 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Arrange connector network")); + DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Arrange connector network")); } }; @@ -628,10 +629,11 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Exchange Positions")); + DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Exchange Positions")); } }; + // instantiae the private static member boost::optional<Geom::Point> ActionExchangePositions::center; @@ -661,8 +663,8 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Unclump")); + DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Unclump")); } }; @@ -715,8 +717,8 @@ private : it != selected.end(); ++it) { - sp_document_ensure_up_to_date(sp_desktop_document (desktop)); - Geom::OptRect item_box = sp_item_bbox_desktop (*it); + sp_desktop_document (desktop)->ensureUpToDate(); + Geom::OptRect item_box = (*it)->getBboxDesktop (); if (item_box) { // find new center, staying within bbox double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 + @@ -732,8 +734,8 @@ private : // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Randomize positions")); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Randomize positions")); } }; @@ -801,7 +803,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * sp_item_i2d_affine(*it); + Geom::Point base = *pt * (*it)->i2d_affine(); if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X]; if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y]; if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X]; @@ -831,8 +833,8 @@ private : } if (changed) { - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Distribute text baselines")); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Distribute text baselines")); } } else { @@ -844,7 +846,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * sp_item_i2d_affine(*it); + Geom::Point base = *pt * (*it)->i2d_affine(); Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; sp_item_move_rel(*it, Geom::Translate(t)); @@ -854,8 +856,8 @@ private : } if (changed) { - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Align text baselines")); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, + _("Align text baselines")); } } } @@ -1239,7 +1241,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem { gdouble max = -1e18; for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = sp_item_bbox_desktop (*it); + Geom::OptRect b = (*it)->getBboxDesktop (); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim > max) { @@ -1256,7 +1258,7 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem { gdouble max = 1e18; for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = sp_item_bbox_desktop (*it); + Geom::OptRect b = (*it)->getBboxDesktop (); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim < max) { diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 97603a8a2..9f163c00c 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -3,6 +3,7 @@ */ /* Authors: * Jon A. Cruz + * Abhishek Sharma * * Copyright (C) 2010 Jon A. Cruz * @@ -458,7 +459,7 @@ void ColorItem::_updatePreviews() SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop ) { SPDocument* document = sp_desktop_document( desktop ); - Inkscape::XML::Node *rroot = sp_document_repr_root( document ); + Inkscape::XML::Node *rroot = document->getReprRoot(); if ( rroot ) { // Find where this thing came from @@ -486,7 +487,7 @@ void ColorItem::_updatePreviews() str = 0; if ( bruteForce( document, rroot, paletteName, def.getR(), def.getG(), def.getB() ) ) { - sp_document_done( document , SP_VERB_DIALOG_SWATCHES, + SPDocumentUndo::done( document , SP_VERB_DIALOG_SWATCHES, _("Change color definition")); } } @@ -720,7 +721,7 @@ void ColorItem::buttonClicked(bool secondary) sp_desktop_set_style(desktop, css); sp_repr_css_attr_unref(css); - sp_document_done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() ); + DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() ); } } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index f22509496..16212bef7 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -8,6 +8,8 @@ * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) * Diederik van Lierop <mail@diedenrezi.nl> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2006-2008 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 2000 - 2008 Authors @@ -404,7 +406,7 @@ DocumentProperties::linkSelectedProfile() g_warning("No color profile available."); return; } - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *cprofRepr = xml_doc->createElement("svg:color-profile"); gchar* tmp = static_cast<gchar*>(_menu.get_active()->get_data("name")); Glib::ustring nameStr = tmp ? tmp : "profile"; // TODO add some auto-numbering to avoid collisions @@ -426,7 +428,7 @@ DocumentProperties::linkSelectedProfile() //Inkscape::GC::release(defsRepr); // inform the document, so we can undo - sp_document_done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile")); + DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile")); populate_linked_profiles_box(); } @@ -436,7 +438,7 @@ void DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" ); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); if (current) _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); @@ -493,13 +495,15 @@ void DocumentProperties::removeSelectedProfile(){ } } - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" ); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); if (!name.compare(prof->name)){ - sp_repr_unparent(obj->repr); - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(obj->getRepr()); + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); } current = g_slist_next(current); } @@ -565,7 +569,7 @@ DocumentProperties::build_cms() _LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release)); cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile)); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "defs" ); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" ); if (current) { _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); } @@ -623,7 +627,7 @@ DocumentProperties::build_scripting() #endif // ENABLE_LCMS //TODO: review this observers code: - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) { _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); } @@ -636,7 +640,7 @@ void DocumentProperties::addExternalScript(){ if (!desktop){ g_warning("No active desktop"); } else { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script"); scriptRepr->setAttribute("xlink:href", (gchar*) _script_entry.get_text().c_str()); _script_entry.set_text(""); @@ -644,7 +648,7 @@ void DocumentProperties::addExternalScript(){ xml_doc->root()->addChild(scriptRepr, NULL); // inform the document, so we can undo - sp_document_done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); + DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); populate_external_scripts_box(); } @@ -662,13 +666,15 @@ void DocumentProperties::removeExternalScript(){ } } - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; if (name == script->xlinkhref){ - sp_repr_unparent(obj->repr); - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(obj->getRepr()); + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); } current = g_slist_next(current); } @@ -679,7 +685,7 @@ void DocumentProperties::removeExternalScript(){ void DocumentProperties::populate_external_scripts_box(){ _ExternalScriptsListStore->clear(); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); @@ -798,8 +804,8 @@ DocumentProperties::update() if (nv->doc_units) _rum_deflt.setUnit (nv->doc_units); - double const doc_w_px = sp_document_width(sp_desktop_document(dt)); - double const doc_h_px = sp_document_height(sp_desktop_document(dt)); + double const doc_w_px = sp_desktop_document(dt)->getWidth(); + double const doc_h_px = sp_desktop_document(dt)->getHeight(); _page_sizer.setDim (doc_w_px, doc_h_px); _page_sizer.updateFitMarginsUI(SP_OBJECT_REPR(nv)); @@ -961,7 +967,7 @@ DocumentProperties::onRemoveGrid() // delete the grid that corresponds with the selected tab // when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer! found_grid->repr->parent()->removeChild(found_grid->repr); - sp_document_done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); + DocumentUndo::done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); } } diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index fbfdc4a9b..855d5a223 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -6,6 +6,7 @@ * Joel Holdsworth * Bruno Dilly * Other dudes from The Inkscape Organization + * Abhishek Sharma * * Copyright (C) 2004-2007 Bob Jamison * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> @@ -123,9 +124,9 @@ findExpanderWidgets(Gtk::Container *parent, bool SVGPreview::setDocument(SPDocument *doc) { if (document) - sp_document_unref(document); + document->doUnref(); - sp_document_ref(doc); + doc->doRef(); document = doc; //This should remove it from the box, and free resources @@ -151,7 +152,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName) * I don't know why passing false to keepalive is bad. But it * prevents the display of an svg with a non-ascii filename */ - SPDocument *doc = sp_document_new (fileName.c_str(), true); + SPDocument *doc = SPDocument::createNewDoc (fileName.c_str(), true); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -159,7 +160,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName) setDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } @@ -172,7 +173,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); - SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0); + SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; @@ -180,7 +181,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) setDocument(doc); - sp_document_unref(doc); + doc->doUnref(); Inkscape::GC::request_early_collection(); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index e2bf47db9..65bb49f13 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -4,6 +4,7 @@ /* Authors: * Joel Holdsworth * The Inkscape Organization + * Abhishek Sharma * * Copyright (C) 2004-2008 The Inkscape Organization * @@ -906,20 +907,20 @@ bool FileOpenDialogImplWin32::set_svg_preview() gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string, _MAX_PATH, NULL, NULL, NULL); - SPDocument *svgDoc = sp_document_new (utf8string, true); + SPDocument *svgDoc = SPDocument::createNewDoc (utf8string, true); g_free(utf8string); // Check the document loaded properly if(svgDoc == NULL) return false; if(svgDoc->root == NULL) { - sp_document_unref(svgDoc); + svgDoc->doUnref(); return false; } // Get the size of the document - const double svgWidth = sp_document_width(svgDoc); - const double svgHeight = sp_document_height(svgDoc); + const double svgWidth = svgDoc->getWidth(); + const double svgHeight = svgDoc->getHeight(); // Find the minimum scale to fit the image inside the preview area const double scaleFactorX = PreviewSize / svgWidth; @@ -936,9 +937,9 @@ bool FileOpenDialogImplWin32::set_svg_preview() // write object bbox to area Geom::OptRect maybeArea(area); - sp_document_ensure_up_to_date (svgDoc); - sp_item_invoke_bbox((SPItem *) svgDoc->root, maybeArea, - sp_item_i2d_affine((SPItem *)(svgDoc->root)), TRUE); + svgDoc->ensureUpToDate (); + static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea, + static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE); NRArena *const arena = NRArena::create(); @@ -968,7 +969,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() // Fail if the pixblock failed to allocate if(pixBlock.data.px == NULL) { - sp_document_unref(svgDoc); + svgDoc->doUnref(); return false; } @@ -980,7 +981,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() nr_arena_item_invoke_render(NULL, root, &bbox, &pixBlock, /*0*/NR_ARENA_ITEM_RENDER_NO_CACHE); // Tidy up - sp_document_unref(svgDoc); + svgDoc->doUnref(); sp_item_invoke_hide((SPItem*)(svgDoc->root), key); nr_object_unref((NRObject *) arena); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index bee6b7c9d..ed7103be3 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -5,6 +5,8 @@ * Nicholas Bishop <nicholasbishop@gmail.org> * Rodrigo Kumpera <kumpera@gmail.com> * Felipe C. da S. Sanches <juca@members.fsf.org> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2007 Authors * @@ -1021,16 +1023,18 @@ private: !(ls == 1 && SP_IS_FEPOINTLIGHT(child)) && !(ls == 2 && SP_IS_FESPOTLIGHT(child))) { if(child) - sp_repr_unparent(child->repr); + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(child->getRepr()); if(ls != -1) { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); + Inkscape::XML::Document *xml_doc = prim->document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); - prim->repr->appendChild(repr); + //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); Inkscape::GC::release(repr); } - sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); + DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); update(); } @@ -1142,8 +1146,7 @@ void FilterEffectsDialog::FilterModifier::on_activate_desktop(Application*, SPDe me->_resource_changed.disconnect(); me->_resource_changed = - sp_document_resources_changed_connect(sp_desktop_document(desktop), "filter", - sigc::mem_fun(me, &FilterModifier::update_filters)); + sp_desktop_document(desktop)->connectResourcesChanged("filter",sigc::mem_fun(me, &FilterModifier::update_filters)); me->_dialog.setDesktop(desktop); @@ -1214,7 +1217,7 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa if(iter) { SPFilter* filter = (*iter)[_columns.filter]; filter->setLabel(text.c_str()); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); + DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); if(iter) (*iter)[_columns.label] = text; } @@ -1250,7 +1253,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri } update_selection(sel); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); + DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); } } @@ -1260,7 +1263,7 @@ void FilterEffectsDialog::FilterModifier::update_filters() { SPDesktop* desktop = _dialog.getDesktop(); SPDocument* document = sp_desktop_document(desktop); - const GSList* filters = sp_document_get_resource_list(document, "filter"); + const GSList* filters = document->getResourceList("filter"); _model->clear(); @@ -1326,7 +1329,7 @@ void FilterEffectsDialog::FilterModifier::add_filter() select_filter(filter); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); + DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); } void FilterEffectsDialog::FilterModifier::remove_filter() @@ -1335,9 +1338,11 @@ void FilterEffectsDialog::FilterModifier::remove_filter() if(filter) { SPDocument* doc = filter->document; - sp_repr_unparent(filter->repr); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(filter->getRepr()); + + DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); update_filters(); } @@ -1352,7 +1357,7 @@ void FilterEffectsDialog::FilterModifier::duplicate_filter() repr = repr->duplicate(repr->document()); parent->appendChild(repr); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter")); + DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter")); update_filters(); } @@ -1487,7 +1492,9 @@ void FilterEffectsDialog::PrimitiveList::update() if(prim) { Gtk::TreeModel::Row row = *_model->append(); row[_columns.primitive] = prim; - row[_columns.type_id] = FPConverter.get_id_from_key(prim->repr->name()); + + //XML Tree being used directly here while it shouldn't be. + row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); row[_columns.id] = prim->getId(); @@ -1540,10 +1547,11 @@ void FilterEffectsDialog::PrimitiveList::remove_selected() if(prim) { _observer->set(0); - sp_repr_unparent(prim->repr); + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(prim->getRepr()); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, - _("Remove filter primitive")); + DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, + _("Remove filter primitive")); update(); } @@ -1913,9 +1921,11 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* if(c == _in_drag && SP_IS_FEMERGENODE(o)) { // If input is null, delete it if(!in_val) { - sp_repr_unparent(o->repr); - sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, - _("Remove merge node")); + + //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(o->getRepr()); + DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, + _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; } else @@ -1925,10 +1935,12 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* } // Add new input? if(!handled && c == _in_drag && in_val) { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); + Inkscape::XML::Document *xml_doc = prim->document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:feMergeNode"); repr->setAttribute("inkscape:collect", "always"); - prim->repr->appendChild(repr); + + //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); SPFeMergeNode *node = SP_FEMERGENODE(prim->document->getObjectByRepr(repr)); Inkscape::GC::release(repr); _dialog.set_attr(node, SP_ATTR_IN, in_val); @@ -2031,7 +2043,7 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra filter->requestModified(SP_OBJECT_MODIFIED_FLAG); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); + DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); } // If a connection is dragged towards the top or bottom of the list, the list should scroll to follow. @@ -2263,7 +2275,7 @@ void FilterEffectsDialog::add_primitive() _primitive_list.select(prim); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); + DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); } } @@ -2359,7 +2371,7 @@ void FilterEffectsDialog::duplicate_primitive() repr = SP_OBJECT_REPR(origprim)->duplicate(SP_OBJECT_REPR(origprim)->document()); SP_OBJECT_REPR(filter)->appendChild(repr); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); + DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); _primitive_list.update(); } @@ -2411,8 +2423,8 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons Glib::ustring undokey = "filtereffects:"; undokey += name; - sp_document_maybe_done(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, - _("Set filter primitive attribute")); + DocumentUndo::maybeDone(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, + _("Set filter primitive attribute")); } _attr_lock = false; @@ -2467,7 +2479,9 @@ void FilterEffectsDialog::update_settings_view() SPFilterPrimitive* prim = _primitive_list.get_selected(); if(prim) { - _settings->show_and_update(FPConverter.get_id_from_key(prim->repr->name()), prim); + + //XML Tree being used directly here while it shouldn't be. + _settings->show_and_update(FPConverter.get_id_from_key(prim->getRepr()->name()), prim); _empty_settings.hide(); } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 7fad00f56..b6d6a0319 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -4,6 +4,8 @@ * Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * Johan Engelen <goejendaagh@zonnet.nl> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * @@ -76,8 +78,8 @@ Find::Find() _check_texts(_("Texts"), _("Search text objects")), _check_groups(_("Groups"), _("Search groups")), _check_clones( - //TRANSLATORS: "Clones" is a noun indicating type of object to find - C_("Find dialog", "Clones"), _("Search clones")), + //TRANSLATORS: "Clones" is a noun indicating type of object to find + C_("Find dialog", "Clones"), _("Search clones")), _check_images(_("Images"), _("Search images")), _check_offsets(_("Offsets"), _("Search offset objects")), @@ -346,7 +348,7 @@ Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked) if (!strcmp (SP_OBJECT_REPR (r)->name(), "svg:metadata")) return l; // we're not interested in metadata - for (SPObject *child = sp_object_first_child(r); child; child = SP_OBJECT_NEXT (child)) { + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { if (SP_IS_ITEM (child) && !SP_OBJECT_IS_CLONED (child) && !desktop->isLayer(SP_ITEM(child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { l = g_slist_prepend (l, child); @@ -415,7 +417,7 @@ Find::onFind() if (_check_search_layer.get_active()) { l = all_items (desktop->currentLayer(), l, hidden, locked); } else { - l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked); + l = all_items(sp_desktop_document(desktop)->getRoot(), l, hidden, locked); } } guint all = g_slist_length (l); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 5e66ca9b8..f3d7ed971 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -4,6 +4,7 @@ /* Authors: * Jon A. Cruz + * Abhishek Sharma * * Copyright (C) 2010 Jon A. Cruz * Released under GNU GPL, read the file 'COPYING' for more information @@ -28,7 +29,7 @@ #include "glyphs.h" #include "desktop.h" -#include "document.h" // for sp_document_done() +#include "document.h" // for SPDocumentUndo::done() #include "libnrtype/font-instance.h" #include "sp-flowtext.h" #include "sp-text.h" @@ -571,7 +572,7 @@ void GlyphsPanel::insertText() } combined += glyphs; sp_te_set_repr_text_multiline(textItem, combined.c_str()); - sp_document_done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); + DocumentUndo::done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); } } } diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index aac6024b9..1ab0d51bc 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -5,6 +5,7 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Andrius R. <knutux@gmail.com> * Johan Engelen + * Abhishek Sharma * * Copyright (C) 1999-2007 Authors * @@ -108,8 +109,8 @@ void GuidelinePropertiesDialog::_onApply() sp_guide_moveto(*_guide, newpos, true); - sp_document_done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, - _("Set guide properties")); + DocumentUndo::done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, + _("Set guide properties")); } void GuidelinePropertiesDialog::_onOK() @@ -121,8 +122,8 @@ void GuidelinePropertiesDialog::_onDelete() { SPDocument *doc = SP_OBJECT_DOCUMENT(_guide); sp_guide_remove(_guide); - sp_document_done(doc, SP_VERB_NONE, - _("Delete guide")); + DocumentUndo::done(doc, SP_VERB_NONE, + _("Delete guide")); } void GuidelinePropertiesDialog::_response(gint response) @@ -225,9 +226,9 @@ void GuidelinePropertiesDialog::_setup() { // initialize dialog _oldpos = _guide->point_on_line; - if (_guide->is_vertical()) { + if (_guide->isVertical()) { _oldangle = 90; - } else if (_guide->is_horizontal()) { + } else if (_guide->isHorizontal()) { _oldangle = 0; } else { _oldangle = Geom::rad_to_deg( std::atan2( - _guide->normal_to_line[Geom::X], _guide->normal_to_line[Geom::Y] ) ); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 07e1ff430..b507d9f9a 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -5,6 +5,7 @@ * Jon A. Cruz * Bob Jamison * Other dudes from The Inkscape Organization + * Abhishek Sharma * * Copyright (C) 2004 Bob Jamison * Copyright (C) 2005,2010 Jon A. Cruz @@ -443,10 +444,9 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) NRArena *arena = NRArena::create(); /* Create ArenaItem and set transform */ - unsigned int visionkey = sp_item_display_key_new(1); + unsigned int visionkey = SPItem::display_key_new(1); - root = sp_item_invoke_show ( SP_ITEM( SP_DOCUMENT_ROOT(doc) ), - arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + root = SP_ITEM( doc->getRoot() )->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); for ( int i = 0; i < numEntries; i++ ) { guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i] ); @@ -462,7 +462,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) } updateMagnify(); - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), visionkey); + SP_ITEM(doc->getRoot())->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); renderTimer->stop(); minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 ); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 1728ff3a6..bf15bcd76 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -4,6 +4,7 @@ /* Author: * Bryce W. Harrington <bryce@bryceharrington.com> * Andrius R. <knutux@gmail.com> + * Abhishek Sharma * * Copyright (C) 2004 Bryce Harrington * Copyright (C) 2006 Andrius R. @@ -105,8 +106,8 @@ LayerPropertiesDialog::_apply() g_assert(_strategy != NULL); _strategy->perform(*this); - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, - _("Add layer")); + DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, + _("Add layer")); _close(); } @@ -188,8 +189,8 @@ void LayerPropertiesDialog::Rename::perform(LayerPropertiesDialog &dialog) { (gchar *)name.c_str(), FALSE ); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, - _("Rename layer")); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, + _("Rename layer")); // TRANSLATORS: This means "The layer has been renamed" desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Renamed layer")); } diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index c3c0ae3c5..0eca5bbca 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -3,6 +3,7 @@ * * Authors: * Jon A. Cruz + * Abhishek Sharma * * Copyright (C) 2006,2010 Jon A. Cruz * @@ -468,8 +469,8 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol ) row[_model->_colVisible] = newValue; item->setHidden( !newValue ); item->updateRepr(); - sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, - newValue? _("Unhide layer") : _("Hide layer")); + DocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, + newValue? _("Unhide layer") : _("Hide layer")); } break; @@ -479,8 +480,8 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol ) row[_model->_colLocked] = newValue; item->setLocked( newValue ); item->updateRepr(); - sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, - newValue? _("Lock layer") : _("Unlock layer")); + DocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, + newValue? _("Lock layer") : _("Unlock layer")); } break; } @@ -766,7 +767,7 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) } } /* - GSList const *layers=sp_document_get_resource_list( _desktop->doc(), "layer" ); + GSList const *layers = _desktop->doc()->getResourceList( "layer" ); g_message( "layers list starts at %p", layers ); for ( GSList const *iter=layers ; iter ; iter = iter->next ) { SPObject *layer=static_cast<SPObject *>(iter->data); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 706a84733..bf60fe059 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -5,6 +5,7 @@ * Johan Engelen <j.b.c.engelen@utwente.nl> * Steren Giannini <steren.giannini@gmail.com> * Bastien Bouclet <bgkweb@gmail.com> + * Abhishek Sharma * * Copyright (C) 2007 Authors * Released under GNU GPL. Read the file 'COPYING' for more information. @@ -376,8 +377,8 @@ LivePathEffectEditor::onApply() LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item); - sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Create and apply path effect")); + DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Create and apply path effect")); lpe_list_locked = false; onSelectionChanged(sel); @@ -394,8 +395,8 @@ LivePathEffectEditor::onRemove() if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Remove path effect") ); + DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Remove path effect") ); effect_list_reload(SP_LPE_ITEM(item)); } @@ -410,8 +411,8 @@ void LivePathEffectEditor::onUp() if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Move path effect up") ); + DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Move path effect up") ); effect_list_reload(SP_LPE_ITEM(item)); } @@ -426,8 +427,8 @@ void LivePathEffectEditor::onDown() if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Move path effect down") ); + DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Move path effect down") ); effect_list_reload(SP_LPE_ITEM(item)); } @@ -465,8 +466,8 @@ void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str ) /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack. * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */ lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false"); - sp_document_done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - newValue ? _("Activate path effect") : _("Deactivate path effect")); + DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + newValue ? _("Activate path effect") : _("Deactivate path effect")); } } diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 2456e10da..a56cbfd9d 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -3,6 +3,7 @@ */ /* Authors: * Kees Cook <kees@outflux.net> + * Abhishek Sharma * * Copyright (C) 2007 Kees Cook * Released under GNU GPL. Read the file 'COPYING' for more information. @@ -46,8 +47,8 @@ static void draw_page( if (junk->_tab->as_bitmap()) { // Render as exported PNG - gdouble width = sp_document_width(junk->_doc); - gdouble height = sp_document_height(junk->_doc); + gdouble width = (junk->_doc)->getWidth(); + gdouble height = (junk->_doc)->getHeight(); gdouble dpi = junk->_tab->bitmap_dpi(); std::string tmp_png; std::string tmp_base = "inkscape-print-png-XXXXXX"; @@ -181,7 +182,7 @@ Print::Print(SPDocument *doc, SPItem *base) : _printop = gtk_print_operation_new (); // set up dialog title, based on document name - gchar *jobname = _doc->name ? _doc->name : _("SVG Document"); + gchar const *jobname = _doc->getName() ? _doc->getName() : _("SVG Document"); Glib::ustring title = _("Print"); title += " "; title += jobname; @@ -190,8 +191,8 @@ Print::Print(SPDocument *doc, SPItem *base) : // set up paper size to match the document size gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); GtkPageSetup *page_setup = gtk_page_setup_new(); - gdouble doc_width = sp_document_width(_doc) * PT_PER_PX; - gdouble doc_height = sp_document_height(_doc) * PT_PER_PX; + gdouble doc_width = _doc->getWidth() * PT_PER_PX; + gdouble doc_height = _doc->getHeight() * PT_PER_PX; GtkPaperSize *paper_size; if (doc_width > doc_height) { gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); diff --git a/src/ui/dialog/session-player.cpp b/src/ui/dialog/session-player.cpp index 51b206a85..d8ff8ca56 100644 --- a/src/ui/dialog/session-player.cpp +++ b/src/ui/dialog/session-player.cpp @@ -3,6 +3,7 @@ */ /* Authors: * David Yip <yipdw@rose-hulman.edu> + * Abhishek Sharma * * Copyright (c) 2005 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@ -171,7 +172,7 @@ SessionPlaybackDialogImpl::_respCallback(int resp) switch (result) { case Gtk::RESPONSE_OK: this->_sm->clearDocument(); - sp_document_done(sp_desktop_document(this->_desktop), SP_VERB_NONE, + SPDocumentUndo::done(sp_desktop_document(this->_desktop), SP_VERB_NONE, /* TODO: annotate */ "session-player.cpp:186"); this->_sm->loadSessionFile(sessionfiledlg.get_filename()); this->_openfile.set_text(this->_sfp->filename()); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 1f11a412e..042acb6e1 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -3,6 +3,8 @@ */ /* Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2008 Authors * Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information. @@ -117,8 +119,8 @@ void SvgFontsDialog::AttrEntry::on_attr_changed(){ Glib::ustring undokey = "svgfonts:"; undokey += name; - sp_document_maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, - _("Set SVG Font attribute")); + DocumentUndo::maybeDone(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, + _("Set SVG Font attribute")); } } @@ -163,15 +165,17 @@ void SvgFontsDialog::on_kerning_value_changed(){ if (!this->kerning_pair) return; SPDocument* document = sp_desktop_document(this->getDesktop()); - //TODO: I am unsure whether this is the correct way of calling sp_document_maybe_done + //TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done Glib::ustring undokey = "svgfonts:hkern:k:"; undokey += this->kerning_pair->u1->attribute_string(); undokey += ":"; undokey += this->kerning_pair->u2->attribute_string(); //slider values increase from right to left so that they match the kerning pair preview - this->kerning_pair->repr->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str()); - sp_document_maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); + + //XML Tree being directly used here while it shouldn't be. + this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str()); + DocumentUndo::maybeDone(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); //populate_kerning_pairs_box(); kerning_preview.redraw(); @@ -243,7 +247,7 @@ void SvgFontsDialog::update_fonts() { SPDesktop* desktop = this->getDesktop(); SPDocument* document = sp_desktop_document(desktop); - const GSList* fonts = sp_document_get_resource_list(document, "font"); + const GSList* fonts = document->getResourceList("font"); _model->clear(); for(const GSList *l = fonts; l; l = l->next) { @@ -423,7 +427,7 @@ SvgFontsDialog::populate_kerning_pairs_box() SPGlyph *new_glyph(SPDocument* document, SPFont *font, const int count) { g_return_val_if_fail(font != NULL, NULL); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); + Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new glyph Inkscape::XML::Node *repr; @@ -462,7 +466,7 @@ void SvgFontsDialog::add_glyph(){ SPDocument* doc = sp_desktop_document(this->getDesktop()); /* SPGlyph* glyph =*/ new_glyph(doc, get_selected_spfont(), count+1); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); update_glyphs(); } @@ -505,8 +509,9 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ msgStack->flash(Inkscape::ERROR_MESSAGE, msg); return; } - glyph->repr->setAttribute("d", (char*) sp_svg_write_path (pathv)); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); + //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); } @@ -547,8 +552,10 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ - obj->repr->setAttribute("d", (char*) sp_svg_write_path (pathv)); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); + + //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } @@ -566,8 +573,9 @@ void SvgFontsDialog::reset_missing_glyph_description(){ SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ - obj->repr->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); + //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@ -579,10 +587,11 @@ void SvgFontsDialog::glyph_name_edit(const Glib::ustring&, const Glib::ustring& if (!i) return; SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; - glyph->repr->setAttribute("glyph-name", str.c_str()); + //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("glyph-name", str.c_str()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); update_glyphs(); } @@ -592,10 +601,11 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin if (!i) return; SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; - glyph->repr->setAttribute("unicode", str.c_str()); + //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("unicode", str.c_str()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); update_glyphs(); } @@ -604,9 +614,10 @@ void SvgFontsDialog::remove_selected_font(){ SPFont* font = get_selected_spfont(); if (!font) return; - sp_repr_unparent(font->repr); + //XML Tree being directly used here while it shouldn't be. + sp_repr_unparent(font->getRepr()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); update_fonts(); } @@ -618,10 +629,12 @@ void SvgFontsDialog::remove_selected_glyph(){ if(!i) return; SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; - sp_repr_unparent(glyph->repr); + + //XML Tree being directly used here while it shouldn't be. + sp_repr_unparent(glyph->getRepr()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); update_glyphs(); } @@ -633,10 +646,12 @@ void SvgFontsDialog::remove_selected_kerning_pair(){ if(!i) return; SPGlyphKerning* pair = (*i)[_KerningPairsListColumns.spnode]; - sp_repr_unparent(pair->repr); + + //XML Tree being directly used here while it shouldn't be. + sp_repr_unparent(pair->getRepr()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); update_glyphs(); } @@ -707,11 +722,10 @@ void SvgFontsDialog::add_kerning_pair(){ if (this->kerning_pair) return; //We already have this kerning pair SPDocument* document = sp_desktop_document(this->getDesktop()); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); + Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new hkern node - Inkscape::XML::Node *repr; - repr = xml_doc->createElement("svg:hkern"); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:hkern"); repr->setAttribute("u1", first_glyph.get_active_text().c_str()); repr->setAttribute("u2", second_glyph.get_active_text().c_str()); @@ -724,7 +738,7 @@ void SvgFontsDialog::add_kerning_pair(){ // get corresponding object this->kerning_pair = SP_HKERN( document->getObjectByRepr(repr) ); - sp_document_done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair")); + DocumentUndo::done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair")); } Gtk::VBox* SvgFontsDialog::kerning_tab(){ @@ -774,11 +788,10 @@ SPFont *new_font(SPDocument *document) SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); + Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new font - Inkscape::XML::Node *repr; - repr = xml_doc->createElement("svg:font"); + Inkscape::XML::Node *repr = xml_doc->createElement("svg:font"); //By default, set the horizontal advance to 1024 units repr->setAttribute("horiz-adv-x", "1024"); @@ -813,11 +826,12 @@ void set_font_family(SPFont* font, char* str){ SPObject* obj; for (obj=font->children; obj; obj=obj->next){ if (SP_IS_FONTFACE(obj)){ - obj->repr->setAttribute("font-family", str); + //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("font-family", str); } } - sp_document_done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); + DocumentUndo::done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); } void SvgFontsDialog::add_font(){ @@ -833,14 +847,15 @@ void SvgFontsDialog::add_font(){ SPObject* obj; for (obj=font->children; obj; obj=obj->next){ if (SP_IS_FONTFACE(obj)){ - obj->repr->setAttribute("font-family", os2.str().c_str()); + //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("font-family", os2.str().c_str()); } } update_fonts(); // select_font(font); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); } SvgFontsDialog::SvgFontsDialog() diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 4c8a018fa..b2b1b26da 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -5,6 +5,7 @@ /* Authors: * Jon A. Cruz * John Bintz + * Abhishek Sharma * * Copyright (C) 2005 Jon A. Cruz * Copyright (C) 2008 John Bintz @@ -155,7 +156,7 @@ static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ ) SPDocument *doc = desktop ? desktop->doc() : 0; if (doc) { std::string targetName(bounceTarget->def.descr); - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); + const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { @@ -177,13 +178,13 @@ void SwatchesPanelHook::convertGradient( GtkMenuItem * /*menuitem*/, gpointer us if ( doc && (index >= 0) && (static_cast<guint>(index) < popupItems.size()) ) { Glib::ustring targetName = popupItems[index]; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); + const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { grad->setSwatch(); - sp_document_done(doc, SP_VERB_CONTEXT_GRADIENT, - _("Add gradient stop")); + DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, + _("Add gradient stop")); break; } } @@ -199,13 +200,13 @@ void SwatchesPanelHook::deleteGradient( GtkMenuItem */*menuitem*/, gpointer /*us SPDocument *doc = desktop ? desktop->doc() : 0; if (doc) { std::string targetName(bounceTarget->def.descr); - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); + const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { grad->setSwatch(false); - sp_document_done(doc, SP_VERB_CONTEXT_GRADIENT, - _("Delete")); + DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, + _("Delete")); break; } } @@ -320,7 +321,7 @@ gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, g SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(wdgt); if ( dtw && dtw->desktop ) { // Pick up all gradients with vectors - const GSList *gradients = sp_document_get_resource_list(dtw->desktop->doc(), "gradient"); + const GSList *gradients = (dtw->desktop->doc())->getResourceList("gradient"); gint index = 0; for (const GSList *curr = gradients; curr; curr = curr->next) { SPGradient* grad = SP_GRADIENT(curr->data); @@ -773,7 +774,7 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) } docPerPanel[panel] = document; if (!found) { - sigc::connection conn1 = sp_document_resources_changed_connect( document, "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); + sigc::connection conn1 = document->connectResourcesChanged( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); @@ -811,7 +812,7 @@ static void recalcSwatchContents(SPDocument* doc, { std::vector<SPGradient*> newList; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); + const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( grad->isSwatch() ) { @@ -967,7 +968,8 @@ void SwatchesPanel::_updateFromSelection() } } if ( target ) { - gchar const* id = target->repr->attribute("id"); + //XML Tree being used directly here while it shouldn't be + gchar const* id = target->getRepr()->attribute("id"); if ( id ) { fillId = id; } @@ -998,7 +1000,8 @@ void SwatchesPanel::_updateFromSelection() } } if ( target ) { - gchar const* id = target->repr->attribute("id"); + //XML Tree being used directly here while it shouldn't be + gchar const* id = target->getRepr()->attribute("id"); if ( id ) { strokeId = id; } diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index b50610938..fccf5c105 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -5,6 +5,7 @@ * Bob Jamison ( based off trace dialog) * John Cliff * Other dudes from The Inkscape Organization + * Abhishek Sharma * * Copyright (C) 2004 Bob Jamison * Copyright (C) 2004 John Cliff @@ -46,8 +47,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) using Geom::X; using Geom::Y; - Geom::OptRect a = first->getBounds(sp_item_i2doc_affine(first)); - Geom::OptRect b = second->getBounds(sp_item_i2doc_affine(second)); + Geom::OptRect a = first->getBounds(first->i2doc_affine()); + Geom::OptRect b = second->getBounds(second->i2doc_affine()); if ( !a || !b ) { // FIXME? @@ -86,8 +87,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - Geom::OptRect a = first->getBounds(sp_item_i2doc_affine(first)); - Geom::OptRect b = second->getBounds(sp_item_i2doc_affine(second)); + Geom::OptRect a = first->getBounds(first->i2doc_affine()); + Geom::OptRect b = second->getBounds(second->i2doc_affine()); if ( !a || !b ) { // FIXME? @@ -159,14 +160,14 @@ void TileDialog::Grid_Arrange () grid_top = 99999; SPDesktop *desktop = getDesktop(); - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); + sp_desktop_document(desktop)->ensureUpToDate(); Inkscape::Selection *selection = sp_desktop_selection (desktop); const GSList *items = selection ? selection->itemList() : 0; cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect b = item->getBounds(item->i2doc_affine()); if (!b) { continue; } @@ -209,7 +210,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect b = item->getBounds(item->i2doc_affine()); if (b) { width = b->dimensions()[Geom::X]; height = b->dimensions()[Geom::Y]; @@ -316,7 +317,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h for (; current_row != NULL; current_row = current_row->next) { SPItem *item=SP_ITEM(current_row->data); Inkscape::XML::Node *repr = SP_OBJECT_REPR(item); - Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect b = item->getBounds(item->i2doc_affine()); Geom::Point min; if (b) { width = b->dimensions()[Geom::X]; @@ -336,16 +337,16 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h // signs are inverted between x and y due to y inversion Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); Geom::Matrix const affine = Geom::Matrix(Geom::Translate(move)); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); - sp_item_write_transform(item, repr, item->transform, NULL); + item->set_i2d_affine(item->i2d_affine() * affine); + item->doWriteTransform(repr, item->transform, NULL); SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; } g_slist_free (current_row); } - sp_document_done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE, - _("Arrange in a grid")); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GRIDTILE, + _("Arrange in a grid")); } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 338e11d38..c895f0be9 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -4,6 +4,7 @@ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * buliabyak@gmail.com + * Abhishek Sharma * * Copyright (C) 2004, 2005 Authors * Released under GNU GPL. Read the file 'COPYING' for more information. @@ -636,7 +637,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = sp_item_bbox_desktop(*it); + Geom::OptRect bbox = (*it)->getBboxDesktop(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -660,7 +661,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = sp_item_bbox_desktop(*it); + Geom::OptRect bbox = (*it)->getBboxDesktop(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -687,8 +688,8 @@ Transformation::applyPageMove(Inkscape::Selection *selection) } } - sp_document_done ( sp_desktop_document (selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, - _("Move")); + DocumentUndo::done( sp_desktop_document(selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, + _("Move")); } void @@ -704,7 +705,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) Geom::Scale scale (0,0); // the values are increments! if (_units_scale.isAbsolute()) { - Geom::OptRect bbox(sp_item_bbox_desktop(item)); + Geom::OptRect bbox(item->getBboxDesktop()); if (bbox) { double new_width = scaleX; if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object @@ -744,8 +745,8 @@ Transformation::applyPageScale(Inkscape::Selection *selection) } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - _("Scale")); + DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + _("Scale")); } void @@ -766,8 +767,8 @@ Transformation::applyPageRotate(Inkscape::Selection *selection) } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - _("Rotate")); + DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + _("Rotate")); } void @@ -791,7 +792,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); - Geom::OptRect bbox(sp_item_bbox_desktop(item)); + Geom::OptRect bbox(item->getBboxDesktop()); if (bbox) { double width = bbox->dimensions()[Geom::X]; double height = bbox->dimensions()[Geom::Y]; @@ -825,8 +826,8 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - _("Skew")); + DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + _("Skew")); } @@ -845,15 +846,15 @@ Transformation::applyPageTransform(Inkscape::Selection *selection) if (_check_replace_matrix.get_active()) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - sp_item_set_item_transform(item, displayed); + item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); } } else { sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - _("Edit transformation matrix")); + DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, + _("Edit transformation matrix")); } diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index 111dc014d..17d032758 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -3,6 +3,7 @@ */ /* Author: * Gustav Broberg <broberg@kth.se> + * Abhishek Sharma * * Copyright (C) 2006 Authors * Released under GNU GPL. Read the file 'COPYING' for more information. @@ -214,7 +215,7 @@ UndoHistory::_onListSelectionChange() _event_log->blockNotifications(); for ( --last ; curr_event != last ; ++curr_event ) { - sp_document_redo(_document); + DocumentUndo::redo(_document); } _event_log->blockNotifications(false); @@ -248,7 +249,7 @@ UndoHistory::_onListSelectionChange() while ( selected != last_selected ) { - sp_document_undo(_document); + DocumentUndo::undo(_document); if ( last_selected->parent() && last_selected == last_selected->parent()->children().begin() ) @@ -273,7 +274,7 @@ UndoHistory::_onListSelectionChange() while ( selected != last_selected ) { - sp_document_redo(_document); + DocumentUndo::redo(_document); if ( !last_selected->children().empty() ) { _event_log->setCurrEventParent(last_selected); @@ -317,10 +318,10 @@ UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::T EventLog::const_iterator last = curr_event_parent->children().end(); _event_log->blockNotifications(); - sp_document_redo(_document); + DocumentUndo::redo(_document); for ( --last ; curr_event != last ; ++curr_event ) { - sp_document_redo(_document); + DocumentUndo::redo(_document); } _event_log->blockNotifications(false); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 82446b7b4..ef1c764bb 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -3,6 +3,7 @@ */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> + * Abhishek Sharma * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@ -706,9 +707,9 @@ void MultiPathManipulator::_commit(CommitEvent cps) _selection.signal_update.emit(); invokeForAll(&PathManipulator::writeXML); if (key) { - sp_document_maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason); + DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason); } else { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); } signal_coords_changed.emit(); } @@ -717,7 +718,7 @@ void MultiPathManipulator::_commit(CommitEvent cps) void MultiPathManipulator::_done(gchar const *reason) { invokeForAll(&PathManipulator::update); invokeForAll(&PathManipulator::writeXML); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); signal_coords_changed.emit(); } diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e046fb573..8661e7946 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -3,6 +3,7 @@ */ /* Authors: * Krzysztof Kosiński <tweenk@gmail.com> + * Abhishek Sharma * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@ -365,7 +366,8 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh using namespace Inkscape::UI; if (!obj) return; - if (SP_IS_PATH(obj) && obj->repr->attribute("inkscape:original-d") != NULL) { + //XML Tree being used directly here while it shouldn't be. + if (SP_IS_PATH(obj) && obj->getRepr()->attribute("inkscape:original-d") != NULL) { ShapeRecord r; r.item = static_cast<SPItem*>(obj); r.edit_transform = Geom::identity(); // TODO wrong? @@ -380,7 +382,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh ShapeRecord r; r.item = item; // TODO add support for objectBoundingBox - r.edit_transform = base ? sp_item_i2doc_affine(base) : Geom::identity(); + r.edit_transform = base ? base->i2doc_affine() : Geom::identity(); r.role = role; if (s.insert(r).second) { // this item was encountered the first time @@ -481,7 +483,7 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) nt->flashed_item = over_item; SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(over_item)); - c->transform(sp_item_i2d_affine(over_item)); + c->transform(over_item->i2d_affine()); SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0, @@ -612,8 +614,7 @@ void ink_node_tool_select_area(InkNodeTool *nt, Geom::Rect const &sel, GdkEventB if (nt->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = nt->desktop->selection; - GSList *items = sp_document_items_in_box( - sp_desktop_document(nt->desktop), nt->desktop->dkey, sel); + GSList *items = sp_desktop_document(nt->desktop)->getItemsInBox(nt->desktop->dkey, sel); selection->setList(items); g_slist_free(items); } else { diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index bb8ce0fb5..5ae9c4137 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -3,6 +3,7 @@ */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> + * Abhishek Sharma * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@ -108,7 +109,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _path(path) , _spcurve(new SPCurve()) , _dragpoint(new CurveDragPoint(*this)) - , _observer(new PathManipulatorObserver(this, SP_OBJECT(path)->repr)) + , /* XML Tree being used here directly while it shouldn't be*/_observer(new PathManipulatorObserver(this, SP_OBJECT(path)->getRepr())) , _edit_transform(et) , _num_selected(0) , _show_handles(true) @@ -119,7 +120,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _lpe_key(lpe_key) { if (_lpe_key.empty()) { - _i2d_transform = sp_item_i2d_affine(SP_ITEM(path)); + _i2d_transform = SP_ITEM(path)->i2d_affine(); } else { _i2d_transform = Geom::identity(); } @@ -1023,7 +1024,7 @@ void PathManipulator::_externalChange(unsigned type) } break; case PATH_CHANGE_TRANSFORM: { Geom::Matrix i2d_change = _d2i_transform; - _i2d_transform = sp_item_i2d_affine(SP_ITEM(_path)); + _i2d_transform = SP_ITEM(_path)->i2d_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { @@ -1104,7 +1105,9 @@ void PathManipulator::_createControlPointsFromGeometry() // so that pickBestType works correctly // TODO maybe migrate to inkscape:node-types? // TODO move this into SPPath - do not manipulate directly - gchar const *nts_raw = _path ? _path->repr->attribute(_nodetypesKey().data()) : 0; + + //XML Tree being used here directly while it shouldn't be. + gchar const *nts_raw = _path ? _path->getRepr()->attribute(_nodetypesKey().data()) : 0; std::string nodetype_string = nts_raw ? nts_raw : ""; /* Calculate the needed length of the nodetype string. * For closed paths, the entry is duplicated for the starting node, @@ -1279,10 +1282,11 @@ void PathManipulator::_setGeometry() LIVEPATHEFFECT(_path)->requestModified(SP_OBJECT_MODIFIED_FLAG); } } else { - if (_path->repr->attribute("inkscape:original-d")) + //XML Tree being used here directly while it shouldn't be. + if (_path->getRepr()->attribute("inkscape:original-d")) sp_path_set_original_curve(_path, _spcurve, false, false); else - sp_shape_set_curve(SP_SHAPE(_path), _spcurve, false); + SP_SHAPE(_path)->setCurve(_spcurve, false); } } @@ -1297,8 +1301,10 @@ Glib::ustring PathManipulator::_nodetypesKey() * This method is wrong but necessary at the moment. */ Inkscape::XML::Node *PathManipulator::_getXMLNode() { - if (_lpe_key.empty()) return _path->repr; - return LIVEPATHEFFECT(_path)->repr; + //XML Tree being used here directly while it shouldn't be. + if (_lpe_key.empty()) return _path->getRepr(); + //XML Tree being used here directly while it shouldn't be. + return LIVEPATHEFFECT(_path)->getRepr(); } bool PathManipulator::_nodeClicked(Node *n, GdkEventButton *event) @@ -1416,14 +1422,14 @@ void PathManipulator::_removeNodesFromSelection() void PathManipulator::_commit(Glib::ustring const &annotation) { writeXML(); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); } void PathManipulator::_commit(Glib::ustring const &annotation, gchar const *key) { writeXML(); - sp_document_maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, - annotation.data()); + DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, + annotation.data()); } /** Update the position of the curve drag point such that it is over the nearest diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index 1b498a846..f05e024d1 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -1,11 +1,10 @@ -#define __SP_VIEW_C__ - /** \file * View implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@ -156,7 +155,7 @@ void View::setDocument(SPDocument *doc) { _doc->connectURISet(sigc::bind(sigc::ptr_fun(&_onDocumentURISet), this)); _document_resized_connection = _doc->connectResized(sigc::bind(sigc::ptr_fun(&_onDocumentResized), this)); - _document_uri_set_signal.emit (SP_DOCUMENT_URI(_doc)); + _document_uri_set_signal.emit( _doc->getURI() ); } }}} diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index b7a67b744..650ed10f6 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -1,5 +1,3 @@ -#define __COLOR_PICKER_C__ - /** \file * \brief Color picker button & window * @@ -7,6 +5,7 @@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Ralf Stephan <ralf@ark.in-berlin.de> + * Abhishek Sharma * * Copyright (C) Authors 2000-2005 * @@ -132,8 +131,8 @@ sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp) (ptr->_preview).setRgba32 (rgba); if (ptr->_undo && SP_ACTIVE_DESKTOP) - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, - /* TODO: annotate */ "color-picker.cpp:130"); + DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, + /* TODO: annotate */ "color-picker.cpp:130"); ptr->on_changed (rgba); _in_use = false; diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index 968e35b6c..e191a9360 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -6,6 +6,8 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2000 - 2005 Authors * @@ -20,6 +22,7 @@ #include <gtkmm/entry.h> #include "inkscape.h" +#include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" @@ -80,10 +83,14 @@ EntityLineEntry::~EntityLineEntry() delete static_cast<Gtk::Entry*>(_packable); } -void -EntityLineEntry::update (SPDocument *doc) +void EntityLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); + // If RDF title is not set, get the document's <title> and set the RDF: + if ( !text && !strcmp(_entity->name, "title") && doc->root ) { + text = doc->root->title(); + rdf_set_work_entity(doc, _entity, text); + } static_cast<Gtk::Entry*>(_packable)->set_text (text ? text : ""); } @@ -95,9 +102,10 @@ EntityLineEntry::on_changed() _wr->setUpdating (true); SPDocument *doc = SP_ACTIVE_DOCUMENT; Glib::ustring text = static_cast<Gtk::Entry*>(_packable)->get_text(); - if (rdf_set_work_entity (doc, _entity, text.c_str())) - sp_document_done (doc, SP_VERB_NONE, - /* TODO: annotate */ "entity-entry.cpp:101"); + if (rdf_set_work_entity (doc, _entity, text.c_str())) { + DocumentUndo::done(doc, SP_VERB_NONE, + /* TODO: annotate */ "entity-entry.cpp:101"); + } _wr->setUpdating (false); } @@ -121,10 +129,14 @@ EntityMultiLineEntry::~EntityMultiLineEntry() delete static_cast<Gtk::ScrolledWindow*>(_packable); } -void -EntityMultiLineEntry::update (SPDocument *doc) +void EntityMultiLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); + // If RDF title is not set, get the document's <title> and set the RDF: + if ( !text && !strcmp(_entity->name, "title") && doc->root ) { + text = doc->root->title(); + rdf_set_work_entity(doc, _entity, text); + } Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); Gtk::TextView *tv = static_cast<Gtk::TextView*>(s->get_child()); tv->get_buffer()->set_text (text ? text : ""); @@ -140,9 +152,10 @@ EntityMultiLineEntry::on_changed() Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); Gtk::TextView *tv = static_cast<Gtk::TextView*>(s->get_child()); Glib::ustring text = tv->get_buffer()->get_text(); - if (rdf_set_work_entity (doc, _entity, text.c_str())) - sp_document_done (doc, SP_VERB_NONE, - /* TODO: annotate */ "entity-entry.cpp:146"); + if (rdf_set_work_entity (doc, _entity, text.c_str())) { + DocumentUndo::done(doc, SP_VERB_NONE, + /* TODO: annotate */ "entity-entry.cpp:146"); + } _wr->setUpdating (false); } diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 71ba4428c..c60e94ab7 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -4,6 +4,7 @@ * Authors: * Bob Jamison * Other dudes from The Inkscape Organization + * Abhishek Sharma * * Copyright (C) 2004 The Inkscape Organization * @@ -76,7 +77,7 @@ ImageIcon::ImageIcon(const ImageIcon &other) ImageIcon::~ImageIcon() { if (document) - sp_document_unref(document); + document->doUnref(); } @@ -98,11 +99,11 @@ bool ImageIcon::showSvgDocument(const SPDocument *docArg) { if (document) - sp_document_unref(document); + document->doUnref(); SPDocument *doc = (SPDocument *)docArg; - sp_document_ref(doc); + doc->doRef(); document = doc; //This should remove it from the box, and free resources @@ -127,7 +128,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) fileName = Glib::filename_to_utf8(fileName); - SPDocument *doc = sp_document_new (fileName.c_str(), 0); + SPDocument *doc = SPDocument::createNewDoc (fileName.c_str(), 0); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -135,7 +136,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) showSvgDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } @@ -148,7 +149,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); - SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0); + SPDocument *doc = SPDocument::createNewDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; @@ -156,7 +157,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) showSvgDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 5fb8089b4..6d1da0af0 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -3,6 +3,7 @@ * * Authors: * MenTaLguY <mental@rydia.net> + * Abhishek Sharma * * Copyright (C) 2004 MenTaLguY * @@ -583,16 +584,16 @@ void LayerSelector::_prepareLabelRenderer( void LayerSelector::_lockLayer(bool lock) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setLocked(lock); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, - lock? _("Lock layer") : _("Unlock layer")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, + lock? _("Lock layer") : _("Unlock layer")); } } void LayerSelector::_hideLayer(bool hide) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setHidden(hide); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, - hide? _("Hide layer") : _("Unhide layer")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, + hide? _("Hide layer") : _("Unhide layer")); } } diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index a5f1d89be..c9550bb27 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -6,6 +6,7 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) + * Abhishek Sharma * * Copyright (C) 2000 - 2005 Authors * @@ -64,8 +65,8 @@ LicenseItem::on_toggled() _wr.setUpdating (true); rdf_set_license (SP_ACTIVE_DOCUMENT, _lic->details ? _lic : 0); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_NONE, - /* TODO: annotate */ "licensor.cpp:65"); + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_NONE, + /* TODO: annotate */ "licensor.cpp:65"); _wr.setUpdating (false); static_cast<Gtk::Entry*>(_eep->_packable)->set_text (_lic->uri); _eep->on_changed(); diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index a9b4fe83e..1de425da3 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -5,6 +5,7 @@ * Bryce W. Harrington <bryce@bryceharrington.org> * Gustav Broberg <broberg@kth.se> * Niko Kiirala <niko@kiirala.com> + * Abhishek Sharma * * Copyright (C) 2004--2008 Authors * @@ -168,7 +169,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() SP_OBJECT_STYLE_MODIFIED_FLAG )); } - sp_document_maybe_done (document, _blur_tag.c_str(), _verb_code, + DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code, _("Change blur")); // resume interruptibility @@ -208,7 +209,7 @@ ObjectCompositeSettings::_opacityValueChanged() sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, + DocumentUndo::maybeDone(sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, _("Change opacity")); // resume interruptibility diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 724848ca5..f7cb6f145 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -8,6 +8,7 @@ * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) * Bob Jamison <ishmal@users.sf.net> + * Abhishek Sharma * * Copyright (C) 2000 - 2006 Authors * @@ -415,14 +416,14 @@ PageSizer::setDim (double w, double h, bool changeList) if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); - double const old_height = sp_document_height(doc); - sp_document_set_width (doc, w, &_px_unit); - sp_document_set_height (doc, h, &_px_unit); + double const old_height = doc->getHeight(); + doc->setWidth (w, &_px_unit); + doc->setHeight (h, &_px_unit); // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset); - sp_document_done (doc, SP_VERB_NONE, _("Set page size")); + DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } if ( w != h ) { diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index db31d08d3..04bd27285 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -8,6 +8,7 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) + * Abhishek Sharma * * Copyright (C) 2000 - 2007 Authors * @@ -349,15 +350,15 @@ RegisteredColorPicker::on_changed (guint32 rgba) gchar c[32]; sp_svg_write_color(c, sizeof(c), rgba); - bool saved = sp_document_get_undo_sensitive (local_doc); - sp_document_set_undo_sensitive (local_doc, false); + bool saved = DocumentUndo::getUndoSensitive(local_doc); + DocumentUndo::setUndoSensitive(local_doc, false); local_repr->setAttribute(_ckey.c_str(), c); sp_repr_set_css_double(local_repr, _akey.c_str(), (rgba & 0xff) / 255.0); - sp_document_set_undo_sensitive (local_doc, saved); + DocumentUndo::setUndoSensitive(local_doc, saved); local_doc->setModifiedSinceSave(); - sp_document_done (local_doc, SP_VERB_NONE, - /* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed"); + DocumentUndo::done(local_doc, SP_VERB_NONE, + /* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed"); _wr->setUpdating (false); } diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 7aefbb90e..efb5eb70e 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -4,6 +4,7 @@ * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Johan Engelen <j.b.c.engelen@utwente.nl> + * Abhishek Sharma * * Copyright (C) 2005-2008 Authors * @@ -104,16 +105,18 @@ protected: local_doc = sp_desktop_document(dt); } - bool saved = sp_document_get_undo_sensitive (local_doc); - sp_document_set_undo_sensitive (local_doc, false); - if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr); - sp_document_set_undo_sensitive (local_doc, saved); + bool saved = DocumentUndo::getUndoSensitive(local_doc); + DocumentUndo::setUndoSensitive(local_doc, false); + if (!write_undo) { + local_repr->setAttribute(_key.c_str(), svgstr); + } + DocumentUndo::setUndoSensitive(local_doc, saved); local_doc->setModifiedSinceSave(); if (write_undo) { local_repr->setAttribute(_key.c_str(), svgstr); - sp_document_done (local_doc, event_type, event_description); + DocumentUndo::done(local_doc, event_type, event_description); } } diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index 7f260680b..107f4e8c6 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -6,6 +6,8 @@ * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Lauris Kaplinski + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma * * Copyright (C) 2005 Ralf Stephan * @@ -145,15 +147,15 @@ Ruler::on_button_release_event(GdkEventButton *evb) _dragging = false; if ( (_horiz_f ? wy : wx ) >= 0 ) { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_dt->doc()); + Inkscape::XML::Document *xml_doc = _dt->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); repr->setAttribute("orientation", _horiz_f ? "horizontal" : "vertical"); double const guide_pos_dt = event_dt[ _horiz_f ? Geom::Y : Geom::X ]; sp_repr_set_svg_double(repr, "position", guide_pos_dt); SP_OBJECT_REPR(_dt->namedview)->appendChild(repr); Inkscape::GC::release(repr); - sp_document_done(sp_desktop_document(_dt), SP_VERB_NONE, - /* TODO: annotate */ "ruler.cpp:157"); + DocumentUndo::done(sp_desktop_document(_dt), SP_VERB_NONE, + /* TODO: annotate */ "ruler.cpp:157"); } _dt->set_coordinate_status(event_dt); } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 8e11c8308..e7d8ac5a3 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -3,6 +3,7 @@ * * Author: * buliabyak@gmail.com + * Abhishek Sharma * * Copyright (C) 2005 author * @@ -464,8 +465,8 @@ void SelectedStyle::dragDataReceived( GtkWidget */*widget*/, sp_repr_css_set_property( css, (tracker->item == SS_FILL) ? "fill":"stroke", c ); sp_desktop_set_style( tracker->parent->_desktop, css ); sp_repr_css_attr_unref( css ); - sp_document_done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, - _("Drop color")); + DocumentUndo::done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, + _("Drop color")); } } break; @@ -477,8 +478,8 @@ void SelectedStyle::on_fill_remove() { sp_repr_css_set_property (css, "fill", "none"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Remove fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Remove fill")); } void SelectedStyle::on_stroke_remove() { @@ -486,8 +487,8 @@ void SelectedStyle::on_stroke_remove() { sp_repr_css_set_property (css, "stroke", "none"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Remove stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Remove stroke")); } void SelectedStyle::on_fill_unset() { @@ -495,8 +496,8 @@ void SelectedStyle::on_fill_unset() { sp_repr_css_unset_property (css, "fill"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Unset fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Unset fill")); } void SelectedStyle::on_stroke_unset() { @@ -511,8 +512,8 @@ void SelectedStyle::on_stroke_unset() { sp_repr_css_unset_property (css, "stroke-dasharray"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Unset stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Unset stroke")); } void SelectedStyle::on_fill_opaque() { @@ -520,8 +521,8 @@ void SelectedStyle::on_fill_opaque() { sp_repr_css_set_property (css, "fill-opacity", "1"); sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Make fill opaque")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Make fill opaque")); } void SelectedStyle::on_stroke_opaque() { @@ -529,8 +530,8 @@ void SelectedStyle::on_stroke_opaque() { sp_repr_css_set_property (css, "stroke-opacity", "1"); sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Make fill opaque")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Make fill opaque")); } void SelectedStyle::on_fill_lastused() { @@ -541,8 +542,8 @@ void SelectedStyle::on_fill_lastused() { sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Apply last set color to fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Apply last set color to fill")); } void SelectedStyle::on_stroke_lastused() { @@ -553,8 +554,8 @@ void SelectedStyle::on_stroke_lastused() { sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Apply last set color to stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Apply last set color to stroke")); } void SelectedStyle::on_fill_lastselected() { @@ -564,8 +565,8 @@ void SelectedStyle::on_fill_lastselected() { sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Apply last selected color to fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Apply last selected color to fill")); } void SelectedStyle::on_stroke_lastselected() { @@ -575,8 +576,8 @@ void SelectedStyle::on_stroke_lastselected() { sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Apply last selected color to stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Apply last selected color to stroke")); } void SelectedStyle::on_fill_invert() { @@ -595,8 +596,8 @@ void SelectedStyle::on_fill_invert() { sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Invert fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Invert fill")); } void SelectedStyle::on_stroke_invert() { @@ -615,8 +616,8 @@ void SelectedStyle::on_stroke_invert() { sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Invert stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Invert stroke")); } void SelectedStyle::on_fill_white() { @@ -627,8 +628,8 @@ void SelectedStyle::on_fill_white() { sp_repr_css_set_property (css, "fill-opacity", "1"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("White fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("White fill")); } void SelectedStyle::on_stroke_white() { @@ -639,8 +640,8 @@ void SelectedStyle::on_stroke_white() { sp_repr_css_set_property (css, "stroke-opacity", "1"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("White stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("White stroke")); } void SelectedStyle::on_fill_black() { @@ -651,8 +652,8 @@ void SelectedStyle::on_fill_black() { sp_repr_css_set_property (css, "fill-opacity", "1.0"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Black fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Black fill")); } void SelectedStyle::on_stroke_black() { @@ -663,8 +664,8 @@ void SelectedStyle::on_stroke_black() { sp_repr_css_set_property (css, "stroke-opacity", "1.0"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Black stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Black stroke")); } void SelectedStyle::on_fill_copy() { @@ -706,8 +707,8 @@ void SelectedStyle::on_fill_paste() { sp_repr_css_set_property (css, "fill", text.c_str()); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Paste fill")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Paste fill")); } } @@ -724,8 +725,8 @@ void SelectedStyle::on_stroke_paste() { sp_repr_css_set_property (css, "stroke", text.c_str()); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Paste stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Paste stroke")); } } @@ -778,8 +779,8 @@ void SelectedStyle::on_fillstroke_swap() { sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Swap fill and stroke")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Swap fill and stroke")); } void SelectedStyle::on_fill_edit() { @@ -853,8 +854,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) sp_repr_css_set_property (css, "opacity", opacity); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document (_desktop), SP_VERB_DIALOG_FILL_STROKE, - _("Change opacity")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, + _("Change opacity")); return true; } @@ -888,8 +889,8 @@ void SelectedStyle::on_popup_preset(int i) { // FIXME: update dash patterns! sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES, - _("Change stroke width")); + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES, + _("Change stroke width")); } void @@ -1147,8 +1148,8 @@ void SelectedStyle::on_opacity_changed () { sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(_desktop), 0); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, - _("Change opacity")); + DocumentUndo::maybeDone(sp_desktop_document(_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, + _("Change opacity")); // resume interruptibility sp_canvas_end_forced_full_redraws(sp_desktop_canvas(_desktop)); spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj())); @@ -1274,19 +1275,19 @@ RotateableSwatch::do_motion(double by, guint modifier) { if (modifier == 3) { // Alt, do nothing } else if (modifier == 2) { // saturation - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation"))); double ch = hsl[1]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 1) { // lightness - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness"))); double ch = hsl[2]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); } else { // hue - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue"))); double ch = hsl[0]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff); @@ -1315,15 +1316,15 @@ RotateableSwatch::do_release(double by, guint modifier) { if (modifier == 3) { // Alt, do nothing } else if (modifier == 2) { // saturation - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation")); } else if (modifier == 1) { // lightness - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness")); } else { // hue - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue")); } @@ -1397,7 +1398,7 @@ RotateableStrokeWidth::do_motion(double by, guint modifier) { if (modifier == 3) { // Alt, do nothing } else { double diff = value_adjust(startvalue, by, modifier, false); - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>stroke width</b>: was %.3g, now <b>%.3g</b> (diff %.3g)"), startvalue, startvalue + diff, diff); } @@ -1411,7 +1412,7 @@ RotateableStrokeWidth::do_release(double by, guint modifier) { } else { value_adjust(startvalue, by, modifier, true); startvalue_set = false; - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, + DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); } diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 09001a993..f4780896b 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -2,6 +2,7 @@ * \brief Abstraction for different style widget operands * * Copyright (C) 2007 MenTaLguY <mental@rydia.net> + * Abhishek Sharma * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -146,7 +147,7 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() { Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { SPObject *layer = _getLayer(); if (layer && SP_IS_ITEM(layer)) { - return sp_item_bbox_desktop(SP_ITEM(layer), type); + return SP_ITEM(layer)->getBboxDesktop(type); } else { return Geom::OptRect(); } diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 3a36127f4..cc179ddbc 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -4,6 +4,7 @@ * * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> + * Abhishek Sharma * * Copyright (C) 2006 Authors * @@ -186,11 +187,11 @@ ToleranceSlider::update (double val) _wr->setUpdating (true); SPDocument *doc = sp_desktop_document(dt); - bool saved = sp_document_get_undo_sensitive (doc); - sp_document_set_undo_sensitive (doc, false); + bool saved = DocumentUndo::getUndoSensitive(doc); + DocumentUndo::setUndoSensitive(doc, false); Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt)); repr->setAttribute(_key.c_str(), os.str().c_str()); - sp_document_set_undo_sensitive (doc, saved); + DocumentUndo::setUndoSensitive(doc, saved); doc->setModifiedSinceSave(); |
