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



Author: kyoshida
Date: Thu Oct 23 03:18:59 2008
New Revision: 14401
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14401&view=rev

Log:
2008-10-22  Kohei Yoshida  <kyoshida novell com>

	* scratch/sc-xlsutil/src/globals.py (getUnsignedInt): added.
	
	* scratch/sc-xlsutil/src/record.py:
	* scratch/sc-xlsutil/src/stream.py: added handler for CHBar - the 
	record containing info about bar chart. 


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	Thu Oct 23 03:18:59 2008
@@ -165,6 +165,26 @@
     raise ByteConvertError
 
 
+def getUnsignedInt (bytes):
+    # little endian
+    n = len(bytes)
+    if n == 0:
+        return 0
+
+    text = toTextBytes(bytes)
+    if n == 1:
+        # byte - 1 byte
+        return struct.unpack('B', text)[0]
+    elif n == 2:
+        # short - 2 bytes
+        return struct.unpack('<H', text)[0]
+    elif n == 4:
+        # int, long - 4 bytes
+        return struct.unpack('<L', text)[0]
+
+    raise ByteConvertError
+
+
 def getFloat (bytes):
     n = len(bytes)
     if n == 0:

Modified: trunk/scratch/sc-xlsutil/src/record.py
==============================================================================
--- trunk/scratch/sc-xlsutil/src/record.py	(original)
+++ trunk/scratch/sc-xlsutil/src/record.py	Thu Oct 23 03:18:59 2008
@@ -43,6 +43,12 @@
     def setCurrentPos (self, pos):
         self.pos = pos
 
+    def getYesNo (self, boolVal):
+        if boolVal:
+            return 'yes'
+        else:
+            return 'no'
+
 # --------------------------------------------------------------------
 
 class BOF(BaseRecordHandler):
@@ -764,12 +770,6 @@
 
 class CHValueRange(BaseRecordHandler):
 
-    def __getYesNo (self, boolVal):
-        if boolVal:
-            return 'yes'
-        else:
-            return 'no'
-
     def parseBytes (self):
         minVal = globals.getDouble(self.readBytes(8))
         maxVal = globals.getDouble(self.readBytes(8))
@@ -788,13 +788,32 @@
         maxCross  = (flags & 0x0080)
         bit8      = (flags & 0x0100)
 
-        self.appendLine("min: %g (auto min: %s)"%(minVal, self.__getYesNo(autoMin)))
-        self.appendLine("max: %g (auto max: %s)"%(maxVal, self.__getYesNo(autoMax)))
+        self.appendLine("min: %g (auto min: %s)"%(minVal, self.getYesNo(autoMin)))
+        self.appendLine("max: %g (auto max: %s)"%(maxVal, self.getYesNo(autoMax)))
         self.appendLine("major step: %g (auto major: %s)"%
-            (majorStep, self.__getYesNo(autoMajor)))
+            (majorStep, self.getYesNo(autoMajor)))
         self.appendLine("minor step: %g (auto minor: %s)"%
-            (minorStep, self.__getYesNo(autoMinor)))
+            (minorStep, self.getYesNo(autoMinor)))
         self.appendLine("cross: %g (auto cross: %s) (max cross: %s)"%
-            (cross, self.__getYesNo(autoCross), self.__getYesNo(maxCross)))
-        self.appendLine("biff5 or above: %s"%self.__getYesNo(bit8))
+            (cross, self.getYesNo(autoCross), self.getYesNo(maxCross)))
+        self.appendLine("biff5 or above: %s"%self.getYesNo(bit8))
+
+
+class CHBar(BaseRecordHandler):
+
+    def parseBytes (self):
+        overlap = globals.getSignedInt(self.readBytes(2))
+        gap     = globals.getSignedInt(self.readBytes(2))
+        flags   = globals.getUnsignedInt(self.readBytes(2))
+
+        horizontal = (flags & 0x0001)
+        stacked    = (flags & 0x0002)
+        percent    = (flags & 0x0004)
+        shadow     = (flags & 0x0008)
 
+        self.appendLine("overlap width: %d"%overlap)
+        self.appendLine("gap: %d"%gap)
+        self.appendLine("horizontal: %s"%self.getYesNo(horizontal))
+        self.appendLine("stacked: %s"%self.getYesNo(stacked))
+        self.appendLine("percent: %s"%self.getYesNo(percent))
+        self.appendLine("shadow: %s"%self.getYesNo(shadow))

Modified: trunk/scratch/sc-xlsutil/src/stream.py
==============================================================================
--- trunk/scratch/sc-xlsutil/src/stream.py	(original)
+++ trunk/scratch/sc-xlsutil/src/stream.py	Thu Oct 23 03:18:59 2008
@@ -204,7 +204,7 @@
     0x100D: ["CHSTRING", "?"],
     0x1014: ["CHTYPEGROUP", "?"],
     0x1015: ["CHLEGEND", "?"],
-    0x1017: ["CHBAR, CHCOLUMN", "?"],
+    0x1017: ["CHBAR, CHCOLUMN", "?", record.CHBar],
     0x1018: ["CHLINE", "?"],
     0x1019: ["CHPIE", "?"],
     0x101A: ["CHAREA", "?"],



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