[dia] svg-import: improve 2 point closed path handling and use style



commit 201daf8b1c20b8673cec69289ac1d449f9ce050f
Author: Hans Breuer <hans breuer org>
Date:   Sun Jan 5 13:16:55 2014 +0100

    svg-import: improve 2 point closed path handling and use style
    
    The latter is still a compromise, but leads to better results
    with render-test round-trip through cairo SVG export. The former
    was throwing a g_warning and is now just closing the path.

 plug-ins/svg/svg-import.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index 1b1e684..2bb7dde 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -639,11 +639,12 @@ read_path_svg(xmlNodePtr node, DiaSvgStyle *parent_style,
          otype = object_get_type("Standard - BezierLine");
        } else if (bezpoints->len < 3) { /* error path: invalid input or parsing error? */
          /* Our beziergon can not handle less than three points
-          * Not sure if turning it into a line is such a good idea ...
+          * So line-to the first point again...
           */
-         g_warning ("Not closing a path with two points.");
-         otype = object_get_type("Standard - BezierLine");
-         closed = FALSE;
+         BezPoint bpz = g_array_index(bezpoints, BezPoint, 0);
+         bpz.type = BEZ_LINE_TO;
+         g_array_append_val(bezpoints, bpz);
+         otype = object_get_type("Standard - Beziergon");
        } else {
          otype = object_get_type("Standard - Beziergon");
        }
@@ -1610,13 +1611,14 @@ read_items (xmlNodePtr   startnode,
           * objects w/o style so we have two options beside complete
           * rewrite:
           *  - use the style from the group and hope it is on defaults
+               (i.e. pass in parent_gs with init=FALSE)
           *  - use a style from scratch instead of parent_gs and hope
           *    the object is already styled correctly
           * Or maybe we should remember the explicit style set during
           * creation, store it with the template as meta info and use
           * that to give NULL or parent_gs here?
           */
-         apply_style (obj, node, NULL, style_ht, pattern_ht, FALSE);
+         apply_style (obj, node, parent_gs, style_ht, pattern_ht, FALSE);
          items = g_list_append (items, obj);
        }
       }


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