Code

pdf/ps/eps+latex: output tex code to ".pdf_tex" instead of to ".tex"
authorJohan Engelen <goejendaagh@zonnet.nl>
Tue, 29 Jun 2010 21:50:45 +0000 (23:50 +0200)
committerJohan Engelen <goejendaagh@zonnet.nl>
Tue, 29 Jun 2010 21:50:45 +0000 (23:50 +0200)
src/extension/internal/cairo-ps-out.cpp
src/extension/internal/cairo-renderer-pdf-out.cpp
src/extension/internal/latex-text-renderer.cpp

index 61760e9d9b85d07b5c655321f21bdbc74188692f..16adebac3b7e70882f7c98ab77889584a3a115f4 100644 (file)
@@ -195,12 +195,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 +278,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();
index 808590e04061725810bc1e6651337b4a7ede15b1..e8eff20b7ab6eedc7a88500f004a9cdc953acab8 100644 (file)
@@ -213,12 +213,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();
index bebc21f2fba3eb20a7e5d76800a45a72d70a5fa5..0d98f6b9c832ca0d9e338d392c21db29bb9169a2 100644 (file)
@@ -51,7 +51,7 @@ namespace Internal {
 
 /**
  * This method is called by the PDF, EPS and PS output extensions.
- * @param filename This should be the filename without extension to which the tex code should be written. Output goes to <filename>.tex.
+ * @param filename This should be the filename without '_tex' extension to which the tex code should be written. Output goes to <filename>_tex, note the underscore instead of period.
  */
 bool
 latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
@@ -132,7 +132,7 @@ LaTeXTextRenderer::setTargetFile(gchar const *filename) {
 
         _filename = g_path_get_basename(filename);
 
-        gchar *filename_ext = g_strdup_printf("%s.tex", filename);
+        gchar *filename_ext = g_strdup_printf("%s_tex", filename);
         Inkscape::IO::dump_fopen_call(filename_ext, "K");
         FILE *osf = Inkscape::IO::fopen_utf8name(filename_ext, "w+");
         if (!osf) {
@@ -176,12 +176,12 @@ LaTeXTextRenderer::setTargetFile(gchar const *filename) {
 
 static char const preamble[] =
 "%% To include the image in your LaTeX document, write\n"
-"%%   \\input{<filename>.tex}\n"
+"%%   \\input{<filename>.pdf_tex}\n"
 "%%  instead of\n"
 "%%   \\includegraphics{<filename>.pdf}\n"
 "%% To scale the image, write\n"
 "%%   \\def{\\svgwidth}{<desired width>}\n"
-"%%   \\input{<filename>.tex}\n"
+"%%   \\input{<filename>.pdf_tex}\n"
 "%%  instead of\n"
 "%%   \\includegraphics[width=<desired width>]{<filename>.pdf}\n"
 "%%\n"
@@ -190,7 +190,7 @@ static char const preamble[] =
 "%% installed) using\n"
 "%%   \\usepackage{import}\n"
 "%% in the preamble, and then including the image with\n"
-"%%   \\import{<path to file>}{<filename>.tex}\n"
+"%%   \\import{<path to file>}{<filename>.pdf_tex}\n"
 "%% Alternatively, one can specify\n"
 "%%   \\graphicspath{{<path to file>/}}\n"
 "%% \n"