mirror of https://github.com/apache/poi.git
clarification of ArrayPtg size increment
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@694620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
658057a44a
commit
9b9d63275a
|
@ -56,20 +56,21 @@ public abstract class Ptg implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* @deprecated - use readTokens()
|
* @deprecated - use readTokens()
|
||||||
*/
|
*/
|
||||||
public static Stack createParsedExpressionTokens(short size, RecordInputStream in)
|
public static Stack createParsedExpressionTokens(short size, RecordInputStream in) {
|
||||||
{
|
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
List arrayPtgs = null;
|
List arrayPtgs = null;
|
||||||
while ( pos < size )
|
while (pos < size) {
|
||||||
{
|
|
||||||
Ptg ptg = Ptg.createPtg( in );
|
Ptg ptg = Ptg.createPtg( in );
|
||||||
if (ptg instanceof ArrayPtg) {
|
if (ptg instanceof ArrayPtg) {
|
||||||
if (arrayPtgs == null)
|
if (arrayPtgs == null) {
|
||||||
arrayPtgs = new ArrayList(5);
|
arrayPtgs = new ArrayList(5);
|
||||||
|
}
|
||||||
arrayPtgs.add(ptg);
|
arrayPtgs.add(ptg);
|
||||||
pos += 8;
|
pos += ArrayPtg.PLAIN_TOKEN_SIZE;
|
||||||
} else pos += ptg.getSize();
|
} else {
|
||||||
|
pos += ptg.getSize();
|
||||||
|
}
|
||||||
stack.push( ptg );
|
stack.push( ptg );
|
||||||
}
|
}
|
||||||
if(pos != size) {
|
if(pos != size) {
|
||||||
|
@ -109,25 +110,25 @@ public abstract class Ptg implements Cloneable {
|
||||||
int baseId = id & 0x1F | 0x20;
|
int baseId = id & 0x1F | 0x20;
|
||||||
|
|
||||||
switch (baseId) {
|
switch (baseId) {
|
||||||
case ArrayPtg.sid: return new ArrayPtg(in); // 0x20, 0x40, 0x60
|
case ArrayPtg.sid: return new ArrayPtg(in); // 0x20, 0x40, 0x60
|
||||||
case FuncPtg.sid: return new FuncPtg(in); // 0x21, 0x41, 0x61
|
case FuncPtg.sid: return new FuncPtg(in); // 0x21, 0x41, 0x61
|
||||||
case FuncVarPtg.sid: return new FuncVarPtg(in); // 0x22, 0x42, 0x62
|
case FuncVarPtg.sid: return new FuncVarPtg(in); // 0x22, 0x42, 0x62
|
||||||
case NamePtg.sid: return new NamePtg(in); // 0x23, 0x43, 0x63
|
case NamePtg.sid: return new NamePtg(in); // 0x23, 0x43, 0x63
|
||||||
case RefPtg.sid: return new RefPtg(in); // 0x24, 0x44, 0x64
|
case RefPtg.sid: return new RefPtg(in); // 0x24, 0x44, 0x64
|
||||||
case AreaPtg.sid: return new AreaPtg(in); // 0x25, 0x45, 0x65
|
case AreaPtg.sid: return new AreaPtg(in); // 0x25, 0x45, 0x65
|
||||||
case MemAreaPtg.sid: return new MemAreaPtg(in); // 0x26, 0x46, 0x66
|
case MemAreaPtg.sid: return new MemAreaPtg(in); // 0x26, 0x46, 0x66
|
||||||
case MemErrPtg.sid: return new MemErrPtg(in); // 0x27, 0x47, 0x67
|
case MemErrPtg.sid: return new MemErrPtg(in); // 0x27, 0x47, 0x67
|
||||||
case MemFuncPtg.sid: return new MemFuncPtg(in); // 0x29, 0x49, 0x69
|
case MemFuncPtg.sid: return new MemFuncPtg(in); // 0x29, 0x49, 0x69
|
||||||
case RefErrorPtg.sid: return new RefErrorPtg(in);// 0x2a, 0x4a, 0x6a
|
case RefErrorPtg.sid: return new RefErrorPtg(in); // 0x2a, 0x4a, 0x6a
|
||||||
case AreaErrPtg.sid: return new AreaErrPtg(in); // 0x2b, 0x4b, 0x6b
|
case AreaErrPtg.sid: return new AreaErrPtg(in); // 0x2b, 0x4b, 0x6b
|
||||||
case RefNPtg.sid: return new RefNPtg(in); // 0x2c, 0x4c, 0x6c
|
case RefNPtg.sid: return new RefNPtg(in); // 0x2c, 0x4c, 0x6c
|
||||||
case AreaNPtg.sid: return new AreaNPtg(in); // 0x2d, 0x4d, 0x6d
|
case AreaNPtg.sid: return new AreaNPtg(in); // 0x2d, 0x4d, 0x6d
|
||||||
|
|
||||||
case NameXPtg.sid: return new NameXPtg(in); // 0x39, 0x49, 0x79
|
case NameXPtg.sid: return new NameXPtg(in); // 0x39, 0x49, 0x79
|
||||||
case Ref3DPtg.sid: return new Ref3DPtg(in); // 0x3a, 0x5a, 0x7a
|
case Ref3DPtg.sid: return new Ref3DPtg(in); // 0x3a, 0x5a, 0x7a
|
||||||
case Area3DPtg.sid: return new Area3DPtg(in); // 0x3b, 0x5b, 0x7b
|
case Area3DPtg.sid: return new Area3DPtg(in); // 0x3b, 0x5b, 0x7b
|
||||||
case DeletedRef3DPtg.sid: return new DeletedRef3DPtg(in); // 0x3c, 0x5c, 0x7c
|
case DeletedRef3DPtg.sid: return new DeletedRef3DPtg(in); // 0x3c, 0x5c, 0x7c
|
||||||
case DeletedArea3DPtg.sid: return new DeletedArea3DPtg(in); // 0x3d, 0x5d, 0x7d
|
case DeletedArea3DPtg.sid: return new DeletedArea3DPtg(in); // 0x3d, 0x5d, 0x7d
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException(" Unknown Ptg in Formula: 0x"+
|
throw new UnsupportedOperationException(" Unknown Ptg in Formula: 0x"+
|
||||||
Integer.toHexString(id) + " (" + ( int ) id + ")");
|
Integer.toHexString(id) + " (" + ( int ) id + ")");
|
||||||
|
@ -262,11 +263,14 @@ public abstract class Ptg implements Cloneable {
|
||||||
|
|
||||||
ptg.writeBytes(array, pos + offset);
|
ptg.writeBytes(array, pos + offset);
|
||||||
if (ptg instanceof ArrayPtg) {
|
if (ptg instanceof ArrayPtg) {
|
||||||
if (arrayPtgs == null)
|
if (arrayPtgs == null) {
|
||||||
arrayPtgs = new ArrayList(5);
|
arrayPtgs = new ArrayList(5);
|
||||||
arrayPtgs.add(ptg);
|
}
|
||||||
pos += 8;
|
arrayPtgs.add(ptg);
|
||||||
} else pos += ptg.getSize();
|
pos += ArrayPtg.PLAIN_TOKEN_SIZE;
|
||||||
|
} else {
|
||||||
|
pos += ptg.getSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (arrayPtgs != null) {
|
if (arrayPtgs != null) {
|
||||||
for (int i=0;i<arrayPtgs.size();i++) {
|
for (int i=0;i<arrayPtgs.size();i++) {
|
||||||
|
|
Loading…
Reference in New Issue