From: Abhishek Sharma Public Date: Mon, 12 Jul 2010 16:36:46 +0000 (+0530) Subject: SPObject c++ification finalized along with the beginning of XML Privatisation tweaks X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=094dc7c249a0253b9bbed67205e341a05b59eca7;p=inkscape.git SPObject c++ification finalized along with the beginning of XML Privatisation tweaks --- diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 69bae53d9..be6d47db7 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -99,7 +99,7 @@ box3d_side_build (SPObject * object, SPDocument * document, Inkscape::XML::Node if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - sp_object_read_attr(object, "inkscape:box3dsidetype"); + object->readAttr( "inkscape:box3dsidetype"); } static Inkscape::XML::Node * @@ -185,6 +185,14 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags) if (((SPObjectClass *) parent_class)->update) ((SPObjectClass *) parent_class)->update (object, ctx, flags); } +/* + * Function which return the type attribute for Box3D. + * Acts as a replacement for directly accessing the XML Tree directly. + */ +long long int Box3DSide::getFaceId() +{ + return this->getIntAttribute("inkscape:box3dsidetype", -1); +} void box3d_side_position_set (Box3DSide *side) { diff --git a/src/box3d-side.h b/src/box3d-side.h index d40e64b75..ba1431fab 100644 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@ -31,6 +31,7 @@ struct Box3DSide : public SPPolygon { Box3D::Axis dir1; Box3D::Axis dir2; Box3D::FrontOrRear front_or_rear; + long long int getFaceId(); }; struct Box3DSideClass { diff --git a/src/box3d.cpp b/src/box3d.cpp index 7985640cd..1facf2c0c 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -132,9 +132,9 @@ box3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) box->persp_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(box3d_ref_changed), box)); - sp_object_read_attr(object, "inkscape:perspectiveID"); - sp_object_read_attr(object, "inkscape:corner0"); - sp_object_read_attr(object, "inkscape:corner7"); + object->readAttr( "inkscape:perspectiveID"); + object->readAttr( "inkscape:corner0"); + object->readAttr( "inkscape:corner7"); } /** @@ -268,7 +268,7 @@ box3d_update(SPObject *object, SPCtx *ctx, guint flags) } -static Inkscape::XML::Node *box3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node * box3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPBox3D *box = SP_BOX3D(object); @@ -290,11 +290,13 @@ static Inkscape::XML::Node *box3d_write(SPObject *object, Inkscape::XML::Documen repr->setAttribute("inkscape:perspectiveID", uri_string); g_free(uri_string); } else { - Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(doc->getCurrentPersp3D()); - const gchar *persp_id = persp_repr->attribute("id"); - gchar *href = g_strdup_printf("#%s", persp_id); - repr->setAttribute("inkscape:perspectiveID", href); - g_free(href); + //Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(doc->getCurrentPersp3D()); + //const gchar *persp_id = persp_repr->attribute("id"); + //gchar *href = g_strdup_printf("#%s", persp_id); + Glib::ustring href = "#"; + href += doc->getCurrentPersp3D()->getId(); + repr->setAttribute("inkscape:perspectiveID", href.c_str()); + //g_free(href); } } @@ -1152,9 +1154,11 @@ static std::map box3d_get_sides (SPBox3D *box) { std::map sides; for (SPObject *side = box->first_child(); side != NULL; side = SP_OBJECT_NEXT(side)) { - if (SP_IS_BOX3D_SIDE(side)) - sides[Box3D::face_to_int(sp_repr_get_int_attribute(SP_OBJECT_REPR(side), - "inkscape:box3dsidetype", -1))] = SP_BOX3D_SIDE(side); + + if (SP_IS_BOX3D_SIDE(side)){ + Box3DSide *bside = SP_BOX3D_SIDE(side); + sides[Box3D::face_to_int(bside->getFaceId())] = bside; + } } sides.erase(-1); return sides; @@ -1328,9 +1332,12 @@ box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, persp3d_remove_box (old_persp, box); persp3d_add_box (new_persp, box); - gchar *href = g_strdup_printf("#%s", SP_OBJECT_REPR(new_persp)->attribute("id")); - SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", href); - g_free(href); + //gchar *href = g_strdup_printf("#%s", SP_OBJECT_REPR(new_persp)->attribute("id")); + Glib::ustring href = "#"; + href += new_persp->getId(); + //SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", href.c_str()); + static_cast(box)->setAttribute("inkscape:perspectiveID", href.c_str()); + //g_free(href); } /* Converts the 3D box to an ordinary SPGroup, adds it to the XML tree at the same position as @@ -1341,14 +1348,14 @@ box3d_convert_to_group(SPBox3D *box) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); // remember position of the box - int pos = SP_OBJECT_REPR(box)->position(); + int pos = static_cast(box)->getPosition(); // remember important attributes - Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box); - gchar const *id = repr_source->attribute("id"); - gchar const *style = repr_source->attribute("style"); - gchar const *mask = repr_source->attribute("mask"); - gchar const *clip_path = repr_source->attribute("clip-path"); + //Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box); + gchar const *id = static_cast(box)->getAttribute("id"); + gchar const *style = static_cast(box)->getAttribute("style"); + gchar const *mask = static_cast(box)->getAttribute("mask"); + gchar const *clip_path = static_cast(box)->getAttribute("clip-path"); // create a new group and add the sides (converted to ordinary paths) as its children Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); @@ -1365,7 +1372,7 @@ box3d_convert_to_group(SPBox3D *box) { // add the new group to the box's parent and set remembered position SPObject *parent = SP_OBJECT_PARENT(box); - SP_OBJECT_REPR(parent)->appendChild(grepr); + parent->appendChild(grepr); grepr->setPosition(pos); grepr->setAttribute("style", style); if (mask) diff --git a/src/box3d.h b/src/box3d.h index 9f2e1d78e..182a312e1 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -29,7 +29,8 @@ class Box3DSide; class Persp3D; class Persp3DReference; -struct SPBox3D : public SPGroup { +class SPBox3D : public SPGroup { + public: gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) gchar *persp_href; @@ -46,7 +47,8 @@ struct SPBox3D : public SPGroup { gint my_counter; // for debugging only }; -struct SPBox3DClass { +class SPBox3DClass { + public: SPGroupClass parent_class; }; diff --git a/src/color-profile-test.h b/src/color-profile-test.h index c479f78c0..4da3c579a 100644 --- a/src/color-profile-test.h +++ b/src/color-profile-test.h @@ -80,7 +80,7 @@ public: for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { std::string descr(cases[i].attr); - sp_object_set(SP_OBJECT(prof), SP_ATTR_RENDERING_INTENT, cases[i].attr); + SP_OBJECT(prof)->setKeyValue( SP_ATTR_RENDERING_INTENT, cases[i].attr); TSM_ASSERT_EQUALS( descr, prof->rendering_intent, (guint)cases[i].intVal ); } @@ -99,13 +99,13 @@ public: SP_OBJECT(prof)->document = _doc; for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { - sp_object_set(SP_OBJECT(prof), SP_ATTR_LOCAL, cases[i]); + SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, cases[i]); TS_ASSERT( prof->local ); if ( prof->local ) { TS_ASSERT_EQUALS( std::string(prof->local), std::string(cases[i]) ); } } - sp_object_set(SP_OBJECT(prof), SP_ATTR_LOCAL, NULL); + SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, NULL); TS_ASSERT_EQUALS( prof->local, (gchar*)0 ); g_object_unref(prof); @@ -123,13 +123,13 @@ public: SP_OBJECT(prof)->document = _doc; for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { - sp_object_set(SP_OBJECT(prof), SP_ATTR_NAME, cases[i]); + SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, cases[i]); TS_ASSERT( prof->name ); if ( prof->name ) { TS_ASSERT_EQUALS( std::string(prof->name), std::string(cases[i]) ); } } - sp_object_set(SP_OBJECT(prof), SP_ATTR_NAME, NULL); + SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, NULL); TS_ASSERT_EQUALS( prof->name, (gchar*)0 ); g_object_unref(prof); diff --git a/src/color-profile.cpp b/src/color-profile.cpp index bda4e6e23..ee4118e4f 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -247,10 +247,10 @@ void ColorProfile::build( SPObject *object, SPDocument *document, Inkscape::XML: if (cprof_parent_class->build) { (* cprof_parent_class->build)(object, document, repr); } - sp_object_read_attr( object, "xlink:href" ); - sp_object_read_attr( object, "local" ); - sp_object_read_attr( object, "name" ); - sp_object_read_attr( object, "rendering-intent" ); + object->readAttr( "xlink:href" ); + object->readAttr( "local" ); + object->readAttr( "name" ); + object->readAttr( "rendering-intent" ); // Register if ( document ) { diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index a6ac2387a..ed2aceb82 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -194,7 +194,7 @@ void SPAvoidRef::setConnectionPointsAttrUndoable(const gchar* value, const gchar { SPDocument* doc = SP_OBJECT_DOCUMENT(item); - sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 ); + SP_OBJECT(item)->setAttribute( "inkscape:connection-points", value, 0 ); item->updateRepr(); doc->ensure_up_to_date(); SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, action); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index ff19c7749..a419af44a 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1286,15 +1286,15 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-start", shape_label, false); - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-start-point", cpid, false); } else { - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-end", shape_label, false); - sp_object_setAttribute(cc->clickeditem, + (cc->clickeditem)->setAttribute( "inkscape:connection-end-point", cpid, false); } g_free(shape_label); @@ -1434,26 +1434,26 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); bool connection = false; - sp_object_setAttribute(cc->newconn, "inkscape:connector-type", + (cc->newconn)->setAttribute( "inkscape:connector-type", cc->isOrthogonal ? "orthogonal" : "polyline", false); - sp_object_setAttribute(cc->newconn, "inkscape:connector-curvature", + (cc->newconn)->setAttribute( "inkscape:connector-curvature", Glib::Ascii::dtostr(cc->curvature).c_str(), false); if (cc->shref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-start", + (cc->newconn)->setAttribute( "inkscape:connection-start", cc->shref, false); if (cc->scpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-start-point", + (cc->newconn)->setAttribute( "inkscape:connection-start-point", cc->scpid, false); connection = true; } if (cc->ehref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-end", + (cc->newconn)->setAttribute( "inkscape:connection-end", cc->ehref, false); if (cc->ecpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-end-point", + (cc->newconn)->setAttribute( "inkscape:connection-end-point", cc->ecpid, false); connection = true; } @@ -1917,7 +1917,7 @@ void cc_selection_set_avoid(bool const set_avoid) char const *value = (set_avoid) ? "true" : NULL; if (cc_item_is_shape(item)) { - sp_object_setAttribute(item, "inkscape:connector-avoid", + item->setAttribute("inkscape:connector-avoid", value, false); item->avoidRef->handleSettingChange(); changes++; diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 8d2b15e44..d96b364ef 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -449,7 +449,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw ) SPException ex; gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_Id")); SP_EXCEPTION_INIT (&ex); - sp_object_setAttribute (SP_OBJECT (item), "id", id, &ex); + SP_OBJECT (item)->setAttribute ("id", id, &ex); SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set object ID")); } diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 1988865d1..a25205db9 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -60,7 +60,7 @@ struct DocumentSubset::Relations : public GC::Managed, while ( first != last ) { Siblings::const_iterator mid = first + ( last - first + 1 ) / 2; - int pos = sp_object_compare_position(*mid, obj); + int pos = sp_object_compare_position(*mid,obj); if ( pos < 0 ) { first = mid; } else if ( pos > 0 ) { @@ -76,7 +76,7 @@ struct DocumentSubset::Relations : public GC::Managed, if ( first == last ) { // compare to the single possiblity left - int pos = sp_object_compare_position(*last, obj); + int pos = sp_object_compare_position(*last,obj); if ( pos < 0 ) { last++; } diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 3cec42291..f297ac199 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -103,8 +103,8 @@ sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "mode"); - sp_object_read_attr(object, "in2"); + object->readAttr( "mode"); + object->readAttr( "in2"); /* Unlike normal in, in2 is required attribute. Make sure, we can call * it by some name. */ @@ -202,8 +202,8 @@ sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags) SPFeBlend *blend = SP_FEBLEND(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "mode"); - sp_object_read_attr(object, "in2"); + object->readAttr( "mode"); + object->readAttr( "in2"); } /* Unlike normal in, in2 is required attribute. Make sure, we can call diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index 3f60ea05c..1b189ef37 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -98,8 +98,8 @@ sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::No } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "type"); - sp_object_read_attr(object, "values"); + object->readAttr( "type"); + object->readAttr( "values"); } /** diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 1dbf07dd5..a45716e08 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -168,13 +168,13 @@ sp_fefuncnode_build(SPObject *object, SPDocument *document, Inkscape::XML::Node } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "type"); - sp_object_read_attr(object, "tableValues"); - sp_object_read_attr(object, "slope"); - sp_object_read_attr(object, "intercept"); - sp_object_read_attr(object, "amplitude"); - sp_object_read_attr(object, "exponent"); - sp_object_read_attr(object, "offset"); + object->readAttr( "type"); + object->readAttr( "tableValues"); + object->readAttr( "slope"); + object->readAttr( "intercept"); + object->readAttr( "amplitude"); + object->readAttr( "exponent"); + object->readAttr( "offset"); //is this necessary? @@ -296,8 +296,8 @@ sp_fefuncnode_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ //TODO - //sp_object_read_attr(object, "azimuth"); - //sp_object_read_attr(object, "elevation"); + //object->readAttr( "azimuth"); + //object->readAttr( "elevation"); } if (((SPObjectClass *) feFuncNode_parent_class)->update) { diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 761115850..ae5be1a81 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -101,14 +101,14 @@ sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node SPFeComposite *comp = SP_FECOMPOSITE(object); - sp_object_read_attr(object, "operator"); + object->readAttr( "operator"); if (comp->composite_operator == COMPOSITE_ARITHMETIC) { - sp_object_read_attr(object, "k1"); - sp_object_read_attr(object, "k2"); - sp_object_read_attr(object, "k3"); - sp_object_read_attr(object, "k4"); + object->readAttr( "k1"); + object->readAttr( "k2"); + object->readAttr( "k3"); + object->readAttr( "k4"); } - sp_object_read_attr(object, "in2"); + object->readAttr( "in2"); /* Unlike normal in, in2 is required attribute. Make sure, we can call * it by some name. */ diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index 6440f340a..2f91c9db5 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -110,15 +110,15 @@ sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML: } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "order"); - sp_object_read_attr(object, "kernelMatrix"); - sp_object_read_attr(object, "divisor"); - sp_object_read_attr(object, "bias"); - sp_object_read_attr(object, "targetX"); - sp_object_read_attr(object, "targetY"); - sp_object_read_attr(object, "edgeMode"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "preserveAlpha"); + object->readAttr( "order"); + object->readAttr( "kernelMatrix"); + object->readAttr( "divisor"); + object->readAttr( "bias"); + object->readAttr( "targetX"); + object->readAttr( "targetY"); + object->readAttr( "edgeMode"); + object->readAttr( "kernelUnitLength"); + object->readAttr( "preserveAlpha"); } /** diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index bdc569083..5681bddc1 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -118,10 +118,10 @@ sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "diffuseConstant"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "lighting-color"); + object->readAttr( "surfaceScale"); + object->readAttr( "diffuseConstant"); + object->readAttr( "kernelUnitLength"); + object->readAttr( "lighting-color"); } @@ -224,10 +224,10 @@ static void sp_feDiffuseLighting_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "diffuseConstant"); - sp_object_read_attr(object, "kernelUnit"); - sp_object_read_attr(object, "lighting-color"); + object->readAttr( "surfaceScale"); + object->readAttr( "diffuseConstant"); + object->readAttr( "kernelUnit"); + object->readAttr( "lighting-color"); } if (((SPObjectClass *) feDiffuseLighting_parent_class)->update) { diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index ea2535f3e..ded7aab45 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -97,10 +97,10 @@ sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "scale"); - sp_object_read_attr(object, "in2"); - sp_object_read_attr(object, "xChannelSelector"); - sp_object_read_attr(object, "yChannelSelector"); + object->readAttr( "scale"); + object->readAttr( "in2"); + object->readAttr( "xChannelSelector"); + object->readAttr( "yChannelSelector"); /* Unlike normal in, in2 is required attribute. Make sure, we can call * it by some name. */ diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index 55c51aa0e..3a56f682b 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -101,8 +101,8 @@ sp_fedistantlight_build(SPObject *object, SPDocument *document, Inkscape::XML::N } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "azimuth"); - sp_object_read_attr(object, "elevation"); + object->readAttr( "azimuth"); + object->readAttr( "elevation"); //is this necessary? document->add_resource("fedistantlight", object); @@ -189,8 +189,8 @@ sp_fedistantlight_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "azimuth"); - sp_object_read_attr(object, "elevation"); + object->readAttr( "azimuth"); + object->readAttr( "elevation"); } if (((SPObjectClass *) feDistantLight_parent_class)->update) { diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp index 221b0daf2..f5179cb41 100644 --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@ -96,8 +96,8 @@ sp_feFlood_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "flood-opacity"); - sp_object_read_attr(object, "flood-color"); + object->readAttr( "flood-opacity"); + object->readAttr( "flood-color"); } /** diff --git a/src/filters/image.cpp b/src/filters/image.cpp index eb6dfc22a..1180799f4 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -100,11 +100,11 @@ static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::X /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "xlink:href"); } diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 8a4e0dd0a..c135c06fb 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -84,7 +84,7 @@ sp_feMergeNode_init(SPFeMergeNode *feMergeNode) static void sp_feMergeNode_build(SPObject *object, SPDocument */*document*/, Inkscape::XML::Node */*repr*/) { - sp_object_read_attr(object, "in"); + object->readAttr( "in"); } /** diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index 1530dae8c..2724dc5b6 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -97,8 +97,8 @@ sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "operator"); - sp_object_read_attr(object, "radius"); + object->readAttr( "operator"); + object->readAttr( "radius"); } /** diff --git a/src/filters/offset.cpp b/src/filters/offset.cpp index 61ea45ff2..64f6661fe 100644 --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@ -96,8 +96,8 @@ sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r ((SPObjectClass *) feOffset_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); + object->readAttr( "dx"); + object->readAttr( "dy"); } /** @@ -151,8 +151,8 @@ static void sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); + object->readAttr( "dx"); + object->readAttr( "dy"); } if (((SPObjectClass *) feOffset_parent_class)->update) { diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index fed07ecf3..55513ccb8 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -104,9 +104,9 @@ sp_fepointlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "z"); //is this necessary? document->add_resource("fepointlight", object); @@ -211,9 +211,9 @@ sp_fepointlight_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "z"); } if (((SPObjectClass *) fePointLight_parent_class)->update) { diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index 03a0c7f96..fcc6c697a 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -120,11 +120,11 @@ sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XM } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "specularConstant"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "lighting-color"); + object->readAttr( "surfaceScale"); + object->readAttr( "specularConstant"); + object->readAttr( "specularExponent"); + object->readAttr( "kernelUnitLength"); + object->readAttr( "lighting-color"); } @@ -250,11 +250,11 @@ static void sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "specularConstant"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "lighting-color"); + object->readAttr( "surfaceScale"); + object->readAttr( "specularConstant"); + object->readAttr( "specularExponent"); + object->readAttr( "kernelUnitLength"); + object->readAttr( "lighting-color"); } if (((SPObjectClass *) feSpecularLighting_parent_class)->update) { diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 613763751..6e0c0cbd0 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -114,14 +114,14 @@ sp_fespotlight_build(SPObject *object, SPDocument *document, Inkscape::XML::Node } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); - sp_object_read_attr(object, "pointsAtX"); - sp_object_read_attr(object, "pointsAtY"); - sp_object_read_attr(object, "pointsAtZ"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "limitingConeAngle"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "z"); + object->readAttr( "pointsAtX"); + object->readAttr( "pointsAtY"); + object->readAttr( "pointsAtZ"); + object->readAttr( "specularExponent"); + object->readAttr( "limitingConeAngle"); //is this necessary? document->add_resource("fespotlight", object); @@ -309,14 +309,14 @@ sp_fespotlight_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); - sp_object_read_attr(object, "pointsAtX"); - sp_object_read_attr(object, "pointsAtY"); - sp_object_read_attr(object, "pointsAtZ"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "limitingConeAngle"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "z"); + object->readAttr( "pointsAtX"); + object->readAttr( "pointsAtY"); + object->readAttr( "pointsAtZ"); + object->readAttr( "specularExponent"); + object->readAttr( "limitingConeAngle"); } if (((SPObjectClass *) feSpotLight_parent_class)->update) { diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index eed056ecc..8c2d0387e 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -100,11 +100,11 @@ sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "baseFrequency"); - sp_object_read_attr(object, "numOctaves"); - sp_object_read_attr(object, "seed"); - sp_object_read_attr(object, "stitchTiles"); - sp_object_read_attr(object, "type"); + object->readAttr( "baseFrequency"); + object->readAttr( "numOctaves"); + object->readAttr( "seed"); + object->readAttr( "stitchTiles"); + object->readAttr( "type"); } /** diff --git a/src/forward.h b/src/forward.h index 0388f8f63..41365611a 100644 --- a/src/forward.h +++ b/src/forward.h @@ -54,15 +54,14 @@ GType sp_document_get_type (); /* Objects */ -class SPObject; -class SPObjectClass; +//class SPObject; +//class SPObjectClass; -#define SP_TYPE_OBJECT (sp_object_get_type ()) -#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) -#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) -#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) +//#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) +//#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) +//#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) -GType sp_object_get_type (); +//GType sp_object_get_type (); //class SPItem; //class SPItemClass; diff --git a/src/interface.cpp b/src/interface.cpp index a535ed1bd..4b95e8de6 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1231,7 +1231,7 @@ sp_ui_drag_data_received(GtkWidget *widget, g_free(str); str = 0; - sp_object_setAttribute( SP_OBJECT(item), + SP_OBJECT(item)->setAttribute( fillnotstroke ? "inkscape:x-fill-tag":"inkscape:x-stroke-tag", palName.c_str(), false ); diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index aa916318d..a77b9817a 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -104,7 +104,7 @@ LivePathEffectObject::livepatheffect_build(SPObject *object, SPDocument *documen if (((SPObjectClass *) livepatheffect_parent_class)->build) (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "effect"); + object->readAttr( "effect"); if (repr) { repr->addListener (&livepatheffect_repr_events, object); diff --git a/src/marker.cpp b/src/marker.cpp index 979ca3011..376b4fa28 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -141,14 +141,14 @@ sp_marker_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *re group = (SPGroup *) object; marker = (SPMarker *) object; - sp_object_read_attr (object, "markerUnits"); - sp_object_read_attr (object, "refX"); - sp_object_read_attr (object, "refY"); - sp_object_read_attr (object, "markerWidth"); - sp_object_read_attr (object, "markerHeight"); - sp_object_read_attr (object, "orient"); - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "preserveAspectRatio"); + object->readAttr( "markerUnits"); + object->readAttr( "refX"); + object->readAttr( "refY"); + object->readAttr( "markerWidth"); + object->readAttr( "markerHeight"); + object->readAttr( "orient"); + object->readAttr( "viewBox"); + object->readAttr( "preserveAspectRatio"); if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 4b2e55b9d..60bfa765a 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -116,10 +116,10 @@ static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML: /* calls sp_object_set for the respective attributes */ // The transformation matrix is updated according to the values we read for the VPs - sp_object_read_attr(object, "inkscape:vp_x"); - sp_object_read_attr(object, "inkscape:vp_y"); - sp_object_read_attr(object, "inkscape:vp_z"); - sp_object_read_attr(object, "inkscape:persp3d-origin"); + object->readAttr( "inkscape:vp_x"); + object->readAttr( "inkscape:vp_y"); + object->readAttr( "inkscape:vp_z"); + object->readAttr( "inkscape:persp3d-origin"); if (repr) { repr->addListener (&persp3d_repr_events, object); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7b0f353ab..8b4db3e25 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1374,7 +1374,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons * Same for linked offset if we are also moving its source: do not move it. */ if (transform_textpath_with_path || transform_offset_with_source) { // Restore item->transform field from the repr, in case it was changed by seltrans. - sp_object_read_attr(SP_OBJECT(item), "transform"); + SP_OBJECT(item)->readAttr( "transform"); } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the so that the flow remains // the same (even though the output itself gets transformed) @@ -1392,7 +1392,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons // transform and its move compensation are both cancelled out. // restore item->transform field from the repr, in case it was changed by seltrans - sp_object_read_attr(SP_OBJECT(item), "transform"); + SP_OBJECT(item)->readAttr( "transform"); // calculate the matrix we need to apply to the clone to cancel its induced transform from its original Geom::Matrix parent2dt = SP_ITEM(SP_OBJECT_PARENT(item))->i2d_affine(); diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index 379ddbb7c..9a5e8b1c1 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -89,14 +89,14 @@ static void sp_anchor_build(SPObject *object, SPDocument *document, Inkscape::XM ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "xlink:type"); - sp_object_read_attr(object, "xlink:role"); - sp_object_read_attr(object, "xlink:arcrole"); - sp_object_read_attr(object, "xlink:title"); - sp_object_read_attr(object, "xlink:show"); - sp_object_read_attr(object, "xlink:actuate"); - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "target"); + object->readAttr( "xlink:type"); + object->readAttr( "xlink:role"); + object->readAttr( "xlink:arcrole"); + object->readAttr( "xlink:title"); + object->readAttr( "xlink:show"); + object->readAttr( "xlink:actuate"); + object->readAttr( "xlink:href"); + object->readAttr( "target"); } static void sp_anchor_release(SPObject *object) diff --git a/src/sp-animation.cpp b/src/sp-animation.cpp index 2d9f2e941..85fa615de 100644 --- a/src/sp-animation.cpp +++ b/src/sp-animation.cpp @@ -89,18 +89,18 @@ sp_animation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node * if (((SPObjectClass *) animation_parent_class)->build) ((SPObjectClass *) animation_parent_class)->build(object, document, repr); - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "attributeName"); - sp_object_read_attr(object, "attributeType"); - sp_object_read_attr(object, "begin"); - sp_object_read_attr(object, "dur"); - sp_object_read_attr(object, "end"); - sp_object_read_attr(object, "min"); - sp_object_read_attr(object, "max"); - sp_object_read_attr(object, "restart"); - sp_object_read_attr(object, "repeatCount"); - sp_object_read_attr(object, "repeatDur"); - sp_object_read_attr(object, "fill"); + object->readAttr( "xlink:href"); + object->readAttr( "attributeName"); + object->readAttr( "attributeType"); + object->readAttr( "begin"); + object->readAttr( "dur"); + object->readAttr( "end"); + object->readAttr( "min"); + object->readAttr( "max"); + object->readAttr( "restart"); + object->readAttr( "repeatCount"); + object->readAttr( "repeatDur"); + object->readAttr( "fill"); } static void @@ -176,15 +176,15 @@ sp_ianimation_build(SPObject *object, SPDocument *document, Inkscape::XML::Node if (((SPObjectClass *) ianimation_parent_class)->build) ((SPObjectClass *) ianimation_parent_class)->build(object, document, repr); - sp_object_read_attr(object, "calcMode"); - sp_object_read_attr(object, "values"); - sp_object_read_attr(object, "keyTimes"); - sp_object_read_attr(object, "keySplines"); - sp_object_read_attr(object, "from"); - sp_object_read_attr(object, "to"); - sp_object_read_attr(object, "by"); - sp_object_read_attr(object, "additive"); - sp_object_read_attr(object, "accumulate"); + object->readAttr( "calcMode"); + object->readAttr( "values"); + object->readAttr( "keyTimes"); + object->readAttr( "keySplines"); + object->readAttr( "from"); + object->readAttr( "to"); + object->readAttr( "by"); + object->readAttr( "additive"); + object->readAttr( "accumulate"); } static void diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index a36d9b443..63e617551 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -104,7 +104,7 @@ sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build(object, document, repr); - sp_object_read_attr(object, "clipPathUnits"); + object->readAttr( "clipPathUnits"); /* Register ourselves */ document->add_resource("clipPath", object); diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 24c7e7e5c..21ecf6b43 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -79,12 +79,12 @@ SPConnEndPair::release() void sp_conn_end_pair_build(SPObject *object) { - sp_object_read_attr(object, "inkscape:connector-type"); - sp_object_read_attr(object, "inkscape:connection-start"); - sp_object_read_attr(object, "inkscape:connection-start-point"); - sp_object_read_attr(object, "inkscape:connection-end"); - sp_object_read_attr(object, "inkscape:connection-end-point"); - sp_object_read_attr(object, "inkscape:connector-curvature"); + object->readAttr( "inkscape:connector-type"); + object->readAttr( "inkscape:connection-start"); + object->readAttr( "inkscape:connection-start-point"); + object->readAttr( "inkscape:connection-end"); + object->readAttr( "inkscape:connection-end-point"); + object->readAttr( "inkscape:connector-curvature"); } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 86b6106c5..b5f0bdab6 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -433,10 +433,10 @@ sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re if (((SPObjectClass *) ellipse_parent_class)->build) (* ((SPObjectClass *) ellipse_parent_class)->build) (object, document, repr); - sp_object_read_attr(object, "cx"); - sp_object_read_attr(object, "cy"); - sp_object_read_attr(object, "rx"); - sp_object_read_attr(object, "ry"); + object->readAttr( "cx"); + object->readAttr( "cy"); + object->readAttr( "rx"); + object->readAttr( "ry"); } static Inkscape::XML::Node * @@ -581,9 +581,9 @@ sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep if (((SPObjectClass *) circle_parent_class)->build) (* ((SPObjectClass *) circle_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "cx"); - sp_object_read_attr(object, "cy"); - sp_object_read_attr(object, "r"); + object->readAttr( "cx"); + object->readAttr( "cy"); + object->readAttr( "r"); } static Inkscape::XML::Node * @@ -706,14 +706,14 @@ sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) if (((SPObjectClass *) arc_parent_class)->build) (* ((SPObjectClass *) arc_parent_class)->build) (object, document, repr); - sp_object_read_attr(object, "sodipodi:cx"); - sp_object_read_attr(object, "sodipodi:cy"); - sp_object_read_attr(object, "sodipodi:rx"); - sp_object_read_attr(object, "sodipodi:ry"); + object->readAttr( "sodipodi:cx"); + object->readAttr( "sodipodi:cy"); + object->readAttr( "sodipodi:rx"); + object->readAttr( "sodipodi:ry"); - sp_object_read_attr(object, "sodipodi:start"); - sp_object_read_attr(object, "sodipodi:end"); - sp_object_read_attr(object, "sodipodi:open"); + object->readAttr( "sodipodi:start"); + object->readAttr( "sodipodi:end"); + object->readAttr( "sodipodi:open"); } /* diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index 7cf0a38bb..4ce0e133d 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -99,8 +99,8 @@ sp_filter_primitive_build(SPObject *object, SPDocument *document, Inkscape::XML: ((SPObjectClass *) filter_primitive_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "in"); - sp_object_read_attr(object, "result"); + object->readAttr( "in"); + object->readAttr( "result"); } /** @@ -164,8 +164,8 @@ sp_filter_primitive_update(SPObject *object, SPCtx *ctx, guint flags) //SPFilterPrimitive *filter_primitive = SP_FILTER_PRIMITIVE(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "in"); - sp_object_read_attr(object, "result"); + object->readAttr( "in"); + object->readAttr( "result"); } if (((SPObjectClass *) filter_primitive_parent_class)->update) { diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 2464b73a5..e65a7be05 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -136,14 +136,14 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "filterUnits"); - sp_object_read_attr(object, "primitiveUnits"); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "filterRes"); - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "filterUnits"); + object->readAttr( "primitiveUnits"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "filterRes"); + object->readAttr( "xlink:href"); //is this necessary? document->add_resource("filter", object); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 2d1f61a29..4c3cc8a6c 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -230,7 +230,7 @@ sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "inkscape:layoutOptions"); // must happen after css has been read + object->readAttr( "inkscape:layoutOptions"); // must happen after css has been read } static void diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 20419a8e5..a5894f83a 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -403,39 +403,39 @@ static void sp_fontface_build(SPObject *object, SPDocument *document, Inkscape:: ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "font-family"); - sp_object_read_attr(object, "font-style"); - sp_object_read_attr(object, "font-variant"); - sp_object_read_attr(object, "font-weight"); - sp_object_read_attr(object, "font-stretch"); - sp_object_read_attr(object, "font-size"); - sp_object_read_attr(object, "unicode-range"); - sp_object_read_attr(object, "units-per-em"); - sp_object_read_attr(object, "panose-1"); - sp_object_read_attr(object, "stem-v"); - sp_object_read_attr(object, "stem-h"); - sp_object_read_attr(object, "slope"); - sp_object_read_attr(object, "cap-height"); - sp_object_read_attr(object, "x-height"); - sp_object_read_attr(object, "accent-height"); - sp_object_read_attr(object, "ascent"); - sp_object_read_attr(object, "descent"); - sp_object_read_attr(object, "widths"); - sp_object_read_attr(object, "bbox"); - sp_object_read_attr(object, "ideographic"); - sp_object_read_attr(object, "alphabetic"); - sp_object_read_attr(object, "mathematical"); - sp_object_read_attr(object, "ranging"); - sp_object_read_attr(object, "v-ideogaphic"); - sp_object_read_attr(object, "v-alphabetic"); - sp_object_read_attr(object, "v-mathematical"); - sp_object_read_attr(object, "v-hanging"); - sp_object_read_attr(object, "underline-position"); - sp_object_read_attr(object, "underline-thickness"); - sp_object_read_attr(object, "strikethrough-position"); - sp_object_read_attr(object, "strikethrough-thickness"); - sp_object_read_attr(object, "overline-position"); - sp_object_read_attr(object, "overline-thickness"); + object->readAttr( "font-family"); + object->readAttr( "font-style"); + object->readAttr( "font-variant"); + object->readAttr( "font-weight"); + object->readAttr( "font-stretch"); + object->readAttr( "font-size"); + object->readAttr( "unicode-range"); + object->readAttr( "units-per-em"); + object->readAttr( "panose-1"); + object->readAttr( "stem-v"); + object->readAttr( "stem-h"); + object->readAttr( "slope"); + object->readAttr( "cap-height"); + object->readAttr( "x-height"); + object->readAttr( "accent-height"); + object->readAttr( "ascent"); + object->readAttr( "descent"); + object->readAttr( "widths"); + object->readAttr( "bbox"); + object->readAttr( "ideographic"); + object->readAttr( "alphabetic"); + object->readAttr( "mathematical"); + object->readAttr( "ranging"); + object->readAttr( "v-ideogaphic"); + object->readAttr( "v-alphabetic"); + object->readAttr( "v-mathematical"); + object->readAttr( "v-hanging"); + object->readAttr( "underline-position"); + object->readAttr( "underline-thickness"); + object->readAttr( "strikethrough-position"); + object->readAttr( "strikethrough-thickness"); + object->readAttr( "overline-position"); + object->readAttr( "overline-thickness"); } static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/) @@ -780,39 +780,39 @@ static void sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "font-family"); - sp_object_read_attr(object, "font-style"); - sp_object_read_attr(object, "font-variant"); - sp_object_read_attr(object, "font-weight"); - sp_object_read_attr(object, "font-stretch"); - sp_object_read_attr(object, "font-size"); - sp_object_read_attr(object, "unicode-range"); - sp_object_read_attr(object, "units-per-em"); - sp_object_read_attr(object, "panose-1"); - sp_object_read_attr(object, "stemv"); - sp_object_read_attr(object, "stemh"); - sp_object_read_attr(object, "slope"); - sp_object_read_attr(object, "cap-height"); - sp_object_read_attr(object, "x-height"); - sp_object_read_attr(object, "accent-height"); - sp_object_read_attr(object, "ascent"); - sp_object_read_attr(object, "descent"); - sp_object_read_attr(object, "widths"); - sp_object_read_attr(object, "bbox"); - sp_object_read_attr(object, "ideographic"); - sp_object_read_attr(object, "alphabetic"); - sp_object_read_attr(object, "mathematical"); - sp_object_read_attr(object, "hanging"); - sp_object_read_attr(object, "v-ideographic"); - sp_object_read_attr(object, "v-alphabetic"); - sp_object_read_attr(object, "v-mathematical"); - sp_object_read_attr(object, "v-hanging"); - sp_object_read_attr(object, "underline-position"); - sp_object_read_attr(object, "underline-thickness"); - sp_object_read_attr(object, "strikethrough-position"); - sp_object_read_attr(object, "strikethrough-thickness"); - sp_object_read_attr(object, "overline-position"); - sp_object_read_attr(object, "overline-thickness"); + object->readAttr( "font-family"); + object->readAttr( "font-style"); + object->readAttr( "font-variant"); + object->readAttr( "font-weight"); + object->readAttr( "font-stretch"); + object->readAttr( "font-size"); + object->readAttr( "unicode-range"); + object->readAttr( "units-per-em"); + object->readAttr( "panose-1"); + object->readAttr( "stemv"); + object->readAttr( "stemh"); + object->readAttr( "slope"); + object->readAttr( "cap-height"); + object->readAttr( "x-height"); + object->readAttr( "accent-height"); + object->readAttr( "ascent"); + object->readAttr( "descent"); + object->readAttr( "widths"); + object->readAttr( "bbox"); + object->readAttr( "ideographic"); + object->readAttr( "alphabetic"); + object->readAttr( "mathematical"); + object->readAttr( "hanging"); + object->readAttr( "v-ideographic"); + object->readAttr( "v-alphabetic"); + object->readAttr( "v-mathematical"); + object->readAttr( "v-hanging"); + object->readAttr( "underline-position"); + object->readAttr( "underline-thickness"); + object->readAttr( "strikethrough-position"); + object->readAttr( "strikethrough-thickness"); + object->readAttr( "overline-position"); + object->readAttr( "overline-thickness"); } if (((SPObjectClass *) parent_class)->update) { diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 4f8bbef6e..a1a2c425f 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -101,12 +101,12 @@ static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML: ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "horiz-origin-x"); - sp_object_read_attr(object, "horiz-origin-y"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); + object->readAttr( "horiz-origin-x"); + object->readAttr( "horiz-origin-y"); + object->readAttr( "horiz-adv-x"); + object->readAttr( "vert-origin-x"); + object->readAttr( "vert-origin-y"); + object->readAttr( "vert-adv-y"); document->add_resource("font", object); } @@ -232,12 +232,12 @@ static void sp_font_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "horiz-origin-x"); - sp_object_read_attr(object, "horiz-origin-y"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); + object->readAttr( "horiz-origin-x"); + object->readAttr( "horiz-origin-y"); + object->readAttr( "horiz-adv-x"); + object->readAttr( "vert-origin-x"); + object->readAttr( "vert-origin-y"); + object->readAttr( "vert-adv-y"); } if (((SPObjectClass *) parent_class)->update) { diff --git a/src/sp-gaussian-blur.cpp b/src/sp-gaussian-blur.cpp index e6eab5032..7182e5ce9 100644 --- a/src/sp-gaussian-blur.cpp +++ b/src/sp-gaussian-blur.cpp @@ -100,7 +100,7 @@ sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Nod ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "stdDeviation"); + object->readAttr( "stdDeviation"); } @@ -143,7 +143,7 @@ static void sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "stdDeviation"); + object->readAttr( "stdDeviation"); } if (((SPObjectClass *) gaussianBlur_parent_class)->update) { diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index 93996d8bc..2efdedf7a 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -110,11 +110,11 @@ static void sp_glyph_kerning_build(SPObject *object, SPDocument *document, Inksc ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "u1"); - sp_object_read_attr(object, "g1"); - sp_object_read_attr(object, "u2"); - sp_object_read_attr(object, "g2"); - sp_object_read_attr(object, "k"); + object->readAttr( "u1"); + object->readAttr( "g1"); + object->readAttr( "u2"); + object->readAttr( "g2"); + object->readAttr( "k"); } static void sp_glyph_kerning_release(SPObject *object) @@ -216,10 +216,10 @@ sp_glyph_kerning_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "u1"); - sp_object_read_attr(object, "u2"); - sp_object_read_attr(object, "g2"); - sp_object_read_attr(object, "k"); + object->readAttr( "u1"); + object->readAttr( "u2"); + object->readAttr( "g2"); + object->readAttr( "k"); } if (((SPObjectClass *) parent_class)->update) { diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 203163b29..a2a5c7fcd 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -90,16 +90,16 @@ static void sp_glyph_build(SPObject *object, SPDocument *document, Inkscape::XML ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "unicode"); - sp_object_read_attr(object, "glyph-name"); - sp_object_read_attr(object, "d"); - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "arabic-form"); - sp_object_read_attr(object, "lang"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); + object->readAttr( "unicode"); + object->readAttr( "glyph-name"); + object->readAttr( "d"); + object->readAttr( "orientation"); + object->readAttr( "arabic-form"); + object->readAttr( "lang"); + object->readAttr( "horiz-adv-x"); + object->readAttr( "vert-origin-x"); + object->readAttr( "vert-origin-y"); + object->readAttr( "vert-adv-y"); } static void sp_glyph_release(SPObject *object) @@ -250,16 +250,16 @@ sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags) if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "unicode"); - sp_object_read_attr(object, "glyph-name"); - sp_object_read_attr(object, "d"); - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "arabic-form"); - sp_object_read_attr(object, "lang"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); + object->readAttr( "unicode"); + object->readAttr( "glyph-name"); + object->readAttr( "d"); + object->readAttr( "orientation"); + object->readAttr( "arabic-form"); + object->readAttr( "lang"); + object->readAttr( "horiz-adv-x"); + object->readAttr( "vert-origin-x"); + object->readAttr( "vert-origin-y"); + object->readAttr( "vert-adv-y"); } if (((SPObjectClass *) parent_class)->update) { diff --git a/src/sp-gradient-test.h b/src/sp-gradient-test.h index 209bc7efb..62c0ac8c2 100644 --- a/src/sp-gradient-test.h +++ b/src/sp-gradient-test.h @@ -56,13 +56,13 @@ public: SPGradient *gr = static_cast(g_object_new(SP_TYPE_GRADIENT, NULL)); SP_OBJECT(gr)->document = _doc; - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)"); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)"); TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Matrix(Geom::Translate(5, 8)) ); - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, ""); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, ""); TS_ASSERT_EQUALS( gr->gradientTransform, Geom::identity() ); - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "rotate(90)"); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "rotate(90)"); TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Matrix(rotate_degrees(90)) ); g_object_unref(gr); @@ -74,7 +74,7 @@ public: SPGradient *gr = static_cast(g_object_new(SP_TYPE_GRADIENT, NULL)); SP_OBJECT(gr)->document = _doc; - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTTRANSFORM, "matrix(0, 1, -1, 0, 0, 0)"); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "matrix(0, 1, -1, 0, 0, 0)"); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_doc); Inkscape::XML::Node *repr = xml_doc->createElement("svg:radialGradient"); SP_OBJECT(gr)->updateRepr(repr, SP_OBJECT_WRITE_ALL); @@ -136,7 +136,7 @@ public: sp_gradient_set_gs2d_matrix(gr, funny, larger_rect, gs2d); TS_ASSERT( Geom::matrix_equalp(gr->gradientTransform, grXform, 1e-12) ); - sp_object_set(SP_OBJECT(gr), SP_ATTR_GRADIENTUNITS, "userSpaceOnUse"); + SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTUNITS, "userSpaceOnUse"); Geom::Matrix const user_g2d(sp_gradient_get_g2d_matrix(gr, funny, larger_rect)); Geom::Matrix const user_gs2d(sp_gradient_get_gs2d_matrix(gr, funny, larger_rect)); TS_ASSERT_EQUALS( user_g2d, funny ); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 604da3b7c..56ddd09d9 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -141,10 +141,10 @@ static void sp_stop_build(SPObject *object, SPDocument *document, Inkscape::XML: if (((SPObjectClass *) stop_parent_class)->build) (* ((SPObjectClass *) stop_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "offset"); - sp_object_read_attr(object, "stop-color"); - sp_object_read_attr(object, "stop-opacity"); - sp_object_read_attr(object, "style"); + object->readAttr( "offset"); + object->readAttr( "stop-color"); + object->readAttr( "stop-opacity"); + object->readAttr( "style"); } /** @@ -168,7 +168,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) * stop-color and stop-opacity properties. */ { - gchar const *p = sp_object_get_style_property(object, "stop-color", "black"); + gchar const *p = object->getStyleProperty( "stop-color", "black"); if (streq(p, "currentColor")) { stop->currentColor = true; } else { @@ -177,7 +177,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) } } { - gchar const *p = sp_object_get_style_property(object, "stop-opacity", "1"); + gchar const *p = object->getStyleProperty( "stop-opacity", "1"); gdouble opacity = sp_svg_read_percentage(p, stop->opacity); stop->opacity = opacity; } @@ -186,7 +186,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) } case SP_PROP_STOP_COLOR: { { - gchar const *p = sp_object_get_style_property(object, "stop-color", "black"); + gchar const *p = object->getStyleProperty( "stop-color", "black"); if (streq(p, "currentColor")) { stop->currentColor = true; } else { @@ -200,7 +200,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) } case SP_PROP_STOP_OPACITY: { { - gchar const *p = sp_object_get_style_property(object, "stop-opacity", "1"); + gchar const *p = object->getStyleProperty( "stop-opacity", "1"); gdouble opacity = sp_svg_read_percentage(p, stop->opacity); stop->opacity = opacity; } @@ -299,7 +299,7 @@ sp_stop_get_rgba32(SPStop const *const stop) * value depends on user agent, and don't give any further restrictions that I can * see.) */ if (stop->currentColor) { - char const *str = sp_object_get_style_property(stop, "color", NULL); + char const *str = stop->getStyleProperty( "color", NULL); if (str) { rgb0 = sp_svg_read_color(str, rgb0); } @@ -319,7 +319,7 @@ static SPColor sp_stop_get_color(SPStop const *const stop) { if (stop->currentColor) { - char const *str = sp_object_get_style_property(stop, "color", NULL); + char const *str = stop->getStyleProperty( "color", NULL); guint32 const dfl = 0; /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial * value depends on user agent, and don't give any further restrictions that I can @@ -433,10 +433,10 @@ void SPGradientImpl::build(SPObject *object, SPDocument *document, Inkscape::XML } } - sp_object_read_attr(object, "gradientUnits"); - sp_object_read_attr(object, "gradientTransform"); - sp_object_read_attr(object, "spreadMethod"); - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "gradientUnits"); + object->readAttr( "gradientTransform"); + object->readAttr( "spreadMethod"); + object->readAttr( "xlink:href"); /* Register ourselves */ document->add_resource("gradient", object); @@ -1492,10 +1492,10 @@ static void sp_lineargradient_build(SPObject *object, if (((SPObjectClass *) lg_parent_class)->build) (* ((SPObjectClass *) lg_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "x1"); - sp_object_read_attr(object, "y1"); - sp_object_read_attr(object, "x2"); - sp_object_read_attr(object, "y2"); + object->readAttr( "x1"); + object->readAttr( "y1"); + object->readAttr( "x2"); + object->readAttr( "y2"); } /** @@ -1769,11 +1769,11 @@ sp_radialgradient_build(SPObject *object, SPDocument *document, Inkscape::XML::N if (((SPObjectClass *) rg_parent_class)->build) (* ((SPObjectClass *) rg_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "cx"); - sp_object_read_attr(object, "cy"); - sp_object_read_attr(object, "r"); - sp_object_read_attr(object, "fx"); - sp_object_read_attr(object, "fy"); + object->readAttr( "cx"); + object->readAttr( "cy"); + object->readAttr( "r"); + object->readAttr( "fx"); + object->readAttr( "fy"); } /** diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 955d4fedc..e43c3056d 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -158,8 +158,8 @@ static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "position"); + object->readAttr( "orientation"); + object->readAttr( "position"); } static void sp_guide_release(SPObject *object) diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 33038d73c..ae7ac6fa3 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -637,13 +637,13 @@ sp_image_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep ((SPObjectClass *) parent_class)->build (object, document, repr); } - sp_object_read_attr (object, "xlink:href"); - sp_object_read_attr (object, "x"); - sp_object_read_attr (object, "y"); - sp_object_read_attr (object, "width"); - sp_object_read_attr (object, "height"); - sp_object_read_attr (object, "preserveAspectRatio"); - sp_object_read_attr (object, "color-profile"); + object->readAttr( "xlink:href"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "preserveAspectRatio"); + object->readAttr( "color-profile"); /* Register */ document->add_resource ("image", object); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 79a673e05..5b15ca326 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -145,7 +145,7 @@ sp_group_init (SPGroup *group) static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "inkscape:groupmode"); + object->readAttr( "inkscape:groupmode"); if (((SPObjectClass *)parent_class)->build) { ((SPObjectClass *)parent_class)->build(object, document, repr); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 7f67caee8..ae77f9d84 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -405,16 +405,16 @@ void SPItem::lowerToBottom() { void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "style"); - sp_object_read_attr(object, "transform"); - sp_object_read_attr(object, "clip-path"); - sp_object_read_attr(object, "mask"); - sp_object_read_attr(object, "sodipodi:insensitive"); - sp_object_read_attr(object, "sodipodi:nonprintable"); - sp_object_read_attr(object, "inkscape:transform-center-x"); - sp_object_read_attr(object, "inkscape:transform-center-y"); - sp_object_read_attr(object, "inkscape:connector-avoid"); - sp_object_read_attr(object, "inkscape:connection-points"); + object->readAttr( "style"); + object->readAttr( "transform"); + object->readAttr( "clip-path"); + object->readAttr( "mask"); + object->readAttr( "sodipodi:insensitive"); + object->readAttr( "sodipodi:nonprintable"); + object->readAttr( "inkscape:transform-center-x"); + object->readAttr( "inkscape:transform-center-y"); + object->readAttr( "inkscape:connector-avoid"); + object->readAttr( "inkscape:connection-points"); if (((SPObjectClass *) (SPItemClass::static_parent_class))->build) { (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr); @@ -1405,8 +1405,8 @@ SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set) void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) { - g_return_if_fail(this != NULL); - g_return_if_fail(SP_IS_ITEM(this)); + //g_return_if_fail(this != NULL); + //g_return_if_fail(SP_IS_ITEM(this)); g_return_if_fail(repr != NULL); // calculate the relative transform, if not given by the adv attribute diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 878fceb67..6d3d2aea7 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -104,10 +104,10 @@ SPLine::sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML:: ((SPObjectClass *) SPLineClass::static_parent_class)->build (object, document, repr); } - sp_object_read_attr (object, "x1"); - sp_object_read_attr (object, "y1"); - sp_object_read_attr (object, "x2"); - sp_object_read_attr (object, "y2"); + object->readAttr( "x1"); + object->readAttr( "y1"); + object->readAttr( "x2"); + object->readAttr( "y2"); } void diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 6c49b79c1..655c4b27e 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -137,7 +137,7 @@ sp_lpe_item_finalize(GObject *object) static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "inkscape:path-effect"); + object->readAttr( "inkscape:path-effect"); if (((SPObjectClass *) parent_class)->build) { ((SPObjectClass *) parent_class)->build(object, document, repr); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 0c28cd014..26ddfa009 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -104,8 +104,8 @@ sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr ((SPObjectClass *) parent_class)->build (object, document, repr); } - sp_object_read_attr (object, "maskUnits"); - sp_object_read_attr (object, "maskContentUnits"); + object->readAttr( "maskUnits"); + object->readAttr( "maskContentUnits"); /* Register ourselves */ document->add_resource ("mask", object); diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index d15000fcb..9833a6995 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -82,11 +82,11 @@ static void sp_missing_glyph_build(SPObject *object, SPDocument *document, Inksc ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "d"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); + object->readAttr( "d"); + object->readAttr( "horiz-adv-x"); + object->readAttr( "vert-origin-x"); + object->readAttr( "vert-origin-y"); + object->readAttr( "vert-adv-y"); } static void sp_missing_glyph_release(SPObject *object) diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 52c42866e..7c974802e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -217,53 +217,53 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "inkscape:document-units"); - sp_object_read_attr(object, "viewonly"); - sp_object_read_attr(object, "showguides"); - sp_object_read_attr(object, "showgrid"); - sp_object_read_attr(object, "gridtolerance"); - sp_object_read_attr(object, "guidetolerance"); - sp_object_read_attr(object, "objecttolerance"); - sp_object_read_attr(object, "guidecolor"); - sp_object_read_attr(object, "guideopacity"); - sp_object_read_attr(object, "guidehicolor"); - sp_object_read_attr(object, "guidehiopacity"); - sp_object_read_attr(object, "showborder"); - sp_object_read_attr(object, "inkscape:showpageshadow"); - sp_object_read_attr(object, "borderlayer"); - sp_object_read_attr(object, "bordercolor"); - sp_object_read_attr(object, "borderopacity"); - sp_object_read_attr(object, "pagecolor"); - sp_object_read_attr(object, "inkscape:pageopacity"); - sp_object_read_attr(object, "inkscape:pageshadow"); - sp_object_read_attr(object, "inkscape:zoom"); - sp_object_read_attr(object, "inkscape:cx"); - sp_object_read_attr(object, "inkscape:cy"); - sp_object_read_attr(object, "inkscape:window-width"); - sp_object_read_attr(object, "inkscape:window-height"); - sp_object_read_attr(object, "inkscape:window-x"); - sp_object_read_attr(object, "inkscape:window-y"); - sp_object_read_attr(object, "inkscape:window-maximized"); - sp_object_read_attr(object, "inkscape:snap-global"); - sp_object_read_attr(object, "inkscape:snap-bbox"); - sp_object_read_attr(object, "inkscape:snap-nodes"); - sp_object_read_attr(object, "inkscape:snap-from-guide"); - sp_object_read_attr(object, "inkscape:snap-center"); - sp_object_read_attr(object, "inkscape:snap-smooth-nodes"); - sp_object_read_attr(object, "inkscape:snap-midpoints"); - sp_object_read_attr(object, "inkscape:snap-object-midpoints"); - sp_object_read_attr(object, "inkscape:snap-bbox-edge-midpoints"); - sp_object_read_attr(object, "inkscape:snap-bbox-midpoints"); - sp_object_read_attr(object, "inkscape:snap-to-guides"); - sp_object_read_attr(object, "inkscape:snap-grids"); - sp_object_read_attr(object, "inkscape:snap-intersection-paths"); - sp_object_read_attr(object, "inkscape:object-paths"); - sp_object_read_attr(object, "inkscape:object-nodes"); - sp_object_read_attr(object, "inkscape:bbox-paths"); - sp_object_read_attr(object, "inkscape:bbox-nodes"); - sp_object_read_attr(object, "inkscape:snap-page"); - sp_object_read_attr(object, "inkscape:current-layer"); - sp_object_read_attr(object, "inkscape:connector-spacing"); + object->readAttr( "inkscape:document-units"); + object->readAttr( "viewonly"); + object->readAttr( "showguides"); + object->readAttr( "showgrid"); + object->readAttr( "gridtolerance"); + object->readAttr( "guidetolerance"); + object->readAttr( "objecttolerance"); + object->readAttr( "guidecolor"); + object->readAttr( "guideopacity"); + object->readAttr( "guidehicolor"); + object->readAttr( "guidehiopacity"); + object->readAttr( "showborder"); + object->readAttr( "inkscape:showpageshadow"); + object->readAttr( "borderlayer"); + object->readAttr( "bordercolor"); + object->readAttr( "borderopacity"); + object->readAttr( "pagecolor"); + object->readAttr( "inkscape:pageopacity"); + object->readAttr( "inkscape:pageshadow"); + object->readAttr( "inkscape:zoom"); + object->readAttr( "inkscape:cx"); + object->readAttr( "inkscape:cy"); + object->readAttr( "inkscape:window-width"); + object->readAttr( "inkscape:window-height"); + object->readAttr( "inkscape:window-x"); + object->readAttr( "inkscape:window-y"); + object->readAttr( "inkscape:window-maximized"); + object->readAttr( "inkscape:snap-global"); + object->readAttr( "inkscape:snap-bbox"); + object->readAttr( "inkscape:snap-nodes"); + object->readAttr( "inkscape:snap-from-guide"); + object->readAttr( "inkscape:snap-center"); + object->readAttr( "inkscape:snap-smooth-nodes"); + object->readAttr( "inkscape:snap-midpoints"); + object->readAttr( "inkscape:snap-object-midpoints"); + object->readAttr( "inkscape:snap-bbox-edge-midpoints"); + object->readAttr( "inkscape:snap-bbox-midpoints"); + object->readAttr( "inkscape:snap-to-guides"); + object->readAttr( "inkscape:snap-grids"); + object->readAttr( "inkscape:snap-intersection-paths"); + object->readAttr( "inkscape:object-paths"); + object->readAttr( "inkscape:object-nodes"); + object->readAttr( "inkscape:bbox-paths"); + object->readAttr( "inkscape:bbox-nodes"); + object->readAttr( "inkscape:snap-page"); + object->readAttr( "inkscape:current-layer"); + object->readAttr( "inkscape:connector-spacing"); /* Construct guideline list */ for (SPObject *o = SP_OBJECT(og)->first_child() ; o != NULL; o = SP_OBJECT_NEXT(o) ) { @@ -920,7 +920,7 @@ gchar const *SPNamedView::getName() const { SPException ex; SP_EXCEPTION_INIT(&ex); - return sp_object_getAttribute(SP_OBJECT(this), "id", &ex); + return SP_OBJECT(this)->getAttribute("id", &ex); } guint SPNamedView::getViewCount() diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h index f3a80f83c..d1501fe3e 100644 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@ -13,7 +13,7 @@ */ #include "forward.h" - +#include "sp-object.h" namespace Inkscape { namespace XML { class Node; @@ -21,7 +21,7 @@ class Node; } -SPObject *sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr); +SPObject * sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr); GType sp_repr_type_lookup (Inkscape::XML::Node *repr); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index f81d5bdb5..f23f374d4 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -75,7 +75,7 @@ using std::strstr; # define debug(f, a...) /**/ #endif -static void sp_object_class_init(SPObjectClass *klass); +/*static void sp_object_class_init(SPObjectClass *klass); static void sp_object_init(SPObject *object); static void sp_object_finalize(GObject *object); @@ -89,9 +89,9 @@ static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XM static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -/* Real handlers of repr signals */ +* Real handlers of repr signals */ -static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); +/*static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); @@ -100,16 +100,16 @@ static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XM static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); -static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); +static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid);*/ guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { - sp_object_repr_child_added, - sp_object_repr_child_removed, - sp_object_repr_attr_changed, - sp_object_repr_content_changed, - sp_object_repr_order_changed + SPObject::sp_object_repr_child_added, + SPObject::sp_object_repr_child_removed, + SPObject::sp_object_repr_attr_changed, + SPObject::sp_object_repr_content_changed, + SPObject::sp_object_repr_order_changed }; // A friend class used to set internal members on SPObject so as to not expose settors in SPObject's public API @@ -143,20 +143,22 @@ public: }; -static GObjectClass *parent_class; +//static GObjectClass *parent_class; + +GObjectClass * SPObjectClass::static_parent_class = 0; /** * Registers the SPObject class with Gdk and returns its type number. */ GType -sp_object_get_type(void) +SPObject::sp_object_get_type() { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPObjectClass), NULL, NULL, - (GClassInitFunc) sp_object_class_init, + (GClassInitFunc) SPObjectClass::sp_object_class_init, NULL, NULL, sizeof(SPObject), 16, @@ -171,34 +173,34 @@ sp_object_get_type(void) /** * Initializes the SPObject vtable. */ -static void -sp_object_class_init(SPObjectClass *klass) +void +SPObjectClass::sp_object_class_init(SPObjectClass *klass) { GObjectClass *object_class; object_class = (GObjectClass *) klass; - parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); + static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); - object_class->finalize = sp_object_finalize; + object_class->finalize = SPObject::sp_object_finalize; - klass->child_added = sp_object_child_added; - klass->remove_child = sp_object_remove_child; - klass->order_changed = sp_object_order_changed; + klass->child_added = SPObject::sp_object_child_added; + klass->remove_child = SPObject::sp_object_remove_child; + klass->order_changed = SPObject::sp_object_order_changed; - klass->release = sp_object_release; + klass->release = SPObject::sp_object_release; - klass->build = sp_object_build; + klass->build = SPObject::sp_object_build; - klass->set = sp_object_private_set; - klass->write = sp_object_private_write; + klass->set = SPObject::sp_object_private_set; + klass->write = SPObject::sp_object_private_write; } /** * Callback to initialize the SPObject object. */ -static void -sp_object_init(SPObject *object) +void +SPObject::sp_object_init(SPObject *object) { debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); @@ -234,8 +236,8 @@ sp_object_init(SPObject *object) /** * Callback to destroy all members and connections of object and itself. */ -static void -sp_object_finalize(GObject *object) +void +SPObject::sp_object_finalize(GObject *object) { SPObject *spobject = (SPObject *)object; @@ -249,8 +251,8 @@ sp_object_finalize(GObject *object) spobject->_successor = NULL; } - if (((GObjectClass *) (parent_class))->finalize) { - (* ((GObjectClass *) (parent_class))->finalize)(object); + if (((GObjectClass *) (SPObjectClass::static_parent_class))->finalize) { + (* ((GObjectClass *) (SPObjectClass::static_parent_class))->finalize)(object); } spobject->_release_signal.~signal(); @@ -754,8 +756,8 @@ SPObject::get_child_by_repr(Inkscape::XML::Node *repr) * Callback for child_added event. * Invoked whenever the given mutation event happens in the XML tree. */ -static void -sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +void +SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { GType type = sp_repr_type_lookup(child); if (!type) { @@ -780,7 +782,7 @@ sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XM * SPRoot destroys the whole document tree. * \see sp_object_build() */ -static void sp_object_release(SPObject *object) +void SPObject::sp_object_release(SPObject *object) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); while (object->children) { @@ -796,8 +798,8 @@ static void sp_object_release(SPObject *object) * tree, BEFORE removal from the XML tree happens, so grouping * objects can safely release the child data. */ -static void -sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) +void +SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); SPObject *ochild = object->get_child_by_repr(child); @@ -812,7 +814,7 @@ sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) * Invoked whenever the given mutation event happens in the XML tree. * \param old_ref Ignored */ -static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/, +void SPObject::sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node */*old_ref*/, Inkscape::XML::Node *new_ref) { SPObject *ochild = object->get_child_by_repr(child); @@ -833,15 +835,15 @@ static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child * SPDocument does after the creation of the XML tree). * \see sp_object_release() */ -static void -sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +void +SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Nothing specific here */ debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); - sp_object_read_attr(object, "xml:space"); - sp_object_read_attr(object, "inkscape:label"); - sp_object_read_attr(object, "inkscape:collect"); + object->readAttr("xml:space"); + object->readAttr("inkscape:label"); + object->readAttr("inkscape:collect"); for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) { GType type = sp_repr_type_lookup(rchild); @@ -918,6 +920,23 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns sp_repr_add_listener(repr, &object_event_vector, this); } +long long int SPObject::getIntAttribute(char const *key, long long int def) +{ + return sp_repr_get_int_attribute(getRepr(),key,def); +} + +unsigned SPObject::getPosition(){ + g_assert(this->repr); + + return repr->position(); +} + +void SPObject::appendChild(Inkscape::XML::Node *child) { + g_assert(this->repr); + + repr->appendChild(child); +} + void SPObject::releaseReferences() { g_assert(this->document); g_assert(this->repr); @@ -966,14 +985,14 @@ SPObject *SPObject::getNext() SPObject *SPObject::getPrev() { - return sp_object_prev(this); + return this->prev(); } /** * Callback for child_added node event. */ -static void -sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) +void +SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -984,8 +1003,8 @@ sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *c /** * Callback for remove_child node event. */ -static void -sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) +void +SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -999,8 +1018,8 @@ sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node * * \todo fixme: */ -static void -sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) +void +SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -1012,8 +1031,8 @@ sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node /** * Callback for set event. */ -static void -sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) +void +SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) { g_assert(key != SP_ATTR_INVALID); @@ -1102,13 +1121,13 @@ sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) * Call virtual set() function of object. */ void -sp_object_set(SPObject *object, unsigned int key, gchar const *value) +SPObject::setKeyValue(unsigned int key, gchar const *value) { - g_assert(object != NULL); - g_assert(SP_IS_OBJECT(object)); + //g_assert(object != NULL); + //g_assert(SP_IS_OBJECT(object)); - if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->set) { - ((SPObjectClass *) G_OBJECT_GET_CLASS(object))->set(object, key, value); + if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->set) { + ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->set(this, key, value); } } @@ -1116,33 +1135,33 @@ sp_object_set(SPObject *object, unsigned int key, gchar const *value) * Read value of key attribute from XML node into object. */ void -sp_object_read_attr(SPObject *object, gchar const *key) +SPObject::readAttr(gchar const *key) { - g_assert(object != NULL); - g_assert(SP_IS_OBJECT(object)); + //g_assert(object != NULL); + //g_assert(SP_IS_OBJECT(object)); g_assert(key != NULL); //XML Tree being used here. - g_assert(object->getRepr() != NULL); + g_assert(this->getRepr() != NULL); unsigned int keyid = sp_attribute_lookup(key); if (keyid != SP_ATTR_INVALID) { /* Retrieve the 'key' attribute from the object's XML representation */ - gchar const *value = object->getRepr()->attribute(key); + gchar const *value = getRepr()->attribute(key); - sp_object_set(object, keyid, value); + setKeyValue(keyid, value); } } /** * Callback for attr_changed node event. */ -static void -sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) +void +SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) { SPObject *object = SP_OBJECT(data); - sp_object_read_attr(object, key); + object->readAttr(key); // manual changes to extension attributes require the normal // attributes, which depend on them, to be updated immediately @@ -1154,8 +1173,8 @@ sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gch /** * Callback for content_changed node event. */ -static void -sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) +void +SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -1182,8 +1201,8 @@ sp_xml_get_space_string(unsigned int space) /** * Callback for write event. */ -static Inkscape::XML::Node * -sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { repr = SP_OBJECT_REPR(object)->duplicate(doc); @@ -1448,8 +1467,9 @@ SPObject::emitModified(unsigned int flags) } gchar const * -sp_object_tagName_get(SPObject const *object, SPException *ex) +SPObject::getTagName(SPException *ex) const { + g_assert(repr != NULL); /* If exception is not clear, return */ if (!SP_EXCEPTION_IS_OK(ex)) { return NULL; @@ -1457,12 +1477,13 @@ sp_object_tagName_get(SPObject const *object, SPException *ex) /// \todo fixme: Exception if object is NULL? */ //XML Tree being used here. - return object->getRepr()->name(); + return getRepr()->name(); } gchar const * -sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex) +SPObject::getAttribute(gchar const *key, SPException *ex) const { + g_assert(this->repr != NULL); /* If exception is not clear, return */ if (!SP_EXCEPTION_IS_OK(ex)) { return NULL; @@ -1470,35 +1491,36 @@ sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex /// \todo fixme: Exception if object is NULL? */ //XML Tree being used here. - return (gchar const *) object->getRepr()->attribute(key); + return (gchar const *) getRepr()->attribute(key); } void -sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex) +SPObject::setAttribute(gchar const *key, gchar const *value, SPException *ex) { + g_assert(this->repr != NULL); /* If exception is not clear, return */ g_return_if_fail(SP_EXCEPTION_IS_OK(ex)); /// \todo fixme: Exception if object is NULL? */ //XML Tree being used here. - object->getRepr()->setAttribute(key, value, false); + getRepr()->setAttribute(key, value, false); } void -sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex) +SPObject::removeAttribute(gchar const *key, SPException *ex) { /* If exception is not clear, return */ g_return_if_fail(SP_EXCEPTION_IS_OK(ex)); /// \todo fixme: Exception if object is NULL? */ //XML Tree being used here. - object->getRepr()->setAttribute(key, NULL, false); + getRepr()->setAttribute(key, NULL, false); } /* Helper */ -static gchar * -sp_object_get_unique_id(SPObject *object, gchar const *id) +gchar * +SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id) { static unsigned long count = 0; @@ -1565,14 +1587,14 @@ sp_object_get_unique_id(SPObject *object, gchar const *id) * responsible for ascending the repr tree as necessary. */ gchar const * -sp_object_get_style_property(SPObject const *object, gchar const *key, gchar const *def) +SPObject::getStyleProperty(gchar const *key, gchar const *def) const { - g_return_val_if_fail(object != NULL, NULL); - g_return_val_if_fail(SP_IS_OBJECT(object), NULL); + //g_return_val_if_fail(object != NULL, NULL); + //g_return_val_if_fail(SP_IS_OBJECT(object), NULL); g_return_val_if_fail(key != NULL, NULL); //XML Tree being used here. - gchar const *style = object->getRepr()->attribute("style"); + gchar const *style = getRepr()->attribute("style"); if (style) { size_t const len = strlen(key); char const *p; @@ -1595,12 +1617,12 @@ sp_object_get_style_property(SPObject const *object, gchar const *key, gchar con } //XML Tree being used here. - gchar const *val = object->getRepr()->attribute(key); + gchar const *val = getRepr()->attribute(key); if (val && !streq(val, "inherit")) { return val; } - if (object->parent) { - return sp_object_get_style_property(object->parent, key, def); + if (this->parent) { + return (this->parent)->getStyleProperty(key, def); } return def; @@ -1626,11 +1648,11 @@ SPObject::_requireSVGVersion(Inkscape::Version version) { * Returns previous object in sibling list or NULL. */ SPObject * -sp_object_prev(SPObject *child) +SPObject::prev() { - SPObject *parent = SP_OBJECT_PARENT(child); + SPObject *parent = SP_OBJECT_PARENT(this); for ( SPObject *i = parent->first_child(); i; i = SP_OBJECT_NEXT(i) ) { - if (SP_OBJECT_NEXT(i) == child) + if (SP_OBJECT_NEXT(i) == this) return i; } return NULL; diff --git a/src/sp-object.h b/src/sp-object.h index e1d49b041..61c69c3aa 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -15,6 +15,14 @@ /* SPObject flags */ +class SPObject; +class SPObjectClass; + +#define SP_TYPE_OBJECT (SPObject::sp_object_get_type ()) +#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) +#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) +#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) + /* Async modification flags */ #define SP_OBJECT_MODIFIED_FLAG (1 << 0) #define SP_OBJECT_CHILD_MODIFIED_FLAG (1 << 1) @@ -50,11 +58,10 @@ #define SP_OBJECT_DOCUMENT(o) (((SPObject *) (o))->document) #define SP_OBJECT_PARENT(o) (((SPObject *) (o))->parent) #define SP_OBJECT_NEXT(o) (((SPObject *) (o))->next) -#define SP_OBJECT_PREV(o) (sp_object_prev((SPObject *) (o))) +#define SP_OBJECT_PREV(o) (((SPObject *) (o))->prev()) #define SP_OBJECT_HREFCOUNT(o) (((SPObject *) (o))->hrefcount) #define SP_OBJECT_STYLE(o) (((SPObject *) (o))->style) - #include #include #include @@ -171,12 +178,14 @@ public: * Returns the XML representation of tree */ //Inkscape::XML::Node const* getRepr() const; +//protected: Inkscape::XML::Node * getRepr(); /** * Returns the XML representation of tree */ Inkscape::XML::Node const* getRepr() const; +public: /** @brief cleans up an SPObject, releasing its references and * requesting that references to it be released @@ -519,6 +528,17 @@ public: return firstChild(); } void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); + long long int getIntAttribute(char const *key, long long int def); + unsigned getPosition(); + gchar const * getAttribute(gchar const *name,SPException *ex=0) const; + void appendChild(Inkscape::XML::Node *child); + void setKeyValue(unsigned int key, gchar const *value); + void setAttribute(gchar const *key, gchar const *value, SPException *ex=0); + void readAttr(gchar const *key); + gchar const *getTagName(SPException *ex) const; + void removeAttribute(gchar const *key, SPException *ex=0); + gchar const *getStyleProperty(gchar const *key, gchar const *def) const; + SPObject *prev(); private: // Private member functions used in the definitions of setTitle(), @@ -528,11 +548,41 @@ private: SPObject * findFirstChild(gchar const *tagname) const; GString * textualContent() const; + static void sp_object_init(SPObject *object); + static void sp_object_finalize(GObject *object); + + static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); + static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child); + static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); + + static void sp_object_release(SPObject *object); + static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); + + static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); + static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); + + /* Real handlers of repr signals */ + + public: + static GType sp_object_get_type(); + static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); + + static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); + + static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); + static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); + + static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); + + + friend class SPObjectClass; friend class SPObjectImpl; }; /// The SPObject vtable. -struct SPObjectClass { +class SPObjectClass { + public: GObjectClass parent_class; void (* build) (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); @@ -554,6 +604,12 @@ struct SPObjectClass { void (* modified) (SPObject *object, unsigned int flags); Inkscape::XML::Node * (* write) (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags); + + private: + static GObjectClass *static_parent_class; + static void sp_object_class_init(SPObjectClass *klass); + + friend class SPObject; }; @@ -572,25 +628,25 @@ struct SPObjectClass { //void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); -void sp_object_set(SPObject *object, unsigned int key, gchar const *value); +//void sp_object_set(SPObject *object, unsigned int key, gchar const *value); -void sp_object_read_attr(SPObject *object, gchar const *key); +//void sp_object_read_attr(SPObject *object, gchar const *key); /* Public */ -gchar const *sp_object_tagName_get(SPObject const *object, SPException *ex); -gchar const *sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex); -void sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex); -void sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex); +//gchar const *sp_object_tagName_get(SPObject const *object, SPException *ex); +//gchar const *sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex); +//void sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex); +//void sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex); /* Style */ -gchar const *sp_object_get_style_property(SPObject const *object, - gchar const *key, gchar const *def); +//gchar const *sp_object_get_style_property(SPObject const *object, +// gchar const *key, gchar const *def); int sp_object_compare_position(SPObject const *first, SPObject const *second); -SPObject *sp_object_prev(SPObject *child); +//SPObject *sp_object_prev(SPObject *child); #endif // SP_OBJECT_H_SEEN diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index ff915c92f..fdff5d7b6 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -219,7 +219,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep //XML Tree being used directly here while it shouldn't be. if (object->getRepr()->attribute("inkscape:radius")) { - sp_object_read_attr (object, "inkscape:radius"); + object->readAttr( "inkscape:radius"); } else { @@ -229,19 +229,19 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep object->getRepr()->setAttribute("inkscape:radius",oldA); object->getRepr()->setAttribute("sodipodi:radius",NULL); - sp_object_read_attr (object, "inkscape:radius"); + object->readAttr( "inkscape:radius"); } if (object->getRepr()->attribute("inkscape:original")) { - sp_object_read_attr (object, "inkscape:original"); + object->readAttr( "inkscape:original"); } else { gchar const *oldA = object->getRepr()->attribute("sodipodi:original"); object->getRepr()->setAttribute("inkscape:original",oldA); object->getRepr()->setAttribute("sodipodi:original",NULL); - sp_object_read_attr (object, "inkscape:original"); + object->readAttr( "inkscape:original"); } if (object->getRepr()->attribute("xlink:href")) { - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "xlink:href"); } else { gchar const *oldA = object->getRepr()->attribute("inkscape:href"); if (oldA) { @@ -254,7 +254,7 @@ sp_offset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep free(nA); object->getRepr()->setAttribute("inkscape:href",NULL); } - sp_object_read_attr (object, "xlink:href"); + object->readAttr( "xlink:href"); } } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 39ed4c657..5a0ff7c08 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -214,10 +214,10 @@ static void sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Are these calls actually necessary? */ - sp_object_read_attr(object, "marker"); - sp_object_read_attr(object, "marker-start"); - sp_object_read_attr(object, "marker-mid"); - sp_object_read_attr(object, "marker-end"); + object->readAttr( "marker"); + object->readAttr( "marker-start"); + object->readAttr( "marker-mid"); + object->readAttr( "marker-end"); sp_conn_end_pair_build(object); @@ -225,13 +225,13 @@ sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) ((SPObjectClass *) parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "inkscape:original-d"); - sp_object_read_attr(object, "d"); + object->readAttr( "inkscape:original-d"); + object->readAttr( "d"); /* d is a required attribute */ - gchar const *d = sp_object_getAttribute(object, "d", NULL); + gchar const *d = object->getAttribute("d", NULL); if (d == NULL) { - sp_object_set(object, sp_attribute_lookup("d"), ""); + object->setKeyValue( sp_attribute_lookup("d"), ""); } } diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 3958da66a..779edc3e8 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -156,15 +156,15 @@ sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *r if (((SPObjectClass *) pattern_parent_class)->build) (* ((SPObjectClass *) pattern_parent_class)->build) (object, document, repr); - sp_object_read_attr (object, "patternUnits"); - sp_object_read_attr (object, "patternContentUnits"); - sp_object_read_attr (object, "patternTransform"); - sp_object_read_attr (object, "x"); - sp_object_read_attr (object, "y"); - sp_object_read_attr (object, "width"); - sp_object_read_attr (object, "height"); - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "xlink:href"); + object->readAttr( "patternUnits"); + object->readAttr( "patternContentUnits"); + object->readAttr( "patternTransform"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "viewBox"); + object->readAttr( "xlink:href"); /* Register ourselves */ document->add_resource ("pattern", object); diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index 014c68c9b..b947e45ec 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -84,7 +84,7 @@ static void sp_polygon_build(SPObject *object, SPDocument *document, Inkscape::X ((SPObjectClass *) parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "points"); + object->readAttr( "points"); } diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 110fb4d01..b5eb81a11 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -89,7 +89,7 @@ SPPolyLine::sp_polyline_build (SPObject * object, SPDocument * document, Inkscap if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->build) ((SPObjectClass *) SPPolyLineClass::static_parent_class)->build (object, document, repr); - sp_object_read_attr (object, "points"); + object->readAttr( "points"); } void diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index f4993cdc9..4e417f35b 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -113,12 +113,12 @@ sp_rect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build(object, document, repr); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "rx"); - sp_object_read_attr(object, "ry"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "rx"); + object->readAttr( "ry"); } static void diff --git a/src/sp-root.cpp b/src/sp-root.cpp index e73e83a7f..ad43bb3db 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -151,16 +151,16 @@ sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) repr->setAttribute("version", SVG_VERSION); } - sp_object_read_attr(object, "version"); - sp_object_read_attr(object, "inkscape:version"); + object->readAttr( "version"); + object->readAttr( "inkscape:version"); /* It is important to parse these here, so objects will have viewport build-time */ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "viewBox"); - sp_object_read_attr(object, "preserveAspectRatio"); - sp_object_read_attr(object, "onload"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "viewBox"); + object->readAttr( "preserveAspectRatio"); + object->readAttr( "onload"); if (((SPObjectClass *) parent_class)->build) (* ((SPObjectClass *) parent_class)->build) (object, document, repr); diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 614187013..6cf120a65 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -83,7 +83,7 @@ sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "xlink:href"); document->add_resource("script", object); } diff --git a/src/sp-skeleton.cpp b/src/sp-skeleton.cpp index ec6c9b437..f67341826 100644 --- a/src/sp-skeleton.cpp +++ b/src/sp-skeleton.cpp @@ -110,18 +110,18 @@ sp_skeleton_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *r /* Pay attention to certain settings here - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "attributeName"); - sp_object_read_attr(object, "attributeType"); - sp_object_read_attr(object, "begin"); - sp_object_read_attr(object, "dur"); - sp_object_read_attr(object, "end"); - sp_object_read_attr(object, "min"); - sp_object_read_attr(object, "max"); - sp_object_read_attr(object, "restart"); - sp_object_read_attr(object, "repeatCount"); - sp_object_read_attr(object, "repeatDur"); - sp_object_read_attr(object, "fill"); + object->readAttr( "xlink:href"); + object->readAttr( "attributeName"); + object->readAttr( "attributeType"); + object->readAttr( "begin"); + object->readAttr( "dur"); + object->readAttr( "end"); + object->readAttr( "min"); + object->readAttr( "max"); + object->readAttr( "restart"); + object->readAttr( "repeatCount"); + object->readAttr( "repeatDur"); + object->readAttr( "fill"); */ } diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index fd44cc4ba..3acc34d2a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -129,13 +129,13 @@ sp_spiral_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - sp_object_read_attr (object, "sodipodi:cx"); - sp_object_read_attr (object, "sodipodi:cy"); - sp_object_read_attr (object, "sodipodi:expansion"); - sp_object_read_attr (object, "sodipodi:revolution"); - sp_object_read_attr (object, "sodipodi:radius"); - sp_object_read_attr (object, "sodipodi:argument"); - sp_object_read_attr (object, "sodipodi:t0"); + object->readAttr( "sodipodi:cx"); + object->readAttr( "sodipodi:cy"); + object->readAttr( "sodipodi:expansion"); + object->readAttr( "sodipodi:revolution"); + object->readAttr( "sodipodi:radius"); + object->readAttr( "sodipodi:argument"); + object->readAttr( "sodipodi:t0"); } /** diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 618d4520e..0d74cf780 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -118,16 +118,16 @@ sp_star_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * r if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - sp_object_read_attr (object, "sodipodi:cx"); - sp_object_read_attr (object, "sodipodi:cy"); - sp_object_read_attr (object, "sodipodi:sides"); - sp_object_read_attr (object, "sodipodi:r1"); - sp_object_read_attr (object, "sodipodi:r2"); - sp_object_read_attr (object, "sodipodi:arg1"); - sp_object_read_attr (object, "sodipodi:arg2"); - sp_object_read_attr (object, "inkscape:flatsided"); - sp_object_read_attr (object, "inkscape:rounded"); - sp_object_read_attr (object, "inkscape:randomized"); + object->readAttr( "sodipodi:cx"); + object->readAttr( "sodipodi:cy"); + object->readAttr( "sodipodi:sides"); + object->readAttr( "sodipodi:r1"); + object->readAttr( "sodipodi:r2"); + object->readAttr( "sodipodi:arg1"); + object->readAttr( "sodipodi:arg2"); + object->readAttr( "inkscape:flatsided"); + object->readAttr( "inkscape:rounded"); + object->readAttr( "inkscape:randomized"); } static Inkscape::XML::Node * diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 38dc1d367..9b096c861 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -56,16 +56,16 @@ public: SPStyleElem *style_elem = static_cast(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); SP_OBJECT(style_elem)->document = _doc; - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "something unrecognized"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "something unrecognized"); TS_ASSERT( !style_elem->is_css ); - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/css"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css"); TS_ASSERT( style_elem->is_css ); - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "atext/css"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "atext/css"); TS_ASSERT( !style_elem->is_css ); - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/cssx"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/cssx"); TS_ASSERT( !style_elem->is_css ); g_object_unref(style_elem); @@ -82,7 +82,7 @@ public: SPStyleElem *style_elem = SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); SP_OBJECT(style_elem)->document = _doc; - sp_object_set(SP_OBJECT(style_elem), SP_ATTR_TYPE, "text/css"); + SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css"); Inkscape::XML::Node *repr = sp_document_repr_doc(_doc)->createElement("svg:style"); SP_OBJECT(style_elem)->updateRepr(sp_document_repr_doc(_doc), repr, SP_OBJECT_WRITE_ALL); { diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp index bb4ccb2e1..68d8e8870 100644 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@ -390,8 +390,8 @@ sp_style_elem_build(SPObject *object, SPDocument *document, Inkscape::XML::Node { sp_style_elem_read_content(object); - sp_object_read_attr(object, "type"); - sp_object_read_attr(object, "media"); + object->readAttr( "type"); + object->readAttr( "media"); static Inkscape::XML::NodeEventVector const nodeEventVector = { child_add_rm_cb, // child_added diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 0dab82bc9..262cfa6a0 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -110,8 +110,8 @@ sp_symbol_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *re group = (SPGroup *) object; symbol = (SPSymbol *) object; - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "preserveAspectRatio"); + object->readAttr( "viewBox"); + object->readAttr( "preserveAspectRatio"); if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); diff --git a/src/sp-text.cpp b/src/sp-text.cpp index e3e919796..dcf9160ff 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -149,16 +149,16 @@ sp_text_release (SPObject *object) static void sp_text_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "dx"); + object->readAttr( "dy"); + object->readAttr( "rotate"); if (((SPObjectClass *) text_parent_class)->build) ((SPObjectClass *) text_parent_class)->build(object, doc, repr); - sp_object_read_attr(object, "sodipodi:linespacing"); // has to happen after the styles are read + object->readAttr( "sodipodi:linespacing"); // has to happen after the styles are read } static void diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 850ebbd42..ef9c89486 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -154,12 +154,12 @@ sp_tref_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) ((SPObjectClass *) tref_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); + object->readAttr( "xlink:href"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "dx"); + object->readAttr( "dy"); + object->readAttr( "rotate"); } /** diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index a7391ac98..8cddc6e5e 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -133,12 +133,12 @@ sp_tspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { //SPTSpan *tspan = SP_TSPAN(object); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - sp_object_read_attr(object, "sodipodi:role"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "dx"); + object->readAttr( "dy"); + object->readAttr( "rotate"); + object->readAttr( "sodipodi:role"); if (((SPObjectClass *) tspan_parent_class)->build) ((SPObjectClass *) tspan_parent_class)->build(object, doc, repr); @@ -392,13 +392,13 @@ sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { //SPTextPath *textpath = SP_TEXTPATH(object); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - sp_object_read_attr(object, "startOffset"); - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "dx"); + object->readAttr( "dy"); + object->readAttr( "rotate"); + object->readAttr( "startOffset"); + object->readAttr( "xlink:href"); bool no_content=true; for (Inkscape::XML::Node* rch = repr->firstChild() ; rch != NULL; rch = rch->next()) { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 3770b2324..075c7f804 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -160,11 +160,11 @@ sp_use_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) (* ((SPObjectClass *) parent_class)->build)(object, document, repr); } - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "xlink:href"); + object->readAttr( "x"); + object->readAttr( "y"); + object->readAttr( "width"); + object->readAttr( "height"); + object->readAttr( "xlink:href"); // We don't need to create child here: // reading xlink:href will attach ref, and that will cause the changed signal to be emitted, @@ -492,7 +492,7 @@ sp_use_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPUse *self return; // restore item->transform field from the repr, in case it was changed by seltrans - sp_object_read_attr (SP_OBJECT (self), "transform"); + SP_OBJECT (self)->readAttr ("transform"); Geom::Matrix t = sp_use_get_parent_transform(self); Geom::Matrix clone_move = t.inverse() * m * t; diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index 571698fd2..46a1e8941 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -13,7 +13,7 @@ #include #include "forward.h" - +#include "sp-object.h" /* Append object-specific part to context menu */ void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu); diff --git a/src/uri-references.h b/src/uri-references.h index a98c84153..e6399bfd9 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -18,6 +18,7 @@ #include "bad-uri-exception.h" #include "forward.h" +#include "sp-object.h" namespace Inkscape { diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 33f2a6ae7..6aa2a1ed5 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -17,6 +17,7 @@ #include "display/display-forward.h" #include "libnr/nr-point.h" #include "forward.h" +#include "sp-object.h" #include "message.h" #include "ui/view/view-widget.h" #include "ui/view/edit-widget-interface.h" diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 29e735536..6da23a696 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -7893,7 +7893,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl SPItem *item = (SPItem *) l->data; if (cc_item_is_connector(item)) { - sp_object_setAttribute(item, "inkscape:connector-type", + item->setAttribute( "inkscape:connector-type", value, false); item->avoidRef->handleSettingChange(); modmade = true; @@ -7941,7 +7941,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) SPItem *item = (SPItem *) l->data; if (cc_item_is_connector(item)) { - sp_object_setAttribute(item, "inkscape:connector-curvature", + item->setAttribute( "inkscape:connector-curvature", value, false); item->avoidRef->handleSettingChange(); modmade = true;