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/export.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/export.cpp')
| -rw-r--r-- | src/ui/dialog/export.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 9ac5c24fe..384aec415 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -601,7 +601,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = g_slist_length((GSList *) SP_ACTIVE_DESKTOP->getSelection()->itemList()); + gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size(); if (num >= 2) { batch_export.set_sensitive(true); batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -813,9 +813,9 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const GSList * reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; + const std::vector<XML::Node*> reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + for(std::vector<XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1006,7 +1006,7 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = g_slist_length(const_cast<GSList *>(desktop->getSelection()->itemList())); + gint num = (desktop->getSelection()->itemList()).size(); gint n = 0; if (num < 1) { @@ -1020,8 +1020,9 @@ void Export::onExport () gint export_count = 0; - for (GSList *i = const_cast<GSList *>(desktop->getSelection()->itemList()); i && !interrupted; i = i->next) { - SPItem *item = reinterpret_cast<SPItem *>(i->data); + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ + SPItem *item = *i; prog_dlg->set_data("current", GINT_TO_POINTER(n)); prog_dlg->set_data("total", GINT_TO_POINTER(num)); @@ -1059,13 +1060,13 @@ void Export::onExport () _("Exporting file <b>%s</b>..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file <b>%s</b>..."), safeFile), desktop); - + std::vector<SPItem*> x; if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? const_cast<GSList *>(desktop->getSelection()->itemList()) : NULL + hide ? (desktop->getSelection()->itemList()) : x )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1149,12 +1150,13 @@ void Export::onExport () prog_dlg->set_data("total", GINT_TO_POINTER(0)); /* Do export */ + std::vector<SPItem*> x; ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? const_cast<GSList *>(desktop->getSelection()->itemList()) : NULL + hide ? (desktop->getSelection()->itemList()) : x ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); @@ -1220,7 +1222,7 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - const GSList * reprlst; + std::vector<XML::Node*> reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; @@ -1228,8 +1230,8 @@ void Export::onExport () DocumentUndo::setUndoSensitive(doc, false); reprlst = desktop->getSelection()->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data); + for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = *i; const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); |
