projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
it works again
[pspp]
/
src
/
output
/
tex.c
diff --git
a/src/output/tex.c
b/src/output/tex.c
index 722549097b0a68d7bef4c89e7c592f23b739d522..bf5eb7115ea540a7e65cbd4debb33970d26b32f3 100644
(file)
--- a/
src/output/tex.c
+++ b/
src/output/tex.c
@@
-36,12
+36,16
@@
#include "libpspp/message.h"
#include "libpspp/temp-file.h"
#include "libpspp/version.h"
#include "libpspp/message.h"
#include "libpspp/temp-file.h"
#include "libpspp/version.h"
+#ifdef HAVE_CAIRO
#include "output/cairo-chart.h"
#include "output/cairo-chart.h"
+#endif
#include "output/chart-item.h"
#include "output/driver-provider.h"
#include "output/message-item.h"
#include "output/options.h"
#include "output/output-item-provider.h"
#include "output/chart-item.h"
#include "output/driver-provider.h"
#include "output/message-item.h"
#include "output/options.h"
#include "output/output-item-provider.h"
+#include "output/pivot-output.h"
+#include "output/pivot-table.h"
#include "output/table-provider.h"
#include "output/table-item.h"
#include "output/text-item.h"
#include "output/table-provider.h"
#include "output/table-item.h"
#include "output/text-item.h"
@@
-58,6
+62,10
@@
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "gettext.h"
#define _(msgid) gettext (msgid)
+/* This file uses TABLE_HORZ and TABLE_VERT enough to warrant abbreviating. */
+#define H TABLE_HORZ
+#define V TABLE_VERT
+
/* The desired maximum line length in the TeX file. */
#define TEX_LINE_MAX 80
/* The desired maximum line length in the TeX file. */
#define TEX_LINE_MAX 80
@@
-372,72
+380,85
@@
tex_submit (struct output_driver *driver,
static void
tex_put_footnote_markers (struct tex_driver *tex,
static void
tex_put_footnote_markers (struct tex_driver *tex,
-
const struct
footnote **footnotes,
-
size_t n_footnotes)
+
struct pivot_
footnote **footnotes,
+ size_t n_footnotes)
{
if (n_footnotes > 0)
shipout (&tex->token_list, "$^{");
for (size_t i = 0; i < n_footnotes; i++)
{
{
if (n_footnotes > 0)
shipout (&tex->token_list, "$^{");
for (size_t i = 0; i < n_footnotes; i++)
{
- const struct footnote *f = footnotes[i];
-
- tex_escape_string (tex, f->marker, true);
+ char *marker = pivot_value_to_string (footnotes[i]->marker,
+ SETTINGS_VALUE_SHOW_DEFAULT,
+ SETTINGS_VALUE_SHOW_DEFAULT);
+ tex_escape_string (tex, marker, true);
+ free (marker);
}
if (n_footnotes > 0)
shipout (&tex->token_list, "}$");
}
static void
}
if (n_footnotes > 0)
shipout (&tex->token_list, "}$");
}
static void
-tex_put_table_item_text (struct tex_driver *tex,
- const struct table_item_text *text)
+tex_put_table_cell (struct tex_driver *tex, const struct table_cell *cell)
{
{
- tex_escape_string (tex,
text->conten
t, false);
- tex_put_footnote_markers (tex,
text->footnotes, text
->n_footnotes);
+ tex_escape_string (tex,
cell->tex
t, false);
+ tex_put_footnote_markers (tex,
cell->footnotes, cell
->n_footnotes);
}
static void
}
static void
-tex_output_table (struct tex_driver *tex, const struct table_item *item)
+tex_output_table_layer (struct tex_driver *tex, const struct pivot_table *pt,
+ const size_t *layer_indexes)
{
/* Tables are rendered in TeX with the \halign command.
This is described in the TeXbook Ch. 22 */
{
/* Tables are rendered in TeX with the \halign command.
This is described in the TeXbook Ch. 22 */
-
- const struct table *t = table_item_get_table (item);
+ struct table *title, *layers, *body, *caption;
+ struct pivot_footnote **footnotes;
+ size_t n_footnotes;
+ pivot_output (pt, layer_indexes, &title, &layers, &body,
+ &caption, NULL, &footnotes, &n_footnotes);
shipout (&tex->token_list, "\n{\\parindent=0pt\n");
shipout (&tex->token_list, "\n{\\parindent=0pt\n");
- const struct table_item_text *caption = table_item_get_caption (item);
if (caption)
{
shipout (&tex->token_list, "{\\sl ");
if (caption)
{
shipout (&tex->token_list, "{\\sl ");
- tex_escape_string (tex, caption->content, false);
+ struct table_cell cell;
+ table_get_cell (caption, 0, 0, &cell);
+ tex_put_table_cell (tex, &cell);
shipout (&tex->token_list, "}\n\n");
}
shipout (&tex->token_list, "}\n\n");
}
- const struct footnote **f;
- size_t n_footnotes = table_collect_footnotes (item, &f);
- const struct table_item_text *title = table_item_get_title (item);
- const struct table_item_layers *layers = table_item_get_layers (item);
if (title || layers)
{
if (title)
{
shipout (&tex->token_list, "{\\bf ");
if (title || layers)
{
if (title)
{
shipout (&tex->token_list, "{\\bf ");
- tex_put_table_item_text (tex, title);
- shipout (&tex->token_list, "}");
+ struct table_cell cell;
+ table_get_cell (title, 0, 0, &cell);
+ tex_put_table_cell (tex, &cell);
+ shipout (&tex->token_list, "}\\par\n");
}
}
+
if (layers)
if (layers)
- abort ();
- shipout (&tex->token_list, "\\par\n");
+ {
+ for (size_t y = 0; y < layers->n[V]; y++)
+ {
+ shipout (&tex->token_list, "{");
+ struct table_cell cell;
+ table_get_cell (layers, 0, y, &cell);
+ tex_put_table_cell (tex, &cell);
+ shipout (&tex->token_list, "}\\par\n");
+ }
+ }
}
shipout (&tex->token_list, "\\offinterlineskip\\halign{\\strut%%\n");
/* Generate the preamble */
}
shipout (&tex->token_list, "\\offinterlineskip\\halign{\\strut%%\n");
/* Generate the preamble */
- for (int x = 0; x <
table_nc (t)
; ++x)
+ for (int x = 0; x <
body->n[H]
; ++x)
{
{
- shipout (&tex->token_list, "{\\vbox{\\cell{%d}#}}",
table_nc (t)
);
+ shipout (&tex->token_list, "{\\vbox{\\cell{%d}#}}",
body->n[H]
);
- if (x <
table_nc (t)
- 1)
+ if (x <
body->n[H]
- 1)
{
shipout (&tex->token_list, "\\hskip\\psppcolumnspace\\hfil");
shipout (&tex->token_list, "&\\vrule\n");
{
shipout (&tex->token_list, "\\hskip\\psppcolumnspace\\hfil");
shipout (&tex->token_list, "&\\vrule\n");
@@
-447,17
+468,17
@@
tex_output_table (struct tex_driver *tex, const struct table_item *item)
}
/* Emit the row data */
}
/* Emit the row data */
- for (int y = 0; y <
table_nr (t)
; y++)
+ for (int y = 0; y <
body->n[V]
; y++)
{
{
- bool is_column_header = (y < table_ht (t)
-
|| y >= table_nr (t) - table_hb (t))
;
+ enum { H = TABLE_HORZ, V = TABLE_VERT };
+
bool is_column_header = y < body->h[V][0] || y >= body->n[V] - body->h[V][1]
;
int prev_x = -1;
int skipped = 0;
int prev_x = -1;
int skipped = 0;
- for (int x = 0; x <
table_nc (t)
;)
+ for (int x = 0; x <
body->n[H]
;)
{
struct table_cell cell;
{
struct table_cell cell;
- table_get_cell (
t
, x, y, &cell);
+ table_get_cell (
body
, x, y, &cell);
int colspan = table_cell_colspan (&cell);
if (x > 0)
int colspan = table_cell_colspan (&cell);
if (x > 0)
@@
-470,11
+491,10
@@
tex_output_table (struct tex_driver *tex, const struct table_item *item)
if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0])
goto next_1;
if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0])
goto next_1;
- /* bool is_header = (y < table_ht (t) */
- /* || y >= table_nr (t) - table_hb (t) */
- /* || x < table_hl (t) */
- /* || x >= table_nc (t) - table_hr (t)); */
-
+ /* bool is_header = (y < body->h[V][0] */
+ /* || y >= body->n[V] - body->h[V][1] */
+ /* || x < body->h[H][0] */
+ /* || x >= body->n[H] - body->h[H][1]); */
enum table_halign halign =
table_halign_interpret (cell.style->cell_style.halign,
enum table_halign halign =
table_halign_interpret (cell.style->cell_style.halign,
@@
-525,14
+545,37
@@
tex_output_table (struct tex_driver *tex, const struct table_item *item)
for (int i = 0; i < n_footnotes; ++i)
{
for (int i = 0; i < n_footnotes; ++i)
{
+ char *marker = pivot_value_to_string (footnotes[i]->marker,
+ SETTINGS_VALUE_SHOW_DEFAULT,
+ SETTINGS_VALUE_SHOW_DEFAULT);
+ char *content = pivot_value_to_string (footnotes[i]->content,
+ SETTINGS_VALUE_SHOW_DEFAULT,
+ SETTINGS_VALUE_SHOW_DEFAULT);
+
shipout (&tex->token_list, "$^{");
shipout (&tex->token_list, "$^{");
- tex_escape_string (tex,
f[i]->
marker, false);
+ tex_escape_string (tex, marker, false);
shipout (&tex->token_list, "}$");
shipout (&tex->token_list, "}$");
- tex_escape_string (tex, f[i]->content, false);
+ tex_escape_string (tex, content, false);
+
+ free (content);
+ free (marker);
}
}
- free (f);
shipout (&tex->token_list, "}\n\\vskip 3ex\n\n");
shipout (&tex->token_list, "}\n\\vskip 3ex\n\n");
+
+ table_unref (title);
+ table_unref (layers);
+ table_unref (body);
+ table_unref (caption);
+ free (footnotes);
+}
+
+static void
+tex_output_table (struct tex_driver *tex, const struct table_item *item)
+{
+ size_t *layer_indexes;
+ PIVOT_OUTPUT_FOR_EACH_LAYER (layer_indexes, item->pt, true)
+ tex_output_table_layer (tex, item->pt, layer_indexes);
}
struct output_driver_factory tex_driver_factory =
}
struct output_driver_factory tex_driver_factory =