output: Rename caption to title.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 13 Sep 2014 23:55:19 +0000 (16:55 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sat, 13 Sep 2014 23:55:49 +0000 (16:55 -0700)
This brings PSPP a small step closer to the table model that SPSS uses,
which allows for a brief title above the table and a more verbose caption
below it.

src/output/csv.c
src/output/html.c
src/output/odt.c
src/output/render.c
src/output/tab.h
src/output/table-item.c
src/output/table-item.h
src/ui/gui/psppire-output-view.c

index d2f2ac3b634349f3dbf6b8c255807a8b03a76838..2784b24998757649e96c7f863f709753873abd6c 100644 (file)
@@ -46,7 +46,7 @@ struct csv_driver
     char *separator;            /* Field separator (usually comma or tab). */
     int quote;                  /* Quote character (usually ' or ") or 0. */
     char *quote_set;            /* Characters that force quoting. */
-    bool captions;              /* Print table captions? */
+    bool titles;                /* Print table titles? */
 
     char *file_name;            /* Output file name. */
     char *command_name;         /* Current command. */
@@ -87,7 +87,7 @@ csv_create (const char *file_name, enum settings_output_devices device_type,
   csv->quote = quote[0];
   free (quote);
   csv->quote_set = xasprintf ("\n\r\t%s%c", csv->separator, csv->quote);
-  csv->captions = parse_boolean (opt (d, o, "captions", "true"));
+  csv->titles = parse_boolean (opt (d, o, "titles", "true"));
   csv->file_name = xstrdup (file_name);
   csv->file = fn_open (csv->file_name, "w");
   csv->n_items = 0;
@@ -189,12 +189,12 @@ csv_output_subtable (struct csv_driver *csv, struct string *s,
                      const struct table_item *item)
 {
   const struct table *t = table_item_get_table (item);
-  const char *caption = table_item_get_caption (item);
+  const char *title = table_item_get_title (item);
   int y, x;
 
-  if (csv->captions && caption != NULL)
+  if (csv->titles && title != NULL)
     {
-      csv_output_field_format (csv, "Table: %s", caption);
+      csv_output_field_format (csv, "Table: %s", title);
       putc ('\n', csv->file);
     }
 
@@ -259,16 +259,16 @@ csv_submit (struct output_driver *driver,
   if (is_table_item (output_item))
     {
       struct table_item *table_item = to_table_item (output_item);
-      const char *caption = table_item_get_caption (table_item);
+      const char *title = table_item_get_title (table_item);
       const struct table *t = table_item_get_table (table_item);
       int footnote_idx;
       int x, y;
 
       csv_put_separator (csv);
 
-      if (csv->captions && caption != NULL)
+      if (csv->titles && title != NULL)
         {
-          csv_output_field_format (csv, "Table: %s", caption);
+          csv_output_field_format (csv, "Table: %s", title);
           putc ('\n', csv->file);
         }
 
index 19d1085e4178d20490b8a10cee5d030fea1245a2..715682a9ea02087a92f4857938a4106b9ead7da3 100644 (file)
@@ -377,7 +377,7 @@ static void
 html_output_table (struct html_driver *html, const struct table_item *item)
 {
   const struct table *t = table_item_get_table (item);
-  const char *caption = table_item_get_caption (item);
+  const char *title = table_item_get_title (item);
   int footnote_idx = 0;
   int y;
 
@@ -428,10 +428,10 @@ html_output_table (struct html_driver *html, const struct table_item *item)
 
   fputs ("<TBODY VALIGN=\"TOP\">\n", html->file);
 
-  if (caption != NULL)
+  if (title != NULL)
     {
       fputs ("  <CAPTION>", html->file);
-      escape_string (html->file, caption, strlen (caption), " ", "<BR>");
+      escape_string (html->file, title, strlen (title), " ", "<BR>");
       fputs ("</CAPTION>\n", html->file);
     }
 
index d0860585cd40c35219bfad9533803770e74613bd..21aaeb6c1a723ebe9927a0d02beb85fc67456c24 100644 (file)
@@ -454,17 +454,17 @@ static void
 write_table (struct odt_driver *odt, const struct table_item *item)
 {
   const struct table *tab = table_item_get_table (item);
-  const char *caption = table_item_get_caption (item);
+  const char *title = table_item_get_title (item);
   int r, c;
 
   /* Write a heading for the table */
-  if (caption != NULL)
+  if (title != NULL)
     {
       xmlTextWriterStartElement (odt->content_wtr, _xml("text:h"));
       xmlTextWriterWriteFormatAttribute (odt->content_wtr,
                                          _xml("text:outline-level"), "%d", 2);
       xmlTextWriterWriteString (odt->content_wtr,
-                                _xml (table_item_get_caption (item)) );
+                                _xml (table_item_get_title (item)) );
       xmlTextWriterEndElement (odt->content_wtr);
     }
 
index f41f504df0a90cc4e73a5941d3c238fb8ecbe17e..84eef66795827dfa74f8ff59540823f0236bac1e 100644 (file)
@@ -1484,14 +1484,14 @@ render_pager_create (const struct render_params *params,
                      const struct table_item *table_item)
 {
   struct render_pager *p;
-  const char *caption;
+  const char *title;
 
   p = xzalloc (sizeof *p);
   p->params = params;
 
-  caption = table_item_get_caption (table_item);
-  if (caption)
-    render_pager_add_table (p, table_from_string (TAB_LEFT, caption));
+  title = table_item_get_title (table_item);
+  if (title)
+    render_pager_add_table (p, table_from_string (TAB_LEFT, title));
   render_pager_add_table (p, table_ref (table_item_get_table (table_item)));
   add_footnote_page (p, p->pages[p->n_pages - 1]);
 
index 76be9d4f65949cd05114b2563186991d2b18e858..bb932fddcbfee60133936ff8bc45cacbb7a1cfa5 100644 (file)
@@ -25,9 +25,9 @@
    Some of the features of this type of table are obsolete but have not yet
    been removed, because some code still uses them.  These features are:
 
-       - The title.  The title (or caption, actually) is a property of the
-         table_item (see output/table-item.h) in which a table is embedded,
-         not a property of the table itself.
+       - The title.  The title is a property of the table_item (see
+         output/table-item.h) in which a table is embedded, not a property of
+         the table itself.
 
        - Row and columns offsets (via tab_offset(), tab_next_row()).  This
          feature simply isn't used enough to justify keeping it.
index 664f093abfb792d9fde5afbb017bba493b5ec9ad..45add25f346635e8ebc4ae67f94471876b11179d 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011, 2014 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 "gl/xalloc.h"
 
 /* Initializes ITEM as a table item for rendering TABLE.  The new table item
-   initially has the specified CAPTION, which may be NULL if no caption is yet
-   available.  The caller retains ownership of CAPTION. */
+   initially has the specified TITLE, which may be NULL if no title is yet
+   available.  The caller retains ownership of TITLE. */
 struct table_item *
-table_item_create (struct table *table, const char *caption)
+table_item_create (struct table *table, const char *title)
 {
   struct table_item *item = xmalloc (sizeof *item);
   output_item_init (&item->output_item, &table_item_class);
   item->table = table;
-  item->caption = caption != NULL ? xstrdup (caption) : NULL;
+  item->title = title != NULL ? xstrdup (title) : NULL;
   return item;
 }
 
@@ -49,25 +49,24 @@ table_item_get_table (const struct table_item *table_item)
   return table_item->table;
 }
 
-/* Returns ITEM's caption, which is a null pointer if no caption has been
+/* Returns ITEM's title, which is a null pointer if no title has been
    set. */
 const char *
-table_item_get_caption (const struct table_item *item)
+table_item_get_title (const struct table_item *item)
 {
-  return item->caption;
+  return item->title;
 }
 
-/* Sets ITEM's caption to CAPTION, replacing any previous caption.  Specify
-   NULL for CAPTION to clear any caption from ITEM.  The caller retains
-   ownership of CAPTION.
+/* Sets ITEM's title to TITLE, replacing any previous title.  Specify NULL for
+   TITLE to clear any title from ITEM.  The caller retains ownership of TITLE.
 
    This function may only be used on a table_item that is unshared. */
 void
-table_item_set_caption (struct table_item *item, const char *caption)
+table_item_set_title (struct table_item *item, const char *title)
 {
   assert (!table_item_is_shared (item));
-  free (item->caption);
-  item->caption = caption != NULL ? xstrdup (caption) : NULL;
+  free (item->title);
+  item->title = title != NULL ? xstrdup (title) : NULL;
 }
 
 /* Submits TABLE_ITEM to the configured output drivers, and transfers ownership
@@ -82,7 +81,7 @@ static void
 table_item_destroy (struct output_item *output_item)
 {
   struct table_item *item = to_table_item (output_item);
-  free (item->caption);
+  free (item->title);
   table_unref (item->table);
   free (item);
 }
index dddf846ca952a08ea0709ffc72f737b9654da175..15f5c568f37b15350363dc40a0fd29692575f2e1 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011, 2014 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
@@ -21,7 +21,7 @@
 
    A table item is a subclass of an output item (see output-item.h) that
    contains a table (see table.h) and some formatting properties (currently
-   just a caption). */
+   just a title). */
 
 #include "libpspp/compiler.h"
 #include "output/output-item.h"
@@ -34,15 +34,15 @@ struct table_item
   {
     struct output_item output_item; /* Superclass. */
     struct table *table;        /* The table to be rendered. */
-    char *caption;              /* May be null if there is no caption. */
+    char *title;                /* May be null if there is no title. */
   };
 
-struct table_item *table_item_create (struct table *, const char *caption);
+struct table_item *table_item_create (struct table *, const char *title);
 
 const struct table *table_item_get_table (const struct table_item *);
 
-const char *table_item_get_caption (const struct table_item *);
-void table_item_set_caption (struct table_item *, const char *);
+const char *table_item_get_title (const struct table_item *);
+void table_item_set_title (struct table_item *, const char *);
 \f
 /* This boilerplate for table_item, a subclass of output_item, was
    autogenerated by mk-class-boilerplate. */
index b8202074639d524064185ad9dc4870bbdeb9f374..6b9445b404e6991ff097582b95e825d45394f4d2 100644 (file)
@@ -76,9 +76,9 @@ struct psppire_output_view
 
 enum
   {
-    COL_TITLE,                  /* Table title. */
+    COL_NAME,                   /* Table name. */
     COL_ADDR,                   /* Pointer to the table */
-    COL_Y,                      /* Y position of top of title. */
+    COL_Y,                      /* Y position of top of name. */
     N_COLS
   };
 
@@ -241,7 +241,7 @@ psppire_output_view_put (struct psppire_output_view *view,
 {
   GtkWidget *drawing_area;
   struct xr_rendering *r;
-  struct string title;
+  struct string name;
   GtkTreeStore *store;
   GtkTreePath *path;
   GtkTreeIter iter;
@@ -301,7 +301,7 @@ psppire_output_view_put (struct psppire_output_view *view,
     {
       store = GTK_TREE_STORE (gtk_tree_view_get_model (view->overview));
 
-      ds_init_empty (&title);
+      ds_init_empty (&name);
       if (is_text_item (item)
           && text_item_get_type (to_text_item (item)) == TEXT_ITEM_COMMAND_OPEN)
         {
@@ -315,38 +315,38 @@ psppire_output_view_put (struct psppire_output_view *view,
           gtk_tree_store_append (store, &iter, p);
         }
 
-      ds_clear (&title);
+      ds_clear (&name);
       if (is_text_item (item))
-        ds_put_cstr (&title, text_item_get_text (to_text_item (item)));
+        ds_put_cstr (&name, text_item_get_text (to_text_item (item)));
       else if (is_message_item (item))
         {
           const struct message_item *msg_item = to_message_item (item);
           const struct msg *msg = message_item_get_msg (msg_item);
-          ds_put_format (&title, "%s: %s", _("Message"),
+          ds_put_format (&name, "%s: %s", _("Message"),
                          msg_severity_to_string (msg->severity));
         }
       else if (is_table_item (item))
         {
-          const char *caption = table_item_get_caption (to_table_item (item));
-          if (caption != NULL)
-            ds_put_format (&title, "Table: %s", caption);
+          const char *title = table_item_get_title (to_table_item (item));
+          if (title != NULL)
+            ds_put_format (&name, "Table: %s", title);
           else
-            ds_put_cstr (&title, "Table");
+            ds_put_cstr (&name, "Table");
         }
       else if (is_chart_item (item))
         {
           const char *s = chart_item_get_title (to_chart_item (item));
           if (s != NULL)
-            ds_put_format (&title, "Chart: %s", s);
+            ds_put_format (&name, "Chart: %s", s);
           else
-            ds_put_cstr (&title, "Chart");
+            ds_put_cstr (&name, "Chart");
         }
       gtk_tree_store_set (store, &iter,
-                          COL_TITLE, ds_cstr (&title),
+                          COL_NAME, ds_cstr (&name),
                          COL_ADDR, item,
                           COL_Y, view->y,
                           -1);
-      ds_destroy (&title);
+      ds_destroy (&name);
 
       path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
       gtk_tree_view_expand_row (view->overview, path, TRUE);
@@ -643,7 +643,7 @@ psppire_output_view_new (GtkLayout *output, GtkTreeView *overview,
     {
       model = GTK_TREE_MODEL (gtk_tree_store_new (
                                 N_COLS,
-                                G_TYPE_STRING,  /* COL_TITLE */
+                                G_TYPE_STRING,  /* COL_NAME */
                                 G_TYPE_POINTER, /* COL_ADDR */
                                 G_TYPE_LONG));  /* COL_Y */
       gtk_tree_view_set_model (overview, model);
@@ -658,7 +658,7 @@ psppire_output_view_new (GtkLayout *output, GtkTreeView *overview,
       gtk_tree_view_append_column (GTK_TREE_VIEW (overview), column);
       renderer = gtk_cell_renderer_text_new ();
       gtk_tree_view_column_pack_start (column, renderer, TRUE);
-      gtk_tree_view_column_add_attribute (column, renderer, "text", COL_TITLE);
+      gtk_tree_view_column_add_attribute (column, renderer, "text", COL_NAME);
 
       g_signal_connect (GTK_TREE_VIEW (overview),
                         "row-activated", G_CALLBACK (on_row_activate), view);