Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / extension / internal / cairo-renderer-pdf-out.cpp
index 6536361bdc13130bbf2e9ed478049857a2841ff0..8406e2a3b53d951f251a89728299a7450ae7253a 100644 (file)
@@ -6,6 +6,8 @@
  *   Ted Gould <ted@gould.cx>
  *   Ulf Erikson <ulferikson@users.sf.net>
  *   Johan Engelen <goejendaagh@zonnet.nl>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2004-2010 Authors
  *
@@ -55,7 +57,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
                             bool texttopath, bool omittext, bool filtertobitmap, int resolution,
                             const gchar * const exportId, bool exportDrawing, bool exportCanvas)
 {
-    doc->ensure_up_to_date();
+    doc->ensureUpToDate();
 
 /* Start */
 
@@ -69,12 +71,13 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
     }
     else {
         // we want to export the entire document from root
-        base = SP_ITEM(sp_document_root(doc));
+        base = SP_ITEM(doc->getRoot());
         pageBoundingBox = !exportDrawing;
     }
 
-    if (!base)
+    if (!base) {
         return false;
+    }
     
     /* Create new arena */
     NRArena *arena = NRArena::create();
@@ -135,11 +138,11 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
     int level = 0;
     try {
         new_level = mod->get_param_enum("PDFversion");
-//        if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.x", new_level) == 0))
-//            level = 1;
+        if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.5", new_level) == 0))
+            level = 1;
     }
     catch(...) {
-//        g_warning("Parameter <PDFversion> might not exist");
+        g_warning("Parameter <PDFversion> might not exist");
     }
 
     bool new_textToPath  = FALSE;
@@ -213,12 +216,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
 
     // Create LaTeX file (if requested)
     if (new_textToLaTeX) {
-        gchar * tex_filename;
-        //strip filename of ".pdf", do not add ".tex" here.
-        gsize n = g_str_has_suffix(filename, ".pdf") ? strlen(filename)-4 : strlen(filename);
-        tex_filename = g_strndup(filename, n);
-        ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
-        g_free(tex_filename);
+        ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
 
         if (!ret)
             throw Inkscape::Extension::Output::save_failed();
@@ -241,16 +239,19 @@ CairoRendererPdfOutput::init (void)
                "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
                        "<name>Portable Document Format</name>\n"
                        "<id>org.inkscape.output.pdf.cairorenderer</id>\n"
-                       "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version") "\" type=\"enum\" >\n"
-                               "<_item value='PDF14'>" N_("PDF 1.4") "</_item>\n"
+                       "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n"
+#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0))
+                               "<_item value='PDF-1.5'>" N_("PDF 1.5") "</_item>\n"
+#endif
+                "<_item value='PDF-1.4'>" N_("PDF 1.4") "</_item>\n"
                        "</param>\n"
                        "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
                        "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, 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\">false</param>\n"
                        "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">false</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>.pdf</extension>\n"
                                "<mimetype>application/pdf</mimetype>\n"