You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2019/05/22 22:59:12 UTC

svn commit: r1859758 - in /poi/trunk/src: java/org/apache/poi/ss/formula/functions/Rank.java scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java

Author: fanningpj
Date: Wed May 22 22:59:12 2019
New Revision: 1859758

URL: http://svn.apache.org/viewvc?rev=1859758&view=rev
Log:
remove some tab indents

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rank.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rank.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rank.java?rev=1859758&r1=1859757&r2=1859758&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rank.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Rank.java Wed May 22 22:59:12 2019
@@ -45,116 +45,116 @@ import org.apache.poi.ss.formula.eval.Va
  */
 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);
+    }
 
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java?rev=1859758&r1=1859757&r2=1859758&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/SlideIdListing.java Wed May 22 22:59:12 2019
@@ -41,128 +41,128 @@ import org.apache.poi.util.LittleEndian;
  *  all mean
  */
 public final class SlideIdListing {
-	private static byte[] fileContents;
+    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);
+    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);
-	}
+        return Record.createRecordForType(type,fileContents,pos,(int)rlen+8);
+    }
 }



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