summaryrefslogtreecommitdiffstats
path: root/src/object/sp-script.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/object/sp-script.cpp
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/object/sp-script.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/object/sp-script.cpp b/src/object/sp-script.cpp
new file mode 100644
index 0000000..7daaa5c
--- /dev/null
+++ b/src/object/sp-script.cpp
@@ -0,0 +1,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(SPAttr::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(SPAttr key, const gchar* value) {
+ switch (key) {
+ case SPAttr::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 :