[dia] svg: respect xml:space="preserve"



commit 3456c289d8f5742fff5468298bad2e0487be4ab7
Author: Hans Breuer <hans breuer org>
Date:   Sat Dec 28 21:50:28 2013 +0100

    svg: respect xml:space="preserve"
    
    w/o it the parsed string is just stripped, it might be necessary to
    also replace extra whitespace within the string.

 plug-ins/svg/svg-import.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index f572066..569d49f 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -697,6 +697,7 @@ read_text_svg(xmlNodePtr node, DiaSvgStyle *parent_style,
     gboolean any_tspan = FALSE;
     DiaMatrix *matrix = NULL;
     real font_height = 0.0;
+    gboolean preserve_space = xmlNodeGetSpacePreserve (node) > 0;
 
     str = xmlGetProp(node, (const xmlChar *)"transform");
     if (str) {
@@ -769,6 +770,8 @@ read_text_svg(xmlNodePtr node, DiaSvgStyle *parent_style,
       prop = g_ptr_array_index(props, 0);
       g_free(prop->text_data);
       prop->text_data = str ? g_strdup((char *) str) : multiline;
+      if (!preserve_space)
+        prop->text_data = g_strstrip (prop->text_data); /* modifies in-place */
       xmlFree(str);
       prop->attr.alignment = gs->alignment;
       prop->attr.position.x = point.x;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]