X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftext-chemistry.cpp;h=3a100a6fe7cf952e26bddf36c5010219effbbeca;hb=aadffb0c53cb958cd70e6520b7c24acf5fc7d06f;hp=79d5e3a2dc390d5a62068ea6b80c0db2beaff839;hpb=0eff20ba7952a46a0a6d16c34f5dc0067172bd0b;p=inkscape.git diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 79d5e3a2d..3a100a6fe 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -14,9 +14,13 @@ #ifdef HAVE_CONFIG_H # include #endif + +#include +#include +#include + #include "libnr/nr-matrix-fns.h" #include "xml/repr.h" -#include #include "sp-rect.h" #include "sp-textpath.h" #include "inkscape.h" @@ -31,6 +35,7 @@ #include "sp-flowtext.h" #include "sp-flowregion.h" #include "sp-flowdiv.h" +#include "sp-tspan.h" SPItem * @@ -165,8 +170,8 @@ text_put_on_path() SP_OBJECT_REPR(text)->addChild(textpath, NULL); for ( GSList *i = text_reprs ; i ; i = i->next ) { - // make a copy of each text child - Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(); + // Make a copy of each text child + Inkscape::XML::Node *copy = ((Inkscape::XML::Node *) i->data)->duplicate(xml_doc); // We cannot have multiline in textpath, so remove line attrs from tspans if (!strcmp(copy->name(), "svg:tspan")) { copy->setAttribute("sodipodi:role", NULL); @@ -220,9 +225,9 @@ text_remove_from_path() if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No texts-on-paths in the selection.")); } else { - selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); + selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description } } @@ -233,6 +238,20 @@ text_remove_all_kerns_recursively(SPObject *o) SP_OBJECT_REPR(o)->setAttribute("dy", NULL); SP_OBJECT_REPR(o)->setAttribute("rotate", NULL); + // if x contains a list, leave only the first value + gchar *x = (gchar *) SP_OBJECT_REPR(o)->attribute("x"); + if (x) { + gchar **xa_space = g_strsplit(x, " ", 0); + gchar **xa_comma = g_strsplit(x, ",", 0); + if (xa_space && *xa_space && *(xa_space + 1)) { + SP_OBJECT_REPR(o)->setAttribute("x", g_strdup(*xa_space)); + } else if (xa_comma && *xa_comma && *(xa_comma + 1)) { + SP_OBJECT_REPR(o)->setAttribute("x", g_strdup(*xa_comma)); + } + g_strfreev(xa_space); + g_strfreev(xa_comma); + } + for (SPObject *i = sp_object_first_child(o); i != NULL; i = SP_OBJECT_NEXT(i)) { text_remove_all_kerns_recursively(i); } @@ -256,13 +275,14 @@ text_remove_all_kerns() for (GSList *items = g_slist_copy((GSList *) selection->itemList()); items != NULL; items = items->next) { + SPObject *obj = SP_OBJECT(items->data); - if (!SP_IS_TEXT(SP_OBJECT(items->data))) { + if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { continue; } - text_remove_all_kerns_recursively(SP_OBJECT(items->data)); - SP_OBJECT(items->data)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + text_remove_all_kerns_recursively(obj); + obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); did = true; } @@ -346,7 +366,7 @@ text_flow_into_shape() } else { // reflow an already flowed text, preserving paras for (SPObject *o = SP_OBJECT(text)->children; o != NULL; o = o->next) { if (SP_IS_FLOWPARA(o)) { - Inkscape::XML::Node *para_repr = SP_OBJECT_REPR(o)->duplicate(); + Inkscape::XML::Node *para_repr = SP_OBJECT_REPR(o)->duplicate(xml_doc); root_repr->appendChild(para_repr); object = doc->getObjectByRepr(para_repr); g_return_if_fail(SP_IS_FLOWPARA(object));