]> source.dussan.org Git - poi.git/commitdiff
bug 61474, github #81: add shiftMergedRegions to BaseRowColShifter interface
authorJaven O'Neal <onealj@apache.org>
Sat, 4 Nov 2017 09:32:05 +0000 (09:32 +0000)
committerJaven O'Neal <onealj@apache.org>
Sat, 4 Nov 2017 09:32:05 +0000 (09:32 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1814264 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/usermodel/helpers/BaseRowColShifter.java
src/java/org/apache/poi/ss/usermodel/helpers/ColumnShifter.java
src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java

index f92672951571e3c0605de2bee46e51ee51212e8d..f0bf7ab21e91b76b2bf9226d442c9d321fd21a77 100644 (file)
@@ -25,6 +25,8 @@ import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.Internal;
 
+import java.util.List;
+
 /**
  * Class for code common to {@link RowShifter} and {@link ColumnShifter}
  * Helper for shifting rows up or down and columns left and right
@@ -44,7 +46,22 @@ public abstract class BaseRowColShifter {
      */
     public abstract void updateFormulas(FormulaShifter formulaShifter);
 
+    /**
+     * Shifts, grows, or shrinks the merged regions due to a row shift
+     * ({@link RowShifter}) or column shift ({@link ColumnShifter}).
+     * Merged regions that are completely overlaid by shifting will be deleted.
+     *
+     * @param start the first row or column to be shifted
+     * @param end   the last row or column to be shifted
+     * @param n     the number of rows or columns to shift
+     * @return a list of affected merged regions, excluding contain deleted ones
+     */
+    public abstract List<CellRangeAddress> shiftMergedRegions(int start, int end, int n);
 
+    /**
+     * Update conditional formatting
+     * @param formulaShifter
+     */
     public abstract void updateConditionalFormatting(FormulaShifter formulaShifter);
 
     /**
index 444039a41b4fd849457e0e2b49a354bb95027490..a4d2508b66a48c3ffceddb976d322e0a3ed8e6b6 100644 (file)
@@ -22,7 +22,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.poi.ss.formula.FormulaShifter;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.Beta;
@@ -50,8 +49,10 @@ public abstract class ColumnShifter extends BaseRowColShifter {
      * @param endColumn   the column to end shifting
      * @param n        the number of columns to shift
      * @return an array of affected merged regions, doesn't contain deleted ones
+     * @since POI 4.0.0
      */
     // Keep this code in sync with {@link RowShifter#shiftMergedRegions}
+    @Override
     public List<CellRangeAddress> shiftMergedRegions(int startColumn, int endColumn, int n) {
         List<CellRangeAddress> shiftedRegions = new ArrayList<>();
         Set<Integer> removedIndices = new HashSet<>();
@@ -118,27 +119,4 @@ public abstract class ColumnShifter extends BaseRowColShifter {
         // if the merged-region and the overwritten area intersect, we need to remove it
         return merged.intersects(overwrite);
     }
-
-    /**
-     * Updated named ranges
-     */
-    public abstract void updateNamedRanges(FormulaShifter formulaShifter);
-
-    /**
-     * Update formulas.
-     */
-    public abstract void updateFormulas(FormulaShifter formulaShifter);
-
-
-    public abstract void updateConditionalFormatting(FormulaShifter formulaShifter);
-    
-    /**
-     * Shift the Hyperlink anchors (not the hyperlink text, even if the hyperlink
-     * is of type LINK_DOCUMENT and refers to a cell that was shifted). Hyperlinks
-     * do not track the content they point to.
-     *
-     * @param formulaShifter the formula shifting policy
-     */
-    public abstract void updateHyperlinks(FormulaShifter formulaShifter);
-
 }
index d0ac13d7f2640d3ddae620878c16164ec23c7afd..4597bd197666468b007e27f164c879874f6590d5 100644 (file)
@@ -49,6 +49,7 @@ public abstract class RowShifter extends BaseRowColShifter {
      * @return an array of affected merged regions, doesn't contain deleted ones
      */
     // Keep this code in sync with {@link ColumnShifter#shiftMergedRegions}
+    @Override
     public List<CellRangeAddress> shiftMergedRegions(int startRow, int endRow, int n) {
         List<CellRangeAddress> shiftedRegions = new ArrayList<>();
         Set<Integer> removedIndices = new HashSet<>();