[Libreoffice-commits] .: src/xlsrecord.py src/xlsstream.py
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Mar 18 15:24:24 PDT 2011
src/xlsrecord.py | 63 ++++++++++++++++++++++++++++++++++---------------------
src/xlsstream.py | 2 -
2 files changed, 40 insertions(+), 25 deletions(-)
New commits:
commit c3aa04a63838954bdbea8f1aab68f37b52f37a3e
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Mar 18 18:21:40 2011 -0400
Reworked chart data source record handler.
Renamed it to BRAI as it's the name used in Microsoft's spec
([MS-XLS].pdf).
diff --git a/src/xlsrecord.py b/src/xlsrecord.py
index 57c3521..170a695 100644
--- a/src/xlsrecord.py
+++ b/src/xlsrecord.py
@@ -3277,39 +3277,54 @@ class CHLine(BaseRecordHandler):
class CHSourceLink(BaseRecordHandler):
destTypes = ['title', 'values', 'category', 'bubbles']
- linkTypes = ['default', 'directly', 'worksheet']
+ linkTypes = ['auto', 'direct value', 'reference']
- DEST_TITLE = 0;
- DEST_VALUES = 1;
- DEST_CATEGORY = 2;
- DEST_BUBBLES = 3;
+ DEST_TITLE = 0
+ DEST_VALUES = 1
+ DEST_CATEGORY = 2
+ DEST_BUBBLES = 3
- LINK_DEFAULT = 0;
- LINK_DIRECTLY = 1;
- LINK_WORKSHEET = 2;
+ # Data source type
+ class DataSourceType:
+ Auto = 0 # category name, series name or bubble size that was automatically generated.
+ Value = 1 # text or value as specified by the formula field
+ Reference = 2 # value from a range of cells as specified by the formula field
- def parseBytes (self):
- destType = self.readUnsignedInt(1)
- linkType = self.readUnsignedInt(1)
+ def __parseBytes (self):
+ self.destType = self.readUnsignedInt(1)
+ self.linkType = self.readUnsignedInt(1)
flags = self.readUnsignedInt(2)
- numFmt = self.readUnsignedInt(2)
+ self.numFmt = self.readUnsignedInt(2)
- destName = 'unknown'
- if destType < len(CHSourceLink.destTypes):
- destName = CHSourceLink.destTypes[destType]
+ self.destName = 'unknown'
+ if self.destType < len(CHSourceLink.destTypes):
+ self.destName = CHSourceLink.destTypes[self.destType]
+
+ self.linkName = 'unknown'
+ if self.linkType < len(CHSourceLink.linkTypes):
+ self.linkName = CHSourceLink.linkTypes[self.linkType]
- linkName = 'unknown'
- if linkType < len(CHSourceLink.linkTypes):
- linkName = CHSourceLink.linkTypes[linkType]
+ if self.linkType == CHSourceLink.DataSourceType.Reference:
+ lenToken = self.readUnsignedInt(2)
+ self.tokens = self.readBytes(lenToken)
- self.appendLine("destination type: %s"%destName)
- self.appendLine("link type: %s"%linkName)
+ self.useNumFormat = (flags & 0x0001) != 0
- if linkType == CHSourceLink.LINK_WORKSHEET:
+ def parseBytes (self):
+ self.__parseBytes()
+
+ self.appendLine("destination type: %s"%self.destName)
+ self.appendLine("link type: %s"%self.linkName)
+
+ if self.linkType == CHSourceLink.DataSourceType.Reference:
# external reference. Read the formula tokens.
- lenToken = self.readUnsignedInt(2)
- tokens = self.readBytes(lenToken)
- self.appendLine("formula tokens: %s"%globals.getRawBytes(tokens,True,False))
+ self.appendLine("formula tokens: %s"%globals.getRawBytes(self.tokens,True,False))
+ parser = formula.FormulaParser2(self.header, self.tokens)
+ parser.parse()
+ self.appendLine("formula: %s"%parser.getText())
+
+ if self.useNumFormat:
+ self.appendLine("number format: %d"%self.numFmt)
class MSODrawing(BaseRecordHandler):
diff --git a/src/xlsstream.py b/src/xlsstream.py
index f7a195a..268f223 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -282,7 +282,7 @@ recData = {
0x104E: ["CHFORMAT", "?"],
0x104F: ["CHFRAMEPOS", "?"],
0x1050: ["CHFORMATRUNS", "?"],
- 0x1051: ["CHSOURCELINK", "Data Source of A Chart", xlsrecord.CHSourceLink],
+ 0x1051: ["BRAI", "Data Source of A Chart", xlsrecord.CHSourceLink],
0x105B: ["CHSERERRORBAR", "?"],
0x105D: ["CHSERIESFORMAT", "?"],
0x105F: ["CH3DDATAFORMAT", "?"],
More information about the Libreoffice-commits
mailing list