diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2015-04-29 21:14:01 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <mc@M0nst3r.bouyguesbox.fr> | 2015-04-29 21:14:01 +0000 |
| commit | 9b7af8caac08ad42a48214518bc004e258eb5873 (patch) | |
| tree | dcaaac56217eb5da334ab420f5e791cf7eb70f23 /src/ui/dialog/text-edit.cpp | |
| parent | Better solution picking (diff) | |
| parent | corrected test file (diff) | |
| download | inkscape-9b7af8caac08ad42a48214518bc004e258eb5873.tar.gz inkscape-9b7af8caac08ad42a48214518bc004e258eb5873.zip | |
bzr merge lp:~mc.../inkscape/SelContainer
The main change of this branch is that the container for selections is now a std::vector and not a GSList.
This change propagates in most of the codebase.
Normally, there are no changes of semantics, except the following:
-> childList is now in the intuitive order (childList()[0] is now firstChild)
-> sp_selection_paste_impl is now in the opposite order (change is local to selection-chemistry.cpp, and simplify a few things there)
-> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it)
-> a few comparison functions now work "the c++ way": the C way was to return -1 if a<b, 0 if a==b and 1 if a>b, now they return (bool)(a<b) so they can be used with std::sort
(bzr r14074)
Diffstat (limited to 'src/ui/dialog/text-edit.cpp')
| -rw-r--r-- | src/ui/dialog/text-edit.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index a8be8b543..815aa12ef 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -418,12 +418,11 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - for (const GSList *item = SP_ACTIVE_DESKTOP->getSelection()->itemList(); - item != NULL; - item = item->next) + std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { - if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) - return SP_ITEM (item->data); + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) + return *i; } return NULL; @@ -437,11 +436,10 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - for (const GSList *item = SP_ACTIVE_DESKTOP->getSelection()->itemList(); - item != NULL; - item = item->next) + std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { - if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) ++items; } @@ -542,20 +540,20 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const GSList *item_list = desktop->getSelection()->itemList(); + const std::vector<SPItem*> item_list = desktop->getSelection()->itemList(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); - for (; item_list != NULL; item_list = item_list->next) { + for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();i++){ // apply style to the reprs of all text objects in the selection - if (SP_IS_TEXT (item_list->data)) { + if (SP_IS_TEXT (*i)) { // backwards compatibility: - reinterpret_cast<SPObject*>(item_list->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + (*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } - else if (SP_IS_FLOWTEXT (item_list->data)) + else if (SP_IS_FLOWTEXT (*i)) // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext ++items; } |
