Figure out cell styling details.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 29 May 2017 05:52:59 +0000 (22:52 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 29 May 2017 05:52:59 +0000 (22:52 -0700)
dump.c
spv-file-format.texi

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);
index 50a94141b924452dc0ee9bd255d6c4d2acdc6d35..09e620e9ae31edba4eeb2066ab6dc8bcaddc7687 100644 (file)
@@ -1264,10 +1264,23 @@ ValueMod @result{}
     v3(count(FormatString Style ValueModUnknown))
   @math{|} 31 int[@t{n-refs}] int16*[@t{n-refs}] Format
   @math{|} 58
-Style @result{} 58 @math{|} 31 01? 00? 00? 00? 01 string[@t{fgcolor}] string[@t{bgcolor}] string[@t{typeface}] byte[@t{size}]
+
+Style @result{}
+    58
+  @math{|} 31
+    bool[@t{bold}] bool[@t{italic}] bool[@t{underline}] bool
+    string[@t{fgcolor}] string[@t{bgcolor}]
+    string[@t{typeface}] byte[@t{size}]
+
 Format @result{} 00 00 count(FormatString Style 58)
+
 FormatString @result{} count((i0 (58 @math{|} 31 string))?)
-ValueModUnknown @result{} 58 @math{|} 31 i0 i0 i0 i0 01 00 (01 @math{|} 02 @math{|} 08) 00 08 00 0a 00)
+
+ValueModUnknown @result{}
+    58
+  @math{|} 31 int[@t{halign}] int[@t{valign}] double[@t{offset}]
+    int16[@t{left-margin}] int16[@t{right-margin}]
+    int16[@t{top-margin}] int16[@t{bottom-margin}]
 @end format
 @end cartouche
 
@@ -1290,6 +1303,17 @@ Format is nested.
 The Style, if present, changes the style for this individual Value.
 The @code{size} is a font size in units of 1/96 inch.
 
+@code{halign} is 0 for center, 2 for left, 4 for right, 6 for decimal,
+0xffffffad for mixed.  For decimal alignment, @code{offset} is the
+decimal point's offset from the right side of the cell, in units of
+1/72 inch.
+
+@code{valign} specifies vertical alignment: 0 for center, 1 for top, 3
+for bottom.
+
+@code{left-margin}, @code{right-margin}, @code{top-margin}, and
+@code{bottom-margin} are in units of 1/72 inch.
+
 @node SPV Legacy Detail Member Binary Format
 @section Legacy Detail Member Binary Format