mirror of https://github.com/apache/poi.git
[github-342] Use foreach. Thanks to XenoAmess. This closes #342
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4f54f29a2d
commit
22badcef27
|
@ -160,8 +160,7 @@ public class XSSFDataValidationHelper implements DataValidationHelper {
|
||||||
|
|
||||||
CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.getCellRangeAddresses();
|
CellRangeAddress[] cellRangeAddresses = cellRangeAddressList.getCellRangeAddresses();
|
||||||
List<String> sqref = new ArrayList<>();
|
List<String> sqref = new ArrayList<>();
|
||||||
for (int i = 0; i < cellRangeAddresses.length; i++) {
|
for (CellRangeAddress cellRangeAddress : cellRangeAddresses) {
|
||||||
CellRangeAddress cellRangeAddress = cellRangeAddresses[i];
|
|
||||||
sqref.add(cellRangeAddress.formatAsString());
|
sqref.add(cellRangeAddress.formatAsString());
|
||||||
}
|
}
|
||||||
newDataValidation.setSqref(sqref);
|
newDataValidation.setSqref(sqref);
|
||||||
|
|
|
@ -85,15 +85,15 @@ public abstract class EscherPart extends HPBFPart {
|
||||||
*/
|
*/
|
||||||
protected void generateData() {
|
protected void generateData() {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for(int i=0; i<records.length; i++) {
|
for (EscherRecord escherRecord : records) {
|
||||||
size += records[i].getRecordSize();
|
size += escherRecord.getRecordSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] data = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
|
byte[] data = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
|
||||||
size = 0;
|
size = 0;
|
||||||
for(int i=0; i<records.length; i++) {
|
for (EscherRecord record : records) {
|
||||||
int thisSize =
|
int thisSize =
|
||||||
records[i].serialize(size, data);
|
record.serialize(size, data);
|
||||||
size += thisSize;
|
size += thisSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,19 +67,19 @@ public final class SLWTTextListing {
|
||||||
|
|
||||||
// Loop over the records, printing the text
|
// Loop over the records, printing the text
|
||||||
Record[] slwtc = thisSets[k].getSlideRecords();
|
Record[] slwtc = thisSets[k].getSlideRecords();
|
||||||
for(int l=0; l<slwtc.length; l++) {
|
for (Record record : slwtc) {
|
||||||
String text = null;
|
String text = null;
|
||||||
if(slwtc[l] instanceof TextBytesAtom) {
|
if (record instanceof TextBytesAtom) {
|
||||||
TextBytesAtom tba = (TextBytesAtom)slwtc[l];
|
TextBytesAtom tba = (TextBytesAtom) record;
|
||||||
text = tba.getText();
|
text = tba.getText();
|
||||||
}
|
}
|
||||||
if(slwtc[l] instanceof TextCharsAtom) {
|
if (record instanceof TextCharsAtom) {
|
||||||
TextCharsAtom tca = (TextCharsAtom)slwtc[l];
|
TextCharsAtom tca = (TextCharsAtom) record;
|
||||||
text = tca.getText();
|
text = tca.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(text != null) {
|
if (text != null) {
|
||||||
text = text.replace('\r','\n');
|
text = text.replace('\r', '\n');
|
||||||
System.out.println(" ''" + text + "''");
|
System.out.println(" ''" + text + "''");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,12 +160,12 @@ public final class MovieShape extends HSLFPictureShape {
|
||||||
}
|
}
|
||||||
|
|
||||||
Record[] r = lst.getChildRecords();
|
Record[] r = lst.getChildRecords();
|
||||||
for (int i = 0; i < r.length; i++) {
|
for (Record record : r) {
|
||||||
if(r[i] instanceof ExMCIMovie){
|
if (record instanceof ExMCIMovie) {
|
||||||
ExMCIMovie mci = (ExMCIMovie)r[i];
|
ExMCIMovie mci = (ExMCIMovie) record;
|
||||||
ExVideoContainer exVideo = mci.getExVideo();
|
ExVideoContainer exVideo = mci.getExVideo();
|
||||||
int objectId = exVideo.getExMediaAtom().getObjectId();
|
int objectId = exVideo.getExMediaAtom().getObjectId();
|
||||||
if(objectId == idx){
|
if (objectId == idx) {
|
||||||
return exVideo.getPathAtom().getText();
|
return exVideo.getPathAtom().getText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,11 @@ public final class Environment extends PositionDependentRecordContainer
|
||||||
_children = Record.findChildRecords(source,start+8,len-8);
|
_children = Record.findChildRecords(source,start+8,len-8);
|
||||||
|
|
||||||
// Find our FontCollection record
|
// Find our FontCollection record
|
||||||
for(int i=0; i<_children.length; i++) {
|
for (Record child : _children) {
|
||||||
if(_children[i] instanceof FontCollection) {
|
if (child instanceof FontCollection) {
|
||||||
fontCollection = (FontCollection)_children[i];
|
fontCollection = (FontCollection) child;
|
||||||
} else if (_children[i] instanceof TxMasterStyleAtom){
|
} else if (child instanceof TxMasterStyleAtom) {
|
||||||
txmaster = (TxMasterStyleAtom)_children[i];
|
txmaster = (TxMasterStyleAtom) child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,9 @@ public class ExObjList extends RecordContainer {
|
||||||
*/
|
*/
|
||||||
public ExHyperlink[] getExHyperlinks() {
|
public ExHyperlink[] getExHyperlinks() {
|
||||||
ArrayList<ExHyperlink> links = new ArrayList<>();
|
ArrayList<ExHyperlink> links = new ArrayList<>();
|
||||||
for(int i=0; i<_children.length; i++) {
|
for (Record child : _children) {
|
||||||
if(_children[i] instanceof ExHyperlink) {
|
if (child instanceof ExHyperlink) {
|
||||||
links.add( (ExHyperlink)_children[i] );
|
links.add((ExHyperlink) child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,10 +114,10 @@ public class ExObjList extends RecordContainer {
|
||||||
* @return found <code>ExHyperlink</code> or <code>null</code>
|
* @return found <code>ExHyperlink</code> or <code>null</code>
|
||||||
*/
|
*/
|
||||||
public ExHyperlink get(int id){
|
public ExHyperlink get(int id){
|
||||||
for(int i=0; i<_children.length; i++) {
|
for (Record child : _children) {
|
||||||
if(_children[i] instanceof ExHyperlink) {
|
if (child instanceof ExHyperlink) {
|
||||||
ExHyperlink rec = (ExHyperlink)_children[i];
|
ExHyperlink rec = (ExHyperlink) child;
|
||||||
if (rec.getExHyperlinkAtom().getNumber() == id){
|
if (rec.getExHyperlinkAtom().getNumber() == id) {
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,13 +75,13 @@ public final class HSLFSoundData {
|
||||||
public static HSLFSoundData[] find(Document document){
|
public static HSLFSoundData[] find(Document document){
|
||||||
ArrayList<HSLFSoundData> lst = new ArrayList<>();
|
ArrayList<HSLFSoundData> lst = new ArrayList<>();
|
||||||
org.apache.poi.hslf.record.Record[] ch = document.getChildRecords();
|
org.apache.poi.hslf.record.Record[] ch = document.getChildRecords();
|
||||||
for (int i = 0; i < ch.length; i++) {
|
for (Record value : ch) {
|
||||||
if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){
|
if (value.getRecordType() == RecordTypes.SoundCollection.typeID) {
|
||||||
RecordContainer col = (RecordContainer)ch[i];
|
RecordContainer col = (RecordContainer) value;
|
||||||
org.apache.poi.hslf.record.Record[] sr = col.getChildRecords();
|
Record[] sr = col.getChildRecords();
|
||||||
for (int j = 0; j < sr.length; j++) {
|
for (Record record : sr) {
|
||||||
if(sr[j] instanceof Sound){
|
if (record instanceof Sound) {
|
||||||
lst.add(new HSLFSoundData((Sound)sr[j]));
|
lst.add(new HSLFSoundData((Sound) record));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,8 +161,8 @@ public final class Ffn {
|
||||||
System.arraycopy(_fontSig, 0, buf, offset, _fontSig.length);
|
System.arraycopy(_fontSig, 0, buf, offset, _fontSig.length);
|
||||||
offset += _fontSig.length;
|
offset += _fontSig.length;
|
||||||
|
|
||||||
for (int i = 0; i < _xszFfn.length; i++) {
|
for (char c : _xszFfn) {
|
||||||
LittleEndian.putShort(buf, offset, (short) _xszFfn[i]);
|
LittleEndian.putShort(buf, offset, (short) c);
|
||||||
offset += LittleEndianConsts.SHORT_SIZE;
|
offset += LittleEndianConsts.SHORT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,9 +129,8 @@ public final class FontTable
|
||||||
LittleEndian.putShort(buf, 0, _extraDataSz);
|
LittleEndian.putShort(buf, 0, _extraDataSz);
|
||||||
tableStream.write(buf);
|
tableStream.write(buf);
|
||||||
|
|
||||||
for(int i = 0; i < _fontNames.length; i++)
|
for (Ffn fontName : _fontNames) {
|
||||||
{
|
tableStream.write(fontName.toByteArray());
|
||||||
tableStream.write(_fontNames[i].toByteArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,7 @@ public class HSSFRequest {
|
||||||
|
|
||||||
if (listeners != null) {
|
if (listeners != null) {
|
||||||
|
|
||||||
for (int k = 0; k < listeners.size(); k++) {
|
for (Object listenObj : listeners) {
|
||||||
Object listenObj = listeners.get(k);
|
|
||||||
if (listenObj instanceof AbortableHSSFListener) {
|
if (listenObj instanceof AbortableHSSFListener) {
|
||||||
AbortableHSSFListener listener = (AbortableHSSFListener) listenObj;
|
AbortableHSSFListener listener = (AbortableHSSFListener) listenObj;
|
||||||
userCode = listener.abortableProcessRecord(rec);
|
userCode = listener.abortableProcessRecord(rec);
|
||||||
|
|
|
@ -294,10 +294,7 @@ final class LinkTable {
|
||||||
* @param sheetNumber 1-based sheet number
|
* @param sheetNumber 1-based sheet number
|
||||||
*/
|
*/
|
||||||
public NameRecord getSpecificBuiltinRecord(byte builtInCode, int sheetNumber) {
|
public NameRecord getSpecificBuiltinRecord(byte builtInCode, int sheetNumber) {
|
||||||
Iterator<NameRecord> iterator = _definedNames.iterator();
|
for (NameRecord record : _definedNames) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
NameRecord record = iterator.next();
|
|
||||||
|
|
||||||
//print areas are one based
|
//print areas are one based
|
||||||
if (record.getBuiltInName() == builtInCode && record.getSheetNumber() == sheetNumber) {
|
if (record.getBuiltInName() == builtInCode && record.getSheetNumber() == sheetNumber) {
|
||||||
return record;
|
return record;
|
||||||
|
|
|
@ -173,8 +173,7 @@ public final class ObjRecord extends Record {
|
||||||
|
|
||||||
if (_uninterpretedData == null) {
|
if (_uninterpretedData == null) {
|
||||||
|
|
||||||
for (int i = 0; i < subrecords.size(); i++) {
|
for (SubRecord record : subrecords) {
|
||||||
SubRecord record = subrecords.get(i);
|
|
||||||
record.serialize(out);
|
record.serialize(out);
|
||||||
}
|
}
|
||||||
int expectedEndIx = offset + dataSize;
|
int expectedEndIx = offset + dataSize;
|
||||||
|
|
|
@ -69,12 +69,11 @@ public final class ChartSubstreamRecordAggregate extends RecordAggregate {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rv.visitRecord(_bofRec);
|
rv.visitRecord(_bofRec);
|
||||||
for (int i = 0; i < _recs.size(); i++) {
|
for (RecordBase rb : _recs) {
|
||||||
RecordBase rb = _recs.get(i);
|
|
||||||
if (rb instanceof RecordAggregate) {
|
if (rb instanceof RecordAggregate) {
|
||||||
((RecordAggregate) rb).visitContainedRecords(rv);
|
((RecordAggregate) rb).visitContainedRecords(rv);
|
||||||
} else {
|
} else {
|
||||||
rv.visitRecord((org.apache.poi.hssf.record.Record) rb);
|
rv.visitRecord((Record) rb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rv.visitRecord(EOFRecord.instance);
|
rv.visitRecord(EOFRecord.instance);
|
||||||
|
|
|
@ -73,12 +73,11 @@ public final class CustomViewSettingsRecordAggregate extends RecordAggregate {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rv.visitRecord(_begin);
|
rv.visitRecord(_begin);
|
||||||
for (int i = 0; i < _recs.size(); i++) {
|
for (RecordBase rb : _recs) {
|
||||||
RecordBase rb = _recs.get(i);
|
|
||||||
if (rb instanceof RecordAggregate) {
|
if (rb instanceof RecordAggregate) {
|
||||||
((RecordAggregate) rb).visitContainedRecords(rv);
|
((RecordAggregate) rb).visitContainedRecords(rv);
|
||||||
} else {
|
} else {
|
||||||
rv.visitRecord((org.apache.poi.hssf.record.Record) rb);
|
rv.visitRecord((Record) rb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rv.visitRecord(_end);
|
rv.visitRecord(_end);
|
||||||
|
|
|
@ -131,11 +131,10 @@ public final class ValueRecordsAggregate implements Iterable<CellValueRecordInte
|
||||||
|
|
||||||
public int getPhysicalNumberOfCells() {
|
public int getPhysicalNumberOfCells() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int r = 0; r < records.length; r++) {
|
for (CellValueRecordInterface[] rowCells : records) {
|
||||||
CellValueRecordInterface[] rowCells = records[r];
|
|
||||||
if (rowCells != null) {
|
if (rowCells != null) {
|
||||||
for (int c = 0; c < rowCells.length; c++) {
|
for (CellValueRecordInterface rowCell : rowCells) {
|
||||||
if (rowCells[c] != null)
|
if (rowCell != null)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +200,9 @@ public final class ValueRecordsAggregate implements Iterable<CellValueRecordInte
|
||||||
}
|
}
|
||||||
CellValueRecordInterface[] rowCells=records[row];
|
CellValueRecordInterface[] rowCells=records[row];
|
||||||
if(rowCells==null) return false;
|
if(rowCells==null) return false;
|
||||||
for(int col=0;col<rowCells.length;col++) {
|
for (CellValueRecordInterface rowCell : rowCells) {
|
||||||
if(rowCells[col]!=null) return true;
|
if (rowCell != null)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -281,17 +281,16 @@ public final class ValueRecordsAggregate implements Iterable<CellValueRecordInte
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateFormulasAfterRowShift(FormulaShifter shifter, int currentExternSheetIndex) {
|
public void updateFormulasAfterRowShift(FormulaShifter shifter, int currentExternSheetIndex) {
|
||||||
for (int i = 0; i < records.length; i++) {
|
for (CellValueRecordInterface[] rowCells : records) {
|
||||||
CellValueRecordInterface[] rowCells = records[i];
|
|
||||||
if (rowCells == null) {
|
if (rowCells == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int j = 0; j < rowCells.length; j++) {
|
for (CellValueRecordInterface cell : rowCells) {
|
||||||
CellValueRecordInterface cell = rowCells[j];
|
|
||||||
if (cell instanceof FormulaRecordAggregate) {
|
if (cell instanceof FormulaRecordAggregate) {
|
||||||
FormulaRecordAggregate fra = (FormulaRecordAggregate)cell;
|
FormulaRecordAggregate fra = (FormulaRecordAggregate) cell;
|
||||||
Ptg[] ptgs = fra.getFormulaTokens(); // needs clone() inside this getter?
|
Ptg[] ptgs = fra.getFormulaTokens(); // needs clone() inside this getter?
|
||||||
Ptg[] ptgs2 = ((FormulaRecordAggregate)cell).getFormulaRecord().getParsedExpression(); // needs clone() inside this getter?
|
Ptg[] ptgs2 = ((FormulaRecordAggregate) cell).getFormulaRecord().getParsedExpression(); // needs
|
||||||
|
// clone() inside this getter?
|
||||||
|
|
||||||
if (shifter.adjustFormula(ptgs, currentExternSheetIndex)) {
|
if (shifter.adjustFormula(ptgs, currentExternSheetIndex)) {
|
||||||
fra.setParsedExpression(ptgs);
|
fra.setParsedExpression(ptgs);
|
||||||
|
|
|
@ -55,9 +55,7 @@ public final class HSSFDataFormat implements DataFormat {
|
||||||
HSSFDataFormat(InternalWorkbook workbook) {
|
HSSFDataFormat(InternalWorkbook workbook) {
|
||||||
_workbook = workbook;
|
_workbook = workbook;
|
||||||
|
|
||||||
Iterator<FormatRecord> i = workbook.getFormats().iterator();
|
for (FormatRecord r : workbook.getFormats()) {
|
||||||
while (i.hasNext()) {
|
|
||||||
FormatRecord r = i.next();
|
|
||||||
ensureFormatsSize(r.getIndexCode());
|
ensureFormatsSize(r.getIndexCode());
|
||||||
_formats.set(r.getIndexCode(), r.getFormatString());
|
_formats.set(r.getIndexCode(), r.getFormatString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,8 @@ public final class HSSFObjectData extends HSSFPicture implements ObjectData {
|
||||||
* Exception if there wasn't one
|
* Exception if there wasn't one
|
||||||
*/
|
*/
|
||||||
protected EmbeddedObjectRefSubRecord findObjectRecord() {
|
protected EmbeddedObjectRefSubRecord findObjectRecord() {
|
||||||
Iterator<SubRecord> subRecordIter = getObjRecord().getSubRecords().iterator();
|
|
||||||
|
|
||||||
while (subRecordIter.hasNext()) {
|
for (Object subRecord : getObjRecord().getSubRecords()) {
|
||||||
Object subRecord = subRecordIter.next();
|
|
||||||
if (subRecord instanceof EmbeddedObjectRefSubRecord) {
|
if (subRecord instanceof EmbeddedObjectRefSubRecord) {
|
||||||
return (EmbeddedObjectRefSubRecord) subRecord;
|
return (EmbeddedObjectRefSubRecord) subRecord;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,11 +67,10 @@ public class POIFSViewEngine
|
||||||
{
|
{
|
||||||
Object[] data = inspected.getViewableArray();
|
Object[] data = inspected.getViewableArray();
|
||||||
|
|
||||||
for (int j = 0; j < data.length; j++)
|
for (Object datum : data) {
|
||||||
{
|
objects.addAll(inspectViewable(datum, drilldown,
|
||||||
objects.addAll(inspectViewable(data[ j ], drilldown,
|
indentLevel + 1,
|
||||||
indentLevel + 1,
|
indentString));
|
||||||
indentString));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -111,8 +111,7 @@ abstract class CellCacheEntry implements ICacheEntry {
|
||||||
protected final void recurseClearCachedFormulaResults() {
|
protected final void recurseClearCachedFormulaResults() {
|
||||||
FormulaCellCacheEntry[] formulaCells = getConsumingCells();
|
FormulaCellCacheEntry[] formulaCells = getConsumingCells();
|
||||||
|
|
||||||
for (int i = 0; i < formulaCells.length; i++) {
|
for (FormulaCellCacheEntry fc : formulaCells) {
|
||||||
FormulaCellCacheEntry fc = formulaCells[i];
|
|
||||||
fc.clearFormulaEntry();
|
fc.clearFormulaEntry();
|
||||||
if (fc != this) {
|
if (fc != this) {
|
||||||
fc.recurseClearCachedFormulaResults();
|
fc.recurseClearCachedFormulaResults();
|
||||||
|
@ -127,11 +126,10 @@ abstract class CellCacheEntry implements ICacheEntry {
|
||||||
FormulaCellCacheEntry[] formulaCells = getConsumingCells();
|
FormulaCellCacheEntry[] formulaCells = getConsumingCells();
|
||||||
|
|
||||||
listener.sortDependentCachedValues(formulaCells);
|
listener.sortDependentCachedValues(formulaCells);
|
||||||
for (int i = 0; i < formulaCells.length; i++) {
|
for (FormulaCellCacheEntry fc : formulaCells) {
|
||||||
FormulaCellCacheEntry fc = formulaCells[i];
|
|
||||||
listener.onClearDependentCachedValue(fc, depth);
|
listener.onClearDependentCachedValue(fc, depth);
|
||||||
fc.clearFormulaEntry();
|
fc.clearFormulaEntry();
|
||||||
fc.recurseClearCachedFormulaResults(listener, depth+1);
|
fc.recurseClearCachedFormulaResults(listener, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,8 @@ final class FormulaCellCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyOperation(IEntryOperation operation) {
|
public void applyOperation(IEntryOperation operation) {
|
||||||
Iterator<FormulaCellCacheEntry> i = _formulaEntriesByCell.values().iterator();
|
for (FormulaCellCacheEntry formulaCellCacheEntry : _formulaEntriesByCell.values()) {
|
||||||
while (i.hasNext()) {
|
operation.processEntry(formulaCellCacheEntry);
|
||||||
operation.processEntry(i.next());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,8 @@ final class FormulaCellCacheEntry extends CellCacheEntry {
|
||||||
|
|
||||||
CellCacheEntry[] prevUsedCells = _sensitiveInputCells;
|
CellCacheEntry[] prevUsedCells = _sensitiveInputCells;
|
||||||
int nUsed = usedCells.length;
|
int nUsed = usedCells.length;
|
||||||
for (int i = 0; i < nUsed; i++) {
|
for (CellCacheEntry usedCell : usedCells) {
|
||||||
usedCells[i].addConsumingCell(this);
|
usedCell.addConsumingCell(this);
|
||||||
}
|
}
|
||||||
if (prevUsedCells == null) {
|
if (prevUsedCells == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -97,8 +97,7 @@ final class FormulaCellCacheEntry extends CellCacheEntry {
|
||||||
usedSet = new HashSet<>(nUsed * 3 / 2);
|
usedSet = new HashSet<>(nUsed * 3 / 2);
|
||||||
usedSet.addAll(Arrays.asList(usedCells).subList(0, nUsed));
|
usedSet.addAll(Arrays.asList(usedCells).subList(0, nUsed));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nPrevUsed; i++) {
|
for (CellCacheEntry prevUsed : prevUsedCells) {
|
||||||
CellCacheEntry prevUsed = prevUsedCells[i];
|
|
||||||
if (!usedSet.contains(prevUsed)) {
|
if (!usedSet.contains(prevUsed)) {
|
||||||
// previously was used by cellLoc, but not anymore
|
// previously was used by cellLoc, but not anymore
|
||||||
prevUsed.clearConsumingCell(this);
|
prevUsed.clearConsumingCell(this);
|
||||||
|
|
|
@ -41,8 +41,7 @@ final class FormulaCellCacheEntrySet {
|
||||||
}
|
}
|
||||||
FormulaCellCacheEntry[] result = new FormulaCellCacheEntry[nItems];
|
FormulaCellCacheEntry[] result = new FormulaCellCacheEntry[nItems];
|
||||||
int j=0;
|
int j=0;
|
||||||
for(int i=0; i<_arr.length; i++) {
|
for (FormulaCellCacheEntry cce : _arr) {
|
||||||
FormulaCellCacheEntry cce = _arr[i];
|
|
||||||
if (cce != null) {
|
if (cce != null) {
|
||||||
result[j++] = cce;
|
result[j++] = cce;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ public final class Count implements Function {
|
||||||
|
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
|
|
||||||
for(int i=0; i<nArgs; i++) {
|
for (ValueEval arg : args) {
|
||||||
temp += CountUtils.countArg(args[i], _predicate);
|
temp += CountUtils.countArg(arg, _predicate);
|
||||||
|
|
||||||
}
|
}
|
||||||
return new NumberEval(temp);
|
return new NumberEval(temp);
|
||||||
|
|
|
@ -57,8 +57,8 @@ public final class Counta implements Function {
|
||||||
|
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
|
|
||||||
for(int i=0; i<nArgs; i++) {
|
for (ValueEval arg : args) {
|
||||||
temp += CountUtils.countArg(args[i], _predicate);
|
temp += CountUtils.countArg(arg, _predicate);
|
||||||
|
|
||||||
}
|
}
|
||||||
return new NumberEval(temp);
|
return new NumberEval(temp);
|
||||||
|
|
|
@ -63,13 +63,13 @@ public class Gcd implements FreeRefFunction {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ArrayList<Long> evals = new ArrayList<>();
|
ArrayList<Long> evals = new ArrayList<>();
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (ValueEval arg : args) {
|
||||||
ValueEval ve = OperandResolver.getSingleValue(args[i], ec.getRowIndex(), ec.getColumnIndex());
|
ValueEval ve = OperandResolver.getSingleValue(arg, ec.getRowIndex(), ec.getColumnIndex());
|
||||||
double d = OperandResolver.coerceValueToDouble(ve);
|
double d = OperandResolver.coerceValueToDouble(ve);
|
||||||
if (isInvalidInput(d)) {
|
if (isInvalidInput(d)) {
|
||||||
return ErrorEval.NUM_ERROR;
|
return ErrorEval.NUM_ERROR;
|
||||||
}
|
}
|
||||||
evals.add((long)d);
|
evals.add((long) d);
|
||||||
}
|
}
|
||||||
long result = evals.get(0);
|
long result = evals.get(0);
|
||||||
for (int i = 1; i < evals.size(); i++) {
|
for (int i = 1; i < evals.size(); i++) {
|
||||||
|
|
|
@ -63,13 +63,13 @@ public class Lcm implements FreeRefFunction {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
ArrayList<Long> evals = new ArrayList<>();
|
ArrayList<Long> evals = new ArrayList<>();
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (ValueEval arg : args) {
|
||||||
ValueEval ve = OperandResolver.getSingleValue(args[i], ec.getRowIndex(), ec.getColumnIndex());
|
ValueEval ve = OperandResolver.getSingleValue(arg, ec.getRowIndex(), ec.getColumnIndex());
|
||||||
double d = OperandResolver.coerceValueToDouble(ve);
|
double d = OperandResolver.coerceValueToDouble(ve);
|
||||||
if (isInvalidInput(d)) {
|
if (isInvalidInput(d)) {
|
||||||
return ErrorEval.NUM_ERROR;
|
return ErrorEval.NUM_ERROR;
|
||||||
}
|
}
|
||||||
evals.add((long)d);
|
evals.add((long) d);
|
||||||
}
|
}
|
||||||
long result = evals.get(0);
|
long result = evals.get(0);
|
||||||
for (int i = 1; i < evals.size(); i++) {
|
for (int i = 1; i < evals.size(); i++) {
|
||||||
|
|
|
@ -114,8 +114,8 @@ public abstract class MultiOperandNumericFunction implements Function {
|
||||||
}
|
}
|
||||||
DoubleList retval = new DoubleList();
|
DoubleList retval = new DoubleList();
|
||||||
|
|
||||||
for (int i = 0, iSize = operands.length; i < iSize; i++) {
|
for (ValueEval operand : operands) {
|
||||||
collectValues(operands[i], retval);
|
collectValues(operand, retval);
|
||||||
}
|
}
|
||||||
return retval.toArray();
|
return retval.toArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,13 @@ final class StatsLib {
|
||||||
double r = 0;
|
double r = 0;
|
||||||
double m = 0;
|
double m = 0;
|
||||||
double s = 0;
|
double s = 0;
|
||||||
for (int i=0, iSize=v.length; i<iSize; i++) {
|
for (double item : v) {
|
||||||
s += v[i];
|
s += item;
|
||||||
}
|
}
|
||||||
m = s / v.length;
|
m = s / v.length;
|
||||||
s = 0;
|
s = 0;
|
||||||
for (int i=0, iSize=v.length; i<iSize; i++) {
|
for (double value : v) {
|
||||||
s += Math.abs(v[i]-m);
|
s += Math.abs(value - m);
|
||||||
}
|
}
|
||||||
r = s / v.length;
|
r = s / v.length;
|
||||||
return r;
|
return r;
|
||||||
|
@ -102,13 +102,13 @@ final class StatsLib {
|
||||||
double m = 0;
|
double m = 0;
|
||||||
double s = 0;
|
double s = 0;
|
||||||
int n = v.length;
|
int n = v.length;
|
||||||
for (int i=0; i<n; i++) {
|
for (double item : v) {
|
||||||
s += v[i];
|
s += item;
|
||||||
}
|
}
|
||||||
m = s / n;
|
m = s / n;
|
||||||
s = 0;
|
s = 0;
|
||||||
for (int i=0; i<n; i++) {
|
for (double value : v) {
|
||||||
s += (v[i]- m) * (v[i] - m);
|
s += (value - m) * (value - m);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = (n == 1)
|
r = (n == 1)
|
||||||
|
|
|
@ -78,8 +78,8 @@ final class TestCellRangeUtil {
|
||||||
private static Set<CellAddress> getCellAddresses(CellRangeAddress[] ranges) {
|
private static Set<CellAddress> getCellAddresses(CellRangeAddress[] ranges) {
|
||||||
final Set<CellAddress> set = new HashSet<>();
|
final Set<CellAddress> set = new HashSet<>();
|
||||||
for (final CellRangeAddress range : ranges) {
|
for (final CellRangeAddress range : ranges) {
|
||||||
for (Iterator<CellAddress> iter = range.iterator(); iter.hasNext(); ) {
|
for (CellAddress cellAddress : range) {
|
||||||
set.add(iter.next());
|
set.add(cellAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return set;
|
return set;
|
||||||
|
|
Loading…
Reference in New Issue