You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/20 01:49:46 UTC
svn commit: r1749247 -
/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
Author: onealj
Date: Mon Jun 20 01:49:46 2016
New Revision: 1749247
URL: http://svn.apache.org/viewvc?rev=1749247&view=rev
Log:
bug 56454: deprecate shiftMerged with unused parameter, move loop-invariant out of for-loop
Modified:
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=1749247&r1=1749246&r2=1749247&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Mon Jun 20 01:49:46 2016
@@ -931,7 +931,8 @@ public final class HSSFSheet implements
@Override
public List<CellRangeAddress> getMergedRegions() {
List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>();
- for (int i=0; i < _sheet.getNumMergedRegions(); i++) {
+ int count = _sheet.getNumMergedRegions();
+ for (int i=0; i < count; i++) {
addresses.add(_sheet.getMergedRegionAt(i));
}
return addresses;
@@ -1463,18 +1464,28 @@ public final class HSSFSheet implements
_sheet.setTopRow(toprow);
_sheet.setLeftCol(leftcol);
}
-
+
/**
- * Shifts the merged regions left or right depending on mode
- * <p/>
- * TODO: MODE , this is only row specific
- *
+ * Shifts, grows, or shrinks the merged regions due to a row shift
+ *
* @param startRow the start-index of the rows to shift, zero-based
* @param endRow the end-index of the rows to shift, zero-based
* @param n how far to shift, negative to shift up
* @param isRow unused, kept for backwards compatibility
+ * @deprecated POI 3.15 beta 2. This will be made private in future releases.
*/
protected void shiftMerged(int startRow, int endRow, int n, boolean isRow) {
+ shiftMerged(startRow, endRow, n);
+ }
+
+ /**
+ * Shifts, grows, or shrinks the merged regions due to a row shift
+ *
+ * @param startRow the start-index of the rows to shift, zero-based
+ * @param endRow the end-index of the rows to shift, zero-based
+ * @param n how far to shift, negative to shift up
+ */
+ private void shiftMerged(int startRow, int endRow, int n) {
List<CellRangeAddress> shiftedRegions = new ArrayList<CellRangeAddress>();
//move merged regions completely if they fall within the new region boundaries when they are shifted
for (int i = 0; i < getNumMergedRegions(); i++) {
@@ -1489,8 +1500,8 @@ public final class HSSFSheet implements
}
//only shift if the region outside the shifted rows is not merged too
- if (!SheetUtil.containsCell(merged, startRow - 1, 0) &&
- !SheetUtil.containsCell(merged, endRow + 1, 0)) {
+ if (!merged.containsRow(startRow - 1) &&
+ !merged.containsRow(endRow + 1)) {
merged.setFirstRow(merged.getFirstRow() + n);
merged.setLastRow(merged.getLastRow() + n);
//have to remove/add it back
@@ -1589,7 +1600,7 @@ public final class HSSFSheet implements
}
// Shift Merged Regions
- shiftMerged(startRow, endRow, n, true);
+ shiftMerged(startRow, endRow, n);
// Shift Row Breaks
_sheet.getPageSettings().shiftRowBreaks(startRow, endRow, n);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org