[Libreoffice-commits] .: src/formula.py src/xlsrecord.py src/xlsstream.py
Kohei Yoshida
kohei at kemper.freedesktop.org
Thu Nov 10 19:43:01 PST 2011
src/formula.py | 24 ++++++++++++++++++++++++
src/xlsrecord.py | 16 +++++++++++-----
src/xlsstream.py | 2 +-
3 files changed, 36 insertions(+), 6 deletions(-)
New commits:
commit aa0775b856a5a8c142dab1999b4491e4dc181644
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 10 22:42:36 2011 -0500
Improved parsing of formula tokens in LBL record.
diff --git a/src/formula.py b/src/formula.py
index 530b3b9..8736485 100644
--- a/src/formula.py
+++ b/src/formula.py
@@ -198,6 +198,27 @@ class PtgStr(PtgBase):
def getText (self):
return "(str: '%s')"%self.value
+class PtgAtt(PtgBase):
+ def parseBytes (self):
+ attType = self.strm.readUnsignedInt(1)
+ if attType == 0x01:
+ # PtgAttSemi: volatile
+ self.attName = 'volatile'
+ self.strm.readBytes(2) # ignore bytes
+ else:
+ raise FormulaParserError("unknown attribute token type (0x%2.2X)"%attType)
+
+ def getText (self):
+ return "(att: %s)"%self.attName
+
+class PtgName(PtgBase):
+ def parseBytes (self):
+ self.nameIdx = self.strm.readUnsignedInt(4)
+
+ def getText (self):
+ return "(name: %d)"%self.nameIdx
+
+
class PtgNameX(PtgBase):
def parseBytes (self):
self.xti = self.strm.readUnsignedInt(2)
@@ -643,10 +664,13 @@ _tokenMap = {
0x15: PtgParen,
0x16: PtgMissArg,
0x17: PtgStr,
+ 0x19: PtgAtt,
0x1E: PtgInt,
+ 0x22: PtgFuncVar,
0x24: PtgRef,
0x29: PtgMemFunc,
0x3B: _Area3d,
+ 0x43: PtgName,
0x59: PtgNameX,
0x5B: _Area3d,
0x7B: _Area3d,
diff --git a/src/xlsrecord.py b/src/xlsrecord.py
index fd706de..1fec69c 100644
--- a/src/xlsrecord.py
+++ b/src/xlsrecord.py
@@ -1811,10 +1811,6 @@ class Name(BaseRecordHandler):
def parseBytes (self):
self.__parseBytes()
- tokenText = globals.getRawBytes(self.tokenBytes, True, False)
- o = formula.FormulaParser(self.header, self.tokenBytes)
- o.parse()
- formulaText = o.getText()
self.appendLine("name: %s"%globals.encodeName(self.name))
# is this name global or sheet-local?
@@ -1835,9 +1831,19 @@ class Name(BaseRecordHandler):
# self.appendLine("description length: %d"%self.descTextLen)
# self.appendLine("help tip text length: %d"%self.helpTextLen)
# self.appendLine("status bar text length: %d"%self.statTextLen)
+
+ tokenText = globals.getRawBytes(self.tokenBytes, True, False)
+ o = formula.FormulaParser(self.header, self.tokenBytes)
self.appendLine("formula length: %d"%self.formulaLen)
self.appendLine("formula bytes: " + tokenText)
- self.appendLine("formula: " + formulaText)
+ try:
+ o.parse()
+ formulaText = o.getText()
+ self.appendLine("formula: " + formulaText)
+ except formula.FormulaParserError as e:
+ self.appendLine("Error while parsing the formula tokens (%s)"%e.args[0])
+
+
def fillModel (self, model):
self.__parseBytes()
diff --git a/src/xlsstream.py b/src/xlsstream.py
index 319194a..d000840 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -50,7 +50,7 @@ recData = {
0x0015: ["FOOTER", "Print Footer on Each Page", xlsrecord.Footer],
0x0016: ["EXTERNCOUNT", "Number of External References"],
0x0017: ["EXTERNSHEET", "External Reference", xlsrecord.ExternSheet],
- 0x0018: ["NAME", "Internal Defined Name", xlsrecord.Name],
+ 0x0018: ["LBL", "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"],
More information about the Libreoffice-commits
mailing list