[ooo-build-commit] .: scratch/mso-dumper

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Apr 14 15:43:14 PDT 2010


 scratch/mso-dumper/src/xlsmodel.py  |   26 +++++++++++++++++++++++++-
 scratch/mso-dumper/src/xlsrecord.py |   12 ++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 9144e34b4659b7f7127a50abdb486ddb3eaa72e9
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Apr 14 18:41:41 2010 -0400

    [xls-dump] Display conditional formatting ranges in cXML mode.
    
    So that I can test against accidental omission of conditional
    formatting on xls import.
    
    * 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 9b1c507..915c66f 100644
--- a/scratch/mso-dumper/src/xlsmodel.py
+++ b/scratch/mso-dumper/src/xlsmodel.py
@@ -318,6 +318,7 @@ class Worksheet(SheetBase):
         self.__rowHeights = Worksheet.OrderedRangeList()
         self.__shapes = []
         self.__lastCell = None
+        self.__condFormats = []
 
     def addShape (self, obj):
         self.__shapes.append(obj)
@@ -355,6 +356,12 @@ class Worksheet(SheetBase):
     def setRowHeight (self, row, height):
         self.__rowHeights.setValue(row, height)
 
+    def setCondFormat (self, condFmt):
+        self.__condFormats.append(condFmt)
+
+    def getLastCondFormat (self):
+        return self.__condFormats[-1]
+
     def createDOM (self, wb):
         nd = node.Element('worksheet')
         nd.setAttr('version', self.version)
@@ -382,7 +389,8 @@ class Worksheet(SheetBase):
         self.__appendAutoFilterNode(wb, nd) # autofilter (if exists)
         self.__appendHiddenRowsNode(wb, nd) # hidden rows
         self.__appendRowHeightNode(wb, nd)  # row heights
-        self.__appendShapesNode(wb, nd) # drawing objects
+        self.__appendShapesNode(wb, nd)     # drawing objects
+        self.__appendCondFormatNode(wb, nd) # conditional formatting
         return nd
 
     def __appendRowHeightNode (self, wb, baseNode):
@@ -447,6 +455,15 @@ class Worksheet(SheetBase):
             objElem.setAttr('offset-begin', "(dx=%d,dy=%d)"%(obj.dx1,obj.dy1))
             objElem.setAttr('offset-end', "(dx=%d,dy=%d)"%(obj.dx2,obj.dy2))
 
+    def __appendCondFormatNode (self, wb, baseNode):
+        n = len(self.__condFormats)
+        if n == 0:
+            return
+
+        elem = baseNode.appendElement('cond-formats')
+        for obj in self.__condFormats:
+            objElem = elem.appendElement('cond-format')
+            objElem.setAttr('format-range', "%s"%obj.formatRange.getName())
 
 
 class CellBase(object):
@@ -528,3 +545,10 @@ class AutoFilterArrow(object):
             eqStr += ',' + self.equalString2
         nd.setAttr('equals', eqStr)
         return nd
+
+
+class CondFormat(object):
+
+    def __init__ (self):
+        self.formatRange = None
+
diff --git a/scratch/mso-dumper/src/xlsrecord.py b/scratch/mso-dumper/src/xlsrecord.py
index 4e5d35e..aa378ba 100644
--- a/scratch/mso-dumper/src/xlsrecord.py
+++ b/scratch/mso-dumper/src/xlsrecord.py
@@ -665,6 +665,18 @@ class CondFmt(BaseRecordHandler):
             self.appendLine("hit range: (col=%d,row=%d) - (col=%d,row=%d)"%
                 (hitRange.col1, hitRange.row1, hitRange.col2, hitRange.row2))
 
+    def fillModel (self, model):
+        self.__parseBytes()
+        formatRange = formula.CellRange()
+        formatRange.firstCol = self.refBound.col1
+        formatRange.lastCol  = self.refBound.col2
+        formatRange.firstRow = self.refBound.row1
+        formatRange.lastRow  = self.refBound.row2
+        obj = xlsmodel.CondFormat()
+        obj.formatRange = formatRange
+        sheet = model.getCurrentSheet()
+        sheet.setCondFormat(obj)
+
 
 class Dimensions(BaseRecordHandler):
 


More information about the ooo-build-commit mailing list