diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-09-19 22:33:11 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-09-19 22:33:11 +0000 |
| commit | 4bda89e32e33c7bdff5d3ea3c1ceee1f806de9f7 (patch) | |
| tree | caeb924426bcc861badc6fa81318b67460b26d47 /src/sp-script.cpp | |
| parent | Update to trunk (diff) | |
| parent | updates for cmake (diff) | |
| download | inkscape-4bda89e32e33c7bdff5d3ea3c1ceee1f806de9f7.tar.gz inkscape-4bda89e32e33c7bdff5d3ea3c1ceee1f806de9f7.zip | |
Update to trunk
(bzr r11950.1.141)
Diffstat (limited to 'src/sp-script.cpp')
| -rw-r--r-- | src/sp-script.cpp | 101 |
1 files changed, 44 insertions, 57 deletions
diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 736ddb4c9..158796e51 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -16,91 +16,77 @@ #include <cstring> #include "document.h" -static void sp_script_release(SPObject *object); -static void sp_script_update(SPObject *object, SPCtx *ctx, guint flags); -static void sp_script_modified(SPObject *object, guint flags); -static void sp_script_set(SPObject *object, unsigned int key, gchar const *value); -static void sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -static Inkscape::XML::Node *sp_script_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -G_DEFINE_TYPE(SPScript, sp_script, SP_TYPE_OBJECT); - -static void sp_script_class_init(SPScriptClass *sc) -{ - SPObjectClass *sp_object_class = (SPObjectClass *) sc; - - sp_object_class->build = sp_script_build; - sp_object_class->release = sp_script_release; - sp_object_class->update = sp_script_update; - sp_object_class->modified = sp_script_modified; - sp_object_class->write = sp_script_write; - sp_object_class->set = sp_script_set; +#include "sp-factory.h" + +namespace { + SPObject* createScript() { + return new SPScript(); + } + + bool scriptRegistered = SPFactory::instance().registerObject("svg:script", createScript); } -static void sp_script_init(SPScript */*script*/) -{ +SPScript::SPScript() : SPObject() { + this->xlinkhref = NULL; +} +SPScript::~SPScript() { } +void SPScript::build(SPDocument* doc, Inkscape::XML::Node* repr) { + SPObject::build(doc, repr); + + //Read values of key attributes from XML nodes into object. + this->readAttr( "xlink:href" ); + + doc->addResource("script", this); +} /** * Reads the Inkscape::XML::Node, and initializes SPScript variables. For this to get called, * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -static void -sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ - if (((SPObjectClass *) sp_script_parent_class)->build) { - ((SPObjectClass *) sp_script_parent_class)->build(object, document, repr); - } - - //Read values of key attributes from XML nodes into object. - object->readAttr( "xlink:href" ); - document->addResource("script", object); -} - -static void sp_script_release(SPObject *object) -{ - if (object->document) { +void SPScript::release() { + if (this->document) { // Unregister ourselves - object->document->removeResource("script", object); + this->document->removeResource("script", this); } - if (((SPObjectClass *) sp_script_parent_class)->release) { - ((SPObjectClass *) sp_script_parent_class)->release(object); - } + SPObject::release(); } -static void sp_script_update(SPObject */*object*/, SPCtx */*ctx*/, guint /*flags*/) -{ +void SPScript::update(SPCtx* ctx, unsigned int flags) { } -static void sp_script_modified(SPObject */*object*/, guint /*flags*/) -{ + +void SPScript::modified(unsigned int flags) { } -static void -sp_script_set(SPObject *object, unsigned int key, gchar const *value) -{ - SPScript *scr = SP_SCRIPT(object); +void SPScript::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_XLINK_HREF: - if (scr->xlinkhref) g_free(scr->xlinkhref); - scr->xlinkhref = g_strdup(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + if (this->xlinkhref) { + g_free(this->xlinkhref); + } + + this->xlinkhref = g_strdup(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) sp_script_parent_class)->set) - ((SPObjectClass *) sp_script_parent_class)->set(object, key, value); + SPObject::set(key, value); break; } } -static Inkscape::XML::Node *sp_script_write(SPObject */*object*/, Inkscape::XML::Document */*xml_doc*/, Inkscape::XML::Node *repr, guint /*flags*/) -{ +Inkscape::XML::Node* SPScript::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { + return repr; +} + +//static Inkscape::XML::Node *sp_script_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +//{ /* TODO: code copied from sp-defs @@ -136,8 +122,9 @@ TODO: (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags); } */ - return repr; -} +// +// return ((SPScript*)object)->cscript->onWrite(xml_doc, repr, flags); +//} /* Local Variables: |
