main.cpp revision aa9235c966804d9b8f8daa083a2d123d9d47d2bb
1549N/A#ifdef HAVE_CONFIG_H
1549N/A#include "ui/widget/panel.h" // This has to be the first to include <glib.h> because of Glibmm's dependence on a deprecated feature...
1549N/A#include "path-prefix.h"
1549N/A#ifdef HAVE_IEEEFP_H
1549N/A#ifndef POPT_TABLEEND
1549N/A#include <glib-object.h>
#include "macros.h"
#include "file.h"
#include "document.h"
#include "layer-model.h"
#include "selection.h"
#include "sp-object.h"
#include "ui/interface.h"
#include "print.h"
#include "color.h"
#include "sp-item.h"
#include "sp-root.h"
#include "svg/svg-color.h"
#include "svg/stringstream.h"
#include "inkscape.h"
#include "inkscape-version.h"
#include "sp-namedview.h"
#include "sp-guide.h"
#include "debug/log-display-config.h"
#include "helper/action-context.h"
#include "helper/png-write.h"
#ifdef WIN32
#include <windows.h>
#include "registrytool.h"
#ifdef WITH_DBUS
#include "extension/dbus/dbus-init.h"
#ifndef HAVE_BIND_TEXTDOMAIN_CODESET
#define bind_textdomain_codeset(p,c)
#include "main-cmdlineact.h"
#include <errno.h>
#include "verbs.h"
#include "path-chemistry.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
#ifdef WITH_DBUS
static void do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id);
#ifdef WITH_DBUS
static void resetCommandlineGlobals() {
#ifdef WITH_DBUS
#ifdef WIN32
NULL},
NULL},
NULL},
N_("Resolution for exporting to bitmap and for rasterization of filters in PS/EPS/PDF (default 96)"),
NULL},
NULL},
NULL},
NULL},
NULL},
N_("Export PDF to given version. (hint: make sure to input the exact string found in the PDF export dialog, e.g. \"PDF 1.4\" which is PDF-a conformant)"),
N_("Export PDF/PS/EPS without text. Besides the PDF/PS/EPS, a LaTeX file is exported, putting the text on top of the PDF/PS/EPS file. Include the result in LaTeX like: \\input{latexfile.tex}"),
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
NULL},
#ifdef WITH_DBUS
NULL},
NULL},
NULL},
static bool needToRecodeParams = true;
#ifdef WIN32
if (path) {
if (pythonpath) {
static void set_extensions_env()
#ifdef WIN32
if (pythonpath) {
#ifdef HAVE_FPSETMASK
#ifdef WIN32
# ifdef ENABLE_NLS
if (!val) {
# ifdef ENABLE_BINRELOC
#ifdef ENABLE_NLS
// Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example)
#ifdef WITH_DBUS
#ifdef WIN32
int retcode;
if (use_gui) {
return retcode;
if ( newFileName )
if ( spare ) {
while ( fl ) {
if ( newFileName ) {
gtk_widget_destroy (w);
newFileName = 0;
GtkWidget *w = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Error: Unable to convert '%s'", safeFn );
gtk_widget_destroy (w);
return newFl;
if ( needToRecodeParams )
if ( needToRecodeParams )
if ( sp_export_png )
if ( sp_export_svg )
if ( sp_global_printer )
#ifdef WITH_DBUS
if ( flDest ) {
fl = 0;
while ( fl ) {
namespace Inkscape {
namespace UI {
namespace Tools {
if (INKSCAPE.mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_KEY_PRESS:
// GDK_MOD1_MASK is in the event->key.state as appropriate.
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_KEY_PRESS:
if (alt_pressed)
case GDK_KEY_RELEASE:
static std::vector<Glib::ustring> getDirectorySet(const gchar* userDir, const gchar* const * systemDirs) {
return listing;
while (fl) {
if (create_new) {
#ifdef WIN32
int retVal = 0;
#ifdef WITH_DBUS
if (!fl) {
if (sp_dbus_listen) {
while (fl) {
g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename);
retVal++;
if (sp_vacuum_defs) {
#ifdef WITH_DBUS
if (sp_dbus_listen) {
Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.inkscape"), doc, filename, false,
if (sp_global_printer) {
if (sp_export_svg) {
if (sp_export_text_to_path) {
if(sp_export_id) {
if (bbox) {
if (sp_export_id_only) {
Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.plain"), doc, sp_export_svg, false,
if (sp_export_ps) {
if (sp_export_eps) {
if (sp_export_pdf) {
if (sp_export_emf) {
if (sp_export_wmf) {
if (sp_query_all) {
delete doc;
return retVal;
int retval = 0;
fprintf(stdout, "Inkscape %s interactive shell mode. Type 'quit' to quit.\n", Inkscape::version_string);
char* linedata = 0;
retval = 0;
if ( ctx ) {
return retval;
* FontInstance.cpp and FontFactory.cpp.
g_type_init();
#ifdef WITH_DBUS
&& !sp_dbus_listen
exit(0);
if (sp_shell) {
if (retVal){
if (id) {
if (!SP_IS_ITEM (o)) {
if (area) {
if (extent) {
if (area) {
while (child) {
bool filename_from_hint = false;
g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored.");
} else if (sp_export_id) {
o_area = o;
} else if (sp_export_area_drawing) {
o_area = o;
if (!SP_IS_ITEM (o)) {
if (sp_export_id_only) {
if (sp_export_use_hints) {
if (fn_hint) {
if (sp_export_png) {
g_warning ("Using export filename from the command line (--export-png). Filename hint %s is ignored.", fn_hint);
filename_from_hint = true;
const gchar *dpi_hint = o->getRepr()->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now
if (dpi_hint) {
g_warning ("Using bitmap dimensions from the command line (--export-dpi, --export-width, or --export-height). DPI hint %s is ignored.", dpi_hint);
if (areaMaybe) {
if (sp_export_area) {
if (sp_export_area_snap) {
unsigned long int width = 0;
unsigned long int height = 0;
if (sp_export_width) {
errno=0;
g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX);
if (sp_export_height) {
errno=0;
g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX);
if (!sp_export_width) {
width = (unsigned long int) (Inkscape::Util::Quantity::convert(area.width(), "px", "in") * dpi + 0.5);
if (!sp_export_height) {
height = (unsigned long int) (Inkscape::Util::Quantity::convert(area.height(), "px", "in") * dpi + 0.5);
if (sp_export_background) {
if (sp_export_background_opacity) {
if (filename_from_hint) {
int retcode = 0;
g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi);
g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX);
return retcode;
if (i == o.end())
if (sp_export_id) {
if (o == NULL) {
g_warning ("You cannot use --export-area-page and --export-area-drawing at the same time; only the former will take effect.");
sp_export_area_drawing = false;
if (sp_export_area_drawing) {
if (sp_export_area_page) {
if (sp_export_eps) {
g_warning ("EPS cannot have its bounding box extend beyond its content, so if your drawing is smaller than the page, --export-area-page will clip it to drawing.");
if (sp_export_eps) {
if (sp_export_text_to_path) {
} else if (sp_export_latex) {
if (sp_export_ignore_filters) {
if (sp_export_dpi) {
float margin = 0.;
if (sp_export_margin) {
bool set_export_pdf_version_fail=true;
if(sp_export_pdf_version) {
set_export_pdf_version_fail=false;
g_warning("Desired PDF export version \"%s\" not supported! Hint: input one of the versions found in the pdf export dialog e.g. \"1.4\".",
if (i == o.end())
uri);
#ifdef WIN32
bool worked = false;
#ifdef REPLACEARGS_DEBUG
MessageBoxA( NULL, "GetCommandLineW() getting called", "GetCommandLineW", MB_OK | MB_ICONINFORMATION );
if ( line )
#ifdef REPLACEARGS_DEBUG
if ( utf8Line )
int numArgs = 0;
#ifdef REPLACEARGS_ANSI
if ( !parsed )
#ifdef REPLACEARGS_DEBUG
MessageBoxA( NULL, "Unable to process command-line. Faking it", "CommandLineToArgvW", MB_OK | MB_ICONINFORMATION );
int pos = 0;
bool inQuotes = false;
bool inWhitespace = true;
if ( inQuotes )
inQuotes = false;
inQuotes = true;
inWhitespace = false;
if ( !inWhitespace )
inWhitespace = true;
inWhitespace = false;
pos++;
#ifdef REPLACEARGS_DEBUG
if ( parsed )
if ( numArgs > 0 )
if ( wildcarded )
#ifdef REPLACEARGS_ANSI
if ( last )
base[0] = 0;
#ifdef REPLACEARGS_ANSI
#ifdef REPLACEARGS_ANSI
if ( howMany > 0 )
} while ( found );
#ifdef REPLACEARGS_ANSI
delete[] base;
int iz = 0;
for ( int i = 0; i < numArgs; i++ )
if ( replacement )
#ifdef REPLACEARGS_DEBUG
if ( safe2 )
int iz = 0;
worked = true;
#ifdef REPLACEARGS_DEBUG
MessageBoxA( NULL, "Unable to process command-line", "CommandLineToArgvW", MB_OK | MB_ICONINFORMATION );
#ifdef REPLACEARGS_DEBUG
MessageBoxA( NULL, "Unable to fetch result from GetCommandLineW()", "GetCommandLineW", MB_OK | MB_ICONINFORMATION );
if ( line2 )
MessageBoxA( NULL, "Unable to fetch result from GetCommandLineA()", "GetCommandLineA", MB_OK | MB_ICONINFORMATION );
return worked;
static GSList *
gint a;
case SP_ARG_FILE: {
case SP_ARG_VERSION: {
exit(0);
case SP_ARG_EXTENSIONDIR: {
exit(0);
case SP_ARG_VERB_LIST: {
exit(0);
case SP_ARG_VERB:
case SP_ARG_SELECT: {
case POPT_ERROR_BADOPT: {
return fl;