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



Author: kyoshida
Date: Thu Jul 17 17:29:08 2008
New Revision: 13277
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13277&view=rev

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

	* scratch/sc-xlsutil/src/formula.py: deal with cell reference 
	variations; Ref3dR variant contains a sheet index.


Modified:
   trunk/ChangeLog
   trunk/scratch/sc-xlsutil/src/formula.py

Modified: trunk/scratch/sc-xlsutil/src/formula.py
==============================================================================
--- trunk/scratch/sc-xlsutil/src/formula.py	(original)
+++ trunk/scratch/sc-xlsutil/src/formula.py	Thu Jul 17 17:29:08 2008
@@ -132,7 +132,7 @@
         return "<externname externSheetID='%d' nameID='%d'>"%(self.refID, self.nameID)
 
 
-class Ref3d(TokenBase):
+class Ref3dR(TokenBase):
     """3D reference or external reference to a cell"""
 
     def __init__ (self, tokens):
@@ -144,6 +144,8 @@
             i += 1
             self.refEntryId = globals.getSignedInt(self.tokens[i:i+2])
             i += 2
+            self.sheet = globals.getSignedInt(self.tokens[i:i+2])
+            i += 2
             self.cell = parseCellAddress(self.tokens[i:i+4])
             i += 4
         except InvalidCellAddress:
@@ -156,6 +158,37 @@
         cellName = self.cell.getName()
         return "<3dref externSheetID='%d' cellAddress='%s'>"%(self.refEntryId, cellName)
 
+
+class Ref3dV(TokenBase):
+    """3D reference or external reference to a cell"""
+
+    def __init__ (self, tokens):
+        TokenBase.__init__(self, tokens)
+        self.cell = None
+
+    def parse (self, i):
+        try:
+            i += 1
+            self.refEntryId = globals.getSignedInt(self.tokens[i:i+2])
+            i += 2
+            self.cell = parseCellAddress(self.tokens[i:i+4])
+            i += 4
+        except InvalidCellAddress:
+            pass
+        return i
+
+    def getText (self):
+        if self.cell == None:
+            return ''
+        cellName = self.cell.getName()
+        return "<3dref externSheetID='%d' cellAddress='%s'>"%(self.refEntryId, cellName)
+
+
+class Ref3dA(Ref3dV):
+    def __init__ (self, tokens):
+        Ref3dA.__init__(self, tokens)
+
+
 tokenMap = {
     # binary operator
     0x03: Add,
@@ -186,9 +219,9 @@
 
     # 3d reference (TODO: There is a slight variation in how a cell reference
     # is represented between 0x3A and 0x5A).
-    0x3A: Ref3d,
-    0x5A: Ref3d,
-    0x7A: Ref3d,
+    0x3A: Ref3dR,
+    0x5A: Ref3dV,
+    0x7A: Ref3dA,
 
     # last item
   0xFFFF: None



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