more usage of shared rebuildRows

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1835494 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-07-09 20:49:21 +00:00
parent 6f3cc9ed80
commit 61a25d079b

View File

@ -3171,17 +3171,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
entry.getKey().setRow(entry.getValue()); entry.getKey().setRow(entry.getValue());
} }
//rebuild the _rows map rebuildRows();
Map<Integer, XSSFRow> map = new HashMap<>();
for(XSSFRow r : _rows.values()) {
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = Integer.valueOf(r.getRowNum()); // NOSONAR
map.put(rownumI, r);
} }
_rows.clear();
_rows.putAll(map);
}
private int shiftedRowNum(int startRow, int endRow, int n, int rownum) { private int shiftedRowNum(int startRow, int endRow, int n, int rownum) {
// no change if before any affected row // no change if before any affected row
if(rownum < startRow && (n > 0 || (startRow - rownum) > n)) { if(rownum < startRow && (n > 0 || (startRow - rownum) > n)) {
@ -3208,6 +3200,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
// row is part of the shifted block // row is part of the shifted block
return rownum + n; return rownum + n;
} }
private void shiftCommentsForColumns(XSSFVMLDrawing vml, int startColumnIndex, int endColumnIndex, final int n){ private void shiftCommentsForColumns(XSSFVMLDrawing vml, int startColumnIndex, int endColumnIndex, final int n){
// then do the actual moving and also adjust comments/rowHeight // then do the actual moving and also adjust comments/rowHeight
// we need to sort it in a way so the shifting does not mess up the structures, // we need to sort it in a way so the shifting does not mess up the structures,
@ -3257,16 +3250,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
entry.getKey().setColumn(entry.getValue()); entry.getKey().setColumn(entry.getValue());
} }
//rebuild the _rows map rebuildRows();
Map<Integer, XSSFRow> map = new HashMap<>();
for(XSSFRow r : _rows.values()) {
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = Integer.valueOf(r.getRowNum()); // NOSONAR
map.put(rownumI, r);
}
_rows.clear();
_rows.putAll(map);
} }
/** /**
@ -3631,8 +3615,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
}*/ }*/
} }
int minCell=Integer.MAX_VALUE, maxCell=Integer.MIN_VALUE; int minCell = Integer.MAX_VALUE, maxCell = Integer.MIN_VALUE;
for(XSSFRow row : _rows.values()){ for(Map.Entry<Integer, XSSFRow> entry : _rows.entrySet()) {
XSSFRow row = entry.getValue();
// first perform the normal write actions for the row // first perform the normal write actions for the row
row.onDocumentWrite(); row.onDocumentWrite();