summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8be695a)
raw | patch | inline | side by side (parent: 8be695a)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Tue, 22 Jul 2008 12:05:49 +0000 (12:05 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Tue, 22 Jul 2008 12:05:49 +0000 (12:05 +0000) |
Some people develope SVG files that contain javascript. We should not
erase their script nodes!
Also, we could develop a scripting IDE in inkscape. Look at
http://wiki.inkscape.org/wiki/index.php/BlueprintScriptingIDE
erase their script nodes!
Also, we could develop a scripting IDE in inkscape. Look at
http://wiki.inkscape.org/wiki/index.php/BlueprintScriptingIDE
src/Makefile_insert | patch | blob | history | |
src/attributes.cpp | patch | blob | history | |
src/attributes.h | patch | blob | history | |
src/sp-object-repr.cpp | patch | blob | history | |
src/sp-root.cpp | patch | blob | history | |
src/sp-root.h | patch | blob | history | |
src/sp-script.cpp | [new file with mode: 0644] | patch | blob |
src/sp-script.h | [new file with mode: 0644] | patch | blob |
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 935abf456ecaa2bb7c497bb48df656a103d80b9c..52adc54e83a3770dded2ce3086b066066fbb9bb2 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
sp-radial-gradient.h \
sp-rect.cpp sp-rect.h \
sp-root.cpp sp-root.h \
+ sp-script.cpp sp-script.h \
sp-shape.cpp sp-shape.h \
sp-spiral.cpp sp-spiral.h \
sp-star.cpp sp-star.h \
diff --git a/src/attributes.cpp b/src/attributes.cpp
index cfadab9c6496806fade88196bab52b972173f7e5..c671446923c03fcd9bee320c99d390645a10b2ab 100644 (file)
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
{SP_ATTR_PRESERVEASPECTRATIO, "preserveAspectRatio"},
{SP_ATTR_SODIPODI_VERSION, "sodipodi:version"},
{SP_ATTR_INKSCAPE_VERSION, "inkscape:version"},
+ {SP_ATTR_ONLOAD, "onload"},
/* SPNamedView */
{SP_ATTR_VIEWONLY, "viewonly"},
{SP_ATTR_SHOWGUIDES, "showguides"},
diff --git a/src/attributes.h b/src/attributes.h
index 7291b0166364405e7b0231ed67bcfc75b72c9d1c..c1c4dcadc7ff8f2179b59f30755ad7913148aa11 100644 (file)
--- a/src/attributes.h
+++ b/src/attributes.h
SP_ATTR_PRESERVEASPECTRATIO,
SP_ATTR_SODIPODI_VERSION,
SP_ATTR_INKSCAPE_VERSION,
+ SP_ATTR_ONLOAD,
/* SPNamedView */
SP_ATTR_VIEWONLY,
SP_ATTR_SHOWGUIDES,
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index 7eb91d281046aa13bc9a6eed2d00374578cabf92..87c27214dbd974e3de3db760c246aa44f9c3d0c8 100644 (file)
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
#include "sp-flowdiv.h"
#include "sp-flowregion.h"
#include "sp-flowtext.h"
+#include "sp-script.h"
#include "config.h"
#ifdef ENABLE_SVG_FONTS
{ "svg:radialGradient", SP_TYPE_RADIALGRADIENT },
{ "svg:rect", SP_TYPE_RECT },
{ "svg:stop", SP_TYPE_STOP },
+ { "svg:script", SP_TYPE_SCRIPT },
{ "svg:svg", SP_TYPE_ROOT },
{ "svg:style", SP_TYPE_STYLE_ELEM },
{ "svg:switch", SP_TYPE_SWITCH },
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 94b561bcce3c3433a09c443afa01e01035c1aa49..0ff3b48b6d241408e5ed5f85f1438b4aedc3ac85 100644 (file)
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -162,6 +162,7 @@ sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
sp_object_read_attr(object, "height");
sp_object_read_attr(object, "viewBox");
sp_object_read_attr(object, "preserveAspectRatio");
+ sp_object_read_attr(object, "onload");
if (((SPObjectClass *) parent_class)->build)
(* ((SPObjectClass *) parent_class)->build) (object, document, repr);
root->aspect_clip = clip;
}
break;
+ case SP_ATTR_ONLOAD:
+ root->onload = (char *) value;
+ break;
default:
/* Pass the set event to the parent */
if (((SPObjectClass *) parent_class)->set) {
diff --git a/src/sp-root.h b/src/sp-root.h
index 8a6a4ed571bbf954f3e1f1d4059b83756e4fc930..c298223f10e2cfcdc968f549257949fc8aaa3c03 100644 (file)
--- a/src/sp-root.h
+++ b/src/sp-root.h
/** Child to parent additional transform. */
NR::Matrix c2p;
+ gchar *onload;
+
/**
* Primary \<defs\> element where we put new defs (patterns, gradients etc.).
*
diff --git a/src/sp-script.cpp b/src/sp-script.cpp
--- /dev/null
+++ b/src/sp-script.cpp
@@ -0,0 +1,127 @@
+#define __SP_SCRIPT_C__
+
+/*
+ * SVG <script> implementation
+ *
+ * Authors:
+ * Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2008 authors
+ *
+ * Released under GNU GPL version 2 or later, read the file 'COPYING' for more information
+ */
+
+#include "sp-script.h"
+
+static void sp_script_class_init(SPScriptClass *sc);
+static void sp_script_init(SPScript *script);
+
+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 Inkscape::XML::Node *sp_script_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
+
+static SPObjectClass *parent_class;
+
+GType sp_script_get_type(void)
+{
+ static GType script_type = 0;
+
+ if (!script_type) {
+ GTypeInfo script_info = {
+ sizeof(SPScriptClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) sp_script_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof(SPScript),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) sp_script_init,
+ NULL, /* value_table */
+ };
+ script_type = g_type_register_static(SP_TYPE_OBJECT, "SPScript", &script_info, (GTypeFlags) 0);
+ }
+
+ return script_type;
+}
+
+static void sp_script_class_init(SPScriptClass *sc)
+{
+ parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
+ SPObjectClass *sp_object_class = (SPObjectClass *) sc;
+
+ 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;
+}
+
+static void sp_script_init(SPScript */*script*/)
+{
+
+}
+
+static void sp_script_release(SPObject *object)
+{
+ if (((SPObjectClass *) (parent_class))->release) {
+ ((SPObjectClass *) (parent_class))->release(object);
+ }
+}
+
+static void sp_script_update(SPObject *object, SPCtx *ctx, guint flags)
+{
+}
+
+static void sp_script_modified(SPObject *object, guint flags)
+{
+}
+
+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
+ decide what to do here!
+
+ if (flags & SP_OBJECT_WRITE_BUILD) {
+
+ if (!repr) {
+ repr = xml_doc->createElement("svg:script");
+ }
+
+ GSList *l = NULL;
+ for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ if (crepr) l = g_slist_prepend(l, crepr);
+ }
+
+ while (l) {
+ repr->addChild((Inkscape::XML::Node *) l->data, NULL);
+ Inkscape::GC::release((Inkscape::XML::Node *) l->data);
+ l = g_slist_remove(l, l->data);
+ }
+
+ } else {
+ for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ child->updateRepr(flags);
+ }
+ }
+
+ if (((SPObjectClass *) (parent_class))->write) {
+ (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, 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 :
diff --git a/src/sp-script.h b/src/sp-script.h
--- /dev/null
+++ b/src/sp-script.h
@@ -0,0 +1,45 @@
+#ifndef __SP_SCRIPT_H__
+#define __SP_SCRIPT_H__
+
+/*
+ * SVG <script> implementation
+ *
+ * Author:
+ * Felipe C. da S. Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2008 Author
+ *
+ * Released under GNU GPL version 2 or later, read the file 'COPYING' for more information
+ */
+
+#include "sp-item.h"
+
+#define SP_TYPE_SCRIPT (sp_script_get_type())
+#define SP_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_SCRIPT, SPScript))
+#define SP_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_SCRIPT, SPScriptClass))
+#define SP_IS_SCRIPT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_SCRIPT))
+#define SP_IS_SCRIPT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_SCRIPT))
+
+/* SPScript */
+
+struct SPScript : public SPObject {
+};
+
+struct SPScriptClass {
+ SPObjectClass parent_class;
+};
+
+GType sp_script_get_type();
+
+#endif
+
+/*
+ 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:encoding=utf-8:textwidth=99 :