[dia/dia-0-97] Bug 637611 - Mangled SVG import (incomplete line-to handling)



commit b4dc27a36865254b65df86ee53a2e1d792feed8b
Author: Hans Breuer <hans breuer org>
Date:   Fri Jan 7 00:59:56 2011 +0100

    Bug 637611 - Mangled SVG import (incomplete line-to handling)
    
    There is a serious limitation with Dia's standard bezier serialization.
    It can only represent a single move-to at the beginning and following
    bezier points are assumed to be curve-to.
    There is a more complete implementation by data_add_bezpoint and
    data_bezpoint, but using that would hamper forward compatibility.
    
    So implemented a work-around in dia_svg_parse_path() which reproduces
    line-to appearance also by curve-to control points.

 lib/dia_svg.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/lib/dia_svg.c b/lib/dia_svg.c
index 4eaac1b..eea21b2 100644
--- a/lib/dia_svg.c
+++ b/lib/dia_svg.c
@@ -736,6 +736,14 @@ dia_svg_parse_path(const gchar *path_str, gchar **unparsed, gboolean *closed)
 	bez.p1.x += last_point.x;
 	bez.p1.y += last_point.y;
       }
+      /* Strictly speeaking it should not be necessary to assign the other 
+       * two points. But it helps hiding a serious limitation with the 
+       * standard bezier serialization, namely only saving one move-to
+       * and the rest as curve-to */
+#define INIT_LINE_TO_AS_CURVE_TO bez.p3 = bez.p1; bez.p2 = last_point
+
+      INIT_LINE_TO_AS_CURVE_TO;
+
       last_point = bez.p1;
       last_control = bez.p1;
 
@@ -748,6 +756,9 @@ dia_svg_parse_path(const gchar *path_str, gchar **unparsed, gboolean *closed)
       bez.p1.y = last_point.y;
       if (last_relative)
 	bez.p1.x += last_point.x;
+
+      INIT_LINE_TO_AS_CURVE_TO;
+
       last_point = bez.p1;
       last_control = bez.p1;
 
@@ -760,6 +771,11 @@ dia_svg_parse_path(const gchar *path_str, gchar **unparsed, gboolean *closed)
       path_chomp(path);
       if (last_relative)
 	bez.p1.y += last_point.y;
+
+      INIT_LINE_TO_AS_CURVE_TO;
+
+#undef INIT_LINE_TO_AS_CURVE_TO
+
       last_point = bez.p1;
       last_control = bez.p1;
 



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