diff --git a/src/java/org/apache/poi/ss/formula/functions/Rank.java b/src/java/org/apache/poi/ss/formula/functions/Rank.java index 225250eccc..97d0700e15 100644 --- a/src/java/org/apache/poi/ss/formula/functions/Rank.java +++ b/src/java/org/apache/poi/ss/formula/functions/Rank.java @@ -45,116 +45,116 @@ import org.apache.poi.ss.formula.eval.ValueEval; */ public class Rank extends Var2or3ArgFunction { - @Override - public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) { - try { - ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex); - double result = OperandResolver.coerceValueToDouble(ve); - if (Double.isNaN(result) || Double.isInfinite(result)) { - throw new EvaluationException(ErrorEval.NUM_ERROR); - } + @Override + public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) { + try { + ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex); + double result = OperandResolver.coerceValueToDouble(ve); + if (Double.isNaN(result) || Double.isInfinite(result)) { + throw new EvaluationException(ErrorEval.NUM_ERROR); + } - if (arg1 instanceof RefListEval) { - return eval(result, ((RefListEval)arg1), true); - } + if (arg1 instanceof RefListEval) { + return eval(result, ((RefListEval)arg1), true); + } - final AreaEval aeRange = convertRangeArg(arg1); + final AreaEval aeRange = convertRangeArg(arg1); - return eval(result, aeRange, true); - } catch (EvaluationException e) { - return e.getErrorEval(); - } - } + return eval(result, aeRange, true); + } catch (EvaluationException e) { + return e.getErrorEval(); + } + } - @Override - public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1, ValueEval arg2) { - try { - ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex); - final double result = OperandResolver.coerceValueToDouble(ve); - if (Double.isNaN(result) || Double.isInfinite(result)) { - throw new EvaluationException(ErrorEval.NUM_ERROR); - } + @Override + public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1, ValueEval arg2) { + try { + ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex); + final double result = OperandResolver.coerceValueToDouble(ve); + if (Double.isNaN(result) || Double.isInfinite(result)) { + throw new EvaluationException(ErrorEval.NUM_ERROR); + } - ve = OperandResolver.getSingleValue(arg2, srcRowIndex, srcColumnIndex); - int order_value = OperandResolver.coerceValueToInt(ve); - final boolean order; - if (order_value==0) { - order = true; - } else if(order_value==1) { - order = false; - } else { - throw new EvaluationException(ErrorEval.NUM_ERROR); - } + ve = OperandResolver.getSingleValue(arg2, srcRowIndex, srcColumnIndex); + int order_value = OperandResolver.coerceValueToInt(ve); + final boolean order; + if (order_value==0) { + order = true; + } else if(order_value==1) { + order = false; + } else { + throw new EvaluationException(ErrorEval.NUM_ERROR); + } - if (arg1 instanceof RefListEval) { - return eval(result, ((RefListEval)arg1), order); - } + if (arg1 instanceof RefListEval) { + return eval(result, ((RefListEval)arg1), order); + } - final AreaEval aeRange = convertRangeArg(arg1); - return eval(result, aeRange, order); - } catch (EvaluationException e) { - return e.getErrorEval(); - } - } + final AreaEval aeRange = convertRangeArg(arg1); + return eval(result, aeRange, order); + } catch (EvaluationException e) { + return e.getErrorEval(); + } + } - private static ValueEval eval(double arg0, AreaEval aeRange, boolean descending_order) { - int rank = 1; - int height=aeRange.getHeight(); - int width= aeRange.getWidth(); - for (int r=0; rarg0 || !descending_order && valuearg0 || !descending_order && valuearg0 || !descending_order && valuearg0 || !descending_order && value sheetOffsets = pph.getSlideLocationsLookup(); - for (Integer id : sheetIDs) { - Integer offset = sheetOffsets.get(id); + // Check the sheet offsets + int[] sheetIDs = pph.getKnownSlideIDs(); + Map sheetOffsets = pph.getSlideLocationsLookup(); + for (Integer id : sheetIDs) { + Integer offset = sheetOffsets.get(id); - System.out.println(" Knows about sheet " + id); - System.out.println(" That sheet lives at " + offset); + System.out.println(" Knows about sheet " + id); + System.out.println(" That sheet lives at " + offset); - Record atPos = findRecordAtPos(offset.intValue()); - System.out.println(" The record at that pos is of type " + atPos.getRecordType()); - System.out.println(" The record at that pos has class " + atPos.getClass().getName()); + Record atPos = findRecordAtPos(offset.intValue()); + System.out.println(" The record at that pos is of type " + atPos.getRecordType()); + System.out.println(" The record at that pos has class " + atPos.getClass().getName()); - if (!(atPos instanceof PositionDependentRecord)) { - System.out.println(" ** The record class isn't position aware! **"); - } - } - } + if (!(atPos instanceof PositionDependentRecord)) { + System.out.println(" ** The record class isn't position aware! **"); + } + } + } - // Increase the position by the on disk size - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - r.writeOut(baos); - pos += baos.size(); - } + // Increase the position by the on disk size + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + r.writeOut(baos); + pos += baos.size(); + } - ss.close(); + ss.close(); - System.out.println(); - } + System.out.println(); + } - // Finds the record at a given position - public static Record findRecordAtPos(int pos) { - long type = LittleEndian.getUShort(fileContents, pos+2); - long rlen = LittleEndian.getUInt(fileContents, pos+4); + // Finds the record at a given position + public static Record findRecordAtPos(int pos) { + long type = LittleEndian.getUShort(fileContents, pos+2); + long rlen = LittleEndian.getUInt(fileContents, pos+4); - return Record.createRecordForType(type,fileContents,pos,(int)rlen+8); - } + return Record.createRecordForType(type,fileContents,pos,(int)rlen+8); + } }