You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/09/12 09:03:01 UTC

svn commit: r694620 - /poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java

Author: josh
Date: Fri Sep 12 00:03:00 2008
New Revision: 694620

URL: http://svn.apache.org/viewvc?rev=694620&view=rev
Log:
clarification of ArrayPtg size increment

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java?rev=694620&r1=694619&r2=694620&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/Ptg.java Fri Sep 12 00:03:00 2008
@@ -56,20 +56,21 @@
 	/**
 	 * @deprecated - use readTokens()
 	 */
-	public static Stack createParsedExpressionTokens(short size, RecordInputStream in)
-	{
+	public static Stack createParsedExpressionTokens(short size, RecordInputStream in) {
 		Stack stack = new Stack();
 		int pos = 0;
 		List arrayPtgs = null;
-		while ( pos < size )
-		{
+		while (pos < size) {
 			Ptg ptg = Ptg.createPtg( in );
 			if (ptg instanceof ArrayPtg) {
-				if (arrayPtgs == null)
+				if (arrayPtgs == null) {
 					arrayPtgs = new ArrayList(5);
+				}
 				arrayPtgs.add(ptg);
-				pos += 8;
-			} else pos += ptg.getSize();
+				pos += ArrayPtg.PLAIN_TOKEN_SIZE;
+			} else {
+				pos += ptg.getSize();
+			}
 			stack.push( ptg );
 		}
 		if(pos != size) {
@@ -109,25 +110,25 @@
 		int baseId = id & 0x1F | 0x20;
 		
 		switch (baseId) {
-			case ArrayPtg.sid:     return new ArrayPtg(in);    // 0x20, 0x40, 0x60
-			 case FuncPtg.sid:     return new FuncPtg(in);     // 0x21, 0x41, 0x61
-			 case FuncVarPtg.sid:  return new FuncVarPtg(in);  // 0x22, 0x42, 0x62
-			 case NamePtg.sid:     return new NamePtg(in);     // 0x23, 0x43, 0x63
-			 case RefPtg.sid:      return new RefPtg(in);      // 0x24, 0x44, 0x64
-			 case AreaPtg.sid:     return new AreaPtg(in);     // 0x25, 0x45, 0x65
-			 case MemAreaPtg.sid:  return new MemAreaPtg(in);  // 0x26, 0x46, 0x66
-			 case MemErrPtg.sid:   return new MemErrPtg(in);   // 0x27, 0x47, 0x67
-			 case MemFuncPtg.sid:  return new MemFuncPtg(in);  // 0x29, 0x49, 0x69
-			 case RefErrorPtg.sid: return  new RefErrorPtg(in);// 0x2a, 0x4a, 0x6a
-			 case AreaErrPtg.sid:  return new AreaErrPtg(in);  // 0x2b, 0x4b, 0x6b
-			 case RefNPtg.sid:     return new RefNPtg(in);     // 0x2c, 0x4c, 0x6c
-			 case AreaNPtg.sid:    return new AreaNPtg(in);    // 0x2d, 0x4d, 0x6d
-
-			 case NameXPtg.sid:    return new NameXPtg(in);    // 0x39, 0x49, 0x79
-			 case Ref3DPtg.sid:    return  new Ref3DPtg(in);   // 0x3a, 0x5a, 0x7a
-			 case Area3DPtg.sid:   return new Area3DPtg(in);   // 0x3b, 0x5b, 0x7b
-			 case DeletedRef3DPtg.sid:  return new DeletedRef3DPtg(in);   // 0x3c, 0x5c, 0x7c
-			 case DeletedArea3DPtg.sid: return  new DeletedArea3DPtg(in); // 0x3d, 0x5d, 0x7d
+			case ArrayPtg.sid:    return new ArrayPtg(in);    // 0x20, 0x40, 0x60
+			case FuncPtg.sid:     return new FuncPtg(in);     // 0x21, 0x41, 0x61
+			case FuncVarPtg.sid:  return new FuncVarPtg(in);  // 0x22, 0x42, 0x62
+			case NamePtg.sid:     return new NamePtg(in);     // 0x23, 0x43, 0x63
+			case RefPtg.sid:      return new RefPtg(in);      // 0x24, 0x44, 0x64
+			case AreaPtg.sid:     return new AreaPtg(in);     // 0x25, 0x45, 0x65
+			case MemAreaPtg.sid:  return new MemAreaPtg(in);  // 0x26, 0x46, 0x66
+			case MemErrPtg.sid:   return new MemErrPtg(in);   // 0x27, 0x47, 0x67
+			case MemFuncPtg.sid:  return new MemFuncPtg(in);  // 0x29, 0x49, 0x69
+			case RefErrorPtg.sid: return new RefErrorPtg(in); // 0x2a, 0x4a, 0x6a
+			case AreaErrPtg.sid:  return new AreaErrPtg(in);  // 0x2b, 0x4b, 0x6b
+			case RefNPtg.sid:     return new RefNPtg(in);     // 0x2c, 0x4c, 0x6c
+			case AreaNPtg.sid:    return new AreaNPtg(in);    // 0x2d, 0x4d, 0x6d
+
+			case NameXPtg.sid:    return new NameXPtg(in);    // 0x39, 0x49, 0x79
+			case Ref3DPtg.sid:    return new Ref3DPtg(in);    // 0x3a, 0x5a, 0x7a
+			case Area3DPtg.sid:   return new Area3DPtg(in);   // 0x3b, 0x5b, 0x7b
+			case DeletedRef3DPtg.sid:  return new DeletedRef3DPtg(in);   // 0x3c, 0x5c, 0x7c
+			case DeletedArea3DPtg.sid: return  new DeletedArea3DPtg(in); // 0x3d, 0x5d, 0x7d
 		}
 		throw new UnsupportedOperationException(" Unknown Ptg in Formula: 0x"+
 				   Integer.toHexString(id) + " (" + ( int ) id + ")");
@@ -262,11 +263,14 @@
 
 			ptg.writeBytes(array, pos + offset);
 			if (ptg instanceof ArrayPtg) {
-			  if (arrayPtgs == null)
-				  arrayPtgs = new ArrayList(5);
-			  arrayPtgs.add(ptg);
-			  pos += 8;
-			} else pos += ptg.getSize();
+				if (arrayPtgs == null) {
+					arrayPtgs = new ArrayList(5);
+				}
+				arrayPtgs.add(ptg);
+				pos += ArrayPtg.PLAIN_TOKEN_SIZE;
+			} else {
+				pos += ptg.getSize();
+			}
 		}
 		if (arrayPtgs != null) {
 			for (int i=0;i<arrayPtgs.size();i++) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org