Code

Added simplistic test cases
[inkscape.git] / src / sp-ellipse.cpp
index 8022be5603e9ddf02daa8e945613fbc4b5963913..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;
@@ -304,7 +317,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, bool const target,
     // Add the centre, if we have a closed slice or when explicitly asked for
     if ((snapprefs->getSnapToItemNode() && slice && ellipse->closed) || snapprefs->getSnapObjectMidpoints()) {
        pt = Geom::Point(cx, cy) * i2d;
-       p.push_back(std::make_pair(pt, target ? int(Inkscape::SNAPTARGET_HANDLE) : int(Inkscape::SNAPSOURCE_HANDLE)));
+       p.push_back(std::make_pair(pt, target ? int(Inkscape::SNAPTARGET_CENTER) : int(Inkscape::SNAPSOURCE_CENTER)));
     }
 
     // And if we have a slice, also snap to the endpoints
@@ -694,8 +707,6 @@ 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);
 
-    Inkscape::Version version = sp_object_get_sodipodi_version(object);
-
     sp_object_read_attr(object, "sodipodi:cx");
     sp_object_read_attr(object, "sodipodi:cy");
     sp_object_read_attr(object, "sodipodi:rx");