summaryrefslogtreecommitdiffstats
path: root/src/text-chemistry.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-05-09 18:34:01 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-05-09 18:34:01 +0000
commit36bc16fc9772ce0271eb5ec62e2c03cb1038282e (patch)
treec13d992c952bd21bc00c393d80bfe31c3b35284e /src/text-chemistry.cpp
parentprevent overflow index on a pathinfo function (diff)
parentFix Doxyfile (diff)
downloadinkscape-36bc16fc9772ce0271eb5ec62e2c03cb1038282e.tar.gz
inkscape-36bc16fc9772ce0271eb5ec62e2c03cb1038282e.zip
update to trunk
(bzr r13645.1.85)
Diffstat (limited to 'src/text-chemistry.cpp')
-rw-r--r--src/text-chemistry.cpp84
1 files changed, 37 insertions, 47 deletions
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index 65b59f2ad..9fc862ad2 100644
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
@@ -43,11 +43,10 @@ using Inkscape::DocumentUndo;
static SPItem *
flowtext_in_selection(Inkscape::Selection *selection)
{
- for (GSList *items = (GSList *) selection->itemList();
- items != NULL;
- items = items->next) {
- if (SP_IS_FLOWTEXT(items->data))
- return ((SPItem *) items->data);
+ std::vector<SPItem*> items = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ if (SP_IS_FLOWTEXT(*i))
+ return *i;
}
return NULL;
}
@@ -55,11 +54,10 @@ flowtext_in_selection(Inkscape::Selection *selection)
static SPItem *
text_or_flowtext_in_selection(Inkscape::Selection *selection)
{
- for (GSList *items = (GSList *) selection->itemList();
- items != NULL;
- items = items->next) {
- if (SP_IS_TEXT(items->data) || SP_IS_FLOWTEXT(items->data))
- return ((SPItem *) items->data);
+ std::vector<SPItem*> items = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
+ return *i;
}
return NULL;
}
@@ -67,11 +65,10 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection)
static SPItem *
shape_in_selection(Inkscape::Selection *selection)
{
- for (GSList *items = (GSList *) selection->itemList();
- items != NULL;
- items = items->next) {
- if (SP_IS_SHAPE(items->data))
- return ((SPItem *) items->data);
+ std::vector<SPItem*> items = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ if (SP_IS_SHAPE(*i))
+ return *i;
}
return NULL;
}
@@ -90,7 +87,7 @@ text_put_on_path()
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
- if (!text || !shape || g_slist_length((GSList *) selection->itemList()) != 2) {
+ if (!text || !shape || selection->itemList().size() != 2) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text and a path</b> to put text on path."));
return;
}
@@ -199,11 +196,9 @@ text_remove_from_path()
}
bool did = false;
-
- for (GSList *items = g_slist_copy((GSList *) selection->itemList());
- items != NULL;
- items = items->next) {
- SPObject *obj = SP_OBJECT(items->data);
+ std::vector<SPItem*> items(selection->itemList());
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPObject *obj = *i;
if (SP_IS_TEXT_TEXTPATH(obj)) {
SPObject *tp = obj->firstChild();
@@ -219,7 +214,7 @@ text_remove_from_path()
} else {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Remove text from path"));
- selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description
+ selection->setList(selection->itemList()); // reselect to update statusbar description
}
}
@@ -265,10 +260,9 @@ text_remove_all_kerns()
bool did = false;
- for (GSList *items = g_slist_copy((GSList *) selection->itemList());
- items != NULL;
- items = items->next) {
- SPObject *obj = SP_OBJECT(items->data);
+ std::vector<SPItem*> items = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPObject *obj = *i;
if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) {
continue;
@@ -302,7 +296,7 @@ text_flow_into_shape()
SPItem *text = text_or_flowtext_in_selection(selection);
SPItem *shape = shape_in_selection(selection);
- if (!text || !shape || g_slist_length((GSList *) selection->itemList()) < 2) {
+ if (!text || !shape || selection->itemList().size() < 2) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text</b> and one or more <b>paths or shapes</b> to flow text into frame."));
return;
}
@@ -326,10 +320,9 @@ text_flow_into_shape()
g_return_if_fail(SP_IS_FLOWREGION(object));
/* Add clones */
- for (GSList *items = (GSList *) selection->itemList();
- items != NULL;
- items = items->next) {
- SPItem *item = SP_ITEM(items->data);
+ std::vector<SPItem*> items = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
+ SPItem *item = *i;
if (SP_IS_SHAPE(item)){
Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
clone->setAttribute("x", "0");
@@ -394,23 +387,22 @@ text_unflow ()
Inkscape::Selection *selection = desktop->getSelection();
- if (!flowtext_in_selection(selection) || g_slist_length((GSList *) selection->itemList()) < 1) {
+ if (!flowtext_in_selection(selection) || selection->itemList().size() < 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a flowed text</b> to unflow it."));
return;
}
- GSList *new_objs = NULL;
+ std::vector<SPItem*> new_objs;
GSList *old_objs = NULL;
- for (GSList *items = g_slist_copy((GSList *) selection->itemList());
- items != NULL;
- items = items->next) {
+ std::vector<SPItem*> items = selection->itemList();
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
- if (!SP_IS_FLOWTEXT(SP_OBJECT(items->data))) {
+ if (!SP_IS_FLOWTEXT(*i)) {
continue;
}
- SPItem *flowtext = SP_ITEM(items->data);
+ SPItem *flowtext = *i;
// we discard transform when unflowing, but we must preserve expansion which is visible as
// font size multiplier
@@ -451,7 +443,7 @@ text_unflow ()
SPText *text = SP_TEXT(text_object);
text->_adjustFontsizeRecursive(text, ex);
- new_objs = g_slist_prepend (new_objs, text_object);
+ new_objs.push_back((SPItem*)text_object);
old_objs = g_slist_prepend (old_objs, flowtext);
Inkscape::GC::release(rtext);
@@ -460,13 +452,13 @@ text_unflow ()
}
selection->clear();
+ reverse(new_objs.begin(),new_objs.end());
selection->setList(new_objs);
for (GSList *i = old_objs; i; i = i->next) {
SP_OBJECT(i->data)->deleteObject (true);
}
g_slist_free (old_objs);
- g_slist_free (new_objs);
DocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT,
_("Unflow flowed text"));
@@ -487,11 +479,11 @@ flowtext_to_text()
bool did = false;
- GSList *reprs = NULL;
- GSList *items = g_slist_copy((GSList *) selection->itemList());
- for (; items != NULL; items = items->next) {
+ std::vector<Inkscape::XML::Node*> reprs;
+ std::vector<SPItem*> items(selection->itemList());
+ for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
- SPItem *item = (SPItem *) items->data;
+ SPItem *item = *i;
if (!SP_IS_FLOWTEXT(item))
continue;
@@ -519,10 +511,9 @@ flowtext_to_text()
Inkscape::GC::release(repr);
item->deleteObject();
- reprs = g_slist_prepend(reprs, repr);
+ reprs.push_back(repr);
}
- g_slist_free(items);
if (did) {
DocumentUndo::done(desktop->getDocument(),
@@ -535,7 +526,6 @@ flowtext_to_text()
_("<b>No flowed text(s)</b> to convert in the selection."));
}
- g_slist_free(reprs);
}