From 6f4ab22c8a752dbd7d73765fb8429f0845dc6d38 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 12 May 2012 12:24:00 +0200 Subject: Fix for externally reported patch by Juergen Weigert, Bug #993500 (inkscape should return non-0 on 'errors') (bzr r11357) --- src/main.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 261df9145..15efd22d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -994,8 +994,9 @@ sp_main_gui(int argc, char const **argv) /** * Process file list */ -void sp_process_file_list(GSList *fl) +int sp_process_file_list(GSList *fl) { + int retVal = 0; while (fl) { const gchar *filename = (gchar *)fl->data; @@ -1019,6 +1020,7 @@ void sp_process_file_list(GSList *fl) } if (doc == NULL) { g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename); + retVal++; } else { if (sp_vacuum_defs) { doc->vacuumDocument(); @@ -1068,6 +1070,7 @@ void sp_process_file_list(GSList *fl) } fl = g_slist_remove(fl, fl->data); } + return retVal; } /** @@ -1123,7 +1126,9 @@ int sp_main_shell(char const* command_name) poptSetOtherOptionHelp(ctx, _("[OPTIONS...] [FILE...]\n\nAvailable options:")); if ( ctx ) { GSList *fl = sp_process_args(ctx); - sp_process_file_list(fl); + if (sp_process_file_list(fl)) { + retval = -1; + } poptFreeContext(ctx); } else { retval = 1; // not sure why. But this was the previous return value @@ -1132,6 +1137,7 @@ int sp_main_shell(char const* command_name) g_strfreev(argv); } else { g_warning("Cannot parse commandline: %s", useme); + retval = -1; } } } @@ -1168,10 +1174,13 @@ int sp_main_console(int argc, char const **argv) inkscape_application_init(argv[0], false); if (sp_shell) { - sp_main_shell(argv[0]); // Run as interactive shell - exit(0); + int retVal = sp_main_shell(argv[0]); // Run as interactive shell + exit((retVal < 0) ? 1 : 0); } else { - sp_process_file_list(fl); // Normal command line invokation + int retVal = sp_process_file_list(fl); // Normal command line invokation + if (retVal){ + exit(1); + } } return 0; -- cgit v1.2.3 From 6ee7c590a4e30b3fa5767bbabde8fa31e9f14927 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 26 May 2012 09:14:56 +0900 Subject: Fix for 903772 : Support --export-text-to-path when outputting plain SVG (bzr r11418) --- src/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 15efd22d9..ee18c8822 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,6 +121,11 @@ #include "compat-key-syms.h" #endif +#include "path-chemistry.h" +#include "sp-text.h" +#include "sp-flowtext.h" +#include "text-editing.h" + enum { SP_ARG_NONE, SP_ARG_NOGUI, @@ -1036,6 +1041,29 @@ int sp_process_file_list(GSList *fl) sp_do_export_png(doc); } if (sp_export_svg) { + if (sp_export_text_to_path) { + GSList *items = NULL; + SPRoot *root = doc->getRoot(); + for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { + SPItem* item = (SPItem*) iter; + if (! (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item) || SP_IS_GROUP(item))) { + continue; + } + + te_update_layout_now_recursive(item); + items = g_slist_append(items, item); + } + + GSList *selected = NULL; + GSList *to_select = NULL; + + sp_item_list_to_curves(items, &selected, &to_select); + + g_slist_free (items); + g_slist_free (selected); + g_slist_free (to_select); + } + Inkscape::XML::Document *rdoc; Inkscape::XML::Node *repr; rdoc = sp_repr_document_new("svg:svg"); -- cgit v1.2.3 From 9abd33133650d77714fccf09d0c9ff27c9b75a78 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 5 Jul 2012 22:39:08 +0100 Subject: Drop GTK+ 2.20 support. Fixed bugs: - https://launchpad.net/bugs/1020494 (bzr r11529) --- src/main.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index ee18c8822..74083e776 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -117,10 +117,6 @@ #include -#if !GTK_CHECK_VERSION(2,22,0) -#include "compat-key-syms.h" -#endif - #include "path-chemistry.h" #include "sp-text.h" #include "sp-flowtext.h" -- cgit v1.2.3 From 93463310815d358c470898aba487ac8392aec027 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 16 Jul 2012 21:29:46 +0200 Subject: Fix for Bug #425202 (Script messages not translated). (bzr r11551) --- src/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 74083e776..e3862589d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -474,7 +474,8 @@ gchar * blankParam = g_strdup(""); #ifdef WIN32 /** - * Set up the PATH and PYTHONPATH environment variables on Windows + * Set up the PATH, INKSCAPE_LOCALEDIR and PYTHONPATH environment + * variables on Windows * @param exe Inkscape executable directory in UTF-8 */ static void _win32_set_inkscape_env(gchar const *exe) @@ -525,7 +526,11 @@ static void _win32_set_inkscape_env(gchar const *exe) } else { printf("python not found\n\n"); }*/ - + + // INKSCAPE_LOCALEDIR is needed by Python/Gettext + gchar *localepath = g_build_filename(exe, PACKAGE_LOCALE_DIR, NULL); + g_setenv("INKSCAPE_LOCALEDIR", localepath, TRUE); + g_free(python); g_free(scripts); g_free(perl); @@ -538,6 +543,8 @@ static void _win32_set_inkscape_env(gchar const *exe) g_free(new_path); g_free(new_pythonpath); + + g_free(localepath); } #endif -- cgit v1.2.3 From 6a101c3761dedff3281cf9a24f77fe1ce8ecb2d3 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 1 Oct 2012 16:03:27 +0900 Subject: Fix for 1059132 : --export-pdf crashes with inkscape trunk (bzr r11718) --- src/main.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index e3862589d..48d2e4de3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1557,25 +1557,21 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime } if (sp_export_area_drawing) { - (*i)->set_param_bool ("areaDrawing", TRUE); - } else { - (*i)->set_param_bool ("areaDrawing", FALSE); + (*i)->set_param_optiongroup ("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."); } - (*i)->set_param_bool ("areaPage", TRUE); - } else { - (*i)->set_param_bool ("areaPage", FALSE); + (*i)->set_param_optiongroup ("area", "page"); } if (!sp_export_area_drawing && !sp_export_area_page && !sp_export_id) { // neither is set, set page as default for ps/pdf and drawing for eps if (sp_export_eps) { try { - (*i)->set_param_bool("areaDrawing", TRUE); + (*i)->set_param_optiongroup("area", "drawing"); } catch (...) {} } } -- cgit v1.2.3 From 370a3f5cc9e39352a081e5d5dd8c43676547a6e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:45:44 +1000 Subject: code cleanup: add own includes to cpp files or make the functions static if they are not used elsewhere. (bzr r11735) --- src/main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 48d2e4de3..d1e087cac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -731,7 +731,7 @@ main(int argc, char **argv) -void fixupSingleFilename( gchar **orig, gchar **spare ) +static void fixupSingleFilename( gchar **orig, gchar **spare ) { if ( orig && *orig && **orig ) { GError *error = NULL; @@ -749,7 +749,7 @@ void fixupSingleFilename( gchar **orig, gchar **spare ) -GSList *fixupFilenameEncoding( GSList* fl ) +static GSList *fixupFilenameEncoding( GSList* fl ) { GSList *newFl = NULL; while ( fl ) { @@ -788,7 +788,7 @@ GSList *fixupFilenameEncoding( GSList* fl ) return newFl; } -int sp_common_main( int argc, char const **argv, GSList **flDest ) +static int sp_common_main( int argc, char const **argv, GSList **flDest ) { /// \todo fixme: Move these to some centralized location (Lauris) sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW); @@ -1002,7 +1002,7 @@ sp_main_gui(int argc, char const **argv) /** * Process file list */ -int sp_process_file_list(GSList *fl) +static int sp_process_file_list(GSList *fl) { int retVal = 0; while (fl) { @@ -1108,7 +1108,7 @@ int sp_process_file_list(GSList *fl) * Run the application as an interactive shell, parsing command lines from stdin * Returns -1 on error. */ -int sp_main_shell(char const* command_name) +static int sp_main_shell(char const* command_name) { int retval = 0; -- cgit v1.2.3 From c37bac565d73ab069263873307286eb19641b99c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 7 Oct 2012 19:41:26 +0200 Subject: Translations. Fix for Bug #425202 (Script messages not translated). (bzr r11749) --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index d1e087cac..578279929 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -625,6 +625,8 @@ main(int argc, char **argv) bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR("")); # else bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); + // needed by Python/Gettext + g_setenv("PACKAGE_LOCALE_DIR", PACKAGE_LOCALE_DIR, TRUE); # endif #endif -- cgit v1.2.3 From 66aa9095eba57e263fff225583c7cbfff121a09d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 9 Oct 2012 13:36:06 +0200 Subject: Fix for Bug #1063831 (--export-text-to-path with SVG is undocumented) by Philipp Hagemeister. Greek and French man page translations updated. (bzr r11769) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 578279929..844aded56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -390,7 +390,7 @@ struct poptOption options[] = { {"export-text-to-path", 'T', POPT_ARG_NONE, &sp_export_text_to_path, SP_ARG_EXPORT_TEXT_TO_PATH, - N_("Convert text object to paths on export (PS, EPS, PDF)"), + N_("Convert text object to paths on export (PS, EPS, PDF, SVG)"), NULL}, {"export-ignore-filters", 0, -- cgit v1.2.3 From 32598fdd4d1e85228e46242d37f83c739591a078 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 29 Nov 2012 09:37:30 +0900 Subject: Fix for 1073128 : Command line PNG export fails if FeFlood filter primitive is present (bzr r11913) --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 844aded56..be8049cf5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1032,6 +1032,9 @@ static int sp_process_file_list(GSList *fl) g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename); retVal++; } else { + + inkscape_add_document(doc); + if (sp_vacuum_defs) { doc->vacuumDocument(); } @@ -1099,6 +1102,8 @@ static int sp_process_file_list(GSList *fl) do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id); } + inkscape_remove_document(doc); + delete doc; } fl = g_slist_remove(fl, fl->data); -- cgit v1.2.3 From 91276e1763b33970684e93ef6a20cd2134a5be57 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 30 Nov 2012 11:05:35 +0900 Subject: Fix for 430301 : core dump exporting to non existing folder (bzr r11915) --- src/main.cpp | 82 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 29 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index be8049cf5..20330edbb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -169,10 +169,10 @@ enum { int sp_main_gui(int argc, char const **argv); int sp_main_console(int argc, char const **argv); -static void sp_do_export_png(SPDocument *doc); -static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime); +static int sp_do_export_png(SPDocument *doc); +static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime); #ifdef WIN32 -static void do_export_emf(SPDocument* doc, gchar const* uri, char const *mime); +static int do_export_emf(SPDocument* doc, gchar const* uri, char const *mime); #endif //WIN32 static void do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id); static void do_query_all (SPDocument *doc); @@ -1046,7 +1046,7 @@ static int sp_process_file_list(GSList *fl) sp_print_document_to_file(doc, sp_global_printer); } if (sp_export_png || (sp_export_id && sp_export_use_hints)) { - sp_do_export_png(doc); + retVal |= sp_do_export_png(doc); } if (sp_export_svg) { if (sp_export_text_to_path) { @@ -1081,17 +1081,17 @@ static int sp_process_file_list(GSList *fl) doc->getBase(), sp_export_svg); } if (sp_export_ps) { - do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript"); + retVal |= do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript"); } if (sp_export_eps) { - do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript"); + retVal |= do_export_ps_pdf(doc, sp_export_eps, "image/x-e-postscript"); } if (sp_export_pdf) { - do_export_ps_pdf(doc, sp_export_pdf, "application/pdf"); + retVal |= do_export_ps_pdf(doc, sp_export_pdf, "application/pdf"); } #ifdef WIN32 if (sp_export_emf) { - do_export_emf(doc, sp_export_emf, "image/x-emf"); + retVal |= do_export_emf(doc, sp_export_emf, "image/x-emf"); } #endif //WIN32 if (sp_query_all) { @@ -1299,7 +1299,7 @@ do_query_all_recurse (SPObject *o) } -static void sp_do_export_png(SPDocument *doc) +static int sp_do_export_png(SPDocument *doc) { Glib::ustring filename; bool filename_from_hint = false; @@ -1330,7 +1330,7 @@ static void sp_do_export_png(SPDocument *doc) if (o) { if (!SP_IS_ITEM (o)) { g_warning("Object with id=\"%s\" is not a visible item. Nothing exported.", sp_export_id); - return; + return 1; } items = g_slist_prepend (items, SP_ITEM(o)); @@ -1377,11 +1377,11 @@ static void sp_do_export_png(SPDocument *doc) area = *areaMaybe; } else { g_warning("Unable to determine a valid bounding box. Nothing exported."); - return; + return 1; } } else { g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id); - return; + return 1; } } @@ -1390,7 +1390,7 @@ static void sp_do_export_png(SPDocument *doc) gdouble x0,y0,x1,y1; if (sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &x0, &y0, &x1, &y1) != 4) { g_warning("Cannot parse export area '%s'; use 'x0:y0:x1:y1'. Nothing exported.", sp_export_area); - return; + return 1; } area = Geom::Rect(Geom::Interval(x0,x1), Geom::Interval(y0,y1)); } else if (sp_export_area_page || !(sp_export_id || sp_export_area_drawing)) { @@ -1404,7 +1404,7 @@ static void sp_do_export_png(SPDocument *doc) if (filename.empty()) { if (!sp_export_png) { g_warning ("No export filename given and no filename hint. Nothing exported."); - return; + return 1; } filename = sp_export_png; } @@ -1413,7 +1413,7 @@ static void sp_do_export_png(SPDocument *doc) dpi = atof(sp_export_dpi); if ((dpi < 0.1) || (dpi > 10000.0)) { g_warning("DPI value %s out of range [0.1 - 10000.0]. Nothing exported.", sp_export_dpi); - return; + return 1; } g_print("DPI: %g\n", dpi); } @@ -1435,7 +1435,7 @@ static void sp_do_export_png(SPDocument *doc) width = strtoul(sp_export_width, NULL, 0); if ((width < 1) || (width > PNG_UINT_31_MAX) || (errno == ERANGE) ) { g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX); - return; + return 1; } dpi = (gdouble) width * PX_PER_IN / area.width(); } @@ -1445,7 +1445,7 @@ static void sp_do_export_png(SPDocument *doc) height = strtoul(sp_export_height, NULL, 0); if ((height < 1) || (height > PNG_UINT_31_MAX)) { g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX); - return; + return 1; } dpi = (gdouble) height * PX_PER_IN / area.height(); } @@ -1508,19 +1508,28 @@ static void sp_do_export_png(SPDocument *doc) path = filename; } - g_print("Background RRGGBBAA: %08x\n", bgcolor); + int retcode = 0; + //check if specified directory exists - 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); + if (!Inkscape::IO::file_directory_exists(filename.c_str())) { + g_warning("File path \"%s\" includes directory that doesn't exist.\n", filename.c_str()); + retcode = 1; + } else { + g_print("Background RRGGBBAA: %08x\n", bgcolor); - g_print("Bitmap saved as: %s\n", filename.c_str()); + 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); - if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { - sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); - } else { - g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); + g_print("Bitmap saved as: %s\n", filename.c_str()); + + if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { + sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); + } else { + g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); + } } g_slist_free (items); + return retcode; } @@ -1532,7 +1541,7 @@ static void sp_do_export_png(SPDocument *doc) * \param mime MIME type to export as. */ -static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) +static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) { Inkscape::Extension::DB::OutputList o; Inkscape::Extension::db.get_output_list(o); @@ -1544,14 +1553,14 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime if (i == o.end()) { g_warning ("Could not find an extension to export to MIME type %s.", mime); - return; + return 1; } if (sp_export_id) { SPObject *o = doc->getObjectById(sp_export_id); if (o == NULL) { g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id); - return; + return 1; } (*i)->set_param_string ("exportId", sp_export_id); } else { @@ -1612,7 +1621,14 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime (*i)->set_param_int("resolution", (int) dpi); } + //check if specified directory exists + if (!Inkscape::IO::file_directory_exists(uri)) { + g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); + return 1; + } + (*i)->save(doc, uri); + return 0; } #ifdef WIN32 @@ -1624,7 +1640,7 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime * \param mime MIME type to export as (should be "image/x-emf") */ -static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) +static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) { Inkscape::Extension::DB::OutputList o; Inkscape::Extension::db.get_output_list(o); @@ -1636,10 +1652,18 @@ static void do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) if (i == o.end()) { g_warning ("Could not find an extension to export to MIME type %s.", mime); - return; + return 1; + } + + //check if specified directory exists + if (!Inkscape::IO::file_directory_exists(uri)){ + g_warning("File path \"%s\" includes directory that doesn't exist.\n", + uri); + return 1; } (*i)->save(doc, uri); + return 0; } #endif //WIN32 -- cgit v1.2.3 From d2bba282171a9e2c70a624794650689ec4531047 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 26 Mar 2013 16:03:49 +0000 Subject: Fix Glibmm inclusions for Gtk+ 3 builds and implement a Gtk+ 3 compatible check for X11 backend Fixed bugs: - https://launchpad.net/bugs/1160252 - https://launchpad.net/bugs/1122774 (bzr r12247) --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 20330edbb..58ab19616 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,7 +47,6 @@ #endif /* Not def: POPT_TABLEEND */ #include -#include #include #include #include @@ -103,6 +102,9 @@ #include "extension/init.h" #include +#include +#include + #include #ifndef HAVE_BIND_TEXTDOMAIN_CODESET -- cgit v1.2.3 From 8443720ce6429b9beec839e60b8a808595f4ba72 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 2 Apr 2013 23:01:45 +0200 Subject: Cleaned up a bit. Uses some C++11 features. (bzr r11608.1.72) --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 58ab19616..83f82fa84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -795,8 +795,8 @@ static GSList *fixupFilenameEncoding( GSList* fl ) static int sp_common_main( int argc, char const **argv, GSList **flDest ) { /// \todo fixme: Move these to some centralized location (Lauris) - sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW); - sp_object_type_register("sodipodi:guide", SP_TYPE_GUIDE); + //sp_object_type_register("sodipodi:namedview", SP_TYPE_NAMEDVIEW); + //sp_object_type_register("sodipodi:guide", SP_TYPE_GUIDE); // temporarily switch gettext encoding to locale, so that help messages can be output properly -- cgit v1.2.3 From 08e8570373c4764f8a8f4146eb2d2dc43c02cb06 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 6 Apr 2013 16:17:29 +0200 Subject: add --export-margin option to PDF/EPS/PS export cmdline (bzr r12268) --- src/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 58ab19616..5bb42d405 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -135,6 +135,7 @@ enum { SP_ARG_EXPORT_AREA, SP_ARG_EXPORT_AREA_DRAWING, SP_ARG_EXPORT_AREA_PAGE, + SP_ARG_EXPORT_MARGIN, SP_ARG_EXPORT_AREA_SNAP, SP_ARG_EXPORT_WIDTH, SP_ARG_EXPORT_HEIGHT, @@ -186,6 +187,7 @@ static gchar *sp_export_dpi = NULL; static gchar *sp_export_area = NULL; static gboolean sp_export_area_drawing = FALSE; static gboolean sp_export_area_page = FALSE; +static gchar *sp_export_margin = NULL; static gboolean sp_export_latex = FALSE; static gchar *sp_export_width = NULL; static gchar *sp_export_height = NULL; @@ -229,6 +231,7 @@ static void resetCommandlineGlobals() { sp_export_area = NULL; sp_export_area_drawing = FALSE; sp_export_area_page = FALSE; + sp_export_margin = NULL; sp_export_latex = FALSE; sp_export_width = NULL; sp_export_height = NULL; @@ -316,6 +319,11 @@ struct poptOption options[] = { N_("Exported area is the entire page"), NULL}, + {"export-margin", 0, + POPT_ARG_STRING, &sp_export_margin, SP_ARG_EXPORT_MARGIN, + N_("Only for PS/EPS/PDF, sets margin in mm around exported area (default 0)"), + N_("VALUE")}, + {"export-area-snap", 0, POPT_ARG_NONE, &sp_export_area_snap, SP_ARG_EXPORT_AREA_SNAP, N_("Snap the bitmap export area outwards to the nearest integer values (in SVG user units)"), @@ -1623,6 +1631,13 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) (*i)->set_param_int("resolution", (int) dpi); } + // if no bleed/margin is given, set to 0 (otherwise it takes the value last used from the UI) + float margin = 0.; + if (sp_export_margin) { + margin = g_ascii_strtod(sp_export_margin, NULL); + } + (*i)->set_param_float("bleed", margin); + //check if specified directory exists if (!Inkscape::IO::file_directory_exists(uri)) { g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); -- cgit v1.2.3 From 8de8047c5e30af8598646d7a66c62dbf290f7c51 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 10 Apr 2013 16:10:04 +0200 Subject: Removed old SPObject factory. (bzr r11608.1.91) --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 83f82fa84..cb8d12a0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,7 +77,6 @@ #include "sp-namedview.h" #include "sp-guide.h" -#include "sp-object-repr.h" #include "xml/repr.h" #include "io/sys.h" -- cgit v1.2.3 From 4cec6d0c7d401ed0616e91a923a7ec4caf806f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Wed, 5 Jun 2013 16:03:06 -0300 Subject: Add command line option to specify PDF export version. Patch from schwieni. From the patch's author: Additional command line option added to export to different PDF-versions supported by cairo (currently only "PDF 1.4" and "PDF 1.5"). The user must provide the exact string found in the PDF-export dialog of Inkscape. This feature was previously only accessible via the GUI of Inkscape. This option is useful for people opting for PDF-a conformance in their PDFs. Moreover, the Extension and Parameter classes are extended by setters for enum parameters (used in combo boxes). (bzr r12348) --- src/main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 5bb42d405..d9e731912 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -148,6 +148,7 @@ enum { SP_ARG_EXPORT_PS, SP_ARG_EXPORT_EPS, SP_ARG_EXPORT_PDF, + SP_ARG_EXPORT_PDF_VERSION, SP_ARG_EXPORT_LATEX, #ifdef WIN32 SP_ARG_EXPORT_EMF, @@ -201,6 +202,7 @@ static gchar *sp_export_svg = NULL; static gchar *sp_export_ps = NULL; static gchar *sp_export_eps = NULL; static gchar *sp_export_pdf = NULL; +static gchar *sp_export_pdf_version = NULL; #ifdef WIN32 static gchar *sp_export_emf = NULL; #endif //WIN32 @@ -245,6 +247,7 @@ static void resetCommandlineGlobals() { sp_export_ps = NULL; sp_export_eps = NULL; sp_export_pdf = NULL; + sp_export_pdf_version = NULL; #ifdef WIN32 sp_export_emf = NULL; #endif //WIN32 @@ -386,6 +389,12 @@ struct poptOption options[] = { N_("Export document to a PDF file"), N_("FILENAME")}, + {"export-pdf-version", 0, + POPT_ARG_STRING, &sp_export_pdf_version, SP_ARG_EXPORT_PDF_VERSION, + // TRANSLATORS: "--export-pdf-version" is an Inkscape command line option; see "inkscape --help" + 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_("PDF_VERSION")}, + {"export-latex", 0, POPT_ARG_NONE, &sp_export_latex, SP_ARG_EXPORT_LATEX, 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}"), @@ -1638,6 +1647,33 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) } (*i)->set_param_float("bleed", margin); + // handle --export-pdf-version + bool set_export_pdf_version_fail=true; + const gchar *pdfver_param_name="PDFversion"; + if(sp_export_pdf_version) { + // combine "PDF " and the given command line + std::string version_gui_string=std::string("PDF ")+sp_export_pdf_version; + try{ + // first, check if the given pdf version is selectable in the ComboBox + if((*i)->get_param_enum_contains("PDFversion", version_gui_string.c_str())) { + (*i)->set_param_enum(pdfver_param_name, version_gui_string.c_str()); + set_export_pdf_version_fail=false; + } else { + 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\".", + sp_export_pdf_version); + } + } catch (...) { + // can be thrown along the way: + // throw Extension::param_not_exist(); + // throw Extension::param_not_enum_param(); + g_warning("Parameter or Enum \"%s\" might not exist",pdfver_param_name); + } + } + // set default pdf export version to 1.4, also if something went wrong + if(set_export_pdf_version_fail) { + (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); + } + //check if specified directory exists if (!Inkscape::IO::file_directory_exists(uri)) { g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); -- cgit v1.2.3 From 1e90e0e6556d48e6e100cf6d5d9752b06c0f5bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Wed, 5 Jun 2013 18:01:35 -0300 Subject: Add option to set --export-ps-level. Fixes bug #669748. Moreover, a bug in --export-pdf-version was fixed. The bug made Inkscape crash if someone try to export a ps file. (bzr r12350) --- src/main.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index d9e731912..e77c748b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -147,6 +147,7 @@ enum { SP_ARG_EXPORT_SVG, SP_ARG_EXPORT_PS, SP_ARG_EXPORT_EPS, + SP_ARG_EXPORT_PS_LEVEL, SP_ARG_EXPORT_PDF, SP_ARG_EXPORT_PDF_VERSION, SP_ARG_EXPORT_LATEX, @@ -201,6 +202,7 @@ static gboolean sp_export_id_only = FALSE; static gchar *sp_export_svg = NULL; static gchar *sp_export_ps = NULL; static gchar *sp_export_eps = NULL; +static gint sp_export_ps_level = 2; static gchar *sp_export_pdf = NULL; static gchar *sp_export_pdf_version = NULL; #ifdef WIN32 @@ -246,6 +248,7 @@ static void resetCommandlineGlobals() { sp_export_svg = NULL; sp_export_ps = NULL; sp_export_eps = NULL; + sp_export_ps_level = 2; sp_export_pdf = NULL; sp_export_pdf_version = NULL; #ifdef WIN32 @@ -384,6 +387,12 @@ struct poptOption options[] = { N_("Export document to an EPS file"), N_("FILENAME")}, + {"export-ps-level", 0, + POPT_ARG_INT, &sp_export_ps_level, SP_ARG_EXPORT_PS_LEVEL, + N_("Choose the PostScript Level used to export. Possible choices are" + " 2 (the default) and 3"), + N_("PS Level")}, + {"export-pdf", 'A', POPT_ARG_STRING, &sp_export_pdf, SP_ARG_EXPORT_PDF, N_("Export document to a PDF file"), @@ -1669,8 +1678,9 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) g_warning("Parameter or Enum \"%s\" might not exist",pdfver_param_name); } } + // set default pdf export version to 1.4, also if something went wrong - if(set_export_pdf_version_fail) { + if(sp_export_pdf_version && set_export_pdf_version_fail) { (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); } @@ -1680,6 +1690,18 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) return 1; } + if ( g_strcmp0(mime, "image/x-postscript") == 0 + || g_strcmp0(mime, "image/x-e-postscript") == 0 ) { + if ( sp_export_ps_level < 2 || sp_export_ps_level > 3 ) { + g_warning("Only supported PostScript levels are 2 and 3." + " Defaulting to 2."); + sp_export_ps_level = 2; + } + + (*i)->set_param_enum("PSlevel", (sp_export_ps_level == 3) + ? "PostScript level 3" : "PostScript level 2"); + } + (*i)->save(doc, uri); return 0; } -- cgit v1.2.3 From fddea897e18dbeab5c205725a896e27f9763906b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 6 Jun 2013 05:32:48 -0300 Subject: Fixes r12348 and r12350. Typo error (sp_export_pdf_version instead sp_export_pdf). (bzr r12352) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index e77c748b7..28ec719f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1680,7 +1680,7 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) } // set default pdf export version to 1.4, also if something went wrong - if(sp_export_pdf_version && set_export_pdf_version_fail) { + if(sp_export_pdf && set_export_pdf_version_fail) { (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); } -- cgit v1.2.3 From 51d3a81afab97d564174dfc816b5feacc564e965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Fri, 7 Jun 2013 13:44:44 -0300 Subject: Refactor --export-pdf-version detection. If the user try to export the pdf and ps versions at one run, the sp_export_pdf detection would fail. A better approach (this commit) is to check the mime argument. (bzr r12359) --- src/main.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 28ec719f3..19ea3f181 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1657,31 +1657,33 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) (*i)->set_param_float("bleed", margin); // handle --export-pdf-version - bool set_export_pdf_version_fail=true; - const gchar *pdfver_param_name="PDFversion"; - if(sp_export_pdf_version) { - // combine "PDF " and the given command line - std::string version_gui_string=std::string("PDF ")+sp_export_pdf_version; - try{ - // first, check if the given pdf version is selectable in the ComboBox - if((*i)->get_param_enum_contains("PDFversion", version_gui_string.c_str())) { - (*i)->set_param_enum(pdfver_param_name, version_gui_string.c_str()); - set_export_pdf_version_fail=false; - } else { - 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\".", - sp_export_pdf_version); + if (g_strcmp0(mime, "application/pdf") == 0) { + bool set_export_pdf_version_fail=true; + const gchar *pdfver_param_name="PDFversion"; + if(sp_export_pdf_version) { + // combine "PDF " and the given command line + std::string version_gui_string=std::string("PDF ")+sp_export_pdf_version; + try{ + // first, check if the given pdf version is selectable in the ComboBox + if((*i)->get_param_enum_contains("PDFversion", version_gui_string.c_str())) { + (*i)->set_param_enum(pdfver_param_name, version_gui_string.c_str()); + set_export_pdf_version_fail=false; + } else { + 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\".", + sp_export_pdf_version); + } + } catch (...) { + // can be thrown along the way: + // throw Extension::param_not_exist(); + // throw Extension::param_not_enum_param(); + g_warning("Parameter or Enum \"%s\" might not exist",pdfver_param_name); } - } catch (...) { - // can be thrown along the way: - // throw Extension::param_not_exist(); - // throw Extension::param_not_enum_param(); - g_warning("Parameter or Enum \"%s\" might not exist",pdfver_param_name); } - } - // set default pdf export version to 1.4, also if something went wrong - if(sp_export_pdf && set_export_pdf_version_fail) { - (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); + // set default pdf export version to 1.4, also if something went wrong + if(set_export_pdf_version_fail) { + (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); + } } //check if specified directory exists -- cgit v1.2.3 From c3a160589a9cb41c70a56e5e7b66a65857a0d10e Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:04:32 +0100 Subject: Factored layer model out into new Inkscape::LayerModel class. This allows Inkscape::Selection to use a LayerModel that is not associated with a UI. Changed the interface of verbs (SPAction) to use a new ActionContext rather than UI::View::View, again so that verbs may be used in a console mode. Modified boolean operation verbs to work in console-only mode. Fixed up DESKTOP_IS_ACTIVE macro to work in the case of no desktops. Modified main.cpp to process selections and verbs in no-GUI mode. Other changes are all consequences of the SPDesktop, Selection and LayerModel interface changes. (bzr r12387.1.1) --- src/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 19ea3f181..49ef33fc9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -60,6 +60,8 @@ #include "macros.h" #include "file.h" #include "document.h" +#include "layer-model.h" +#include "selection.h" #include "sp-object.h" #include "interface.h" #include "print.h" @@ -85,6 +87,7 @@ #include "debug/logger.h" #include "debug/log-display-config.h" +#include "helper/action-context.h" #include "helper/png-write.h" #include "helper/geom.h" @@ -1066,7 +1069,20 @@ static int sp_process_file_list(GSList *fl) if (sp_vacuum_defs) { doc->vacuumDocument(); } - if (sp_vacuum_defs && !sp_export_svg) { + + bool has_performed_actions = false; + { + // Create layer model and selection model so we can run some verbs without a GUI + Inkscape::LayerModel layer_model; + layer_model.setDocument(doc); + Inkscape::Selection *selection = Inkscape::GC::release(new Inkscape::Selection(&layer_model, NULL)); + + // Execute command-line actions (selections and verbs) using our local models + Inkscape::ActionContext context(selection); + has_performed_actions = Inkscape::CmdLineAction::doList(context); + } + + if (!sp_export_svg && (sp_vacuum_defs || has_performed_actions)) { // save under the name given in the command line sp_repr_save_file(doc->rdoc, filename, SP_SVG_NS_URI); } -- cgit v1.2.3 From 09ce234c1fc367a2607936e6cf106cb24c60e94f Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Wed, 3 Jul 2013 20:06:11 +0100 Subject: Modified dbus interface so that it works in console mode (--dbus-listen) Modified action context setup so that in console mode, when a document is added to the main inkscape app instance, it gets a selection model and layer model automatically set up for it Made a couple more verbs work in console mode (bzr r12387.1.4) --- src/main.cpp | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 49ef33fc9..630411dde 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -169,6 +169,9 @@ enum { SP_ARG_SHELL, SP_ARG_VERSION, SP_ARG_VACUUM_DEFS, +#ifdef WITH_DBUS + SP_ARG_DBUS_LISTEN, +#endif // WITH_DBUS SP_ARG_VERB_LIST, SP_ARG_VERB, SP_ARG_SELECT, @@ -222,7 +225,9 @@ static gboolean sp_query_all = FALSE; static gchar *sp_query_id = NULL; static gboolean sp_shell = FALSE; static gboolean sp_vacuum_defs = FALSE; - +#ifdef WITH_DBUS +static gboolean sp_dbus_listen = FALSE; +#endif // WITH_DBUS static gchar *sp_export_png_utf8 = NULL; static gchar *sp_export_svg_utf8 = NULL; static gchar *sp_global_printer_utf8 = NULL; @@ -267,6 +272,9 @@ static void resetCommandlineGlobals() { sp_query_all = FALSE; sp_query_id = NULL; sp_vacuum_defs = FALSE; +#ifdef WITH_DBUS + sp_dbus_listen = FALSE; +#endif // WITH_DBUS sp_export_png_utf8 = NULL; sp_export_svg_utf8 = NULL; @@ -473,6 +481,13 @@ struct poptOption options[] = { POPT_ARG_NONE, &sp_vacuum_defs, SP_ARG_VACUUM_DEFS, N_("Remove unused definitions from the defs section(s) of the document"), NULL}, + +#ifdef WITH_DBUS + {"dbus-listen", 0, + POPT_ARG_NONE, &sp_dbus_listen, SP_ARG_DBUS_LISTEN, + N_("Enter a listening loop for D-Bus messages in console mode"), + NULL}, +#endif // WITH_DBUS {"verb-list", 0, POPT_ARG_NONE, NULL, SP_ARG_VERB_LIST, @@ -731,6 +746,9 @@ main(int argc, char **argv) || !strcmp(argv[i], "-Y") || !strncmp(argv[i], "--query-y", 9) || !strcmp(argv[i], "--vacuum-defs") +#ifdef WITH_DBUS + || !strcmp(argv[i], "--dbus-listen") +#endif // WITH_DBUS || !strcmp(argv[i], "--shell") ) { @@ -1038,6 +1056,17 @@ sp_main_gui(int argc, char const **argv) static int sp_process_file_list(GSList *fl) { int retVal = 0; +#ifdef WITH_DBUS + if (!fl) { + // If we've been asked to listen for D-Bus messages, enter a main loop here + // The main loop may be exited by calling "exit" on the D-Bus application interface. + if (sp_dbus_listen) { + Gtk::Main main_dbus_loop(0, NULL); + main_dbus_loop.run(); + } + } +#endif // WITH_DBUS + while (fl) { const gchar *filename = (gchar *)fl->data; @@ -1070,17 +1099,17 @@ static int sp_process_file_list(GSList *fl) doc->vacuumDocument(); } - bool has_performed_actions = false; - { - // Create layer model and selection model so we can run some verbs without a GUI - Inkscape::LayerModel layer_model; - layer_model.setDocument(doc); - Inkscape::Selection *selection = Inkscape::GC::release(new Inkscape::Selection(&layer_model, NULL)); - - // Execute command-line actions (selections and verbs) using our local models - Inkscape::ActionContext context(selection); - has_performed_actions = Inkscape::CmdLineAction::doList(context); + // Execute command-line actions (selections and verbs) using our local models + bool has_performed_actions = Inkscape::CmdLineAction::doList(inkscape_active_action_context()); + +#ifdef WITH_DBUS + // If we've been asked to listen for D-Bus messages, enter a main loop here + // The main loop may be exited by calling "exit" on the D-Bus application interface. + if (sp_dbus_listen) { + Gtk::Main main_dbus_loop(0, NULL); + main_dbus_loop.run(); } +#endif // WITH_DBUS if (!sp_export_svg && (sp_vacuum_defs || has_performed_actions)) { // save under the name given in the command line @@ -1248,7 +1277,7 @@ int sp_main_console(int argc, char const **argv) int retVal = sp_common_main( argc, argv, &fl ); g_return_val_if_fail(retVal == 0, 1); - if (fl == NULL && !sp_shell) { + if (fl == NULL && !sp_shell && !sp_dbus_listen) { g_print("Nothing to do!\n"); exit(0); } -- cgit v1.2.3 From c165601973334cdb21088219a3cb9d0a20abb181 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Thu, 4 Jul 2013 23:57:15 +0100 Subject: Fix for builds without --enable-dbusapi (missing #ifdef) (bzr r12387.1.9) --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 630411dde..ba51951da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1277,7 +1277,11 @@ int sp_main_console(int argc, char const **argv) int retVal = sp_common_main( argc, argv, &fl ); g_return_val_if_fail(retVal == 0, 1); - if (fl == NULL && !sp_shell && !sp_dbus_listen) { + if (fl == NULL && !sp_shell +#ifdef WITH_DBUS + && !sp_dbus_listen +#endif // WITH_DBUS + ) { g_print("Nothing to do!\n"); exit(0); } -- cgit v1.2.3 From bea3d29ac007d6c8faca786538fafb0d7d789ffc Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Wed, 10 Jul 2013 11:50:45 +0100 Subject: Added "dbus-name" command line option to allow a D-Bus bus name other than "org.inkscape" to be specified. This allows multiple Inkscape instances to be controlled over D-Bus in a single user session. (bzr r12402.1.1) --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index ba51951da..4e2f2fd2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,6 +103,11 @@ #endif // WIN32 #include "extension/init.h" +// Not ideal, but there doesn't appear to be a nicer system in place for +// passing command-line parameters to extensions before initialization... +#ifdef WITH_DBUS +#include "extension/dbus/dbus-init.h" +#endif // WITH_DBUS #include #include @@ -171,6 +176,7 @@ enum { SP_ARG_VACUUM_DEFS, #ifdef WITH_DBUS SP_ARG_DBUS_LISTEN, + SP_ARG_DBUS_NAME, #endif // WITH_DBUS SP_ARG_VERB_LIST, SP_ARG_VERB, @@ -227,6 +233,7 @@ static gboolean sp_shell = FALSE; static gboolean sp_vacuum_defs = FALSE; #ifdef WITH_DBUS static gboolean sp_dbus_listen = FALSE; +static gchar *sp_dbus_name = NULL; #endif // WITH_DBUS static gchar *sp_export_png_utf8 = NULL; static gchar *sp_export_svg_utf8 = NULL; @@ -274,6 +281,7 @@ static void resetCommandlineGlobals() { sp_vacuum_defs = FALSE; #ifdef WITH_DBUS sp_dbus_listen = FALSE; + sp_dbus_name = NULL; #endif // WITH_DBUS sp_export_png_utf8 = NULL; @@ -487,6 +495,11 @@ struct poptOption options[] = { POPT_ARG_NONE, &sp_dbus_listen, SP_ARG_DBUS_LISTEN, N_("Enter a listening loop for D-Bus messages in console mode"), NULL}, + + {"dbus-name", 0, + POPT_ARG_STRING, &sp_dbus_name, SP_ARG_DBUS_NAME, + N_("Specify the D-Bus bus name to listen for messages on (default is org.inkscape)"), + N_("BUS-NAME")}, #endif // WITH_DBUS {"verb-list", 0, @@ -885,6 +898,13 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) if ( sp_global_printer ) sp_global_printer_utf8 = g_strdup( sp_global_printer ); } + +#ifdef WITH_DBUS + // Before initializing extensions, we must set the DBus bus name if required + if (sp_dbus_name != NULL) { + Inkscape::Extension::Dbus::dbus_set_bus_name(sp_dbus_name); + } +#endif // Return the list if wanted, else free it up. if ( flDest ) { -- cgit v1.2.3 From f5023f704fb05b25d5fa6c78e0faefd93ef044ae Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 17 Jul 2013 12:42:40 +0100 Subject: Fix remaining g_type_init deprecation issues (bzr r12421) --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 4e2f2fd2b..d425b88bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1283,12 +1283,15 @@ int sp_main_console(int argc, char const **argv) { /* We are started in text mode */ +#if !GLIB_CHECK_VERSION(2,36,0) /* Do this g_type_init(), so that we can use Xft/Freetype2 (Pango) * in a non-Gtk environment. Used in libnrtype's * FontInstance.cpp and FontFactory.cpp. * http://mail.gnome.org/archives/gtk-list/2003-December/msg00063.html */ g_type_init(); +#endif + char **argv2 = const_cast(argv); gtk_init_check( &argc, &argv2 ); //setlocale(LC_ALL, ""); -- cgit v1.2.3 From f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 18:33:03 -0400 Subject: Eliminate "unit-constants.h". (bzr r12380.1.54) --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index d425b88bb..577cc3d79 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,7 +68,7 @@ #include "color.h" #include "sp-item.h" #include "sp-root.h" -#include "unit-constants.h" +#include "util/units.h" #include "svg/svg.h" #include "svg/svg-color.h" @@ -1524,7 +1524,7 @@ static int sp_do_export_png(SPDocument *doc) // default dpi if (dpi == 0.0) { - dpi = PX_PER_IN; + dpi = Inkscape::Util::Quantity::convert(1, "in", "px"); } unsigned long int width = 0; @@ -1537,7 +1537,7 @@ static int sp_do_export_png(SPDocument *doc) g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX); return 1; } - dpi = (gdouble) width * PX_PER_IN / area.width(); + dpi = (gdouble) width * Inkscape::Util::Quantity::convert(1, "in", "px") / area.width(); } if (sp_export_height) { @@ -1547,15 +1547,15 @@ static int sp_do_export_png(SPDocument *doc) g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX); return 1; } - dpi = (gdouble) height * PX_PER_IN / area.height(); + dpi = (gdouble) height * Inkscape::Util::Quantity::convert(1, "in", "px") / area.height(); } if (!sp_export_width) { - width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); + width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); } if (!sp_export_height) { - height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5); + height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); } guint32 bgcolor = 0x00000000; -- cgit v1.2.3 From 6ae6c0bea96eef09907091279e0678aa5f83102d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 4 Aug 2013 18:01:18 -0400 Subject: Switched to global UnitTable. (bzr r12380.1.62) --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 577cc3d79..29f431aa8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,7 +68,6 @@ #include "color.h" #include "sp-item.h" #include "sp-root.h" -#include "util/units.h" #include "svg/svg.h" #include "svg/svg-color.h" -- cgit v1.2.3 From 3bfb610bb7719d49821fe5381ae449789c3cb968 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 23:32:14 -0400 Subject: Improve code readability. (bzr r12475.1.9) --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 29f431aa8..dccf70889 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1536,7 +1536,7 @@ static int sp_do_export_png(SPDocument *doc) g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX); return 1; } - dpi = (gdouble) width * Inkscape::Util::Quantity::convert(1, "in", "px") / area.width(); + dpi = (gdouble) Inkscape::Util::Quantity::convert(width, "in", "px") / area.width(); } if (sp_export_height) { @@ -1546,15 +1546,15 @@ static int sp_do_export_png(SPDocument *doc) g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX); return 1; } - dpi = (gdouble) height * Inkscape::Util::Quantity::convert(1, "in", "px") / area.height(); + dpi = (gdouble) Inkscape::Util::Quantity::convert(height, "in", "px") / area.height(); } if (!sp_export_width) { - width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); + width = (unsigned long int) (Inkscape::Util::Quantity::convert(area.width(), "px", "in") * dpi + 0.5); } if (!sp_export_height) { - height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); + height = (unsigned long int) (Inkscape::Util::Quantity::convert(area.height(), "px", "in") * dpi + 0.5); } guint32 bgcolor = 0x00000000; -- cgit v1.2.3 From eba05095970a9ee1de53703f5533efbbfbf91715 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 24 Sep 2013 11:31:44 -0700 Subject: Fix my email address through codebase (bzr r12588) --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 9a365424c..1c0f4cee7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,7 +11,7 @@ * Michael Meeks * Chema Celorio * Pawel Palucha - * Bryce Harrington + * Bryce Harrington * ... and various people who have worked with various projects * Jon A. Cruz * Abhishek Sharma -- cgit v1.2.3 From 55b451bf382e0c3d5ed8728e42fbb535acfa8a33 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 7 Nov 2013 21:44:00 +0100 Subject: First step of moving tools into appropriate namespaces. (bzr r12782) --- src/main.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 1c0f4cee7..29bc7f7e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -917,6 +917,16 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) return 0; } +namespace Inkscape { +namespace UI { +namespace Tools { + +guint get_group0_keyval(GdkEventKey* event); + +} +} +} + static void snooper(GdkEvent *event, gpointer /*data*/) { if (inkscape_mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */ @@ -959,7 +969,7 @@ snooper(GdkEvent *event, gpointer /*data*/) { static gboolean altL_pressed = FALSE; static gboolean altR_pressed = FALSE; static gboolean alt_pressed = FALSE; - guint get_group0_keyval(GdkEventKey* event); + guint keyval = 0; switch (event->type) { case GDK_MOTION_NOTIFY: @@ -969,7 +979,7 @@ snooper(GdkEvent *event, gpointer /*data*/) { alt_pressed = TRUE && (event->button.state & GDK_MOD1_MASK); break; case GDK_KEY_PRESS: - keyval = get_group0_keyval(&event->key); + keyval = Inkscape::UI::Tools::get_group0_keyval(&event->key); if (keyval == GDK_KEY_Alt_L) altL_pressed = TRUE; if (keyval == GDK_KEY_Alt_R) altR_pressed = TRUE; alt_pressed = alt_pressed || altL_pressed || altR_pressed; @@ -980,7 +990,7 @@ snooper(GdkEvent *event, gpointer /*data*/) { event->key.state &= ~GDK_MOD1_MASK; break; case GDK_KEY_RELEASE: - keyval = get_group0_keyval(&event->key); + keyval = Inkscape::UI::Tools::get_group0_keyval(&event->key); if (keyval == GDK_KEY_Alt_L) altL_pressed = FALSE; if (keyval == GDK_KEY_Alt_R) altR_pressed = FALSE; if (!altL_pressed && !altR_pressed) -- cgit v1.2.3 From 67e24fa688c6b9da489a22a6bd281bf1956f38eb Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 13 Nov 2013 19:03:07 +0100 Subject: Add command line support for EMF and WMF export, by David Mathog. Fixed bugs: - https://launchpad.net/bugs/1244749 (bzr r12809) --- src/main.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 29bc7f7e9..c6427dc6f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -157,9 +157,8 @@ enum { SP_ARG_EXPORT_PDF, SP_ARG_EXPORT_PDF_VERSION, SP_ARG_EXPORT_LATEX, -#ifdef WIN32 SP_ARG_EXPORT_EMF, -#endif //WIN32 + SP_ARG_EXPORT_WMF, SP_ARG_EXPORT_TEXT_TO_PATH, SP_ARG_EXPORT_IGNORE_FILTERS, SP_ARG_EXTENSIONDIR, @@ -186,9 +185,9 @@ int sp_main_gui(int argc, char const **argv); int sp_main_console(int argc, char const **argv); static int sp_do_export_png(SPDocument *doc); static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime); -#ifdef WIN32 static int do_export_emf(SPDocument* doc, gchar const* uri, char const *mime); -#endif //WIN32 +static int do_export_wmf(SPDocument* doc, gchar const* uri, char const *mime); +static int do_export_win_metafile_common(SPDocument* doc, gchar const* uri, char const *mime); static void do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id); static void do_query_all (SPDocument *doc); static void do_query_all_recurse (SPObject *o); @@ -215,9 +214,8 @@ static gchar *sp_export_eps = NULL; static gint sp_export_ps_level = 2; static gchar *sp_export_pdf = NULL; static gchar *sp_export_pdf_version = NULL; -#ifdef WIN32 static gchar *sp_export_emf = NULL; -#endif //WIN32 +static gchar *sp_export_wmf = NULL; static gboolean sp_export_text_to_path = FALSE; static gboolean sp_export_ignore_filters = FALSE; static gboolean sp_export_font = FALSE; @@ -264,9 +262,8 @@ static void resetCommandlineGlobals() { sp_export_ps_level = 2; sp_export_pdf = NULL; sp_export_pdf_version = NULL; -#ifdef WIN32 sp_export_emf = NULL; -#endif //WIN32 + sp_export_wmf = NULL; sp_export_text_to_path = FALSE; sp_export_ignore_filters = FALSE; sp_export_font = FALSE; @@ -426,12 +423,15 @@ struct poptOption options[] = { 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}, -#ifdef WIN32 {"export-emf", 'M', POPT_ARG_STRING, &sp_export_emf, SP_ARG_EXPORT_EMF, N_("Export document to an Enhanced Metafile (EMF) File"), N_("FILENAME")}, -#endif //WIN32 + + {"export-wmf", 'm', + POPT_ARG_STRING, &sp_export_wmf, SP_ARG_EXPORT_WMF, + N_("Export document to a Windows Metafile (WMF) File"), + N_("FILENAME")}, {"export-text-to-path", 'T', POPT_ARG_NONE, &sp_export_text_to_path, SP_ARG_EXPORT_TEXT_TO_PATH, @@ -742,10 +742,10 @@ main(int argc, char **argv) || !strcmp(argv[i], "-A") || !strncmp(argv[i], "--export-pdf", 12) || !strncmp(argv[i], "--export-latex", 14) -#ifdef WIN32 || !strcmp(argv[i], "-M") || !strncmp(argv[i], "--export-emf", 12) -#endif //WIN32 + || !strcmp(argv[i], "-m") + || !strncmp(argv[i], "--export-wmf", 12) || !strcmp(argv[i], "-W") || !strncmp(argv[i], "--query-width", 13) || !strcmp(argv[i], "-H") @@ -1190,11 +1190,12 @@ static int sp_process_file_list(GSList *fl) if (sp_export_pdf) { retVal |= do_export_ps_pdf(doc, sp_export_pdf, "application/pdf"); } -#ifdef WIN32 if (sp_export_emf) { retVal |= do_export_emf(doc, sp_export_emf, "image/x-emf"); } -#endif //WIN32 + if (sp_export_wmf) { + retVal |= do_export_wmf(doc, sp_export_wmf, "image/x-wmf"); + } if (sp_query_all) { do_query_all (doc); } else if (sp_query_width || sp_query_height) { @@ -1788,16 +1789,15 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) return 0; } -#ifdef WIN32 /** - * Export a document to EMF + * Export a document to EMF or WMF * * \param doc Document to export. * \param uri URI to export to. - * \param mime MIME type to export as (should be "image/x-emf") + * \param mime MIME type to export as (should be "image/x-emf" or "image/x-wmf") */ -static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) +static int do_export_win_metafile_common(SPDocument* doc, gchar const* uri, char const* mime) { Inkscape::Extension::DB::OutputList o; Inkscape::Extension::db.get_output_list(o); @@ -1822,7 +1822,32 @@ static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) (*i)->save(doc, uri); return 0; } -#endif //WIN32 + +/** + * Export a document to EMF + * + * \param doc Document to export. + * \param uri URI to export to. + * \param mime MIME type to export as (should be "image/x-emf") + */ + +static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) +{ + return do_export_win_metafile_common(doc, uri, mime); +} + +/** + * Export a document to WMF + * + * \param doc Document to export. + * \param uri URI to export to. + * \param mime MIME type to export as (should be "image/x-wmf") + */ + +static int do_export_wmf(SPDocument* doc, gchar const* uri, char const* mime) +{ + return do_export_win_metafile_common(doc, uri, mime); +} #ifdef WIN32 bool replaceArgs( int& argc, char**& argv ) -- cgit v1.2.3 From 7348cf1e4e3ef512d32007931c5fb144784db9e2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 21 Nov 2013 23:41:17 +0100 Subject: reorder header file includes. Because glibmm depends on a deprecated/threads.h of glib, it has to be included first. (bzr r12830) --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index c6427dc6f..9f5a95ffe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,12 +26,13 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include "path-prefix.h" // This has to be included prior to anything that includes setjmp.h, it croaks otherwise #include -#include "ui/widget/panel.h" +#include "ui/widget/panel.h" // This has to be the first to include because of Glibmm's dependence on a deprecated feature... + +#include "path-prefix.h" #ifdef HAVE_IEEEFP_H #include -- cgit v1.2.3 From a13410f14b3bc2acafe48d07e4c53d16fd6be594 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 2 Jan 2014 09:29:29 +0100 Subject: Fix for Bug #950781 (There is no disk in drive error when opening Inkscape in Windows 7) by Max Gaukler. Fixed bugs: - https://launchpad.net/bugs/950781 (bzr r12866) --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 9f5a95ffe..079944af6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -584,11 +584,14 @@ static void _win32_set_inkscape_env(gchar const *exe) } else { printf("python not found\n\n"); }*/ - + // INKSCAPE_LOCALEDIR is needed by Python/Gettext gchar *localepath = g_build_filename(exe, PACKAGE_LOCALE_DIR, NULL); g_setenv("INKSCAPE_LOCALEDIR", localepath, TRUE); - + + // prevent "please insert disk" messages. fixes bug #950781 + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + g_free(python); g_free(scripts); g_free(perl); -- cgit v1.2.3 From 8da52916bd86c3c19749b3062dcdbda63de3b554 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 27 Jan 2014 08:11:24 -0500 Subject: Protect export options from blank filenames, png, pdf, emf and wmf. This should fix Bug #941103 Fixed bugs: - https://launchpad.net/bugs/941103 (bzr r12981) --- src/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 079944af6..868f389a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1515,7 +1515,7 @@ static int sp_do_export_png(SPDocument *doc) // set filename and dpi from options, if not yet set from the hints if (filename.empty()) { - if (!sp_export_png) { + if (!sp_export_png || sp_export_png[0] == '\0') { g_warning ("No export filename given and no filename hint. Nothing exported."); return 1; } @@ -1771,6 +1771,11 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) } } + if(!uri || uri[0] == '\0') { + g_warning ("No export filename given. Nothing exported."); + return 0; + } + //check if specified directory exists if (!Inkscape::IO::file_directory_exists(uri)) { g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); @@ -1837,6 +1842,10 @@ static int do_export_win_metafile_common(SPDocument* doc, gchar const* uri, char static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) { + if(!uri || uri[0] == '\0') { + g_warning("No filename provided for emf export."); + return 0; + } return do_export_win_metafile_common(doc, uri, mime); } @@ -1850,6 +1859,10 @@ static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) static int do_export_wmf(SPDocument* doc, gchar const* uri, char const* mime) { + if(!uri || uri[0] == '\0') { + g_warning("No filename provided for wmf export."); + return 0; + } return do_export_win_metafile_common(doc, uri, mime); } -- cgit v1.2.3 From fd1ceb05805f20402606fd9fae1a048e0bca8e78 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 27 Jan 2014 13:19:30 -0500 Subject: Protect pdf and png exports from failure and output reasonalbe warnings. (bzr r12982) --- src/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 868f389a8..25f813c2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1632,10 +1632,13 @@ static int sp_do_export_png(SPDocument *doc) 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_print("Bitmap saved as: %s\n", filename.c_str()); - if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { - sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); + if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) { + g_print("Bitmap saved as: %s\n", filename.c_str()); + } else { + g_warning("Bitmap failed to save to: %s", filename.c_str()); + } } else { g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); } @@ -1794,7 +1797,11 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) ? "PostScript level 3" : "PostScript level 2"); } - (*i)->save(doc, uri); + try { + (*i)->save(doc, uri); + } catch(...) { + g_warning("Failed to save pdf to: %s", uri); + } return 0; } -- cgit v1.2.3