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
*/
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);
/**
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;
* @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<>();
// 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);
-
}
* @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<>();