[ooo-build-commit] scratch/mso-dumper

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Jul 16 17:40:53 PDT 2009


 scratch/mso-dumper/src/xlsrecord.py |   31 +++++++++++++++++++++++++++++++
 scratch/mso-dumper/src/xlsstream.py |    5 +++--
 2 files changed, 34 insertions(+), 2 deletions(-)

New commits:
commit fd9f519d49c8aa24680bb1e711bc6eae8020faf4
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jul 16 18:20:28 2009 -0400

    [xls-dump] Added handler for ARRAY records (0x0221)
    
    An undocumented record whose opcode is 0x0021 looks awfully similar
    to the ARRAY record (0x0221).  I'll treat them as the same record
    for now.
    
    * scratch/mso-dumper/src/xlsrecord.py:
    * scratch/mso-dumper/src/xlsstream.py:

diff --git a/scratch/mso-dumper/src/xlsrecord.py b/scratch/mso-dumper/src/xlsrecord.py
index 2fa18b9..1db916d 100644
--- a/scratch/mso-dumper/src/xlsrecord.py
+++ b/scratch/mso-dumper/src/xlsrecord.py
@@ -242,6 +242,37 @@ class Formula(BaseRecordHandler):
         self.appendLine("tokens: "+ftext)
 
 
+class Array(BaseRecordHandler):
+
+    def parseBytes (self):
+        row1 = self.readUnsignedInt(2)
+        row2 = self.readUnsignedInt(2)
+        col1 = self.readUnsignedInt(1)
+        col2 = self.readUnsignedInt(1)
+
+        flags = self.readUnsignedInt(2)
+        alwaysCalc = (0x01 & flags)
+        calcOnLoad = (0x02 & flags)
+
+        # Ignore these bits when reading a BIFF file.  When a BIFF file is 
+        # being written, chn must be 00000000.
+        chn = self.readUnsignedInt(4)
+
+        fmlLen = self.readUnsignedInt(2)
+        tokens = self.readBytes(fmlLen)
+
+        fparser = formula.FormulaParser(self.header, tokens)
+        fparser.parse()
+        ftext = fparser.getText()
+
+        self.appendLine("rows: %d - %d"%(row1, row2))
+        self.appendLine("columns: %d - %d"%(col1, col2))
+        self.appendLine("always calculate formula: " + self.getTrueFalse(alwaysCalc))
+        self.appendLine("calculate formula on file load: " + self.getTrueFalse(calcOnLoad))
+        self.appendLine("formula bytes: %s"%globals.getRawBytes(tokens, True, False))
+        self.appendLine("tokens: " + ftext)
+
+
 class Label(BaseRecordHandler):
 
     def parseBytes (self):
diff --git a/scratch/mso-dumper/src/xlsstream.py b/scratch/mso-dumper/src/xlsstream.py
index c30ba61..1d79bed 100644
--- a/scratch/mso-dumper/src/xlsstream.py
+++ b/scratch/mso-dumper/src/xlsstream.py
@@ -8,7 +8,7 @@ class EndOfStream(Exception): pass
     # opcode: [canonical name, description, handler (optional)]
 
 recData = {
-    0x0006: ["FORMULA", "Formula Token Array and Result", xlsrecord.Formula],
+    0x0006: ["FORMULA", "Cell Formula", xlsrecord.Formula],
     0x000A: ["EOF", "End of File"],
     0x000C: ["CALCCOUNT", "Iteration Count"],
     0x000D: ["CALCMODE", "Calculation Mode"],
@@ -24,6 +24,7 @@ recData = {
     0x0017: ["EXTERNSHEET", "External Reference", xlsrecord.ExternSheet],
     0x0018: ["NAME", "Internal Defined Name", xlsrecord.Name],
     0x0019: ["WINDOWPROTECT", "Windows Are Protected"],
+    0x0021: ["ARRAY", "Array-Entered Formula", xlsrecord.Array], # undocumented, but identical to 0x0221 ?
     0x001A: ["VERTICALPAGEBREAKS", "Explicit Column Page Breaks"],
     0x001B: ["HORIZONTALPAGEBREAKS", "Explicit Row Page Breaks"],
     0x001C: ["NOTE", "Comment Associated with a Cell"],
@@ -181,7 +182,7 @@ recData = {
     0x0208: ["ROW", "Describes a Row", xlsrecord.Row],
     0x020B: ["INDEX", "Index Record"],
     0x0218: ["NAME", "Defined Name"],
-    0x0221: ["ARRAY", "Array-Entered Formula"],
+    0x0221: ["ARRAY", "Array-Entered Formula", xlsrecord.Array],
     0x0223: ["EXTERNNAME", "Externally Referenced Name"],
     0x0225: ["DEFAULTROWHEIGHT", "Default Row Height"],
     0x0231: ["FONT", "Font Description"],


More information about the ooo-build-commit mailing list