HTML output driver: Correct typo
[pspp] / tests / output / render-test.c
index 506afbf09176501e2c44b6c00cd23c41adb922e9..19bb0ccfab5321a8312b015bfe466ec43e5009f6 100644 (file)
@@ -28,7 +28,7 @@
 #include "libpspp/string-map.h"
 #include "output/ascii.h"
 #include "output/driver.h"
-#include "output/tab.h"
+#include "output/table.h"
 #include "output/table-item.h"
 
 #include "gl/error.h"
@@ -346,7 +346,7 @@ replace_newlines (char *p)
 {
   char *q;
 
-  for (q = p; *p != '\0'; )
+  for (q = p; *p != '\0';)
     if (*p == '\\' && p[1] == 'n')
       {
         *q++ = '\n';
@@ -381,12 +381,11 @@ read_table (FILE *stream)
   ht = n_input >= 5 ? input[4] : 0;
   hb = n_input >= 6 ? input[5] : 0;
 
-  tab = tab_create (nc, nr, hl, hr, ht, hb);
+  tab = table_create (nc, nr, hl, hr, ht, hb);
   for (r = 0; r < nr; r++)
     for (c = 0; c < nc; c++)
-      if (tab_cell_is_empty (tab, c, r))
+      if (table_cell_is_empty (tab, c, r))
         {
-          unsigned int opt;
           char *new_line;
           char *text;
           int rs, cs;
@@ -412,44 +411,47 @@ read_table (FILE *stream)
               cs = 1;
             }
 
-          opt = 0;
+#define S(H) { AREA_STYLE_INITIALIZER__, .cell_style.halign = H }
+          static const struct area_style left_style = S (TABLE_HALIGN_LEFT);
+          static const struct area_style right_style = S (TABLE_HALIGN_RIGHT);
+          static const struct area_style center_style
+            = S (TABLE_HALIGN_CENTER);
+
+          const struct area_style *style = &right_style;
           while (*text && strchr ("<>^,@()|", *text))
             switch (*text++)
               {
               case '<':
-                tab_vline (tab, TAL_1, c, r, r + rs - 1);
+                table_vline (tab, TABLE_STROKE_SOLID, c, r, r + rs - 1);
                 break;
 
               case '>':
-                tab_vline (tab, TAL_1, c + cs, r, r + rs - 1);
+                table_vline (tab, TABLE_STROKE_SOLID, c + cs, r, r + rs - 1);
                 break;
 
               case '^':
-                tab_hline (tab, TAL_1, c, c + cs - 1, r);
+                table_hline (tab, TABLE_STROKE_SOLID, c, c + cs - 1, r);
                 break;
 
               case ',':
-                tab_hline (tab, TAL_1, c, c + cs - 1, r + rs);
+                table_hline (tab, TABLE_STROKE_SOLID, c, c + cs - 1, r + rs);
                 break;
 
               case '@':
-                tab_box (tab, TAL_1, TAL_1, -1, -1, c, r,
-                         c + cs - 1, r + rs - 1);
+                table_box (tab, TABLE_STROKE_SOLID, TABLE_STROKE_SOLID,
+                           -1, -1, c, r, c + cs - 1, r + rs - 1);
                 break;
 
               case '(':
-                opt &= ~TAB_HALIGN;
-                opt |= TAB_LEFT;
+                style = &left_style;
                 break;
 
               case ')':
-                opt &= ~TAB_HALIGN;
-                opt |= TAB_RIGHT;
+                style = &right_style;
                 break;
 
               case '|':
-                opt &= ~TAB_HALIGN;
-                opt |= TAB_CENTER;
+                style = &center_style;
                 break;
 
               default:
@@ -464,14 +466,18 @@ read_table (FILE *stream)
 
           for (i = 0; (content = strsep (&pos, "#")) != NULL; i++)
             if (!i)
-              tab_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt,
-                              content);
+              {
+                table_joint_text (tab, c, r, c + cs - 1, r + rs - 1, 0,
+                                  content);
+                table_add_style (tab, c, r, style);
+              }
             else
               {
                 char marker[2] = { 'a' + n_footnotes, '\0' };
-                struct footnote *f = tab_create_footnote (
-                  tab, n_footnotes, content, marker, NULL);
-                tab_add_footnote (tab, c, r, f);
+                struct footnote *f = table_create_footnote (
+                  tab, n_footnotes, content, marker,
+                  area_style_clone (tab->container, &left_style));
+                table_add_footnote (tab, c, r, f);
                 n_footnotes++;
               }
         }