diff options
58 files changed, 166 insertions, 147 deletions
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index f23e4d883..90f1707b9 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -190,7 +190,7 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g * circumstances, after 'vacuum defs' or when a pre-0.46 file is opened). */ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { - SPDefs *defs = reinterpret_cast<SPDefs *>(SP_DOCUMENT_DEFS(document)); + SPDefs *defs = document->getDefs(); bool has_persp = false; for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 0c74a8f7e..fdbe33222 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -217,7 +217,7 @@ void box3d_side_set_shape (SPShape *shape) { Box3DSide *side = SP_BOX3D_SIDE (shape); - if (!side->document->root) { + if (!side->document->getRoot()) { // avoid a warning caused by sp_document_height() (which is called from sp_item_i2d_affine() below) // when reading a file containing 3D boxes return; diff --git a/src/desktop.cpp b/src/desktop.cpp index 361ed7fea..cfd3dddd0 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -93,6 +93,8 @@ #include "widgets/desktop-widget.h" #include "box3d-context.h" #include "desktop-style.h" +#include "sp-item-group.h" +#include "sp-root.h" // TODO those includes are only for node tool quick zoom. Remove them after fixing it. #include "ui/tool/node-tool.h" @@ -713,7 +715,7 @@ SPDesktop::set_coordinate_status (Geom::Point p) { SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return SPDocument::getItemFromListAtPointBottom(dkey, SP_GROUP (doc()->root), list, p); + return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); } /** diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 40b5f601e..7ad0eaa14 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -46,6 +46,7 @@ #include "../verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "sp-root.h" using Inkscape::DocumentUndo; diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index b05f6589a..4c1ad4af1 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -54,6 +54,7 @@ #include "preferences.h" #include "verbs.h" #include "interface.h" +#include "sp-root.h" #include "extension/output.h" #include "extension/db.h" @@ -784,7 +785,7 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, if ( SP_ACTIVE_DESKTOP ) { SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); if (bbox) { sp_export_set_area (base, bbox->min()[Geom::X], bbox->min()[Geom::Y], @@ -865,7 +866,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) /** \todo * This returns wrong values if the document has a viewBox. */ - bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); + bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); /* If the drawing is valid, then we'll use it and break otherwise we drop through to the page settings */ if (bbox) { @@ -1501,7 +1502,7 @@ sp_export_detect_size(GtkObject * base) { case SELECTION_DRAWING: { SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); + Geom::OptRect bbox = doc->getRoot()->getBboxDesktop(SPItem::RENDERING_BBOX); // std::cout << "Drawing " << bbox2; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) { diff --git a/src/dialogs/find.cpp b/src/dialogs/find.cpp index c112b3531..4d392a316 100644 --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@ -60,6 +60,7 @@ sp_find_dialog(){ #include "../sp-image.h" #include "../sp-offset.h" #include <xml/repr.h> +#include "sp-root.h" #define MIN_ONSCREEN_DISTANCE 50 diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index f72612420..ecdc0e0ca 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -40,6 +40,7 @@ #include "display/canvas-bpath.h" #include "display/curve.h" #include "document-undo.h" +#include "sp-root.h" #ifdef HAVE_ASPELL #include <aspell.h> diff --git a/src/document-private.h b/src/document-private.h index d641679ed..c851594c3 100644 --- a/src/document-private.h +++ b/src/document-private.h @@ -29,8 +29,6 @@ // XXX only for testing! #include "console-output-undo-observer.h" -#define SP_DOCUMENT_DEFS(d) ((SPObject *) SP_ROOT(d->getRoot())->defs) - namespace Inkscape { namespace XML { class Event; diff --git a/src/document.cpp b/src/document.cpp index c9b822ce6..22cfa5663 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -214,6 +214,11 @@ SPDocument::~SPDocument() { //delete this->_whiteboard_session_manager; } +SPDefs *SPDocument::getDefs() +{ + return root->defs; +} + Persp3D * SPDocument::getCurrentPersp3D() { // Check if current_persp3d is still valid @@ -243,8 +248,7 @@ SPDocument::setCurrentPersp3D(Persp3D * const persp) { void SPDocument::getPerspectivesInDefs(std::vector<Persp3D*> &list) const { - SPDefs *defs = SP_ROOT(this->root)->defs; - for (SPObject *i = defs->firstChild(); i; i = i->getNext() ) { + for (SPObject *i = root->defs->firstChild(); i; i = i->getNext() ) { if (SP_IS_PERSP3D(i)) { list.push_back(SP_PERSP3D(i)); } @@ -348,7 +352,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, rroot->setAttribute("baseProfile", NULL); // creating namedview - if (!sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview")) { + if (!sp_item_group_get_child_by_name(document->root, NULL, "sodipodi:namedview")) { // if there's none in the document already, Inkscape::XML::Node *rnew = NULL; @@ -388,13 +392,12 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, Inkscape::GC::release(rnew); } - /* Defs */ - if (!SP_ROOT(document->root)->defs) { - Inkscape::XML::Node *r; - r = rdoc->createElement("svg:defs"); + // Defs + if (!document->root->defs) { + Inkscape::XML::Node *r = rdoc->createElement("svg:defs"); rroot->addChild(r, NULL); Inkscape::GC::release(r); - g_assert(SP_ROOT(document->root)->defs); + g_assert(document->root->defs); } /* Default RDF */ @@ -520,17 +523,15 @@ gdouble SPDocument::getWidth() const g_return_val_if_fail(this->priv != NULL, 0.0); g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(this->root); - - if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) - return root->viewBox.x1 - root->viewBox.x0; - return root->width.computed; + gdouble result = root->width.computed; + if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { + result = root->viewBox.x1 - root->viewBox.x0; + } + return result; } void SPDocument::setWidth(gdouble width, const SPUnit *unit) { - SPRoot *root = SP_ROOT(this->root); - if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit); } else { // set to width= @@ -555,8 +556,6 @@ void SPDocument::setWidth(gdouble width, const SPUnit *unit) void SPDocument::setHeight(gdouble height, const SPUnit *unit) { - SPRoot *root = SP_ROOT(this->root); - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit); } else { // set to height= @@ -584,11 +583,11 @@ gdouble SPDocument::getHeight() const g_return_val_if_fail(this->priv != NULL, 0.0); g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(this->root); - - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) - return root->viewBox.y1 - root->viewBox.y0; - return root->height.computed; + gdouble result = root->height.computed; + if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { + result = root->viewBox.y1 - root->viewBox.y0; + } + return result; } Geom::Point SPDocument::getDimensions() const @@ -649,7 +648,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) - to_2geom(rect_with_margins.min())); - SP_GROUP(root)->translateChildItems(tr); + root->translateChildItems(tr); if(nv) { Geom::Translate tr2(-rect_with_margins.min()); @@ -922,17 +921,16 @@ void SPDocument::requestModified() } } -void -sp_document_setup_viewport (SPDocument *doc, SPItemCtx *ctx) +void SPDocument::setupViewport(SPItemCtx *ctx) { ctx->ctx.flags = 0; ctx->i2doc = Geom::identity(); - /* Set up viewport in case svg has it defined as percentages */ - if (SP_ROOT(doc->root)->viewBox_set) { // if set, take from viewBox - ctx->vp.x0 = SP_ROOT(doc->root)->viewBox.x0; - ctx->vp.y0 = SP_ROOT(doc->root)->viewBox.y0; - ctx->vp.x1 = SP_ROOT(doc->root)->viewBox.x1; - ctx->vp.y1 = SP_ROOT(doc->root)->viewBox.y1; + // Set up viewport in case svg has it defined as percentages + if (root->viewBox_set) { // if set, take from viewBox + ctx->vp.x0 = root->viewBox.x0; + ctx->vp.y0 = root->viewBox.y0; + ctx->vp.x1 = root->viewBox.x1; + ctx->vp.y1 = root->viewBox.y1; } else { // as a last resort, set size to A4 ctx->vp.x0 = 0.0; ctx->vp.y0 = 0.0; @@ -954,7 +952,7 @@ SPDocument::_updateDocument() if (this->root->uflags || this->root->mflags) { if (this->root->uflags) { SPItemCtx ctx; - sp_document_setup_viewport (this, &ctx); + setupViewport(&ctx); bool saved = DocumentUndo::getUndoSensitive(this); DocumentUndo::setUndoSensitive(this, false); diff --git a/src/document.h b/src/document.h index 2eb5e2e09..e3c70b2c6 100644 --- a/src/document.h +++ b/src/document.h @@ -44,6 +44,7 @@ struct SPDesktop; struct SPItem; struct SPObject; struct SPGroup; +struct SPRoot; namespace Inkscape { struct Application; @@ -57,9 +58,11 @@ namespace Inkscape { } } +class SPDefs; class SP3DBox; class Persp3D; class Persp3DImpl; +class SPItemCtx; namespace Proj { class TransfMat3x4; @@ -72,6 +75,8 @@ class SPDocument : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, public Inkscape::GC::Anchored { +// Note: multiple public and private sections is not a good practice, but happens +// in this class as transitional to fixing encapsulation: public: typedef sigc::signal<void, SPObject *> IDChangedSignal; typedef sigc::signal<void> ResourcesChangedSignal; @@ -91,7 +96,9 @@ public: Inkscape::XML::Document *rdoc; ///< Our Inkscape::XML::Document Inkscape::XML::Node *rroot; ///< Root element of Inkscape::XML::Document - SPObject *root; ///< Our SPRoot +private: + SPRoot *root; ///< Our SPRoot +public: CRCascade *style_cascade; protected: @@ -122,7 +129,7 @@ public: bool oldSignalsConnected; /** Returns our SPRoot */ - SPObject *getRoot() { return root; } + SPRoot *getRoot() { return root; } Inkscape::XML::Node *getReprRoot() { return rroot; } @@ -141,6 +148,9 @@ public: /** basename(uri) or other human-readable label for the document. */ gchar const* getName() const { return name; } + /** Return the main defs object for the document. */ + SPDefs *getDefs(); + void setCurrentPersp3D(Persp3D * const persp); inline void setCurrentPersp3DImpl(Persp3DImpl * const persp_impl) { current_persp3d_impl = persp_impl; } @@ -248,6 +258,7 @@ public: private: void do_change_uri(gchar const *const filename, bool const rebase); + void setupViewport(SPItemCtx *ctx); }; struct SPUnit; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index f5504d755..bbafd7e94 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -420,19 +420,18 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) ctx->popState(); } -static void sp_root_render(SPItem *item, CairoRenderContext *ctx) +static void sp_root_render(SPRoot *root, CairoRenderContext *ctx) { - SPRoot *root = SP_ROOT(item); CairoRenderer *renderer = ctx->getRenderer(); - if (!ctx->getCurrentState()->has_overflow && item->parent) + if (!ctx->getCurrentState()->has_overflow && root->parent) ctx->addClippingRect(root->x.computed, root->y.computed, root->width.computed, root->height.computed); ctx->pushState(); - renderer->setStateForItem(ctx, item); + renderer->setStateForItem(ctx, root); Geom::Affine tempmat (root->c2p); ctx->transform(&tempmat); - sp_group_render(item, ctx); + sp_group_render(root, ctx); ctx->popState(); } @@ -543,7 +542,7 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) if (SP_IS_ROOT(item)) { TRACE(("root\n")); - return sp_root_render(item, ctx); + return sp_root_render(SP_ROOT(item), ctx); } else if (SP_IS_SYMBOL(item)) { TRACE(("symbol\n")); return sp_symbol_render(item, ctx); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 715278051..fb8d4de4b 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -133,7 +133,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); - Inkscape::XML::Node * defsrepr = SP_DOCUMENT_DEFS(document->doc())->getRepr(); + Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); for(std::list<SPItem *>::iterator item = items.begin(); item != items.end(); item++) { diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 750849eb1..8399d602f 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -38,7 +38,7 @@ #include "helper/geom.h" #include "helper/geom-curves.h" #include <io/sys.h> - +#include "sp-root.h" #include <string> #include <stdio.h> @@ -758,7 +758,7 @@ bool JavaFXOutput::doTree(SPDocument *doc) miny = bignum; maxy = -bignum; - if (!doTreeRecursive(doc, doc->root)) { + if (!doTreeRecursive(doc, doc->getRoot())) { return false; } @@ -875,7 +875,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8) out(" content: [\n"); idindex = 0; - doBody(doc, doc->root); + doBody(doc, doc->getRoot()); if (!doTail()) { return false; diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 98142632d..cf7c48251 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -542,13 +542,10 @@ Flowing in rectangle is possible, not in arb shape. fprintf(_stream, "%s", os.str().c_str()); } -void -LaTeXTextRenderer::sp_root_render(SPItem *item) +void LaTeXTextRenderer::sp_root_render(SPRoot *root) { - SPRoot *root = SP_ROOT(item); - push_transform(root->c2p); - sp_group_render(item); + sp_group_render(root); pop_transform(); } @@ -561,7 +558,7 @@ LaTeXTextRenderer::sp_item_invoke_render(SPItem *item) } if (SP_IS_ROOT(item)) { - return sp_root_render(item); + return sp_root_render(SP_ROOT(item)); } else if (SP_IS_GROUP(item)) { return sp_group_render(item); } else if (SP_IS_USE(item)) { diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h index 2259427d6..66055a3bc 100644 --- a/src/extension/internal/latex-text-renderer.h +++ b/src/extension/internal/latex-text-renderer.h @@ -22,6 +22,7 @@ #include <stack> class SPItem; +struct SPRoot; namespace Inkscape { namespace Extension { @@ -60,7 +61,7 @@ protected: void writePostamble(); void sp_item_invoke_render(SPItem *item); - void sp_root_render(SPItem *item); + void sp_root_render(SPRoot *item); void sp_group_render(SPItem *item); void sp_use_render(SPItem *item); void sp_text_render(SPItem *item); diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index 94edf826e..dc995b7aa 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -531,7 +531,7 @@ void SvgBuilder::setClipPath(GfxState *state, bool even_odd) { clip_path->appendChild(path); Inkscape::GC::release(path); // Append clipPath to defs and get id - SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(clip_path); + _doc->getDefs()->getRepr()->appendChild(clip_path); gchar *urltext = g_strdup_printf ("url(#%s)", clip_path->attribute("id")); Inkscape::GC::release(clip_path); _container->setAttribute("clip-path", urltext); @@ -678,7 +678,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern, delete pattern_builder; // Append the pattern to defs - SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(pattern_node); + _doc->getDefs()->getRepr()->appendChild(pattern_node); gchar *id = g_strdup(pattern_node->attribute("id")); Inkscape::GC::release(pattern_node); @@ -752,7 +752,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for return NULL; } - Inkscape::XML::Node *defs = SP_DOCUMENT_DEFS(_doc)->getRepr(); + Inkscape::XML::Node *defs = _doc->getDefs()->getRepr(); defs->appendChild(gradient); gchar *id = g_strdup(gradient->attribute("id")); Inkscape::GC::release(gradient); @@ -1635,9 +1635,9 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) { sp_repr_set_svg_double(mask_node, "height", height); // Append mask to defs if (_is_top_level) { - SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(mask_node); + _doc->getDefs()->getRepr()->appendChild(mask_node); Inkscape::GC::release(mask_node); - return SP_DOCUMENT_DEFS(_doc)->getRepr()->lastChild(); + return _doc->getDefs()->getRepr()->lastChild(); } else { // Work around for renderer bug when mask isn't defined in pattern static int mask_count = 0; Inkscape::XML::Node *defs = _root->firstChild(); diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 1563d04c1..382f8cbfb 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -35,6 +35,7 @@ #include "helper/geom.h" #include "helper/geom-curves.h" #include <io/sys.h> +#include "sp-root.h" #include <string> #include <stdio.h> @@ -485,7 +486,7 @@ bool PovOutput::doTree(SPDocument *doc) miny = bignum; maxy = -bignum; - if (!doTreeRecursive(doc, doc->root)) + if (!doTreeRecursive(doc, doc->getRoot())) return false; //## Let's make a union of all of the Shapes diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 946ff22fe..afc706e89 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -24,6 +24,7 @@ #include "extension/output.h" #include <vector> #include "xml/attribute-record.h" +#include "sp-root.h" #ifdef WITH_GNOME_VFS # include <libgnomevfs/gnome-vfs.h> diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index fb53035a1..455fcc3bb 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -354,7 +354,7 @@ Parameter::new_child (Inkscape::XML::Node * parent) Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr(); + Inkscape::XML::Node * defs = doc->getDefs()->getRepr(); Inkscape::XML::Node * params = NULL; GQuark const name_quark = g_quark_from_string("inkscape:extension-params"); diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index 09ee9be0b..6da310d30 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -42,7 +42,7 @@ PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path) return; gchar ** patheffects = g_strsplit(patheffectlist, ";", 128); - Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr(); + Inkscape::XML::Node * defs = doc->getDefs()->getRepr(); for (int i = 0; patheffects[i] != NULL && i < 128; i++) { gchar * patheffect = patheffects[i]; diff --git a/src/file.cpp b/src/file.cpp index a1fc23117..2e7e74610 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -802,7 +802,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens } else { dialog_title = (char const *) _("Select file to save to"); } - gchar* doc_title = doc->root->title(); + gchar* doc_title = doc->getRoot()->title(); Inkscape::UI::Dialog::FileSaveDialog *saveDialog = Inkscape::UI::Dialog::FileSaveDialog::create( parentWindow, @@ -975,7 +975,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, prevent_id_clashes(doc, in_doc); - SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc); + SPObject *in_defs = in_doc->getDefs(); Inkscape::XML::Node *last_def = in_defs->getRepr()->lastChild(); SPCSSAttr *style = sp_css_attr_from_object(doc->getRoot()); @@ -1051,7 +1051,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // preserve parent and viewBox transformations // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); - Geom::Affine affine = SP_ROOT(doc->getRoot())->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); + Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index b2c5f3020..18a31f0d7 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -90,7 +90,7 @@ SPFilter *new_filter(SPDocument *document) { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -187,7 +187,7 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -242,7 +242,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -356,7 +356,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it // If there are more users for this filter, duplicate it if (filter->hrefcount > count_filter_hrefs(item, filter)) { Inkscape::XML::Node *repr = item->style->getFilter()->getRepr()->duplicate(xml_doc); - SPDefs *defs = reinterpret_cast<SPDefs *>(SP_DOCUMENT_DEFS(document)); + SPDefs *defs = document->getDefs(); defs->appendChild(repr); filter = SP_FILTER( document->getObjectByRepr(repr) ); diff --git a/src/forward.h b/src/forward.h index 897f3fe48..352fae6fa 100644 --- a/src/forward.h +++ b/src/forward.h @@ -52,12 +52,6 @@ class SPDocumentClass; class SPGroup; class SPGroupClass; -class SPDefs; -class SPDefsClass; - -class SPRoot; -class SPRootClass; - class SPNamedView; class SPNamedViewClass; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 86b63855b..889e319b2 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -106,7 +106,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr g_return_val_if_fail(SP_IS_GRADIENT(vector), NULL); g_return_val_if_fail(vector->hasStops(), NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new private gradient of the requested type @@ -208,7 +208,7 @@ SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *ve } SPDocument *doc = gr->document; - SPObject *defs = SP_DOCUMENT_DEFS(doc); + SPObject *defs = doc->getDefs(); if ((gr->hasStops()) || (gr->state != SP_GRADIENT_STATE_UNKNOWN) || @@ -259,7 +259,7 @@ SPGradient *sp_gradient_fork_vector_if_necessary(SPGradient *gr) Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = gr->getRepr()->duplicate(xml_doc); - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); + doc->getDefs()->getRepr()->addChild(repr, NULL); SPGradient *gr_new = (SPGradient *) doc->getObjectByRepr(repr); gr_new = sp_gradient_ensure_vector_normalized (gr_new); Inkscape::GC::release(repr); @@ -1198,7 +1198,7 @@ static void addStop( Inkscape::XML::Node *parent, Glib::ustring const &color, gi */ SPGradient *sp_document_default_gradient_vector( SPDocument *document, SPColor const &color, bool singleStop ) { - SPDefs *defs = static_cast<SPDefs *>(SP_DOCUMENT_DEFS(document)); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->rdoc; Inkscape::XML::Node *repr = xml_doc->createElement("svg:linearGradient"); diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 9f3f172ac..96454cf3a 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -69,7 +69,7 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current /* Get the marker we want */ SPObject *object = doc->getObjectById(name); if (object && SP_IS_MARKER(object)) { - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); + SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *mark_repr = object->getRepr()->duplicate(xml_doc); defs->getRepr()->addChild(mark_repr, NULL); @@ -113,7 +113,7 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) /* Get the pattern we want */ SPObject *object = doc->getObjectById(name); if (object && SP_IS_PATTERN(object)) { - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); + SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = object->getRepr()->duplicate(xml_doc); defs->getRepr()->addChild(pat_repr, NULL); @@ -156,7 +156,7 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) /* Get the gradient we want */ SPObject *object = doc->getObjectById(name); if (object && SP_IS_GRADIENT(object)) { - SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); + SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = object->getRepr()->duplicate(xml_doc); defs->getRepr()->addChild(pat_repr, NULL); @@ -195,7 +195,7 @@ SPObject *get_stock_item(gchar const *urn) SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); - SPDefs *defs = reinterpret_cast<SPDefs *>(SP_DOCUMENT_DEFS(doc)); + SPDefs *defs = doc->getDefs(); SPObject *object = NULL; if (!strcmp(base, "marker")) { diff --git a/src/id-clash.cpp b/src/id-clash.cpp index d305b5a9f..d5740c0ba 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -25,6 +25,7 @@ #include "sp-paint-server.h" #include "xml/node.h" #include "xml/repr.h" +#include "sp-root.h" typedef enum { REF_HREF, REF_STYLE, REF_URL, REF_CLIPBOARD } ID_REF_TYPE; diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index ed0d162ac..10abef4a1 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -262,7 +262,7 @@ void Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item) Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); repr->setAttribute("effect", name); - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute + doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute const gchar * repr_id = repr->attribute("id"); Inkscape::GC::release(repr); diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 1b5ed1d49..3e4e40198 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -253,7 +253,7 @@ LivePathEffectObject *LivePathEffectObject::fork_private_if_necessary(unsigned i Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *dup_repr = this->getRepr()->duplicate(xml_doc); - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(dup_repr, NULL); + doc->getDefs()->getRepr()->addChild(dup_repr, NULL); LivePathEffectObject *lpeobj_new = LIVEPATHEFFECT( doc->getObjectByRepr(dup_repr) ); Inkscape::GC::release(dup_repr); diff --git a/src/main.cpp b/src/main.cpp index ac0994be6..82a4b28c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1353,7 +1353,7 @@ sp_do_export_png(SPDocument *doc) } else if (sp_export_area_page || !(sp_export_id || sp_export_area_drawing)) { /* Export the whole page: note: Inkscape uses 'page' in all menus and dialogs, not 'canvas' */ doc->ensureUpToDate(); - Geom::Point origin (SP_ROOT(doc->root)->x.computed, SP_ROOT(doc->root)->y.computed); + Geom::Point origin(doc->getRoot()->x.computed, doc->getRoot()->y.computed); area = Geom::Rect(origin, origin + doc->getDimensions()); } diff --git a/src/marker.cpp b/src/marker.cpp index faffadd58..5dd23fb1e 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -713,7 +713,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine /*transform*/, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:marker"); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 1e2f71c95..682c26869 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -36,6 +36,7 @@ #include "sp-mask.h" #include "helper/geom-curves.h" #include "desktop.h" +#include "sp-root.h" Inkscape::ObjectSnapper::ObjectSnapper(SnapManager *sm, Geom::Coord const d) : Snapper(sm, d) diff --git a/src/persp3d.cpp b/src/persp3d.cpp index d43e6b2c5..0b346622a 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -209,7 +209,7 @@ persp3d_update(SPObject *object, SPCtx *ctx, guint flags) } Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// if dup is given, copy the attributes over - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr; @@ -253,7 +253,7 @@ Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// Persp3D *persp3d_document_first_persp(SPDocument *document) { Persp3D *first = 0; - for ( SPObject *child = SP_DOCUMENT_DEFS(document)->firstChild(); child && !first; child = child->getNext() ) { + for ( SPObject *child = document->getDefs()->firstChild(); child && !first; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { first = SP_PERSP3D(child); } @@ -565,7 +565,7 @@ persp3d_print_debugging_info (Persp3D *persp) { void persp3d_print_debugging_info_all(SPDocument *document) { - for ( SPObject *child = SP_DOCUMENT_DEFS(document)->firstChild(); child; child = child->getNext() ) { + for ( SPObject *child = document->getDefs()->firstChild(); child; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { persp3d_print_debugging_info(SP_PERSP3D(child)); } diff --git a/src/rdf.cpp b/src/rdf.cpp index c9378cf53..cabbaaed3 100644 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@ -18,6 +18,7 @@ #include "rdf.h" #include "sp-item-group.h" #include "inkscape.h" +#include "sp-root.h" /* Example RDF XML from various places... @@ -566,7 +567,9 @@ unsigned int RDFImpl::setReprText( Inkscape::XML::Node * repr, // set document's title element to the RDF title if (!strcmp(entity.name, "title")) { SPDocument *doc = SP_ACTIVE_DOCUMENT; - if(doc && doc->root) doc->root->setTitle(text); + if (doc && doc->getRoot()) { + doc->getRoot()->setTitle(text); + } } switch (entity.datatype) { @@ -1104,7 +1107,7 @@ void RDFImpl::setDefaults( SPDocument * doc ) g_assert( doc != NULL ); // Create metadata node if it doesn't already exist - if (!sp_item_group_get_child_by_name((SPGroup *) doc->root, NULL, + if (!sp_item_group_get_child_by_name( doc->getRoot(), NULL, XML_TAG_NAME_METADATA)) { if ( !doc->getReprDoc()) { g_critical("XML doc is null."); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 67aba5218..0f756a9a3 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3234,7 +3234,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) g_return_val_if_fail(doc != NULL, false); doc->ensureUpToDate(); - SPItem const *const root = SP_ITEM(doc->root); + SPItem const *const root = doc->getRoot(); Geom::OptRect const bbox(root->getBounds(root->i2d_affine(), SPItem::RENDERING_BBOX)); if (bbox) { doc->fitToRect(*bbox, with_margins); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index be5b9a4d1..89e140f12 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -357,7 +357,7 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view) // Create a mask element (using passed elements), add it to <defs> const gchar *SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform) { - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath"); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index a31961d2e..91342688a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -49,6 +49,7 @@ #include "sp-title.h" #include "sp-desc.h" #include "sp-switch.h" +#include "sp-defs.h" using Inkscape::DocumentUndo; @@ -345,8 +346,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) g_return_if_fail (SP_IS_GROUP (group)); SPDocument *doc = group->document; - SPObject *root = doc->getRoot(); - SPObject *defs = SP_OBJECT(SP_ROOT(root)->defs); + SPRoot *root = doc->getRoot(); + SPObject *defs = root->defs; SPItem *gitem = SP_ITEM (group); Inkscape::XML::Node *grepr = gitem->getRepr(); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 700efa572..513e52911 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -268,7 +268,7 @@ sp_mask_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML const gchar * sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform) { - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:mask"); diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 21410d4fd..84dc114db 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -20,6 +20,7 @@ #include "document.h" #include "sp-item-group.h" +#include "sp-root.h" #define noDEBUG_METADATA #ifdef DEBUG_METADATA @@ -213,7 +214,7 @@ sp_document_metadata (SPDocument *document) g_return_val_if_fail (document != NULL, NULL); - nv = sp_item_group_get_child_by_name ((SPGroup *) document->root, NULL, + nv = sp_item_group_get_child_by_name( document->getRoot(), NULL, "metadata"); g_assert (nv != NULL); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 001f7731f..1feb644ad 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -34,6 +34,7 @@ #include "preferences.h" #include "desktop.h" #include "conn-avoid-ref.h" // for defaultConnSpacing. +#include "sp-root.h" using Inkscape::DocumentUndo; @@ -1013,7 +1014,7 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) { g_return_val_if_fail(document != NULL, NULL); - SPObject *nv = sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview"); + SPObject *nv = sp_item_group_get_child_by_name(document->getRoot(), NULL, "sodipodi:namedview"); g_assert(nv != NULL); if (id == NULL) { @@ -1021,7 +1022,7 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) } while (nv && strcmp(nv->getId(), id)) { - nv = sp_item_group_get_child_by_name((SPGroup *) document->root, nv, "sodipodi:namedview"); + nv = sp_item_group_get_child_by_name(document->getRoot(), nv, "sodipodi:namedview"); } return (SPNamedView *) nv; diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 475a57521..a995739b1 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -89,11 +89,7 @@ static unsigned const N_NAME_TYPES = SODIPODI_TYPE + 1; static GType name_to_gtype(NameType name_type, gchar const *name); -/** - * Construct an SPRoot and all its descendents from the given repr. - */ -SPObject * -sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) +SPRoot *sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) { g_assert(document != NULL); g_assert(repr != NULL); @@ -108,7 +104,7 @@ sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) g_assert(object != NULL); object->invoke_build(document, repr, FALSE); - return object; + return SP_ROOT(object); } GType diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h index 02ad3ea93..407af0bcc 100644 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@ -21,7 +21,10 @@ class Node; } -SPObject * sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr); +/** + * Construct an SPRoot and all its descendents from the given repr. + */ +SPRoot *sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr); GType sp_repr_type_lookup (Inkscape::XML::Node *repr); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index c37e48983..e0b3e3201 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1604,9 +1604,9 @@ gchar const * SPObject::getStyleProperty(gchar const *key, gchar const *def) con */ void SPObject::_requireSVGVersion(Inkscape::Version version) { for ( SPObject::ParentIterator iter=this ; iter ; ++iter ) { - SPObject *object=iter; + SPObject *object = iter; if (SP_IS_ROOT(object)) { - SPRoot *root=SP_ROOT(object); + SPRoot *root = SP_ROOT(object); if ( root->version.svg < version ) { root->version.svg = version; } diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 0b2fe8389..d7522fce8 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -469,7 +469,7 @@ SPPattern *pattern_chain(SPPattern *pattern) { SPDocument *document = pattern->document; Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("inkscape:collect", "always"); @@ -522,7 +522,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); + Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("patternUnits", "userSpaceOnUse"); diff --git a/src/sp-root.h b/src/sp-root.h index ab379fb50..86b92b2b3 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -25,6 +25,8 @@ #include "enums.h" #include "sp-item-group.h" +class SPDefs; + /** \<svg\> element */ struct SPRoot : public SPGroup { struct { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 4f4f8a022..60379a966 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -894,7 +894,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) SPDocument *target_document = sp_desktop_document(desktop); Inkscape::XML::Node *root = clipdoc->getReprRoot(); Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); - Inkscape::XML::Node *target_defs = SP_DOCUMENT_DEFS(target_document)->getRepr(); + Inkscape::XML::Node *target_defs = target_document->getDefs()->getRepr(); Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); prevent_id_clashes(clipdoc, target_document); @@ -1197,7 +1197,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) gdouble dpi = PX_PER_IN; guint32 bgcolor = 0x00000000; - Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed); + Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); @@ -1254,7 +1254,7 @@ void ClipboardManagerImpl::_createInternalClipboard() if ( _clipboardSPDoc == NULL ) { _clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); - _defs = SP_DOCUMENT_DEFS(_clipboardSPDoc)->getRepr(); + _defs = _clipboardSPDoc->getDefs()->getRepr(); _doc = _clipboardSPDoc->getReprDoc(); _root = _clipboardSPDoc->getReprRoot(); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 81e2b64a9..a2169c0b3 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -43,6 +43,7 @@ #include "util/glib-list-iterators.h" #include "verbs.h" #include "widgets/icon.h" +#include "sp-root.h" #include "align-and-distribute.h" @@ -171,7 +172,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = static_cast<SPItem *>( sp_desktop_document(desktop)->getRoot() )->getBboxDesktop(); + Geom::OptRect b = 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]); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0c001da4b..b2ca2a3a8 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -145,7 +145,7 @@ DocumentProperties::init() Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->addListener (&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->addListener (&_repr_events, this); show_all_children(); @@ -156,7 +156,7 @@ DocumentProperties::~DocumentProperties() { Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->removeListenerByData (this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->removeListenerByData (this); } @@ -421,7 +421,7 @@ DocumentProperties::linkSelectedProfile() xml_doc->root()->addChild(defsRepr, NULL); } - g_assert(SP_ROOT(desktop->doc()->root)->defs); + g_assert(desktop->doc()->getDefs()); defsRepr->addChild(cprofRepr, NULL); // TODO check if this next line was sometimes needed. It being there caused an assertion. @@ -877,7 +877,7 @@ DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *docu { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = document->root->getRepr(); + Inkscape::XML::Node *root = document->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } @@ -887,7 +887,7 @@ DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *d { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } @@ -897,7 +897,7 @@ DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->removeListenerByData(this); } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index bdae14c62..aa6b4081e 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -50,6 +50,7 @@ #include "sp-use.h" #include "sp-image.h" #include "sp-offset.h" +#include "sp-root.h" #include "xml/repr.h" diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 0eca5bbca..30924ab86 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -35,6 +35,7 @@ #include "verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "sp-root.h" #include "layers.h" @@ -293,7 +294,7 @@ bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::Tre } void LayersPanel::_selectLayer( SPObject *layer ) { - if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->root)) ) { + if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->getRoot())) ) { if ( _tree.get_selection()->count_selected_rows() != 0 ) { _tree.get_selection()->unselect_all(); } @@ -328,7 +329,7 @@ void LayersPanel::_layersChanged() // g_message("_layersChanged()"); if (_desktop) { SPDocument* document = _desktop->doc(); - SPObject* root = document->root; + SPRoot* root = document->getRoot(); if ( root ) { _selectedConnection.block(); if ( _desktop->layer_manager && _desktop->layer_manager->includes( root ) ) { @@ -402,7 +403,7 @@ void LayersPanel::_pushTreeSelectionToCurrent() _desktop->layer_manager->setCurrentLayer( inTree ); } } else { - _desktop->layer_manager->setCurrentLayer( _desktop->doc()->root ); + _desktop->layer_manager->setCurrentLayer( _desktop->doc()->getRoot() ); } } } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 4d53154d8..fbca0bf10 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -794,7 +794,7 @@ SPFont *new_font(SPDocument *document) { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -911,7 +911,7 @@ SvgFontsDialog::SvgFontsDialog() _FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release)); create_fonts_popup_menu(_FontsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_font)); - _defs_observer.set(SP_DOCUMENT_DEFS(sp_desktop_document(this->getDesktop()))); + _defs_observer.set(sp_desktop_document(this->getDesktop())->getDefs()); _defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts)); _getContents()->show_all(); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 935fe9806..0f4626126 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -858,8 +858,8 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) docPerPanel[panel] = document; if (!found) { 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))) ); + sigc::connection conn2 = document->getDefs()->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); + sigc::connection conn3 = document->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); DocTrack *dt = new DocTrack(document, conn1, conn2, conn3); docTrackings.push_back(dt); diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index e191a9360..e62eb009c 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -25,6 +25,7 @@ #include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" +#include "sp-root.h" #include "entity-entry.h" @@ -87,8 +88,8 @@ 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(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } static_cast<Gtk::Entry*>(_packable)->set_text (text ? text : ""); @@ -133,8 +134,8 @@ 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(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index f306b9eea..672e1415b 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -422,7 +422,7 @@ PageSizer::setDim (double w, double h, bool changeList) // 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); + doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 87ce9053f..9f0367665 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -58,6 +58,7 @@ #include "ui/widget/selected-style.h" #include "ui/uxmanager.h" #include "util/ege-appear-time-tracker.h" +#include "sp-root.h" // We're in the "widgets" directory, so no need to explicitly prefix these: #include "button.h" @@ -1888,9 +1889,8 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) SPDocument *doc = dtw->desktop->doc(); Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()), Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) ); - SPObject* root = doc->root; - SPItem* item = SP_ITEM(root); - Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop()); + + Geom::OptRect deskarea = Geom::unify(darea, doc->getRoot()->getBboxDesktop()); /* Canvas region we always show unconditionally */ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64), diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index f7a981c9f..9b1664ac3 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -360,7 +360,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s Inkscape::GC::release(stop); } - SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); + doc->getDefs()->getRepr()->addChild(repr, NULL); gr = (SPGradient *) doc->getObjectByRepr(repr); sp_gradient_vector_selector_set_gradient( diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index e7596ead4..64ed1e309 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -521,9 +521,9 @@ GtkWidget * gr_change_widget(SPDesktop *desktop) // connect to release and modified signals of the defs (i.e. when someone changes gradient) sigc::connection *release_connection = new sigc::connection(); - *release_connection = SP_DOCUMENT_DEFS(document)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), widget)); + *release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), widget)); sigc::connection *modified_connection = new sigc::connection(); - *modified_connection = SP_DOCUMENT_DEFS(document)->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), widget)); + *modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), widget)); // when widget is destroyed, disconnect g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(gr_disconnect_sigc), release_connection); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 839ddf67c..8ef0ee313 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -204,8 +204,8 @@ void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPD // Connect signals if (doc) { - gvs->defs_release_connection = SP_DOCUMENT_DEFS(doc)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs)); - gvs->defs_modified_connection = SP_DOCUMENT_DEFS(doc)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs)); + gvs->defs_release_connection = doc->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs)); + gvs->defs_modified_connection = doc->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs)); } if (gr) { gvs->gradient_release_connection = gr->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs)); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 99d8228c8..d2b280e44 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -225,7 +225,7 @@ ink_marker_list_get (SPDocument *source) return NULL; GSList *ml = NULL; - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source); + SPDefs *defs = source->getDefs(); for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_IS_MARKER(child)) { |
