Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / extension / internal / cairo-ps-out.cpp
index 76b68bf2c0ffb92a9e5d1c2ee4738cd23b0a29a9..07312aab180d8c948fd86ac4dc4ba19a21839a03 100644 (file)
@@ -6,6 +6,8 @@
  *   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
  *
@@ -65,7 +67,7 @@ static bool
 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)
 {
-    doc->ensure_up_to_date();
+    doc->ensureUpToDate();
 
     SPItem *base = NULL;
 
@@ -77,7 +79,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
     }
     else {
         // we want to export the entire document from root
-        base = SP_ITEM(sp_document_root(doc));
+        base = SP_ITEM(doc->getRoot());
         pageBoundingBox = !exportDrawing;
     }
 
@@ -195,12 +197,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
 
     // Create LaTeX file (if requested)
     if (new_textToLaTeX) {
-        gchar * tex_filename;
-        //strip filename of ".ps", do not add ".tex" here.
-        gsize n = g_str_has_suffix(filename, ".ps") ? strlen(filename)-3 : strlen(filename);
-        tex_filename = g_strndup(filename, n);
-        ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
-        g_free(tex_filename);
+        ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
 
         if (!ret)
             throw Inkscape::Extension::Output::save_failed();
@@ -283,12 +280,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
 
     // Create LaTeX file (if requested)
     if (new_textToLaTeX) {
-        gchar * tex_filename;
-        //strip filename of ".eps", do not add ".tex" here.
-        gsize n = g_str_has_suffix(filename, ".eps") ? strlen(filename)-4 : strlen(filename);
-        tex_filename = g_strndup(filename, n);
-        ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
-        g_free(tex_filename);
+        ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
 
         if (!ret)
             throw Inkscape::Extension::Output::save_failed();
@@ -324,7 +316,7 @@ CairoPsOutput::init (void)
                "<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"
@@ -333,10 +325,10 @@ CairoPsOutput::init (void)
                        "<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=\"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"
+                       "<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"
@@ -362,7 +354,7 @@ CairoEpsOutput::init (void)
                "<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"
@@ -371,10 +363,10 @@ CairoEpsOutput::init (void)
                        "<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=\"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"
+                       "<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"