summaryrefslogtreecommitdiffstats
path: root/src/text-chemistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/text-chemistry.cpp')
-rw-r--r--src/text-chemistry.cpp55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index ddadf8275..2b731c75d 100644
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
@@ -42,8 +42,8 @@ using Inkscape::DocumentUndo;
static SPItem *
flowtext_in_selection(Inkscape::Selection *selection)
{
- std::vector<SPItem*> items = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (SP_IS_FLOWTEXT(*i))
return *i;
}
@@ -53,8 +53,8 @@ flowtext_in_selection(Inkscape::Selection *selection)
static SPItem *
text_or_flowtext_in_selection(Inkscape::Selection *selection)
{
- std::vector<SPItem*> items = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i))
return *i;
}
@@ -64,8 +64,8 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection)
static SPItem *
shape_in_selection(Inkscape::Selection *selection)
{
- std::vector<SPItem*> items = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (SP_IS_SHAPE(*i))
return *i;
}
@@ -86,7 +86,7 @@ text_put_on_path()
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
- if (!text || !shape || selection->itemList().size() != 2) {
+ if (!text || !shape || boost::distance(selection->items()) != 2) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text and a path</b> to put text on path."));
return;
}
@@ -141,8 +141,8 @@ text_put_on_path()
// make a list of text children
GSList *text_reprs = NULL;
- for (SPObject *o = text->children; o != NULL; o = o->next) {
- text_reprs = g_slist_prepend(text_reprs, o->getRepr());
+ for(auto& o: text->children) {
+ text_reprs = g_slist_prepend(text_reprs, o.getRepr());
}
// create textPath and put it into the text
@@ -195,8 +195,8 @@ text_remove_from_path()
}
bool did = false;
- std::vector<SPItem*> items(selection->itemList());
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *obj = *i;
if (SP_IS_TEXT_TEXTPATH(obj)) {
@@ -213,7 +213,8 @@ text_remove_from_path()
} else {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Remove text from path"));
- selection->setList(selection->itemList()); // reselect to update statusbar description
+ std::vector<SPItem *> vec(selection->items().begin(), selection->items().end());
+ selection->setList(vec); // reselect to update statusbar description
}
}
@@ -238,9 +239,9 @@ text_remove_all_kerns_recursively(SPObject *o)
g_strfreev(xa_comma);
}
- for (SPObject *i = o->firstChild(); i != NULL; i = i->getNext()) {
- text_remove_all_kerns_recursively(i);
- i->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
+ for (auto& i: o->children) {
+ text_remove_all_kerns_recursively(&i);
+ i.requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG);
}
}
@@ -259,8 +260,8 @@ text_remove_all_kerns()
bool did = false;
- std::vector<SPItem*> items = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *obj = *i;
if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) {
@@ -295,7 +296,7 @@ text_flow_into_shape()
SPItem *text = text_or_flowtext_in_selection(selection);
SPItem *shape = shape_in_selection(selection);
- if (!text || !shape || selection->itemList().size() < 2) {
+ if (!text || !shape || boost::distance(selection->items()) < 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;
}
@@ -319,8 +320,8 @@ text_flow_into_shape()
g_return_if_fail(SP_IS_FLOWREGION(object));
/* Add clones */
- std::vector<SPItem*> items = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPItem *item = *i;
if (SP_IS_SHAPE(item)){
Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
@@ -351,9 +352,9 @@ text_flow_into_shape()
Inkscape::GC::release(text_repr);
} else { // reflow an already flowed text, preserving paras
- for (SPObject *o = text->children; o != NULL; o = o->next) {
- if (SP_IS_FLOWPARA(o)) {
- Inkscape::XML::Node *para_repr = o->getRepr()->duplicate(xml_doc);
+ for(auto& o: text->children) {
+ if (SP_IS_FLOWPARA(&o)) {
+ Inkscape::XML::Node *para_repr = o.getRepr()->duplicate(xml_doc);
root_repr->appendChild(para_repr);
object = doc->getObjectByRepr(para_repr);
g_return_if_fail(SP_IS_FLOWPARA(object));
@@ -386,7 +387,7 @@ text_unflow ()
Inkscape::Selection *selection = desktop->getSelection();
- if (!flowtext_in_selection(selection) || selection->itemList().size() < 1) {
+ if (!flowtext_in_selection(selection) || boost::distance(selection->items()) < 1) {
desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a flowed text</b> to unflow it."));
return;
}
@@ -394,8 +395,8 @@ text_unflow ()
std::vector<SPItem*> new_objs;
GSList *old_objs = NULL;
- std::vector<SPItem*> items = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items = selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (!SP_IS_FLOWTEXT(*i)) {
continue;
@@ -479,7 +480,7 @@ flowtext_to_text()
bool did = false;
std::vector<Inkscape::XML::Node*> reprs;
- std::vector<SPItem*> items(selection->itemList());
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
SPItem *item = *i;