Figure out cell styling details.
[pspp] / dump.c
diff --git a/dump.c b/dump.c
index 205167951ca20dab22cf99d3b8143111d5d59abb..991dd366b4515bae2da7fdb4bc243100bf99473a 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -384,18 +384,13 @@ dump_counted_string(void)
 static void
 dump_style(FILE *stream)
 {
-  match_byte(1);
-  match_byte(0);
-  match_byte(0);
-  match_byte(0);
-  match_byte_assert(1);
+  for (int i = 0; i < 4; i++)
+    printf (" %d", get_byte());
   char *fg = get_string();     /* foreground */
   char *bg = get_string();     /* background */
   char *font = get_string();     /* font */
-  int size = data[pos];
-  if (!match_byte(14))
-    match_byte_assert(12); /* size? */
-  fprintf(stream, " fgcolor=\"%s\" bgcolor=\"%s\" font=\"%s\" size=\"%d\"",
+  int size = get_byte() * (72. / 96.);
+  fprintf(stream, " fgcolor=\"%s\" bgcolor=\"%s\" font=\"%s\" size=\"%dpt\"",
           fg, bg, font, size);
 }
 
@@ -477,21 +472,26 @@ dump_value_modifier(FILE *stream)
             match_byte_assert(0x58);
           if (match_byte(0x31))
             {
-              /* Only two SPV files have anything like this, so it's hard to
-                 generalize. */
-              match_u32_assert(0);
-              match_u32_assert(0);
-              match_u32_assert(0);
-              match_u32_assert(0);
-              match_byte_assert(1);
-              match_byte_assert(0);
-              if (!match_byte(8) && !match_byte(1))
-                match_byte_assert(2);
-              match_byte_assert(0);
-              match_byte_assert(8);
-              match_byte_assert(0);
-              match_byte_assert(10);
-              match_byte_assert(0);
+              uint32_t halign = get_u32();
+              printf (" halign=\"%s\"",
+                      halign == 0 ? "center"
+                      : halign == 2 ? "left"
+                      : halign == 4 ? "right"
+                      : halign == 6 ? "decimal"
+                      : halign == 0xffffffad ? "mixed"
+                      : "<error>");
+              int valign = get_u32();
+              printf (" valign=\"%s\"",
+                      valign == 0 ? "center"
+                      : valign == 1 ? "top"
+                      : valign == 3 ? "bottom"
+                      : "<error>");
+              printf (" %g", get_double());
+              int l = get_u16();
+              int r = get_u16();
+              int t = get_u16();
+              int b = get_u16();
+              printf (" margins=\"%d %d %d %d\"", l, r, t, b);
             }
           else
             match_byte_assert(0x58);