summaryrefslogtreecommitdiffstats
path: root/src/object/sp-script.cpp
blob: d965421cbbdaa92f553c396b88ff4dadeb679e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * SVG <script> implementation
 *
 * Authors:
 *   Felipe Corrêa da Silva Sanches <juca@members.fsf.org>
 *   Jon A. Cruz <jon@joncruz.org>
 *   Abhishek Sharma
 *
 * Copyright (C) 2008 authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include "sp-script.h"
#include "attributes.h"

SPScript::SPScript() : SPObject() {
	this->xlinkhref = nullptr;
}

SPScript::~SPScript() = default;

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.
 */

void SPScript::release() {
    if (this->document) {
        // Unregister ourselves
        this->document->removeResource("script", this);
    }

    SPObject::release();
}

void SPScript::update(SPCtx* /*ctx*/, unsigned int /*flags*/) {
}


void SPScript::modified(unsigned int /*flags*/) {
}


void SPScript::set(SPAttributeEnum key, const gchar* value) {
    switch (key) {
	case SP_ATTR_XLINK_HREF:
            if (this->xlinkhref) {
            	g_free(this->xlinkhref);
            }

            this->xlinkhref = g_strdup(value);
            this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
            break;
	default:
            SPObject::set(key, value);
            break;
    }
}

Inkscape::XML::Node* SPScript::write(Inkscape::XML::Document* /*doc*/, Inkscape::XML::Node* repr, guint /*flags*/) {
	return repr;
}

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :