From: Andreas Beeker Date: Sun, 26 Jan 2014 16:26:59 +0000 (+0000) Subject: TreeSet without JDK 6 method usages X-Git-Tag: REL_3_10_FINAL^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ba8bfcc27b88591b62ab4c9252e871ac5730162b;p=poi.git TreeSet without JDK 6 method usages git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1561511 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java index e8751ef896..4f64c7a4db 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java @@ -123,15 +123,31 @@ public class ColumnHelper { if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; while (currentIndex <= nextIndex && !currentElements.isEmpty()) { Set currentIndexElements = new HashSet(); - CTCol currentElem = currentElements.first(); - long currentElemIndex = currentElem.getMax(); - currentIndexElements.add(currentElem); - while (currentElements.higher(currentElem) != null && currentElements.higher(currentElem).getMax() == currentElemIndex) { - currentElem = currentElements.higher(currentElem); + long currentElemIndex; + + { + // narrow scope of currentElem + CTCol currentElem = currentElements.first(); + currentElemIndex = currentElem.getMax(); currentIndexElements.add(currentElem); - if (col.getMax() > currentMax) currentMax = col.getMax(); - if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; + + for (CTCol cc : currentElements.tailSet(currentElem)) { + if (cc == null || cc.getMax() == currentElemIndex) break; + currentIndexElements.add(cc); + if (col.getMax() > currentMax) currentMax = col.getMax(); + if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; + } + + // JDK 6 code + // while (currentElements.higher(currentElem) != null && currentElements.higher(currentElem).getMax() == currentElemIndex) { + // currentElem = currentElements.higher(currentElem); + // currentIndexElements.add(currentElem); + // if (col.getMax() > currentMax) currentMax = col.getMax(); + // if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn; + // } } + + if (currentElemIndex < nextIndex || !flIter.hasNext()) { insertCol(cols, currentIndex, currentElemIndex, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn); if (flIter.hasNext()) {