[ooo-build-commit] .: 2 commits - scratch/mso-dumper
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Mar 23 17:45:02 PDT 2010
scratch/mso-dumper/src/globals.py | 7 +++++--
scratch/mso-dumper/src/msodraw.py | 1 -
scratch/mso-dumper/src/xlsmodel.py | 9 +++++++++
scratch/mso-dumper/src/xlsrecord.py | 17 +++++++++++++----
4 files changed, 27 insertions(+), 7 deletions(-)
New commits:
commit 28458152be086dd14799d55387a10b9c55182461
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Mar 23 20:42:56 2010 -0400
[mso-dumper] Display cached formula results in cXML mode.
* scratch/mso-dumper/src/xlsmodel.py:
* scratch/mso-dumper/src/xlsrecord.py:
diff --git a/scratch/mso-dumper/src/xlsmodel.py b/scratch/mso-dumper/src/xlsmodel.py
index 876572e..3a1961e 100644
--- a/scratch/mso-dumper/src/xlsmodel.py
+++ b/scratch/mso-dumper/src/xlsmodel.py
@@ -233,6 +233,7 @@ class Worksheet(SheetBase):
self.__hiddenRows = Worksheet.OrderedRangeList()
self.__rowHeights = Worksheet.OrderedRangeList()
self.__shapes = []
+ self.__lastCell = None
def addShape (self, obj):
self.__shapes.append(obj)
@@ -259,6 +260,10 @@ class Worksheet(SheetBase):
self.__rows[row] = {}
self.__rows[row][col] = cell
+ self.__lastCell = cell
+
+ def getLastCell (self):
+ return self.__lastCell
def setRowHidden (self, row):
self.__hiddenRows.setValue(row, True)
@@ -401,6 +406,7 @@ class FormulaCell(CellBase):
def __init__ (self):
CellBase.__init__(self, CellBase.Type.Formula)
self.tokens = None
+ self.cachedResult = None
def createDOM (self, wb):
nd = node.Element('formula-cell')
@@ -410,6 +416,9 @@ class FormulaCell(CellBase):
nd.setAttr('formula', parser.getText())
s = globals.getRawBytes(self.tokens, True, False)
nd.setAttr('token-bytes', s)
+ if self.cachedResult != None:
+ nd.setAttr('formula-result', self.cachedResult)
+
return nd
diff --git a/scratch/mso-dumper/src/xlsrecord.py b/scratch/mso-dumper/src/xlsrecord.py
index 42c289b..aec7944 100644
--- a/scratch/mso-dumper/src/xlsrecord.py
+++ b/scratch/mso-dumper/src/xlsrecord.py
@@ -560,6 +560,7 @@ class Formula(BaseRecordHandler):
sheet = model.getCurrentSheet()
cell = xlsmodel.FormulaCell()
cell.tokens = self.tokens
+ cell.cachedResult = self.fval
sheet.setCell(self.col, self.row, cell)
@@ -872,10 +873,19 @@ class RK(BaseRecordHandler):
class String(BaseRecordHandler):
"""Cached string formula result for preceding formula record."""
- def parseBytes (self):
+ def __parseBytes (self):
strLen = globals.getSignedInt(self.bytes[0:1])
- name, byteLen = globals.getRichText(self.bytes[2:], strLen)
- self.appendLine("string value: '%s'"%name)
+ self.name, byteLen = globals.getRichText(self.bytes[2:], strLen)
+
+ def parseBytes (self):
+ self.__parseBytes()
+ self.appendLine("string value: '%s'"%self.name)
+
+ def fillModel (self, model):
+ self.__parseBytes()
+ cell = model.getCurrentSheet().getLastCell()
+ if cell.modelType == xlsmodel.CellBase.Type.Formula:
+ cell.cachedResult = self.name
class SST(BaseRecordHandler):
commit 770323ac229249f5939d7f426d971112330cac8a
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Mar 23 20:24:13 2010 -0400
[mso-dumper] Convert UTF-16 strings in the FONT records.
* scratch/mso-dumper/src/globals.py:
* scratch/mso-dumper/src/msodraw.py:
* scratch/mso-dumper/src/xlsrecord.py:
diff --git a/scratch/mso-dumper/src/globals.py b/scratch/mso-dumper/src/globals.py
index bcabcf4..ab38062 100644
--- a/scratch/mso-dumper/src/globals.py
+++ b/scratch/mso-dumper/src/globals.py
@@ -246,9 +246,12 @@ Note the following:
totalByteLen = strm.getCurrentPos() + textLen + extraBytes
if is16Bit:
- return ("<16-bit strings not supported yet>", totalByteLen)
+ text = ''
+ for i in xrange(0, textLen):
+ text += toTextBytes(strm.readBytes(2)).decode('utf-16')
+ else:
+ text = toTextBytes(strm.readBytes(textLen))
- text = toTextBytes(strm.readBytes(textLen))
return (text, totalByteLen)
diff --git a/scratch/mso-dumper/src/msodraw.py b/scratch/mso-dumper/src/msodraw.py
index 0feadfa..26835ff 100644
--- a/scratch/mso-dumper/src/msodraw.py
+++ b/scratch/mso-dumper/src/msodraw.py
@@ -588,7 +588,6 @@ class MSODrawHandler(globals.ByteStream):
bytes = self.readBytes(rh.recLen)
self.parent.appendLine(globals.getRawBytes(bytes, True, False))
-
def fillModel (self, model):
sheet = model.getCurrentSheet()
while not self.isEndOfRecord():
diff --git a/scratch/mso-dumper/src/xlsrecord.py b/scratch/mso-dumper/src/xlsrecord.py
index ad45aca..42c289b 100644
--- a/scratch/mso-dumper/src/xlsrecord.py
+++ b/scratch/mso-dumper/src/xlsrecord.py
@@ -2795,7 +2795,6 @@ class MSODrawingSelection(BaseRecordHandler):
def __parseBytes (self):
self.msodHdl = msodraw.MSODrawHandler(self.bytes, self)
-
def parseBytes (self):
self.__parseBytes()
self.msodHdl.parseBytes()
More information about the ooo-build-commit
mailing list