[Libreoffice-commits] .: src/formula.py src/xlsrecord.py
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Apr 8 21:03:14 PDT 2011
src/formula.py | 9 ++++++
src/xlsrecord.py | 76 ++++++++++---------------------------------------------
2 files changed, 23 insertions(+), 62 deletions(-)
New commits:
commit e844245a8237addbf90de60305d498e4a7b219a8
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Sat Apr 9 00:01:27 2011 -0400
Redo the parsing of ARRAY record, and parse PtgNameX formula token.
diff --git a/src/formula.py b/src/formula.py
index 9d9e869..6b0fa1d 100644
--- a/src/formula.py
+++ b/src/formula.py
@@ -409,6 +409,14 @@ class PtgExp(PtgBase):
def getText (self):
return "(ptgexp: row=%d, col=%d)"%(self.row, self.col)
+class PtgNameX(PtgBase):
+ def parseBytes (self):
+ self.xti = self.strm.readUnsignedInt(2)
+ self.nameID = self.strm.readUnsignedInt(4)
+
+ def getText (self):
+ return "(xti=%d,name=%d)"%(self.xti, self.nameID)
+
class _Int(PtgBase):
def parseBytes (self):
self.value = self.strm.readUnsignedInt(2)
@@ -840,6 +848,7 @@ _tokenMap = {
0x01: PtgExp,
0x1E: _Int,
0x3B: _Area3d,
+ 0x59: PtgNameX,
0x5B: _Area3d,
0x7B: _Area3d,
diff --git a/src/xlsrecord.py b/src/xlsrecord.py
index ffd04ce..7644dc7 100644
--- a/src/xlsrecord.py
+++ b/src/xlsrecord.py
@@ -969,70 +969,22 @@ class Formula(BaseRecordHandler):
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)
+ def __parseBytes (self):
+ self.ref = RefU(self)
+ flag = self.readUnsignedInt(2)
+ self.alwaysCalc = (flag & 0x0001) != 0
+ unused = self.readBytes(4)
+ tokenSize = self.readUnsignedInt(2)
+ self.tokens = self.readBytes(tokenSize)
- fparser = formula.FormulaParser(self.header, tokens)
+ def parseBytes (self):
+ self.__parseBytes()
+ self.appendLine("range: %s"%self.ref.toString())
+ self.appendLineBoolean("always calc", self.alwaysCalc)
+ fparser = formula.FormulaParser2(self.header, self.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)
-
- if self.getCurrentPos() >= len(self.bytes):
- return
-
- # cached values
- cols = self.readUnsignedInt(1) + 1
- rows = self.readUnsignedInt(2) + 1
- self.appendLine("array size: cols=%d, rows=%d"%(cols, rows))
- for row in xrange(0, rows):
- for col in xrange(0, cols):
- msg = "(row=%d, col=%d): "%(row, col)
- valtype = self.readUnsignedInt(1)
- if valtype == 0x00:
- # empty - ignore 8 bytes.
- self.readUnsignedInt(8)
- msg += "empty"
- elif valtype == 0x01:
- # double
- val = self.readDouble()
- msg += "double: %g"%val
- elif valtype == 0x02:
- # string
- strLen = self.readUnsignedInt(2) + 1
- text, strLen = globals.getRichText(self.readBytes(strLen), strLen)
- msg += "text: '%s'"%text
- elif valtype == 0x04:
- # bool
- val = self.readUnsignedInt(1)
- msg += "bool: " + self.getTrueFalse(val)
- elif valtype == 0x10:
- # error
- val = self.readUnsignedInt(1)
- msg += "error: %d"%val
- self.appendLine(msg)
-
- return
-
+ self.appendLine("formula bytes: %s"%globals.getRawBytes(self.tokens, True, False))
+ self.appendLine("formula string: %s"%fparser.getText())
class Label(BaseRecordHandler):
More information about the Libreoffice-commits
mailing list