[dia] svg: parse comments to meta info
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] svg: parse comments to meta info
- Date: Sun, 4 Aug 2013 12:43:46 +0000 (UTC)
commit 437cafd1b296b4656df6fbd73cc637d648b58a0d
Author: Hans Breuer <hans breuer org>
Date: Sun Jul 28 14:16:58 2013 +0200
svg: parse comments to meta info
plug-ins/svg/svg-import.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index b99ec64..96f23c5 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -1059,6 +1059,7 @@ read_items (xmlNodePtr startnode,
{
xmlNodePtr node;
GList *items = NULL;
+ gchar *comment = NULL;
for (node = startnode; node != NULL; node = node->next) {
@@ -1069,6 +1070,16 @@ read_items (xmlNodePtr startnode,
DiaObject *obj = NULL;
if (xmlIsBlankNode(node)) continue;
+ if (node->type == XML_COMMENT_NODE) {
+ if (!comment)
+ comment = g_strdup ((gchar *)node->content);
+ else {
+ gchar *prev = comment;
+ comment = g_strjoin ("\n", comment, (gchar *)node->content, NULL);
+ g_free (prev);
+ }
+ continue;
+ }
if (node->type != XML_ELEMENT_NODE) continue;
if (!xmlStrcmp(node->name, (const xmlChar *)"g")) {
@@ -1189,11 +1200,13 @@ read_items (xmlNodePtr startnode,
DiaObject *otemp = g_hash_table_lookup (defs_ht, key+1);
if (otemp) {
- DiaObject *onew = otemp->ops->copy (otemp);
+ /* The new object can be referenced again by use or
+ * be target for meta info, comment or something. */
+ obj = otemp->ops->copy (otemp);
- use_position (onew, node);
- apply_style (onew, node, parent_gs, FALSE);
- items = g_list_append (items, onew);
+ use_position (obj, node);
+ apply_style (obj, node, parent_gs, FALSE);
+ items = g_list_append (items, obj);
}
xmlFree (key);
}
@@ -1237,8 +1250,15 @@ read_items (xmlNodePtr startnode,
g_hash_table_insert (defs_ht, g_strdup ((char *)val), obj);
xmlFree (val);
}
+ if (comment) {
+ dia_object_set_meta (obj, "comment", (char *)comment);
+ g_free (comment);
+ comment = NULL;
+ }
}
}
+ /* just to be sure */
+ g_free (comment);
return items;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]