[Libreoffice-commits] .: src/xlsrecord.py src/xlsstream.py

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Dec 12 17:38:24 PST 2012


 src/xlsrecord.py |   34 +++++++++++++++++++++++++++++++++-
 src/xlsstream.py |    2 +-
 2 files changed, 34 insertions(+), 2 deletions(-)

New commits:
commit 40622aab5dfc2223d639b11594423e3a27cff9ef
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Dec 12 20:39:17 2012 -0500

    Handler for SXPI (pivot table page item) record.
    
    Also, let's not catch all exceptions, since that would make debugging
    of record handler quite hard.

diff --git a/src/xlsrecord.py b/src/xlsrecord.py
index 4393c8f..88a92cc 100644
--- a/src/xlsrecord.py
+++ b/src/xlsrecord.py
@@ -187,7 +187,7 @@ Like parseBytes(), the derived classes must overwrite this method."""
             self.parseBytes()
             for line in self.lines:
                 print (headerStr + line)
-        except:
+        except globals.ByteStreamError:
             print(headerStr + "Error interpreting the record!")
 
     def debug (self, msg):
@@ -3458,6 +3458,38 @@ class SXDataItem(BaseRecordHandler):
 
         return
 
+class SXPageItem(BaseRecordHandler):
+
+    class Item(object):
+
+        def __init__ (self, strm):
+            self.isxvd = strm.readSignedInt(2)
+            self.isxvi = strm.readSignedInt(2)
+            self.idObj = strm.readSignedInt(2)
+
+        def appendLines (self, parent):
+            parent.appendLine("item")
+            parent.appendLine("  field index: %d"%self.isxvd)
+            if self.isxvi == 0x7FFD:
+                parent.appendLine("  index of selected item: all")
+            else:
+                # Index of SXVI record, not of cache item in pivot cache.
+                # SXVI record holds the index of the cache item in pivot cache.
+                # Don't get confused.
+                parent.appendLine("  index of selected item: %d"%self.isxvi)
+            parent.appendLine("  OBJ record ID for page item drop-down arrow: %d"%self.idObj)
+
+    def __parseBytes (self):
+        self.items = []
+        while not self.isEndOfRecord():
+            item = SXPageItem.Item(self)
+            self.items.append(item)
+
+    def parseBytes (self):
+        self.__parseBytes()
+        for item in self.items:
+            item.appendLines(self)
+
 
 class SXVI(BaseRecordHandler):
 
diff --git a/src/xlsstream.py b/src/xlsstream.py
index aab6ce5..6234779 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -125,7 +125,7 @@ recData = {
     0x00B2: ["SXVI", "View Item", xlsrecord.SXVI],
     0x00B4: ["SXIVD", "Row/Column Field IDs", xlsrecord.SxIvd],
     0x00B5: ["SXLI", "Line Item Array", xlsrecord.SXLI],
-    0x00B6: ["SXPI", "Page Item"],
+    0x00B6: ["SXPI", "Page Item", xlsrecord.SXPageItem],
     0x00B8: ["DOCROUTE", "Routing Slip Information"],
     0x00B9: ["RECIPNAME", "Recipient Name"],
     0x00BC: ["SHRFMLA", "Shared Formula"],


More information about the Libreoffice-commits mailing list