Index: src/sp-desc.h =================================================================== --- src/sp-desc.h (revision 0) +++ src/sp-desc.h (revision 0) @@ -0,0 +1,32 @@ +#ifndef __SP_DESC_H__ +#define __SP_DESC_H__ + +/* + * SVG implementation + * + * Authors: + * Jeff Schiller + * + * Copyright (C) 2008 Jeff Schiller + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-object.h" + +#define SP_TYPE_DESC (sp_desc_get_type ()) +#define SP_IS_DESC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DESC)) + +class SPDesc; +class SPDescClass; + +struct SPDesc : public SPObject { +}; + +struct SPDescClass { + SPObjectClass parent_class; +}; + +GType sp_desc_get_type (void); + +#endif Index: src/sp-object-repr.cpp =================================================================== --- src/sp-object-repr.cpp (revision 19598) +++ src/sp-object-repr.cpp (working copy) @@ -81,6 +81,8 @@ #include "sp-feturbulence.h" #include "sp-femergenode.h" #include "live_effects/lpeobject.h" +#include "sp-title.h" +#include "sp-desc.h" enum NameType { REPR_NAME, SODIPODI_TYPE }; @@ -138,6 +140,7 @@ { "svg:color-profile", COLORPROFILE_TYPE }, { "svg:clipPath", SP_TYPE_CLIPPATH }, { "svg:defs", SP_TYPE_DEFS }, + { "svg:desc", SP_TYPE_DESC }, { "svg:ellipse", SP_TYPE_ELLIPSE }, { "svg:filter", SP_TYPE_FILTER }, /* Note: flow* elements are proposed additions for SVG 1.2, they aren't in @@ -203,6 +206,7 @@ { "svg:symbol", SP_TYPE_SYMBOL }, { "svg:text", SP_TYPE_TEXT }, { "svg:textPath", SP_TYPE_TEXTPATH }, + { "svg:title", SP_TYPE_TITLE }, { "svg:tref", SP_TYPE_TREF }, { "svg:tspan", SP_TYPE_TSPAN }, { "svg:use", SP_TYPE_USE }, Index: src/sp-flowregion.cpp =================================================================== --- src/sp-flowregion.cpp (revision 19598) +++ src/sp-flowregion.cpp (working copy) @@ -15,6 +15,8 @@ #include "sp-use.h" #include "style.h" #include "document.h" +#include "sp-title.h" +#include "sp-desc.h" #include "sp-flowregion.h" @@ -240,6 +242,7 @@ GSList *l = NULL; for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); } @@ -252,6 +255,7 @@ } else { for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; child->updateRepr(flags); } } Index: src/sp-text.cpp =================================================================== --- src/sp-text.cpp (revision 19598) +++ src/sp-text.cpp (working copy) @@ -44,6 +44,8 @@ #include "xml/quote.h" #include "xml/repr.h" #include "mod360.h" +#include "sp-title.h" +#include "sp-desc.h" #include "sp-textpath.h" #include "sp-tref.h" @@ -308,6 +310,7 @@ repr = xml_doc->createElement("svg:text"); GSList *l = NULL; for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; Inkscape::XML::Node *crepr = NULL; if (SP_IS_STRING(child)) { crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); @@ -323,6 +326,7 @@ } } else { for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; if (SP_IS_STRING(child)) { SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); } else { Index: src/sp-title.cpp =================================================================== --- src/sp-title.cpp (revision 0) +++ src/sp-title.cpp (revision 0) @@ -0,0 +1,76 @@ +#define __SP_TITLE_C__ + +/* + * SVG implementation + * + * Authors: + * Jeff Schiller <codedread@gmail.com> + * + * Copyright (C) 2008 Jeff Schiller + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "sp-title.h" +#include "xml/repr.h" + +static void sp_title_class_init(SPTitleClass *klass); +static void sp_title_init(SPTitle *rect); +static Inkscape::XML::Node *sp_title_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *title_parent_class; + +GType +sp_title_get_type (void) +{ + static GType title_type = 0; + + if (!title_type) { + GTypeInfo title_info = { + sizeof (SPTitleClass), + NULL, NULL, + (GClassInitFunc) sp_title_class_init, + NULL, NULL, + sizeof (SPTitle), + 16, + (GInstanceInitFunc) sp_title_init, + NULL, /* value_table */ + }; + title_type = g_type_register_static (SP_TYPE_OBJECT, "SPTitle", &title_info, (GTypeFlags)0); + } + return title_type; +} + +static void +sp_title_class_init(SPTitleClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *) klass; + title_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); + + sp_object_class->write = sp_title_write; +} + +static void +sp_title_init(SPTitle */*desc*/) +{ +} + +/* + * \brief Writes it's settings to an incoming repr object, if any + */ +static Inkscape::XML::Node * +sp_title_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +{ + if (!repr) { + repr = SP_OBJECT_REPR (object)->duplicate(doc); + } + + if (((SPObjectClass *) title_parent_class)->write) + ((SPObjectClass *) title_parent_class)->write(object, doc, repr, flags); + + return repr; +} Index: src/Makefile_insert =================================================================== --- src/Makefile_insert (revision 19598) +++ src/Makefile_insert (working copy) @@ -164,6 +164,7 @@ sp-conn-end.cpp sp-conn-end.h \ sp-cursor.cpp sp-cursor.h \ sp-defs.cpp sp-defs.h \ + sp-desc.cpp sp-desc.h \ sp-ellipse.cpp sp-ellipse.h \ sp-feblend.cpp sp-feblend.h \ sp-feblend-fns.h \ @@ -269,6 +270,7 @@ sp-switch.cpp sp-switch.h\ sp-text.cpp sp-text.h \ sp-textpath.h \ + sp-title.cpp sp-title.h \ sp-tref-reference.cpp sp-tref-reference.h \ sp-tref.cpp sp-tref.h \ sp-tspan.cpp sp-tspan.h \ Index: src/sp-title.h =================================================================== --- src/sp-title.h (revision 0) +++ src/sp-title.h (revision 0) @@ -0,0 +1,32 @@ +#ifndef __SP_TITLE_H__ +#define __SP_TITLE_H__ + +/* + * SVG <title> implementation + * + * Authors: + * Jeff Schiller <codedread@gmail.com> + * + * Copyright (C) 2008 Jeff Schiller + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-object.h" + +#define SP_TYPE_TITLE (sp_title_get_type ()) +#define SP_IS_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_TITLE)) + +class SPTitle; +class SPTitleClass; + +struct SPTitle : public SPObject { +}; + +struct SPTitleClass { + SPObjectClass parent_class; +}; + +GType sp_title_get_type (void); + +#endif Index: src/sp-item-group.cpp =================================================================== --- src/sp-item-group.cpp (revision 19598) +++ src/sp-item-group.cpp (working copy) @@ -45,6 +45,8 @@ #include "selection.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" +#include "sp-title.h" +#include "sp-desc.h" static void sp_group_class_init (SPGroupClass *klass); static void sp_group_init (SPGroup *group); @@ -233,6 +235,7 @@ } l = NULL; for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend (l, crepr); } @@ -243,6 +246,7 @@ } } else { for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; child->updateRepr(flags); } } Index: src/sp-item.cpp =================================================================== --- src/sp-item.cpp (revision 19598) +++ src/sp-item.cpp (working copy) @@ -55,6 +55,8 @@ #include "sp-filter-reference.h" #include "filter-chemistry.h" #include "sp-guide.h" +#include "sp-title.h" +#include "sp-desc.h" #include "libnr/nr-matrix-fns.h" #include "libnr/nr-matrix-scale-ops.h" @@ -657,8 +659,32 @@ static Inkscape::XML::Node * sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPObject *child; SPItem *item = SP_ITEM(object); + // in the case of SP_OBJECT_WRITE_BUILD, the item should always be newly created, + // so we need to add any children from the underlying object to the new repr + if (flags & SP_OBJECT_WRITE_BUILD) { + Inkscape::XML::Node *crepr; + GSList *l; + l = NULL; + for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; + 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 (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; + child->updateRepr(flags); + } + } + gchar *c = sp_svg_transform_write(item->transform); repr->setAttribute("transform", c); g_free(c); Index: src/sp-desc.cpp =================================================================== --- src/sp-desc.cpp (revision 0) +++ src/sp-desc.cpp (revision 0) @@ -0,0 +1,76 @@ +#define __SP_DESC_C__ + +/* + * SVG <desc> implementation + * + * Authors: + * Jeff Schiller <codedread@gmail.com> + * + * Copyright (C) 2008 Jeff Schiller + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "sp-desc.h" +#include "xml/repr.h" + +static void sp_desc_class_init(SPDescClass *klass); +static void sp_desc_init(SPDesc *rect); +static Inkscape::XML::Node *sp_desc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *desc_parent_class; + +GType +sp_desc_get_type (void) +{ + static GType desc_type = 0; + + if (!desc_type) { + GTypeInfo desc_info = { + sizeof (SPDescClass), + NULL, NULL, + (GClassInitFunc) sp_desc_class_init, + NULL, NULL, + sizeof (SPDesc), + 16, + (GInstanceInitFunc) sp_desc_init, + NULL, /* value_table */ + }; + desc_type = g_type_register_static (SP_TYPE_OBJECT, "SPDesc", &desc_info, (GTypeFlags)0); + } + return desc_type; +} + +static void +sp_desc_class_init(SPDescClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *) klass; + desc_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);; + + sp_object_class->write = sp_desc_write; +} + +static void +sp_desc_init(SPDesc */*desc*/) +{ +} + +/* + * \brief Writes it's settings to an incoming repr object, if any + */ +static Inkscape::XML::Node * +sp_desc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) +{ + if (!repr) { + repr = SP_OBJECT_REPR (object)->duplicate(doc); + } + + if (((SPObjectClass *) desc_parent_class)->write) + ((SPObjectClass *) desc_parent_class)->write(object, doc, repr, flags); + + return repr; +}