[ooo-build-commit] scratch/mso-dumper
Kohei Yoshida
kohei at kemper.freedesktop.org
Thu Jan 7 17:08:50 PST 2010
scratch/mso-dumper/src/xlsmodel.py | 26 ++++++++++++++--
scratch/mso-dumper/src/xlsrecord.py | 58 +++++++++++++++++++++---------------
2 files changed, 59 insertions(+), 25 deletions(-)
New commits:
commit 1737f3874c0a938315d4a7aeaed12c061db14bd5
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Thu Jan 7 20:07:43 2010 -0500
[xls-dump] Display hidden rows 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 df13542..c4425b1 100644
--- a/scratch/mso-dumper/src/xlsmodel.py
+++ b/scratch/mso-dumper/src/xlsmodel.py
@@ -169,6 +169,7 @@ class Worksheet(SheetBase):
self.__sheetID = sheetID
self.__firstDefinedCell = None
self.__firstFreeCell = None
+ self.__hiddenRows = [] # list of row ranges stored as pairs (start, end)
def setFirstDefinedCell (self, col, row):
self.__firstDefinedCell = formula.CellAddress(col, row)
@@ -193,6 +194,18 @@ class Worksheet(SheetBase):
self.__rows[row][col] = cell
+ def setRowHidden (self, row):
+ if len(self.__hiddenRows) == 0:
+ self.__hiddenRows.append([row, row])
+ return
+
+ if (row - self.__hiddenRows[-1][1]) <= 1:
+ # expand the last range.
+ self.__hiddenRows[-1][1] = row
+ else:
+ # start a new range.
+ self.__hiddenRows.append([row, row])
+
def createDOM (self, wb):
nd = node.Element('worksheet')
nd.setAttr('version', self.version)
@@ -217,11 +230,20 @@ class Worksheet(SheetBase):
if self.__firstFreeCell != None:
nd.setAttr('first-free-cell', self.__firstFreeCell.getName())
- # autofilter (if exists)
- self.__appendAutoFilterNode(wb, nd)
+ self.__appendAutoFilterNode(wb, nd) # autofilter (if exists)
+ self.__appendHiddenRowsNode(wb, nd) # hidden rows
return nd
+ def __appendHiddenRowsNode (self, wb, baseNode):
+ if len(self.__hiddenRows) == 0:
+ # no hidden rows
+ return
+
+ elem = baseNode.appendElement('hidden-rows')
+ for rowRange in self.__hiddenRows:
+ rangeNode = elem.appendElement('range').setAttr('span', "%d:%d"%(rowRange[0]+1, rowRange[1]+1))
+
def __appendAutoFilterNode (self, wb, baseNode):
if len(self.__autoFilterArrows) <= 0:
# No autofilter in this sheet.
diff --git a/scratch/mso-dumper/src/xlsrecord.py b/scratch/mso-dumper/src/xlsrecord.py
index 75582e9..fd9c98a 100644
--- a/scratch/mso-dumper/src/xlsrecord.py
+++ b/scratch/mso-dumper/src/xlsrecord.py
@@ -919,37 +919,49 @@ class ColInfo(BaseRecordHandler):
class Row(BaseRecordHandler):
+ def __parseBytes (self):
+ self.row = self.readUnsignedInt(2)
+ self.col1 = self.readUnsignedInt(2)
+ self.col2 = self.readUnsignedInt(2)
+
+ flag = self.readUnsignedInt(2)
+ self.rowHeight = (flag & 0x7FFF)
+ self.defaultHeight = ((flag & 0x8000) == 1)
+ self.irwMac = self.readUnsignedInt(2)
+
+ dummy = self.readUnsignedInt(2)
+ flag = self.readUnsignedInt(2)
+ self.outLevel = (flag & 0x0007)
+ self.collapsed = (flag & 0x0010)
+ self.zeroHeight = (flag & 0x0020)
+ self.unsynced = (flag & 0x0040)
+ self.ghostDirty = (flag & 0x0080)
+
def parseBytes (self):
- row = self.readUnsignedInt(2)
- col1 = self.readUnsignedInt(2)
- col2 = self.readUnsignedInt(2)
+ self.__parseBytes()
- rowHeightBits = self.readUnsignedInt(2)
- rowHeight = (rowHeightBits & 0x7FFF)
- defaultHeight = ((rowHeightBits & 0x8000) == 1)
+ self.appendLine("row: %d; col: %d - %d"%(self.row, self.col1, self.col2))
+ self.appendLine("row height (twips): %d"%self.rowHeight)
- self.appendLine("row: %d; col: %d - %d"%(row, col1, col2))
- self.appendLine("row height (twips): %d"%rowHeight)
- if defaultHeight:
+ if self.defaultHeight:
self.appendLine("row height type: default")
else:
self.appendLine("row height type: custom")
- irwMac = self.readUnsignedInt(2)
- self.appendLine("optimize flag (0 for BIFF): %d"%irwMac)
+ self.appendLine("optimize flag (0 for BIFF): %d"%self.irwMac)
- dummy = self.readUnsignedInt(2)
- flags = self.readUnsignedInt(2)
- outLevel = (flags & 0x0007)
- collapsed = (flags & 0x0010)
- zeroHeight = (flags & 0x0020)
- unsynced = (flags & 0x0040)
- ghostDirty = (flags & 0x0080)
- self.appendLine("outline level: %d"%outLevel)
- self.appendLine("collapsed: %s"%self.getYesNo(collapsed))
- self.appendLine("zero height: %s"%self.getYesNo(zeroHeight))
- self.appendLine("unsynced: %s"%self.getYesNo(unsynced))
- self.appendLine("ghost dirty: %s"%self.getYesNo(ghostDirty))
+ self.appendLine("outline level: %d"%self.outLevel)
+ self.appendLine("collapsed: %s"%self.getYesNo(self.collapsed))
+ self.appendLine("zero height: %s"%self.getYesNo(self.zeroHeight))
+ self.appendLine("unsynced: %s"%self.getYesNo(self.unsynced))
+ self.appendLine("ghost dirty: %s"%self.getYesNo(self.ghostDirty))
+
+ def fillModel (self, model):
+ self.__parseBytes()
+ sh = model.getCurrentSheet()
+ # store whether or not this row is hidden.
+ if self.zeroHeight:
+ sh.setRowHidden(self.row)
class Name(BaseRecordHandler):
More information about the ooo-build-commit
mailing list