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) @@ -238,6 +238,8 @@ repr = xml_doc->createElement("svg:flowRegion"); } + // this chunk of code was refactored out to sp-item's write method +/* 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); @@ -254,6 +256,7 @@ for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); } +*/ } if (((SPObjectClass *) (flowregion_parent_class))->write) Index: src/dialogs/item-properties.cpp =================================================================== --- src/dialogs/item-properties.cpp (revision 19598) +++ src/dialogs/item-properties.cpp (working copy) @@ -348,8 +348,8 @@ gtk_text_buffer_set_text(buf, desc, -1); g_free(desc); } else { - gtk_text_buffer_set_text(buf, "", 0); - } + gtk_text_buffer_set_text(buf, "", 0); + } w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc_frame")); gtk_widget_set_sensitive(w, TRUE); } Index: src/sp-text.cpp =================================================================== --- src/sp-text.cpp (revision 19598) +++ src/sp-text.cpp (working copy) @@ -303,9 +303,11 @@ { SPText *text = SP_TEXT (object); - if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) repr = xml_doc->createElement("svg:text"); + + // this code was refactored out to sp-item's write method +/* GSList *l = NULL; for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *crepr = NULL; @@ -330,6 +332,7 @@ } } } +*/ text->attributes.writeTo(repr); Index: src/sp-tspan.cpp =================================================================== --- src/sp-tspan.cpp (revision 19598) +++ src/sp-tspan.cpp (working copy) @@ -234,12 +234,14 @@ { SPTSpan *tspan = SP_TSPAN(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + if (!repr) { repr = xml_doc->createElement("svg:tspan"); } tspan->attributes.writeTo(repr); - + + // this chunk of code has been refactored to sp-item's write method +/* if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { @@ -268,7 +270,7 @@ SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); } } - } + }*/ if (((SPObjectClass *) tspan_parent_class)->write) ((SPObjectClass *) tspan_parent_class)->write(object, xml_doc, repr, flags); Index: src/sp-flowdiv.cpp =================================================================== --- src/sp-flowdiv.cpp (revision 19598) +++ src/sp-flowdiv.cpp (working copy) @@ -199,6 +199,10 @@ if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowDiv"); + } + + // this chunk of code was refactored out to sp-item's write method +/* GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; @@ -227,6 +231,7 @@ } } } +*/ if (((SPObjectClass *) (flowdiv_parent_class))->write) ((SPObjectClass *) (flowdiv_parent_class))->write (object, xml_doc, repr, flags); @@ -370,6 +375,10 @@ { if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowSpan"); + } + + // this chunk of code has been refactored to sp-item's write method + /* GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; @@ -398,6 +407,7 @@ } } } + */ if (((SPObjectClass *) (flowtspan_parent_class))->write) ((SPObjectClass *) (flowtspan_parent_class))->write (object, xml_doc, repr, flags); @@ -543,6 +553,10 @@ if ( flags&SP_OBJECT_WRITE_BUILD ) { if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara"); + } + + // this chunk of code has been refactored out to sp-item's write method +/* GSList *l = NULL; for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node* c_repr=NULL; @@ -571,6 +585,7 @@ } } } + */ if (((SPObjectClass *) (flowpara_parent_class))->write) ((SPObjectClass *) (flowpara_parent_class))->write (object, xml_doc, repr, flags); Index: src/sp-flowtext.cpp =================================================================== --- src/sp-flowtext.cpp (revision 19598) +++ src/sp-flowtext.cpp (working copy) @@ -293,8 +293,12 @@ static Inkscape::XML::Node * sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + if (!repr) + repr = xml_doc->createElement("svg:flowRoot"); + + // this chunk of code was refactored out to sp-item's write method +/* if ( flags & SP_OBJECT_WRITE_BUILD ) { - if ( repr == NULL ) repr = xml_doc->createElement("svg:flowRoot"); GSList *l = NULL; for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *c_repr = NULL; @@ -315,6 +319,7 @@ } } } +*/ if (((SPObjectClass *) (parent_class))->write) ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); 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) @@ -221,11 +221,13 @@ sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPGroup *group; - SPObject *child; - Inkscape::XML::Node *crepr; group = SP_GROUP (object); - + if (!repr) { + repr = xml_doc->createElement("svg:g"); + } + // this chunk of code has been refactored to sp-item's write method + /* if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l; if (!repr) { @@ -245,7 +247,7 @@ for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); } - } + }*/ if ( flags & SP_OBJECT_WRITE_EXT ) { const char *value; Index: src/sp-item.cpp =================================================================== --- src/sp-item.cpp (revision 19598) +++ src/sp-item.cpp (working copy) @@ -657,8 +657,38 @@ 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_STRING(child) ) { + crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + } else { + 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_STRING(child) ) { + SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); + } else { + 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; +}