diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-07-16 18:08:50 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-07-16 18:08:50 +0000 |
commit | 22badcef272f4c61313b2ea1e520f88f9c65a400 (patch) | |
tree | 39bba51cac6807bd655bce4f878a94863470ae27 /poi-scratchpad | |
parent | 4f54f29a2daa62839d22804d22544e4197cfda75 (diff) | |
download | poi-22badcef272f4c61313b2ea1e520f88f9c65a400.tar.gz poi-22badcef272f4c61313b2ea1e520f88f9c65a400.zip |
[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
Diffstat (limited to 'poi-scratchpad')
8 files changed, 38 insertions, 39 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java index 44cc2aee7f..cdda185953 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/EscherPart.java @@ -85,15 +85,15 @@ public abstract class EscherPart extends HPBFPart { */ protected void generateData() { int size = 0; - for(int i=0; i<records.length; i++) { - size += records[i].getRecordSize(); + for (EscherRecord escherRecord : records) { + size += escherRecord.getRecordSize(); } byte[] data = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); size = 0; - for(int i=0; i<records.length; i++) { + for (EscherRecord record : records) { int thisSize = - records[i].serialize(size, data); + record.serialize(size, data); size += thisSize; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SLWTTextListing.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SLWTTextListing.java index db6bffbaa8..6d94953227 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SLWTTextListing.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/SLWTTextListing.java @@ -67,19 +67,19 @@ public final class SLWTTextListing { // Loop over the records, printing the text Record[] slwtc = thisSets[k].getSlideRecords(); - for(int l=0; l<slwtc.length; l++) { + for (Record record : slwtc) { String text = null; - if(slwtc[l] instanceof TextBytesAtom) { - TextBytesAtom tba = (TextBytesAtom)slwtc[l]; + if (record instanceof TextBytesAtom) { + TextBytesAtom tba = (TextBytesAtom) record; text = tba.getText(); } - if(slwtc[l] instanceof TextCharsAtom) { - TextCharsAtom tca = (TextCharsAtom)slwtc[l]; + if (record instanceof TextCharsAtom) { + TextCharsAtom tca = (TextCharsAtom) record; text = tca.getText(); } - if(text != null) { - text = text.replace('\r','\n'); + if (text != null) { + text = text.replace('\r', '\n'); System.out.println(" ''" + text + "''"); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/MovieShape.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/MovieShape.java index c5e001ff7e..455e2e0a45 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/MovieShape.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/MovieShape.java @@ -160,12 +160,12 @@ public final class MovieShape extends HSLFPictureShape { } Record[] r = lst.getChildRecords(); - for (int i = 0; i < r.length; i++) { - if(r[i] instanceof ExMCIMovie){ - ExMCIMovie mci = (ExMCIMovie)r[i]; + for (Record record : r) { + if (record instanceof ExMCIMovie) { + ExMCIMovie mci = (ExMCIMovie) record; ExVideoContainer exVideo = mci.getExVideo(); int objectId = exVideo.getExMediaAtom().getObjectId(); - if(objectId == idx){ + if (objectId == idx) { return exVideo.getPathAtom().getText(); } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java index 8845454ded..5a7597e45b 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Environment.java @@ -52,11 +52,11 @@ public final class Environment extends PositionDependentRecordContainer _children = Record.findChildRecords(source,start+8,len-8); // Find our FontCollection record - for(int i=0; i<_children.length; i++) { - if(_children[i] instanceof FontCollection) { - fontCollection = (FontCollection)_children[i]; - } else if (_children[i] instanceof TxMasterStyleAtom){ - txmaster = (TxMasterStyleAtom)_children[i]; + for (Record child : _children) { + if (child instanceof FontCollection) { + fontCollection = (FontCollection) child; + } else if (child instanceof TxMasterStyleAtom) { + txmaster = (TxMasterStyleAtom) child; } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java index ccd0975d6f..6ccdae947b 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/ExObjList.java @@ -43,9 +43,9 @@ public class ExObjList extends RecordContainer { */ public ExHyperlink[] getExHyperlinks() { ArrayList<ExHyperlink> links = new ArrayList<>(); - for(int i=0; i<_children.length; i++) { - if(_children[i] instanceof ExHyperlink) { - links.add( (ExHyperlink)_children[i] ); + for (Record child : _children) { + if (child instanceof ExHyperlink) { + links.add((ExHyperlink) child); } } @@ -114,10 +114,10 @@ public class ExObjList extends RecordContainer { * @return found <code>ExHyperlink</code> or <code>null</code> */ public ExHyperlink get(int id){ - for(int i=0; i<_children.length; i++) { - if(_children[i] instanceof ExHyperlink) { - ExHyperlink rec = (ExHyperlink)_children[i]; - if (rec.getExHyperlinkAtom().getNumber() == id){ + for (Record child : _children) { + if (child instanceof ExHyperlink) { + ExHyperlink rec = (ExHyperlink) child; + if (rec.getExHyperlinkAtom().getNumber() == id) { return rec; } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSoundData.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSoundData.java index d6403b204e..10b299cf4f 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSoundData.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSoundData.java @@ -75,13 +75,13 @@ public final class HSLFSoundData { public static HSLFSoundData[] find(Document document){ ArrayList<HSLFSoundData> lst = new ArrayList<>(); org.apache.poi.hslf.record.Record[] ch = document.getChildRecords(); - for (int i = 0; i < ch.length; i++) { - if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){ - RecordContainer col = (RecordContainer)ch[i]; - org.apache.poi.hslf.record.Record[] sr = col.getChildRecords(); - for (int j = 0; j < sr.length; j++) { - if(sr[j] instanceof Sound){ - lst.add(new HSLFSoundData((Sound)sr[j])); + for (Record value : ch) { + if (value.getRecordType() == RecordTypes.SoundCollection.typeID) { + RecordContainer col = (RecordContainer) value; + Record[] sr = col.getChildRecords(); + for (Record record : sr) { + if (record instanceof Sound) { + lst.add(new HSLFSoundData((Sound) record)); } } } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java index 7c30f2346a..3f925f8626 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java @@ -161,8 +161,8 @@ public final class Ffn { System.arraycopy(_fontSig, 0, buf, offset, _fontSig.length); offset += _fontSig.length; - for (int i = 0; i < _xszFfn.length; i++) { - LittleEndian.putShort(buf, offset, (short) _xszFfn[i]); + for (char c : _xszFfn) { + LittleEndian.putShort(buf, offset, (short) c); offset += LittleEndianConsts.SHORT_SIZE; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FontTable.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FontTable.java index 1a67d1c87d..947f8e1009 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FontTable.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FontTable.java @@ -129,9 +129,8 @@ public final class FontTable LittleEndian.putShort(buf, 0, _extraDataSz); tableStream.write(buf); - for(int i = 0; i < _fontNames.length; i++) - { - tableStream.write(_fontNames[i].toByteArray()); + for (Ffn fontName : _fontNames) { + tableStream.write(fontName.toByteArray()); } } |