summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-06-02 22:06:18 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-06-02 22:06:18 +0000
commit344c6e8f6489b820f81b1adde1d9717720311eb3 (patch)
tree57a7ea9fb4e099f632bfb39c8345f3dde999ed27
parentAdd preview to Font Features tab of Text and Font dialog. (diff)
downloadinkscape-344c6e8f6489b820f81b1adde1d9717720311eb3.tar.gz
inkscape-344c6e8f6489b820f81b1adde1d9717720311eb3.zip
Fixes on convert to paths LPE shapes
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp21
-rw-r--r--src/object/sp-lpe-item.cpp56
-rw-r--r--src/path-chemistry.cpp18
3 files changed, 74 insertions, 21 deletions
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 8ac5991a3..650d45747 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -211,18 +211,21 @@ LPECopyRotate::cloneD(SPObject *orig, SPObject *dest, Geom::Affine transform, bo
}
SPShape * shape = SP_SHAPE(orig);
SPPath * path = SP_PATH(dest);
- if (shape && !path) {
- const char * id = dest->getId();
- shape->removeAllPathEffects(true);
- Inkscape::XML::Node *dest_node = sp_selected_item_to_curved_repr(SP_ITEM(dest), 0);
- dest->updateRepr(xml_doc, dest_node, SP_OBJECT_WRITE_ALL);
- dest->getRepr()->setAttribute("d", id);
- path = SP_PATH(dest);
- }
- if (path && shape) {
+ if (shape) {
SPCurve *c = shape->getCurve();
if (c) {
gchar *str = sp_svg_write_path(c->get_pathvector());
+ if (shape && !path) {
+ const char * id = dest->getRepr()->attribute("id");
+ const char * style = dest->getRepr()->attribute("style");
+ Inkscape::XML::Document *xml_doc = dest->document->getReprDoc();
+ Inkscape::XML::Node *dest_node = xml_doc->createElement("svg:path");;
+ dest->updateRepr(xml_doc, dest_node, SP_OBJECT_WRITE_ALL);
+ dest_node->setAttribute("id", id);
+ dest_node->setAttribute("inkscape:connector-curvature", "0");
+ dest_node->setAttribute("style", style);
+ path = SP_PATH(dest);
+ }
path->getRepr()->setAttribute("d", str);
g_free(str);
c->unref();
diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp
index 98c99e3ae..8e1f425a8 100644
--- a/src/object/sp-lpe-item.cpp
+++ b/src/object/sp-lpe-item.cpp
@@ -450,13 +450,54 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths,
repr->setAttribute("d", NULL);
shape->setCurveBeforeLPE(NULL);
} else {
- repr->setAttribute("d", NULL);
- Inkscape::XML::Node *parent = repr->parent();
- Inkscape::XML::Node *spnew = sp_selected_item_to_curved_repr(lpeitem, 0);
- sp_repr_unparent(repr);
- parent->appendChild(spnew);
- Inkscape::GC::release(spnew);
- spnew->setAttribute("d", d_str);
+ const char * id = repr->attribute("id");
+ const char * style = repr->attribute("style");
+ // remember the position of the item
+ gint pos = shape->getRepr()->position();
+ // remember parent
+ Inkscape::XML::Node *parent = shape->getRepr()->parent();
+ // remember class
+ char const *class_attr = shape->getRepr()->attribute("class");
+ // remember title
+ gchar *title = shape->title();
+ // remember description
+ gchar *desc = shape->desc();
+ // remember highlight color
+ guint32 highlight_color = 0;
+ if (shape->isHighlightSet())
+ highlight_color = shape->highlight_color();
+
+ // It's going to resurrect, so we delete without notifying listeners.
+ SPDocument * doc = shape->document;
+ shape->deleteObject(false);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
+ // restore id
+ repr->setAttribute("id", id);
+ // restore class
+ repr->setAttribute("class", class_attr);
+ //restore d
+ repr->setAttribute("d", d_str);
+ //restore style
+ repr->setAttribute("style", style);
+ // add the new repr to the parent
+ parent->appendChild(repr);
+ SPObject* newObj = doc->getObjectByRepr(repr);
+ if (title && newObj) {
+ newObj->setTitle(title);
+ g_free(title);
+ }
+ if (desc && newObj) {
+ newObj->setDesc(desc);
+ g_free(desc);
+ }
+ if (highlight_color && newObj) {
+ SP_ITEM(newObj)->setHighlightColor( highlight_color );
+ }
+ // move to the saved position
+ repr->setPosition(pos > 0 ? pos : 0);
+ Inkscape::GC::release(repr);
+ lpeitem = dynamic_cast<SPLPEItem *>(newObj);
}
} else {
if (!keep_paths) {
@@ -597,6 +638,7 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths)
}
}
sp_lpe_item_cleanup_original_path_recursive(this, keep_paths);
+
}
void SPLPEItem::downCurrentPathEffect()
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 95b55a829..ac212388b 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -393,12 +393,22 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>&
continue;
}
-
+ // remember id
+ char const *id = item->getRepr()->attribute("id");
+
SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
if (lpeitem) {
+ selected.erase(remove(selected.begin(), selected.end(), item), selected.end());
lpeitem->removeAllPathEffects(true);
+ SPObject *elemref = NULL;
+ if (elemref = document->getObjectById(id)) {
+ //If the LPE item is a shape is converted to a path so we need to reupdate the item
+
+ item = dynamic_cast<SPItem *>(elemref);
+ selected.push_back(item);
+ }
}
-
+
SPPath *path = dynamic_cast<SPPath *>(item);
if (path) {
// remove connector attributes
@@ -436,10 +446,8 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>&
gint pos = item->getRepr()->position();
// remember parent
Inkscape::XML::Node *parent = item->getRepr()->parent();
- // remember id
- char const *id = item->getRepr()->attribute("id");
// remember class
- char const *class_attr = item->getRepr()->attribute("class");
+ char const *class_attr = item->getRepr()->attribute("class");
// remember title
gchar *title = item->title();
// remember description