Code

Added simplistic test cases
[inkscape.git] / src / sp-ellipse.cpp
index 2847d23e9d342a8ca8f14230d2d82873856810e0..769fa54fd62ed41b84ac16d06b6b9251eebe0041 100644 (file)
@@ -28,6 +28,7 @@
 #include "display/curve.h"
 #include <glibmm/i18n.h>
 #include <2geom/transforms.h>
+#include <2geom/pathvector.h>
 
 #include "document.h"
 #include "sp-ellipse.h"
@@ -184,6 +185,18 @@ sp_genericellipse_update_patheffect(SPLPEItem *lpeitem, bool write)
 /* Can't we use arcto in this method? */
 static void sp_genericellipse_set_shape(SPShape *shape)
 {
+    if (sp_lpe_item_has_broken_path_effect(SP_LPE_ITEM(shape))) {
+        g_warning ("The ellipse shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as ellipse will remove the bad LPE");
+        if (SP_OBJECT_REPR(shape)->attribute("d")) {
+            // unconditionally read the curve from d, if any, to preserve appearance
+            Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
+            SPCurve *cold = new SPCurve(pv);
+            sp_shape_set_curve_insync (shape, cold, TRUE);
+            cold->unref();
+        }
+        return;
+    }
+
     double rx, ry, s, e;
     double x0, y0, x1, y1, x2, y2, x3, y3;
     double len;
@@ -366,7 +379,7 @@ static Inkscape::XML::Node *sp_genericellipse_write(SPObject *object, Inkscape::
 static void sp_ellipse_class_init(SPEllipseClass *klass);
 static void sp_ellipse_init(SPEllipse *ellipse);
 
-static void sp_ellipse_build(SPObject *object, Document *document, Inkscape::XML::Node *repr);
+static void sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
 static Inkscape::XML::Node *sp_ellipse_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 static void sp_ellipse_set(SPObject *object, unsigned int key, gchar const *value);
 static gchar *sp_ellipse_description(SPItem *item);
@@ -416,7 +429,7 @@ sp_ellipse_init(SPEllipse */*ellipse*/)
 }
 
 static void
-sp_ellipse_build(SPObject *object, Document *document, Inkscape::XML::Node *repr)
+sp_ellipse_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
 {
     if (((SPObjectClass *) ellipse_parent_class)->build)
         (* ((SPObjectClass *) ellipse_parent_class)->build) (object, document, repr);
@@ -513,7 +526,7 @@ sp_ellipse_position_set(SPEllipse *ellipse, gdouble x, gdouble y, gdouble rx, gd
 static void sp_circle_class_init(SPCircleClass *klass);
 static void sp_circle_init(SPCircle *circle);
 
-static void sp_circle_build(SPObject *object, Document *document, Inkscape::XML::Node *repr);
+static void sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
 static Inkscape::XML::Node *sp_circle_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 static void sp_circle_set(SPObject *object, unsigned int key, gchar const *value);
 static gchar *sp_circle_description(SPItem *item);
@@ -564,7 +577,7 @@ sp_circle_init(SPCircle */*circle*/)
 }
 
 static void
-sp_circle_build(SPObject *object, Document *document, Inkscape::XML::Node *repr)
+sp_circle_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
 {
     if (((SPObjectClass *) circle_parent_class)->build)
         (* ((SPObjectClass *) circle_parent_class)->build)(object, document, repr);
@@ -635,7 +648,7 @@ static gchar *sp_circle_description(SPItem */*item*/)
 static void sp_arc_class_init(SPArcClass *klass);
 static void sp_arc_init(SPArc *arc);
 
-static void sp_arc_build(SPObject *object, Document *document, Inkscape::XML::Node *repr);
+static void sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
 static Inkscape::XML::Node *sp_arc_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 static void sp_arc_set(SPObject *object, unsigned int key, gchar const *value);
 static void sp_arc_modified(SPObject *object, guint flags);
@@ -689,7 +702,7 @@ sp_arc_init(SPArc */*arc*/)
 }
 
 static void
-sp_arc_build(SPObject *object, Document *document, Inkscape::XML::Node *repr)
+sp_arc_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
 {
     if (((SPObjectClass *) arc_parent_class)->build)
         (* ((SPObjectClass *) arc_parent_class)->build) (object, document, repr);