X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Ftex.c;h=6b0175ed06f81bbcfaca0e7c95fd67eb69986d0a;hb=7fceea6249f2a570ecc44b5cb35f94711da957c1;hp=4191e6938179b30fa420540830f4b59b9fca8a82;hpb=4ab3ada839067eaee164be95efc0df37df6bce62;p=pspp diff --git a/src/output/tex.c b/src/output/tex.c index 4191e69381..6b0175ed06 100644 --- a/src/output/tex.c +++ b/src/output/tex.c @@ -36,7 +36,9 @@ #include "libpspp/message.h" #include "libpspp/temp-file.h" #include "libpspp/version.h" -#include "output/cairo.h" +#ifdef HAVE_CAIRO +#include "output/cairo-chart.h" +#endif #include "output/chart-item.h" #include "output/driver-provider.h" #include "output/message-item.h" @@ -66,6 +68,7 @@ struct tex_driver struct output_driver driver; /* A hash table containing any Tex macros which need to be emitted. */ struct hmap macros; + bool require_graphics; #ifdef HAVE_CAIRO struct cell_color fg; struct cell_color bg; @@ -132,8 +135,8 @@ tex_create (struct file_handle *fh, enum settings_output_devices device_type, fh_get_file_name (fh))); tex->chart_cnt = 1; #ifdef HAVE_CAIRO - parse_color (d, o, "background-color", "#FFFFFFFFFFFF", &tex->bg); - parse_color (d, o, "foreground-color", "#000000000000", &tex->fg); + tex->bg = parse_color (opt (d, o, "background-color", "#FFFFFFFFFFFF")); + tex->fg = parse_color (opt (d, o, "foreground-color", "#000000000000")); #endif tex->file = fn_open (tex->handle, "w"); @@ -215,8 +218,6 @@ tex_destroy (struct output_driver *driver) shipout (&tex->preamble_list, "%%%% Define the horizontal space between table columns\n"); shipout (&tex->preamble_list, "\\def\\psppcolumnspace{1mm}\n\n"); - shipout (&tex->preamble_list, "\\input graphicx\n\n"); - char *ln = get_language (); if (ln) shipout (&tex->preamble_list, "%%%% Language is \"%s\"\n", ln); @@ -260,6 +261,9 @@ tex_destroy (struct output_driver *driver) } hmap_destroy (&tex->macros); + if (tex->require_graphics) + shipout (&tex->preamble_list, "\\input graphicx\n\n"); + post_process_tokens (tex->file, &tex->preamble_list); shipout (&tex->token_list, "\n\\bye\n"); @@ -327,6 +331,7 @@ tex_submit (struct output_driver *driver, // printf ("The chart title is %s\n", title); shipout (&tex->token_list, "\\includegraphics{%s}\n", file_name); + tex->require_graphics = true; free (file_name); } } @@ -350,10 +355,6 @@ tex_submit (struct output_driver *driver, shipout (&tex->token_list, "}\\par\n\n"); break; - case TEXT_ITEM_EJECT_PAGE: - /* Nothing to do. */ - break; - case TEXT_ITEM_SYNTAX: /* So far as I'm aware, this can never happen. */ default: