summaryrefslogtreecommitdiffstats
path: root/src/ui/clipboard.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <mc@localhost.localdomain>2015-02-17 02:00:37 +0000
committerMarc Jeanmougin <mc@localhost.localdomain>2015-02-17 02:00:37 +0000
commita7f2b2ba3f13ceb60376802f4a31e104153839e8 (patch)
tree6db393e9e5a0a9ab7916a0e7ed29d875efa39ea1 /src/ui/clipboard.cpp
parentdevice-manager: Get rid of GLists (diff)
downloadinkscape-a7f2b2ba3f13ceb60376802f4a31e104153839e8.tar.gz
inkscape-a7f2b2ba3f13ceb60376802f4a31e104153839e8.zip
At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems"
So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1)
Diffstat (limited to 'src/ui/clipboard.cpp')
-rw-r--r--src/ui/clipboard.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 94a1eb2dc..20b43af3b 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -523,8 +523,9 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
// resize each object in the selection
if (separately) {
- for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ SelContainer itemlist=selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ SPItem *item = SP_ITEM(*i);
if (item) {
Geom::OptRect obj_size = item->desktopVisualBounds();
if ( obj_size ) {
@@ -578,8 +579,9 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
desktop->doc()->importDefs(tempdoc);
// make sure all selected items are converted to paths first (i.e. rectangles)
sp_selected_to_lpeitems(desktop);
- for (GSList *itemptr = const_cast<GSList *>(selection->itemList()) ; itemptr ; itemptr = itemptr->next) {
- SPItem *item = reinterpret_cast<SPItem*>(itemptr->data);
+ SelContainer itemlist=selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ SPItem *item = SP_ITEM(*i);
_applyPathEffect(item, effectstack);
}
@@ -659,10 +661,10 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
*/
void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
{
- GSList const *items = selection->itemList();
// copy the defs used by all items
- for (GSList *i = const_cast<GSList *>(items) ; i != NULL ; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ SelContainer itemlist=selection->itemList();
+ for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ SPItem *item = SP_ITEM(*i);
if (item) {
_copyUsedDefs(item);
} else {
@@ -671,11 +673,11 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
}
// copy the representation of the items
- GSList *sorted_items = g_slist_copy(const_cast<GSList *>(items));
- sorted_items = g_slist_sort(sorted_items, (GCompareFunc) sp_object_compare_position);
+ SelContainer sorted_items(itemlist);
+ sorted_items.sort(sp_object_compare_position);
- for (GSList *i = sorted_items ; i ; i = i->next) {
- SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ for(SelContainer::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){
+ SPItem *item = SP_ITEM(*i);
if (item) {
Inkscape::XML::Node *obj = item->getRepr();
Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root);
@@ -695,8 +697,8 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
}
// copy style for Paste Style action
- if (sorted_items) {
- SPObject *object = static_cast<SPObject *>(sorted_items->data);
+ if (!sorted_items.empty()) {
+ SPObject *object = static_cast<SPObject *>(sorted_items.front());
SPItem *item = dynamic_cast<SPItem *>(object);
if (item) {
SPCSSAttr *style = take_style_from_item(item);
@@ -719,7 +721,6 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
sp_repr_set_point(_clipnode, "max", size->max());
}
- g_slist_free(sorted_items);
}
@@ -1156,8 +1157,8 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
sp_repr_get_double(nv, "inkscape:pageopacity", &opacity);
bgcolor |= SP_COLOR_F_TO_U(opacity);
}
-
- sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, NULL);
+ SelContainer x;
+ sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, x);
}
else
{