diff options
author | rbuj <robert.buj@gmail.com> | 2014-07-27 12:01:40 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-07-28 10:18:13 +0000 |
commit | a9a944eab5edae826767fabdbc12ee4e74d76d23 (patch) | |
tree | 656794ef2e937bd8349c997c130a394e6c22c2fd /xmerge | |
parent | e221c954ea0b7c3846bd6971a06b6a28672a28c7 (diff) |
xmerge: Enhanced For-Loops
Change-Id: Id9fbffbf74d7583bf1ac8239899abdf0c2347cf2
Reviewed-on: https://gerrit.libreoffice.org/10573
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'xmerge')
6 files changed, 22 insertions, 39 deletions
diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java index cd362f7fa9ab..5a24b43c4426 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/palm/PalmDB.java @@ -353,8 +353,9 @@ public final class PalmDB { out.writeShort(records.length); // let each Record object write out its own info. - for (int i = 0; i < records.length; i++) - records[i].write(out); + for (Record record : records) { + record.write(out); + } } /** diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java index 3e170b5d387f..cc45fa5f486f 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/TextStyle.java @@ -662,9 +662,10 @@ public class TextStyle extends Style implements Cloneable { * otherwise false. */ private boolean isIgnored(String attribute) { - for (int i = 0; i < ignored.length; i++) { - if (ignored[i].equals(attribute)) + for (String ignored1 : ignored) { + if (ignored1.equals(attribute)) { return true; + } } return false; } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java index f1cf6a16ba22..255d8bfaeaa5 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/converter/xml/sxc/BookSettings.java @@ -19,7 +19,6 @@ package org.openoffice.xmerge.converter.xml.sxc; import java.util.ArrayList; -import java.util.Iterator; import org.openoffice.xmerge.converter.xml.OfficeConstants; import org.openoffice.xmerge.util.Debug; @@ -138,8 +137,7 @@ public class BookSettings implements OfficeConstants { this.settings = settings; Element configItemMapNamed = settings.createElement(TAG_CONFIG_ITEM_MAP_NAMED); configItemMapNamed.setAttribute(ATTRIBUTE_CONFIG_NAME, "Tables"); - for(Iterator<SheetSettings> e = worksheetSettings.iterator();e.hasNext();) { - SheetSettings s = e.next(); + for (SheetSettings s : worksheetSettings) { s.writeNode(settings, configItemMapNamed); } addConfigItem(root, "ActiveTable", "string", activeSheet); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java index 87dd1dabbf05..a4ba311964da 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/merger/merge/DocumentMerge.java @@ -64,18 +64,18 @@ public class DocumentMerge implements MergeAlgorithm { int currentPosition = -1; boolean haveDeleteOperation = false; - for (int i = 0; i < differences.length; i++) { - if (differences[i].getOrgPosition() > currentPosition) { - currentPosition = differences[i].getOrgPosition(); - if (differences[i].getOperation() == Difference.DELETE) { + for (Difference difference : differences) { + if (difference.getOrgPosition() > currentPosition) { + currentPosition = difference.getOrgPosition(); + if (difference.getOperation() == Difference.DELETE) { haveDeleteOperation = true; } else { haveDeleteOperation = false; } - } else if (differences[i].getOrgPosition() == currentPosition) { - if (differences[i].getOperation() == Difference.DELETE) { + } else if (difference.getOrgPosition() == currentPosition) { + if (difference.getOperation() == Difference.DELETE) { haveDeleteOperation = true; - } else if (differences[i].getOperation() == Difference.ADD && + } else if (difference.getOperation() == Difference.ADD && haveDeleteOperation == true) { throw new MergeException( "Differences array is not sorted. Delete before Add"); @@ -93,9 +93,7 @@ public class DocumentMerge implements MergeAlgorithm { int modSeqCounter = 0; // check for each diff unit in the diff array to apply the diff - for (int i = 0; i < differences.length; i++) { - - Difference currentDiff = differences[i]; + for (Difference currentDiff : differences) { int operation = currentDiff.getOperation(); diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java index d6b171c8050d..6458290fdbe6 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfo.java @@ -384,8 +384,8 @@ public class ConverterInfo { public static boolean isValidOfficeType(String officeMime) { boolean rc = false; - for (int i=0; i < validOfficeTypes.length; i++) { - if (officeMime.equals(validOfficeTypes[i])) { + for (String validOfficeType : validOfficeTypes) { + if (officeMime.equals(validOfficeType)) { rc = true; } } diff --git a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java index c53437aa48fe..1bf160df27d2 100644 --- a/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java +++ b/xmerge/source/xmerge/java/org/openoffice/xmerge/util/registry/ConverterInfoMgr.java @@ -53,8 +53,6 @@ public final class ConverterInfoMgr { */ public static void addPlugIn(ConverterInfo ci) throws RegistryException { - ConverterInfo converterInfo; - // Validate if (ci.getDisplayName() == null) { @@ -80,10 +78,7 @@ public final class ConverterInfoMgr { // Verify there is no converter with the same Display Name in // the registry. - - Iterator<ConverterInfo> ciEnum = converterInfoList.iterator(); - while (ciEnum.hasNext()) { - converterInfo = ciEnum.next(); + for (ConverterInfo converterInfo : converterInfoList) { if (ci.getDisplayName().equals(converterInfo.getDisplayName())) { RegistryException re = new RegistryException( "Converter with specified display name already exists."); @@ -179,16 +174,12 @@ public final class ConverterInfoMgr { */ public static boolean removeByName(String name) { - ConverterInfo converterInfo; boolean rc = false; - Iterator<ConverterInfo> ciEnum = converterInfoList.iterator(); - while (ciEnum.hasNext()) - { - converterInfo = ciEnum.next(); + for (ConverterInfo converterInfo : converterInfoList) { if (name.equals(converterInfo.getDisplayName())) { - converterInfoList.remove(converterInfo); - rc = true; + converterInfoList.remove(converterInfo); + rc = true; } } return rc; @@ -208,19 +199,13 @@ public final class ConverterInfoMgr { */ public static ConverterInfo findConverterInfo(String deviceMime, String officeMime) { - ConverterInfo converterInfo; - if (deviceMime == null || ConverterInfo.isValidOfficeType(officeMime) == false) { return null; } // Loop over elements comparing with deviceFromMime - - Iterator<ConverterInfo> ciEnum = converterInfoList.iterator(); - while (ciEnum.hasNext()) { - - converterInfo = ciEnum.next(); + for (ConverterInfo converterInfo : converterInfoList) { String toDeviceInfo = converterInfo.getOfficeMime(); Iterator<String> fromEnum = converterInfo.getDeviceMime(); |