bug 61474, github #81: add shiftMergedRegions to BaseRowColShifter interface
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1814264 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9375ae7873
commit
6234d725e6
@ -25,6 +25,8 @@ import org.apache.poi.ss.formula.ptg.Ptg;
|
|||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for code common to {@link RowShifter} and {@link ColumnShifter}
|
* Class for code common to {@link RowShifter} and {@link ColumnShifter}
|
||||||
* Helper for shifting rows up or down and columns left and right
|
* 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);
|
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);
|
public abstract void updateConditionalFormatting(FormulaShifter formulaShifter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.poi.ss.formula.FormulaShifter;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.util.Beta;
|
import org.apache.poi.util.Beta;
|
||||||
@ -50,8 +49,10 @@ public abstract class ColumnShifter extends BaseRowColShifter {
|
|||||||
* @param endColumn the column to end shifting
|
* @param endColumn the column to end shifting
|
||||||
* @param n the number of columns to shift
|
* @param n the number of columns to shift
|
||||||
* @return an array of affected merged regions, doesn't contain deleted ones
|
* @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}
|
// Keep this code in sync with {@link RowShifter#shiftMergedRegions}
|
||||||
|
@Override
|
||||||
public List<CellRangeAddress> shiftMergedRegions(int startColumn, int endColumn, int n) {
|
public List<CellRangeAddress> shiftMergedRegions(int startColumn, int endColumn, int n) {
|
||||||
List<CellRangeAddress> shiftedRegions = new ArrayList<>();
|
List<CellRangeAddress> shiftedRegions = new ArrayList<>();
|
||||||
Set<Integer> removedIndices = new HashSet<>();
|
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
|
// if the merged-region and the overwritten area intersect, we need to remove it
|
||||||
return merged.intersects(overwrite);
|
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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public abstract class RowShifter extends BaseRowColShifter {
|
|||||||
* @return an array of affected merged regions, doesn't contain deleted ones
|
* @return an array of affected merged regions, doesn't contain deleted ones
|
||||||
*/
|
*/
|
||||||
// Keep this code in sync with {@link ColumnShifter#shiftMergedRegions}
|
// Keep this code in sync with {@link ColumnShifter#shiftMergedRegions}
|
||||||
|
@Override
|
||||||
public List<CellRangeAddress> shiftMergedRegions(int startRow, int endRow, int n) {
|
public List<CellRangeAddress> shiftMergedRegions(int startRow, int endRow, int n) {
|
||||||
List<CellRangeAddress> shiftedRegions = new ArrayList<>();
|
List<CellRangeAddress> shiftedRegions = new ArrayList<>();
|
||||||
Set<Integer> removedIndices = new HashSet<>();
|
Set<Integer> removedIndices = new HashSet<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user