aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2019-05-22 22:59:12 +0000
committerPJ Fanning <fanningpj@apache.org>2019-05-22 22:59:12 +0000
commit3d5671ac5ea9a4b724019fb1d83aa3736751e4a5 (patch)
tree017122d7b142cc58077b2e4b8f7e58212cd167c9 /src
parent3e80ec9c5eefb736244fbeccc00714bf19c7333e (diff)
downloadpoi-3d5671ac5ea9a4b724019fb1d83aa3736751e4a5.tar.gz
poi-3d5671ac5ea9a4b724019fb1d83aa3736751e4a5.zip
remove some tab indents
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1859758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/ss/formula/functions/Rank.java222
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java248
2 files changed, 235 insertions, 235 deletions
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);
- }
-
- if (arg1 instanceof RefListEval) {
- return eval(result, ((RefListEval)arg1), true);
- }
-
- final AreaEval aeRange = convertRangeArg(arg1);
-
- 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);
- }
-
- 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);
- }
-
- 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; r<height; r++) {
- for (int c=0; c<width; c++) {
-
- Double value = getValue(aeRange, r, c);
- if (value==null) {
- continue;
- }
- if (descending_order && value>arg0 || !descending_order && value<arg0){
- rank++;
- }
- }
- }
- return new NumberEval(rank);
- }
-
- private static ValueEval eval(double arg0, RefListEval aeRange, boolean descending_order) {
- int rank = 1;
- for(ValueEval ve : aeRange.getList()) {
- if (ve instanceof RefEval) {
- ve = ((RefEval) ve).getInnerValueEval(((RefEval) ve).getFirstSheetIndex());
- }
-
- final double value;
- if (ve instanceof NumberEval) {
- value = ((NumberEval)ve).getNumberValue();
- } else {
- continue;
- }
-
- if (descending_order && value>arg0 || !descending_order && value<arg0){
- rank++;
- }
- }
-
- return new NumberEval(rank);
- }
-
- private static Double getValue(AreaEval aeRange, int relRowIndex, int relColIndex) {
- ValueEval addend = aeRange.getRelativeValue(relRowIndex, relColIndex);
- if (addend instanceof NumberEval) {
- return ((NumberEval)addend).getNumberValue();
- }
- // everything else (including string and boolean values) counts as zero
- return null;
- }
-
- private static AreaEval convertRangeArg(ValueEval eval) throws EvaluationException {
- if (eval instanceof AreaEval) {
- return (AreaEval) eval;
- }
- if (eval instanceof RefEval) {
- return ((RefEval)eval).offset(0, 0, 0, 0);
- }
- throw new EvaluationException(ErrorEval.VALUE_INVALID);
- }
+ @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);
+ }
+
+ final AreaEval aeRange = convertRangeArg(arg1);
+
+ 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);
+ }
+
+ 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);
+ }
+
+ 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; r<height; r++) {
+ for (int c=0; c<width; c++) {
+
+ Double value = getValue(aeRange, r, c);
+ if (value==null) {
+ continue;
+ }
+ if (descending_order && value>arg0 || !descending_order && value<arg0){
+ rank++;
+ }
+ }
+ }
+ return new NumberEval(rank);
+ }
+
+ private static ValueEval eval(double arg0, RefListEval aeRange, boolean descending_order) {
+ int rank = 1;
+ for(ValueEval ve : aeRange.getList()) {
+ if (ve instanceof RefEval) {
+ ve = ((RefEval) ve).getInnerValueEval(((RefEval) ve).getFirstSheetIndex());
+ }
+
+ final double value;
+ if (ve instanceof NumberEval) {
+ value = ((NumberEval)ve).getNumberValue();
+ } else {
+ continue;
+ }
+
+ if (descending_order && value>arg0 || !descending_order && value<arg0){
+ rank++;
+ }
+ }
+
+ return new NumberEval(rank);
+ }
+
+ private static Double getValue(AreaEval aeRange, int relRowIndex, int relColIndex) {
+ ValueEval addend = aeRange.getRelativeValue(relRowIndex, relColIndex);
+ if (addend instanceof NumberEval) {
+ return ((NumberEval)addend).getNumberValue();
+ }
+ // everything else (including string and boolean values) counts as zero
+ return null;
+ }
+
+ private static AreaEval convertRangeArg(ValueEval eval) throws EvaluationException {
+ if (eval instanceof AreaEval) {
+ return (AreaEval) eval;
+ }
+ if (eval instanceof RefEval) {
+ return ((RefEval)eval).offset(0, 0, 0, 0);
+ }
+ throw new EvaluationException(ErrorEval.VALUE_INVALID);
+ }
}
diff --git a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java
index 30a02151c6..5fdd48e090 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java
@@ -41,128 +41,128 @@ import org.apache.poi.util.LittleEndian;
* all mean
*/
public final class SlideIdListing {
- private static byte[] fileContents;
-
- public static void main(String[] args) throws IOException {
- if (args.length < 1) {
- System.err.println("Need to give a filename");
- System.exit(1);
- }
-
-
- // Create the slideshow object, for normal working with
- HSLFSlideShowImpl hss = new HSLFSlideShowImpl(args[0]);
- HSLFSlideShow ss = new HSLFSlideShow(hss);
-
- // Grab the base contents
- fileContents = hss.getUnderlyingBytes();
- Record[] records = hss.getRecords();
- Record[] latestRecords = ss.getMostRecentCoreRecords();
-
- // Grab any records that interest us
- Document document = null;
- for (Record latestRecord : latestRecords) {
- if (latestRecord instanceof Document) {
- document = (Document) latestRecord;
- }
- }
-
- System.out.println();
-
-
- // Look for SlidePersistAtoms, and report what they have to
- // say about possible slide IDs
- SlideListWithText[] slwts = document.getSlideListWithTexts();
- for (SlideListWithText slwt : slwts) {
- Record[] cr = slwt.getChildRecords();
- for (Record record : cr) {
- if (record instanceof SlidePersistAtom) {
- SlidePersistAtom spa = (SlidePersistAtom) record;
- System.out.println("SlidePersistAtom knows about slide:");
- System.out.println("\t" + spa.getRefID());
- System.out.println("\t" + spa.getSlideIdentifier());
- }
- }
- }
-
- System.out.println();
-
- // Look for latest core records that are slides or notes
- for (int i=0; i<latestRecords.length; i++) {
- if (latestRecords[i] instanceof Slide) {
- Slide s = (Slide)latestRecords[i];
- SlideAtom sa = s.getSlideAtom();
- System.out.println("Found the latest version of a slide record:");
- System.out.println("\tCore ID is " + s.getSheetId());
- System.out.println("\t(Core Records count is " + i + ")");
- System.out.println("\tDisk Position is " + s.getLastOnDiskOffset());
- System.out.println("\tMaster ID is " + sa.getMasterID());
- System.out.println("\tNotes ID is " + sa.getNotesID());
- }
- }
- System.out.println();
- for (int i=0; i<latestRecords.length; i++) {
- if (latestRecords[i] instanceof Notes) {
- Notes n = (Notes)latestRecords[i];
- NotesAtom na = n.getNotesAtom();
- System.out.println("Found the latest version of a notes record:");
- System.out.println("\tCore ID is " + n.getSheetId());
- System.out.println("\t(Core Records count is " + i + ")");
- System.out.println("\tDisk Position is " + n.getLastOnDiskOffset());
- System.out.println("\tMatching slide is " + na.getSlideID());
- }
- }
-
- System.out.println();
-
- // Find any persist ones first
- int pos = 0;
- for (Record r : records) {
- if (r.getRecordType() == 6001L) {
- // PersistPtrFullBlock
- System.out.println("Found PersistPtrFullBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
- }
- if (r.getRecordType() == 6002L) {
- // PersistPtrIncrementalBlock
- System.out.println("Found PersistPtrIncrementalBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
- PersistPtrHolder pph = (PersistPtrHolder) r;
-
- // Check the sheet offsets
- int[] sheetIDs = pph.getKnownSlideIDs();
- Map<Integer, Integer> 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);
-
- 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! **");
- }
- }
- }
-
- // Increase the position by the on disk size
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- r.writeOut(baos);
- pos += baos.size();
- }
-
- ss.close();
-
- 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);
-
- return Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
- }
+ private static byte[] fileContents;
+
+ public static void main(String[] args) throws IOException {
+ if (args.length < 1) {
+ System.err.println("Need to give a filename");
+ System.exit(1);
+ }
+
+
+ // Create the slideshow object, for normal working with
+ HSLFSlideShowImpl hss = new HSLFSlideShowImpl(args[0]);
+ HSLFSlideShow ss = new HSLFSlideShow(hss);
+
+ // Grab the base contents
+ fileContents = hss.getUnderlyingBytes();
+ Record[] records = hss.getRecords();
+ Record[] latestRecords = ss.getMostRecentCoreRecords();
+
+ // Grab any records that interest us
+ Document document = null;
+ for (Record latestRecord : latestRecords) {
+ if (latestRecord instanceof Document) {
+ document = (Document) latestRecord;
+ }
+ }
+
+ System.out.println();
+
+
+ // Look for SlidePersistAtoms, and report what they have to
+ // say about possible slide IDs
+ SlideListWithText[] slwts = document.getSlideListWithTexts();
+ for (SlideListWithText slwt : slwts) {
+ Record[] cr = slwt.getChildRecords();
+ for (Record record : cr) {
+ if (record instanceof SlidePersistAtom) {
+ SlidePersistAtom spa = (SlidePersistAtom) record;
+ System.out.println("SlidePersistAtom knows about slide:");
+ System.out.println("\t" + spa.getRefID());
+ System.out.println("\t" + spa.getSlideIdentifier());
+ }
+ }
+ }
+
+ System.out.println();
+
+ // Look for latest core records that are slides or notes
+ for (int i=0; i<latestRecords.length; i++) {
+ if (latestRecords[i] instanceof Slide) {
+ Slide s = (Slide)latestRecords[i];
+ SlideAtom sa = s.getSlideAtom();
+ System.out.println("Found the latest version of a slide record:");
+ System.out.println("\tCore ID is " + s.getSheetId());
+ System.out.println("\t(Core Records count is " + i + ")");
+ System.out.println("\tDisk Position is " + s.getLastOnDiskOffset());
+ System.out.println("\tMaster ID is " + sa.getMasterID());
+ System.out.println("\tNotes ID is " + sa.getNotesID());
+ }
+ }
+ System.out.println();
+ for (int i=0; i<latestRecords.length; i++) {
+ if (latestRecords[i] instanceof Notes) {
+ Notes n = (Notes)latestRecords[i];
+ NotesAtom na = n.getNotesAtom();
+ System.out.println("Found the latest version of a notes record:");
+ System.out.println("\tCore ID is " + n.getSheetId());
+ System.out.println("\t(Core Records count is " + i + ")");
+ System.out.println("\tDisk Position is " + n.getLastOnDiskOffset());
+ System.out.println("\tMatching slide is " + na.getSlideID());
+ }
+ }
+
+ System.out.println();
+
+ // Find any persist ones first
+ int pos = 0;
+ for (Record r : records) {
+ if (r.getRecordType() == 6001L) {
+ // PersistPtrFullBlock
+ System.out.println("Found PersistPtrFullBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
+ }
+ if (r.getRecordType() == 6002L) {
+ // PersistPtrIncrementalBlock
+ System.out.println("Found PersistPtrIncrementalBlock at " + pos + " (" + Integer.toHexString(pos) + ")");
+ PersistPtrHolder pph = (PersistPtrHolder) r;
+
+ // Check the sheet offsets
+ int[] sheetIDs = pph.getKnownSlideIDs();
+ Map<Integer, Integer> 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);
+
+ 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! **");
+ }
+ }
+ }
+
+ // Increase the position by the on disk size
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ r.writeOut(baos);
+ pos += baos.size();
+ }
+
+ ss.close();
+
+ 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);
+
+ return Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
+ }
}