--- src/extension/internal/odf.cpp 2013-03-29 23:10:32.546875000 +0100 +++ src/extension/internal/odf.cpp 2013-03-29 22:52:18.140625000 +0100 @@ -2446,7 +2446,7 @@ "org.inkscape.output.odf\n" "\n" ".odg\n" - "text/x-povray-script\n" + "application/vnd.oasis.opendocument.graphics\n" "" N_("OpenDocument drawing (*.odg)") "\n" "" N_("OpenDocument drawing file") "\n" "\n" --- src/main.cpp 2013-03-29 23:12:37.531250000 +0100 +++ src/main.cpp 2013-03-29 23:01:30.515625000 +0100 @@ -147,6 +147,7 @@ SP_ARG_EXPORT_PS, SP_ARG_EXPORT_EPS, SP_ARG_EXPORT_PDF, + SP_ARG_EXPORT_ODG, SP_ARG_EXPORT_LATEX, #ifdef WIN32 SP_ARG_EXPORT_EMF, @@ -173,6 +174,7 @@ 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); +static int do_export_odg(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 @@ -199,6 +201,7 @@ static gchar *sp_export_ps = NULL; static gchar *sp_export_eps = NULL; static gchar *sp_export_pdf = NULL; +static gchar *sp_export_odg = NULL; #ifdef WIN32 static gchar *sp_export_emf = NULL; #endif //WIN32 @@ -242,6 +245,7 @@ sp_export_ps = NULL; sp_export_eps = NULL; sp_export_pdf = NULL; + sp_export_odg = NULL; #ifdef WIN32 sp_export_emf = NULL; #endif //WIN32 @@ -378,6 +382,11 @@ N_("Export document to a PDF file"), N_("FILENAME")}, + {"export-odg", 'G', + POPT_ARG_STRING, &sp_export_odg, SP_ARG_EXPORT_ODG, + N_("Export document to an ODG file"), + N_("FILENAME")}, + {"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}"), @@ -686,6 +695,8 @@ || !strncmp(argv[i], "--export-eps", 12) || !strcmp(argv[i], "-A") || !strncmp(argv[i], "--export-pdf", 12) + || !strcmp(argv[i], "-G") + || !strncmp(argv[i], "--export-odg", 12) || !strncmp(argv[i], "--export-latex", 14) #ifdef WIN32 || !strcmp(argv[i], "-M") @@ -1091,6 +1102,9 @@ if (sp_export_pdf) { retVal |= do_export_ps_pdf(doc, sp_export_pdf, "application/pdf"); } + if (sp_export_odg) { + retVal |= do_export_odg(doc, sp_export_odg, "application/vnd.oasis.opendocument.graphics"); + } #ifdef WIN32 if (sp_export_emf) { retVal |= do_export_emf(doc, sp_export_emf, "image/x-emf"); @@ -1633,6 +1647,40 @@ return 0; } +/** + * Export a document to ODG + * + * \param doc Document to export. + * \param uri URI to export to. + * \param mime MIME type to export as (should be "application/vnd.oasis.opendocument.graphics") + */ + +static int do_export_odg(SPDocument* doc, gchar const* uri, char const* mime) +{ + Inkscape::Extension::DB::OutputList o; + Inkscape::Extension::db.get_output_list(o); + Inkscape::Extension::DB::OutputList::const_iterator i = o.begin(); + while (i != o.end() && strcmp( (*i)->get_mimetype(), mime ) != 0) { + i++; + } + + if (i == o.end()) + { + g_warning ("Could not find an extension to export to MIME type %s.", mime); + 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; +} + #ifdef WIN32 /** * Export a document to EMF