/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <libpspp/message.h>
#include <libpspp/str.h>
#include <output/manager.h>
-#include <output/table.h>
#include <libpspp/getl.h>
#if HAVE_SYS_WAIT_H
/* Execute command. */
msg_set_command_name (command->name);
- tab_set_command_name (command->name);
+ som_set_command_name (command->name);
result = command->function (lexer, ds);
- tab_set_command_name (NULL);
+ som_set_command_name (NULL);
msg_set_command_name (NULL);
assert (cmd_result_is_valid (result));
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
-#include "manager.h"
+
+#include <output/manager.h>
+
#include <stdio.h>
#include <stdlib.h>
+
#include <libpspp/assertion.h>
-#include "output.h"
+#include <output/output.h>
+
+#include "gl/xalloc.h"
/* Table. */
static int table_num = 1;
static int subtable_num;
+
+/* Name of PSPP's current command, or NULL if outside a command. */
+static char *command_name;
\f
+struct som_entity *
+som_entity_clone (struct som_entity *entity)
+{
+ struct som_entity *copy = xmemdup (entity, sizeof *entity);
+ copy->command_name = xstrdup (entity->command_name);
+ return copy;
+}
+
+void
+som_entity_destroy (struct som_entity *entity)
+{
+ if (entity != NULL)
+ {
+ free (entity->command_name);
+ free (entity);
+ }
+}
+
/* Increments table_num so different procedures' output can be
distinguished. */
void
}
}
+/* Sets COMMAND_NAME as the name of the current command,
+ for embedding in output. */
+void
+som_set_command_name (const char *command_name_)
+{
+ free (command_name);
+ command_name = command_name_ ? xstrdup (command_name_) : NULL;
+}
+
/* Ejects the paper for all active devices. */
void
som_eject_page (void)
som_submit (struct som_entity *t)
{
struct outp_driver *d;
+ unsigned int flags;
#if DEBUGGING
static int entry;
assert (entry++ == 0);
#endif
+ t->class->flags (t, &flags);
+ if (!(flags & SOMF_NO_TITLE))
+ subtable_num++;
+ t->table_num = table_num;
+ t->subtable_num = subtable_num;
+ t->command_name = xstrdup (command_name);
+
if (t->type == SOM_TABLE)
{
- unsigned int flags;
int hl, hr, ht, hb;
int nc, nr;
- t->class->flags (t, &flags);
- if (!(flags & SOMF_NO_TITLE))
- subtable_num++;
- t->table_num = table_num;
- t->subtable_num = subtable_num;
-
t->class->count (t, &nc, &nr);
t->class->headers (t, &hl, &hr, &ht, &hb);
if (hl + hr > nc || ht + hb > nr)
if (len > max_len)
max_len = len;
- t->class->title (r, index++, 0, t->table_num, t->subtable_num);
+ t->class->title (r, index++, 0, t->table_num, t->subtable_num,
+ t->command_name);
t->class->render (r, 0, y0, nc, y1);
d->cp_x += tw + 2 * d->prop_em_width;
assert (d->cp_x == 0);
assert (tw < d->width && th + d->cp_y < d->length);
- t->class->title (r, 0, 0, t->table_num, t->subtable_num);
+ t->class->title (r, 0, 0, t->table_num, t->subtable_num, t->command_name);
t->class->render (r, hl, ht, nc - hr, nr - hb);
d->cp_y += th;
}
{
t->class->title (r, x_index ? x_index : y_index,
x_index ? y_index : 0,
- t->table_num, t->subtable_num);
+ t->table_num, t->subtable_num, t->command_name);
t->class->render (r, x0, y0, x1, y1);
d->cp_y += len;
void *ext; /* Owned by table or chart class. */
int table_num; /* Table number. */
int subtable_num; /* Sub-table number. */
+ char *command_name; /* Command that yielded this output. */
};
+struct som_entity *som_entity_clone (struct som_entity *);
+void som_entity_destroy (struct som_entity *);
+
/* Group styles. */
enum
{
void (*area) (void *, int *horiz, int *vert);
void (*cumulate) (void *, int cumtype, int start, int *end,
int max, int *actual);
- void (*title) (void *, int x, int y, int table_num, int subtable_num);
+ void (*title) (void *, int x, int y, int table_num, int subtable_num,
+ const char *command_name);
void (*render) (void *, int x1, int y1, int x2, int y2);
};
/* Submission. */
void som_new_series (void);
+void som_set_command_name (const char *);
void som_submit (struct som_entity *t);
/* Miscellaneous. */
#define _(msgid) gettext (msgid)
\f
const struct som_table_class tab_table_class;
-static char *command_name;
/* Returns the font to use for a cell with the given OPTIONS. */
static enum outp_font
Y. Y may be zero, or X and Y may be zero, but X should be nonzero
if Y is nonzero. */
static void
-tabi_title (void *r_, int x, int y, int table_num, int subtable_num)
+tabi_title (void *r_, int x, int y, int table_num, int subtable_num,
+ const char *command_name)
{
const struct tab_rendering *r = r_;
const struct tab_table *t = r->table;
return x;
}
-
-/* Sets COMMAND_NAME as the name of the current command,
- for embedding in output. */
-void
-tab_set_command_name (const char *command_name_)
-{
- free (command_name);
- command_name = command_name_ ? xstrdup (command_name_) : NULL;
-}
void tab_output_text (int options, const char *string, ...)
PRINTF_FORMAT (2, 3);
-/* Embedding the command name in the output. */
-void tab_set_command_name (const char *);
-
#endif /* tab_h */
tab_r (t), tab_t (t), tab_b (t));
entity->class->title (rendering, 0, 0,
- entity->table_num, entity->subtable_num);
+ entity->table_num, entity->subtable_num,
+ entity->command_name);
entity->class->render (rendering, tab_l (t), tab_t (t),
tab_nc (t) - tab_r (t),
tab_nr (t) - tab_b (t));
gtk_widget_modify_bg (GTK_WIDGET (drawing_area), GTK_STATE_NORMAL,
>k_widget_get_style (drawing_area)->base[GTK_STATE_NORMAL]);
g_object_set_data (G_OBJECT (drawing_area),
- "entity", xmemdup (entity, sizeof *entity));
+ "entity", som_entity_clone (entity));
gtk_widget_set_size_request (drawing_area, tw / 1024, th / 1024);
gtk_layout_put (the_output_viewer->output, drawing_area,
0, the_output_viewer->y);