export.cpp revision b9154536a25c0e0ecea63154ae5081edf68c885c
6643N/A#ifdef HAVE_CONFIG_H
6643N/A#ifdef WITH_GNOME_VFS
6643N/A#include "helper/unit-menu.h"
6643N/A#include "unit-constants.h"
6643N/A#include "inkscape-private.h"
6643N/A#include "document.h"
6643N/A#include "document-undo.h"
6643N/A#include "desktop-handles.h"
6643N/A#include "selection.h"
7077N/A#include "sp-namedview.h"
7077N/A#include "selection-chemistry.h"
7077N/A#include "dialogs/dialog-events.h"
7077N/A#include "preferences.h"
7077N/A#include "interface.h"
6643N/A#include "helper/png-write.h"
6643N/A#include "libgdl/gdl-dock-item.h"
6643N/A#include "message-stack.h"
6643N/A#include "../../desktop-handles.h"
6643N/A#include "../../document.h"
6643N/A#include "../../document-undo.h"
6643N/Aclass MessageCleaner
6643N/A filename_modified(false),
6643N/A singleexport_box(false, 0),
6643N/A batch_export(_("B_atch export all selected objects"), _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)")),
6643N/A hide_export(_("Hide a_ll except selected"), _("In the exported image, hide all objects except those that are selected")),
6643N/A closeWhenDone(_("Close this dialog when complete"), _("Once the export completes, close this dialog")),
6643N/A interrupted(false),
6643N/A sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units);
7077N/A for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
6643N/A selectiontype_buttons[i]->signal_clicked().connect(sigc::mem_fun(*this, &Export::onAreaToggled));
6643N/A x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
6643N/A x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
7077N/A y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
6643N/A y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(),
ydpi_adj = createSpinbutton ( "ydpi", prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
flabel = new Gtk::Label(_("<big><b>_Filename</b></big>"), Gtk::ALIGN_START, Gtk::ALIGN_CENTER, true);
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Export::setTargetDesktop) );
setExporting(false);
if (this->desktop) {
selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged)));
subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged)));
selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &Export::onSelectionModified)));
const gchar *text_extension = get_file_save_extension (Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS).c_str();
oextension = dynamic_cast<Inkscape::Extension::Output *>(Inkscape::Extension::db.get(text_extension));
#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max,
#if WITH_GTKMM_3_0
if (us) {
int pos = 0;
pos++;
#if WITH_GTKMM_3_0
pos++;
pos++;
if (cb) {
return adj;
Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ustring &file_entry_text)
if (docURI) {
return filename;
batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
int i = SELECTION_NUMBER_OF;
for (i = 0; i < SELECTION_NUMBER_OF; i++) {
was_empty) {
if ( selection &&
switch (current_key) {
case SELECTION_DRAWING:
if ( SP_ACTIVE_DESKTOP ) {
if (bbox) {
case SELECTION_SELECTION:
if (bbox)
if (update) {
for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
if ( SP_ACTIVE_DESKTOP )
switch (key) {
case SELECTION_SELECTION:
case SELECTION_DRAWING:
if (bbox) {
case SELECTION_PAGE:
case SELECTION_CUSTOM:
switch (key) {
case SELECTION_PAGE:
case SELECTION_DRAWING: {
case SELECTION_SELECTION:
case SELECTION_CUSTOM:
interrupted = true;
return TRUE;
interrupted = true;
return FALSE;
if (total > 0) {
if (self) {
int evtcount = 0;
return TRUE;
if (exporting) {
return dlg;
if ( !dot )
return filename;
Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, const Glib::ustring &filename)
return path;
if (!desktop) return;
bool exportSuccessful = false;
gint n = 0;
for (GSList *i = const_cast<GSList *>(sp_desktop_selection(desktop)->itemList()); i && !interrupted; i = i->next) {
if (!filename) {
const gchar *dpi_hint = item->getRepr()->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now
if (dpi_hint) {
if (area) {
setExporting(false);
delete prog_dlg;
interrupted = false;
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The chosen area to be exported is invalid."));
|| !Inkscape::IO::file_test(dirname.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) )
safeDir);
prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 (%2 x %3)"), fn, width, height));
exportSuccessful = true;
desktop->messageStack()->flashF(Inkscape::INFORMATION_MESSAGE, _("Drawing exported to <b>%s</b>."), safeFile);
filename_modified = false;
setExporting(false);
delete prog_dlg;
interrupted = false;
switch (current_key) {
case SELECTION_PAGE:
case SELECTION_DRAWING: {
bool modified = false;
modified = true;
modified = true;
modified = true;
if (modified) {
case SELECTION_SELECTION: {
bool modified = false;
if (docURI)
( !docURI ||
modified = true;
modified = true;
modified = true;
if (modified) {
if (item) {
/// @todo refactor this code to use ui/dialogs/filedialog.cpp
NULL );
#ifdef WITH_GNOME_VFS
if (gnome_vfs_initialized()) {
#ifdef WIN32
// code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp
WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL);
// TODO: Move this to nr-rect-fns.h.
static const selection_type test_order[SELECTION_NUMBER_OF] = {SELECTION_SELECTION, SELECTION_DRAWING, SELECTION_PAGE, SELECTION_CUSTOM};
for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
switch (this_test[i]) {
case SELECTION_SELECTION:
case SELECTION_DRAWING: {
case SELECTION_PAGE: {
#if WITH_GTKMM_3_0
if (update) {
update = true;
detectSize();
update = false;
#if WITH_GTKMM_3_0
if (update) {
update = true;
detectSize();
update = false;
if (update) {
update = true;
update = false;
if (update) {
update = true;
update = false;
if (update) {
update = true;
setImageY ();
update = false;
if (update) {
update = true;
setImageX ();
update = false;
if (update) {
update = true;
setImageY ();
update = false;
update = true;
update = false;
#if WITH_GTKMM_3_0
if (adj) {
#if WITH_GTKMM_3_0
#if WITH_GTKMM_3_0
if (!adj) {
#if WITH_GTKMM_3_0
filename_modified = false;
filename_modified = true;