[Libreoffice-commits] .: 2 commits - src/xlsrecord.py src/xlsstream.py
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Aug 8 16:02:13 PDT 2011
src/xlsrecord.py | 84 ++++++++++++++++++++++++++-----------------------------
src/xlsstream.py | 5 +--
2 files changed, 42 insertions(+), 47 deletions(-)
New commits:
commit b78a9750b5f371bb7bcdfc92ceb8d35d50141160
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Aug 8 19:04:41 2011 -0400
Reworked the handler for BRAI record, which stores linked data type.
diff --git a/src/xlsrecord.py b/src/xlsrecord.py
index 4e013c8..d37bd9b 100644
--- a/src/xlsrecord.py
+++ b/src/xlsrecord.py
@@ -3522,58 +3522,40 @@ class CHLine(BaseRecordHandler):
self.appendLine("shadow: %s"%self.getYesNo(shadow))
-class CHSourceLink(BaseRecordHandler):
+class Brai(BaseRecordHandler):
- destTypes = ['title', 'values', 'category', 'bubbles']
- linkTypes = ['auto', 'direct value', 'reference']
+ destTypes = [
+ 'series, legend entry, trendline name, or error bars name',
+ 'values or horizontal values',
+ 'categories or vertical values',
+ 'bubble size values of the series']
- DEST_TITLE = 0
- DEST_VALUES = 1
- DEST_CATEGORY = 2
- DEST_BUBBLES = 3
-
- # 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
+ linkTypes = [
+ 'auto-generated category name, series name, or bubble size',
+ 'text or value',
+ 'range of cells']
def __parseBytes (self):
- self.destType = self.readUnsignedInt(1)
- self.linkType = self.readUnsignedInt(1)
- flags = self.readUnsignedInt(2)
- self.numFmt = self.readUnsignedInt(2)
-
- 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]
-
- if self.linkType == CHSourceLink.DataSourceType.Reference:
- lenToken = self.readUnsignedInt(2)
- self.tokens = self.readBytes(lenToken)
-
- self.useNumFormat = (flags & 0x0001) != 0
+ self.id = self.readUnsignedInt(1)
+ self.rt = self.readUnsignedInt(1)
+ flag = self.readUnsignedInt(2)
+ self.unlinkedIFmt = (flag & 0x0001) != 0
+ self.iFmt = self.readUnsignedInt(2)
+ tokenCount = self.readUnsignedInt(2)
+ # TODO: parse chart formula tokens here.
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.
- self.appendLine("formula tokens: %s"%globals.getRawBytes(self.tokens,True,False))
- parser = formula.FormulaParser(self.header, self.tokens)
- parser.parse()
- self.appendLine("formula: %s"%parser.getText())
-
- if self.useNumFormat:
- self.appendLine("number format: %d"%self.numFmt)
+ self.appendLine("part type: %s"%globals.getValueOrUnknown(Brai.destTypes, self.id))
+ self.appendLine("referenced data type: %s"%globals.getValueOrUnknown(Brai.linkTypes, self.rt))
+ s = "number format: "
+ if self.unlinkedIFmt:
+ s += "custom format"
+ else:
+ s += "source data format"
+ self.appendLine(s)
+ self.appendLine("number format ID: %d"%self.iFmt)
class MSODrawing(BaseRecordHandler):
"""Handler for the MSODRAWING record
diff --git a/src/xlsstream.py b/src/xlsstream.py
index b71da54..f775e1c 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -282,7 +282,7 @@ recData = {
0x104E: ["CHFORMAT", "?"],
0x104F: ["CHFRAMEPOS", "?"],
0x1050: ["CHFORMATRUNS", "?"],
- 0x1051: ["BRAI", "Data Source of A Chart", xlsrecord.CHSourceLink],
+ 0x1051: ["BRAI", "Data Source of A Chart", xlsrecord.Brai],
0x105B: ["CHSERERRORBAR", "?"],
0x105D: ["CHSERIESFORMAT", "?"],
0x105F: ["CH3DDATAFORMAT", "?"],
commit d16db062d11885900a7225274d31c73c1f0be0c0
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Aug 8 18:25:21 2011 -0400
Handler for SERIESTEXT record.
SeriesText record store string data for misc items in a chart.
diff --git a/src/xlsrecord.py b/src/xlsrecord.py
index 8dc4d9d..4e013c8 100644
--- a/src/xlsrecord.py
+++ b/src/xlsrecord.py
@@ -181,6 +181,9 @@ Like parseBytes(), the derived classes must overwrite this method."""
else:
return falseStr
+ def readShortXLUnicodeString (self):
+ cch = self.readUnsignedInt(1)
+ return self.readUnicodeString(cch)
class AutofilterInfo(BaseRecordHandler):
@@ -1341,6 +1344,17 @@ class Scl(BaseRecordHandler):
val /= self.denominator
self.appendLine("zoom level: %g"%val)
+class SeriesText(BaseRecordHandler):
+
+ def __parseBytes (self):
+ self.readBytes(2) # must be zero, ignored.
+ self.text = self.readShortXLUnicodeString()
+
+ def parseBytes (self):
+ self.__parseBytes()
+ self.appendLine("text: '%s'"%self.text)
+
+
class String(BaseRecordHandler):
"""Cached string formula result for preceding formula record."""
diff --git a/src/xlsstream.py b/src/xlsstream.py
index bf3a4ac..b71da54 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -242,11 +242,10 @@ recData = {
0x1006: ["CHDATAFORMAT", "?"],
0x1007: ["LINEFORMAT", "Appearance of A Line"],
0x1009: ["CHMARKERFORMAT", "?"],
- 0x100D: ["CHSTRING", "Series Category Name or Title Text in Chart"],
0x100A: ["AREAFORMAT", "Patterns and Colors in Filled Region of Chart"],
0x100B: ["CHPIEFORMAT", "?"],
0x100C: ["CHATTACHEDLABEL", "?"],
- 0x100D: ["CHSTRING", "?"],
+ 0x100D: ["SERIESTEXT", "Series Category Name or Title Text in Chart", xlsrecord.SeriesText],
0x1014: ["CHTYPEGROUP", "?"],
0x1015: ["CHLEGEND", "?", xlsrecord.CHLegend],
0x1017: ["CHBAR, CHCOLUMN", "?", xlsrecord.CHBar],
More information about the Libreoffice-commits
mailing list