Code

Another take to fixing pdf import crash, likely without memory leak
[inkscape.git] / src / box3d-side.cpp
index e4f60075b943c91d27d9616ee1677d20422fd79b..9db03c584eec19a6c7d5f6e4df94cb5a761d7442 100644 (file)
@@ -39,7 +39,6 @@ static void box3d_side_update (SPObject *object, SPCtx *ctx, guint flags);
 //static void box3d_side_set_shape (SPShape *shape);
 //static void box3d_side_update_patheffect (SPShape *shape, bool write);
 
-static void box3d_side_apply_style (Box3DSide *side);
 static Proj::Pt3 box3d_side_corner (Box3DSide *side, guint index);
 static std::vector<Proj::Pt3> box3d_side_corners (Box3DSide *side);
 // static gint box3d_side_descr_to_id (gchar const *descr);
@@ -110,7 +109,7 @@ box3d_side_build (SPObject * object, SPDocument * document, Inkscape::XML::Node
     if (((SPObjectClass *) parent_class)->build)
         ((SPObjectClass *) parent_class)->build (object, document, repr);
 
-    sp_object_read_attr (object, "inkscape:box3dsidetype");
+    sp_object_read_attr(object, "inkscape:box3dsidetype");
 }
 
 static Inkscape::XML::Node *
@@ -145,8 +144,6 @@ box3d_side_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
     repr->setAttribute("d", d);
     g_free (d);
 
-    box3d_side_apply_style (side);
-
     if (((SPObjectClass *) (parent_class))->write)
         ((SPObjectClass *) (parent_class))->write (object, repr, flags);
 
@@ -196,7 +193,6 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags)
 
     //g_print ("box3d_side_update\n");
     if (flags & (SP_OBJECT_MODIFIED_FLAG |
-                 //SP_OBJECT_CHILD_MODIFIED_FLAG |
                  SP_OBJECT_STYLE_MODIFIED_FLAG |
                  SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
         sp_shape_set_shape ((SPShape *) object);
@@ -311,19 +307,10 @@ box3d_side_set_shape (SPShape *shape)
     sp_curve_unref (c);
 }
 
-static void
-//box3d_side_apply_style (SPBox3D *box, bool extruded) {
+void
 box3d_side_apply_style (Box3DSide *side) {
     Inkscape::XML::Node *repr_face = SP_OBJECT_REPR(SP_OBJECT(side));
 
-    /**
-    if (!extruded && !strcmp (box3d_side_axes_string (), "XYrear")) {
-        // to avoid "flashing" during the initial dragging process, we make the rear face invisible in this case
-        repr_face->setAttribute("style", "fill:none");
-        return;
-    }
-    **/
-
     gchar *descr = g_strconcat ("desktop.", box3d_side_axes_string (side), NULL);
     const gchar * cur_style = prefs_get_string_attribute(descr, "style");
     g_free (descr);    
@@ -409,6 +396,19 @@ box3d_side_perspective(Box3DSide *side) {
     return SP_BOX3D(SP_OBJECT(side)->parent)->persp_ref->getObject();
 }
 
+Inkscape::XML::Node *
+box3d_side_convert_to_path(Box3DSide *side) {
+    // TODO: Copy over all important attributes (see sp_selected_item_to_curved_repr() for an example)
+    SPDocument *doc = SP_OBJECT_DOCUMENT(side);
+    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+
+    Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
+    repr->setAttribute("d", SP_OBJECT_REPR(side)->attribute("d"));
+    repr->setAttribute("style", SP_OBJECT_REPR(side)->attribute("style"));
+
+    return repr;
+}
+
 /*
   Local Variables:
   mode:c++