ooo-build r13230 - in trunk: . scratch/sc-xlsutil/src



Author: kyoshida
Date: Tue Jul 15 16:43:35 2008
New Revision: 13230
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13230&view=rev

Log:
2008-07-15  Kohei Yoshida  <kyoshida novell com>

	* scratch/sc-xlsutil/src/globals.py:
	* scratch/sc-xlsutil/src/record.py:
	* scratch/sc-xlsutil/src/stream.py: parse the XCT and CRN records.


Modified:
   trunk/ChangeLog
   trunk/scratch/sc-xlsutil/src/globals.py
   trunk/scratch/sc-xlsutil/src/record.py
   trunk/scratch/sc-xlsutil/src/stream.py

Modified: trunk/scratch/sc-xlsutil/src/globals.py
==============================================================================
--- trunk/scratch/sc-xlsutil/src/globals.py	(original)
+++ trunk/scratch/sc-xlsutil/src/globals.py	Tue Jul 15 16:43:35 2008
@@ -20,13 +20,18 @@
 def decodeName (name):
     """decode name that contains unprintable characters."""
 
-    if len(name) == 0:
+    n = len(name)
+    if n == 0:
         return name
 
-    if ord(name[0]) <= 20:
-        name = "<%2.2Xh>"%ord(name[0]) + name[1:]
+    newname = ''
+    for i in xrange(0, n):
+        if ord(name[i]) <= 20:
+            newname += "<%2.2Xh>"%ord(name[i])
+        else:
+            newname += name[i]
 
-    return name
+    return newname
 
 
 def getRichText (bytes, textLen=None):

Modified: trunk/scratch/sc-xlsutil/src/record.py
==============================================================================
--- trunk/scratch/sc-xlsutil/src/record.py	(original)
+++ trunk/scratch/sc-xlsutil/src/record.py	Tue Jul 15 16:43:35 2008
@@ -356,6 +356,61 @@
             self.appendLine("formula: %s"%ftext)
 
 
+class Xct(BaseRecordHandler):
+
+    def parseBytes (self):
+        crnCount = globals.getSignedInt(self.bytes[0:2])
+        sheetIndex = globals.getSignedInt(self.bytes[2:4])
+        self.appendLine("CRN count: %d"%crnCount)
+        self.appendLine("index of referenced sheet in the SUPBOOK record: %d"%sheetIndex)
+
+class Crn(BaseRecordHandler):
+
+    def parseBytes (self):
+        lastCol = globals.getSignedInt(self.bytes[0:1])
+        firstCol = globals.getSignedInt(self.bytes[1:2])
+        rowIndex = globals.getSignedInt(self.bytes[2:4])
+        self.appendLine("first column: %d"%firstCol)
+        self.appendLine("last column:  %d"%lastCol)
+        self.appendLine("row index: %d"%rowIndex)
+
+        i = 4
+        n = len(self.bytes)
+        while i < n:
+            typeId = self.bytes[i]
+            i += 1
+            if typeId == 0x00:
+                # empty value
+                i += 8
+                self.appendLine("* empty value")
+            elif typeId == 0x01:
+                # number
+                val = globals.getDouble(self.bytes[i:i+8])
+                i += 8
+                self.appendLine("* numeric value (%g)"%val)
+            elif typeId == 0x2:
+                # string
+                text, length = globals.getRichText(self.bytes[i:])
+                i += length
+                text = globals.decodeName(text)
+                self.appendLine("* string value (%s)"%text)
+            elif typeId == 0x04:
+                # boolean
+                val = self.bytes[i]
+                i += 7 # next 7 bytes not used
+                self.appendLine("* boolean value (%d)"%val)
+            elif typeId == 0x10:
+                # error value
+                val = self.bytes[i]
+                i += 7 # not used
+                self.appendLine("* error value (%d)"%val)
+            else:
+                sys.stderr.write("error parsing CRN record")
+                sys.exit(1)
+            
+
+
+
 # -------------------------------------------------------------------
 # CT - Change Tracking
 

Modified: trunk/scratch/sc-xlsutil/src/stream.py
==============================================================================
--- trunk/scratch/sc-xlsutil/src/stream.py	(original)
+++ trunk/scratch/sc-xlsutil/src/stream.py	Tue Jul 15 16:43:35 2008
@@ -48,8 +48,8 @@
     0x0051: ["DCONREF", "Data Consolidation References"],
     0x0052: ["DCONNAME", "Data Consolidation Named References"],
     0x0055: ["DEFCOLWIDTH", "Default Width for Columns"],
-    0x0059: ["XCT", "CRN Record Count"],
-    0x005A: ["CRN", "Nonresident Operands"],
+    0x0059: ["XCT", "CRN Record Count", record.Xct],
+    0x005A: ["CRN", "Nonresident Operands", record.Crn],
     0x005B: ["FILESHARING", "File-Sharing Information"],
     0x005C: ["WRITEACCESS", "Write Access User Name"],
     0x005D: ["OBJ", "Describes a Graphic Object"],



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]