index dff89c1ed0595ef9b74bcd85e76ad69ba4ce6762..a5b7b32377e46d13b71982a2dfee2a0488845a1e 100644 (file)
* Ted Gould <ted@gould.cx>
* Ulf Erikson <ulferikson@users.sf.net>
* Adib Taraben <theAdib@yahoo.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2006 Authors
*
#include "cairo-ps-out.h"
#include "cairo-render-context.h"
#include "cairo-renderer.h"
+#include "latex-text-renderer.h"
#include <print.h>
#include "extension/system.h"
#include "extension/print.h"
namespace Extension {
namespace Internal {
-bool
-CairoPsOutput::check (Inkscape::Extension::Extension * module)
+bool CairoPsOutput::check (Inkscape::Extension::Extension * /*module*/)
{
- if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_PS))
- return FALSE;
-
- return TRUE;
+ if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_PS)) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
}
-bool
-CairoEpsOutput::check (Inkscape::Extension::Extension * module)
+bool CairoEpsOutput::check (Inkscape::Extension::Extension * /*module*/)
{
- if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_EPS))
- return FALSE;
-
- return TRUE;
+ if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_EPS)) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
}
static bool
-ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false)
+ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext,
+ bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false)
{
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
SPItem *base = NULL;
}
else {
// we want to export the entire document from root
- base = SP_ITEM(sp_document_root(doc));
+ base = SP_ITEM(doc->getRoot());
pageBoundingBox = !exportDrawing;
}
/* Create new arena */
NRArena *arena = NRArena::create();
- unsigned dkey = sp_item_display_key_new(1);
- sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ unsigned dkey = SPItem::display_key_new(1);
+ base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
CairoRenderer *renderer = new CairoRenderer();
ctx->setPSLevel(level);
ctx->setEPS(eps);
ctx->setTextToPath(texttopath);
+ renderer->_omitText = omittext;
ctx->setFilterToBitmap(filtertobitmap);
ctx->setBitmapResolution(resolution);
@@ -107,7 +112,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
}
/* Release arena */
- sp_item_invoke_hide(base, dkey);
+ base->invoke_hide(dkey);
nr_object_unref((NRObject *) arena);
renderer->destroyContext(ctx);
@@ -137,7 +142,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
int level = CAIRO_PS_LEVEL_2;
try {
new_level = mod->get_param_enum("PSlevel");
- if((new_level != NULL) && !(g_ascii_strcasecmp("PS3", new_level) == 0))
+ if((new_level != NULL) && (g_ascii_strcasecmp("PS3", new_level) == 0))
level = CAIRO_PS_LEVEL_3;
} catch(...) {}
@@ -146,6 +151,14 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
new_textToPath = mod->get_param_bool("textToPath");
} catch(...) {}
+ bool new_textToLaTeX = FALSE;
+ try {
+ new_textToLaTeX = mod->get_param_bool("textToLaTeX");
+ }
+ catch(...) {
+ g_warning("Parameter <textToLaTeX> might not exist");
+ }
+
bool new_blurToBitmap = FALSE;
try {
new_blurToBitmap = mod->get_param_bool("blurToBitmap");
@@ -156,9 +169,9 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
new_bitmapResolution = mod->get_param_int("resolution");
} catch(...) {}
- bool new_areaCanvas = true;
+ bool new_areaPage = true;
try {
- new_areaCanvas = mod->get_param_bool("areaCanvas");
+ new_areaPage = mod->get_param_bool("areaPage");
} catch(...) {}
bool new_areaDrawing = true;
@@ -171,13 +184,24 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
new_exportId = mod->get_param_string("exportId");
} catch(...) {}
- gchar * final_name;
- final_name = g_strdup_printf("> %s", filename);
- ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaCanvas);
- g_free(final_name);
+ // Create PS
+ {
+ gchar * final_name;
+ final_name = g_strdup_printf("> %s", filename);
+ ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaPage);
+ g_free(final_name);
+
+ if (!ret)
+ throw Inkscape::Extension::Output::save_failed();
+ }
+
+ // Create LaTeX file (if requested)
+ if (new_textToLaTeX) {
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
- if (!ret)
- throw Inkscape::Extension::Output::save_failed();
+ if (!ret)
+ throw Inkscape::Extension::Output::save_failed();
+ }
}
@@ -201,7 +225,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
int level = CAIRO_PS_LEVEL_2;
try {
new_level = mod->get_param_enum("PSlevel");
- if((new_level != NULL) && !(g_ascii_strcasecmp("PS3", new_level) == 0))
+ if((new_level != NULL) && (g_ascii_strcasecmp("PS3", new_level) == 0))
level = CAIRO_PS_LEVEL_3;
} catch(...) {}
@@ -210,6 +234,14 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
new_textToPath = mod->get_param_bool("textToPath");
} catch(...) {}
+ bool new_textToLaTeX = FALSE;
+ try {
+ new_textToLaTeX = mod->get_param_bool("textToLaTeX");
+ }
+ catch(...) {
+ g_warning("Parameter <textToLaTeX> might not exist");
+ }
+
bool new_blurToBitmap = FALSE;
try {
new_blurToBitmap = mod->get_param_bool("blurToBitmap");
@@ -220,9 +252,9 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
new_bitmapResolution = mod->get_param_int("resolution");
} catch(...) {}
- bool new_areaCanvas = true;
+ bool new_areaPage = true;
try {
- new_areaCanvas = mod->get_param_bool("areaCanvas");
+ new_areaPage = mod->get_param_bool("areaPage");
} catch(...) {}
bool new_areaDrawing = true;
@@ -235,13 +267,24 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
new_exportId = mod->get_param_string("exportId");
} catch(...) {}
- gchar * final_name;
- final_name = g_strdup_printf("> %s", filename);
- ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaCanvas, true);
- g_free(final_name);
+ // Create EPS
+ {
+ gchar * final_name;
+ final_name = g_strdup_printf("> %s", filename);
+ ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaPage, true);
+ g_free(final_name);
+
+ if (!ret)
+ throw Inkscape::Extension::Output::save_failed();
+ }
- if (!ret)
- throw Inkscape::Extension::Output::save_failed();
+ // Create LaTeX file (if requested)
+ if (new_textToLaTeX) {
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+
+ if (!ret)
+ throw Inkscape::Extension::Output::save_failed();
+ }
}
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("PostScript") "</name>\n"
"<id>" SP_MODULE_KEY_PRINT_CAIRO_PS "</id>\n"
- "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level") "\" type=\"enum\" >\n"
+ "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
"<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
"<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
#endif
"</param>\n"
- "<param name=\"areaCanvas\" gui-text=\"" N_("Export area is whole canvas") "\" type=\"boolean\">true</param>\n"
- "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is the drawing") "\" type=\"boolean\">true</param>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"textToLaTeX\" gui-text=\"" N_("PS+LaTeX: Omit text in PS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
- "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi)") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
- "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
+ "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
+ "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.ps</extension>\n"
"<mimetype>image/x-postscript</mimetype>\n"
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("Encapsulated PostScript") "</name>\n"
"<id>" SP_MODULE_KEY_PRINT_CAIRO_EPS "</id>\n"
- "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level") "\" type=\"enum\" >\n"
+ "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
"<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
"<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
#endif
"</param>\n"
- "<param name=\"areaCanvas\" gui-text=\"" N_("Export area is whole canvas") "\" type=\"boolean\">true</param>\n"
- "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is the drawing") "\" type=\"boolean\">true</param>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"textToLaTeX\" gui-text=\"" N_("EPS+LaTeX: Omit text in EPS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
- "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi)") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
- "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID") "\" type=\"string\"></param>\n"
+ "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
+ "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.eps</extension>\n"
"<mimetype>image/x-e-postscript</mimetype>\n"