output-item: Collapse the inheritance hierarchy into a single struct.
[pspp] / src / output / spv / spv-output.c
index 00b3dead4729416faa1ca19cb28a63314a850ced..8006f85eb26d09256ca206638acc4b85f95dfcd9 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "output/pivot-table.h"
 #include "output/spv/spv.h"
-#include "output/text-item.h"
+#include "output/output-item.h"
 
 #include "gl/xalloc.h"
 
@@ -28,20 +28,11 @@ void
 spv_text_submit (const struct spv_item *in)
 {
   enum spv_item_class class = spv_item_get_class (in);
-  enum text_item_type type
-    = (class == SPV_CLASS_HEADINGS ? TEXT_ITEM_TITLE
-       : class == SPV_CLASS_PAGETITLE ? TEXT_ITEM_PAGE_TITLE
-       : TEXT_ITEM_LOG);
-  const struct pivot_value *value = spv_item_get_text (in);
-  char *text = pivot_value_to_string (value, SETTINGS_VALUE_SHOW_DEFAULT,
-                                      SETTINGS_VALUE_SHOW_DEFAULT);
-  char *label = in->label ? xstrdup (in->label) : NULL;
-  struct text_item *item = text_item_create_nocopy (type, text, label);
-
-  if (value->font_style)
-    {
-      font_style_uninit (&item->style);
-      font_style_copy (NULL, &item->style, value->font_style);
-    }
-  text_item_submit (item);
+  struct output_item *item = text_item_create_value (
+    (class == SPV_CLASS_HEADINGS ? TEXT_ITEM_TITLE
+     : class == SPV_CLASS_PAGETITLE ? TEXT_ITEM_PAGE_TITLE
+     : TEXT_ITEM_LOG),
+    pivot_value_clone (spv_item_get_text (in)),
+    xstrdup_if_nonnull (in->label));
+  output_item_submit (item);
 }