/**
* Helper for shifting columns up or down
+ *
+ * @since POI 4.0.0
*/
// non-Javadoc: When possible, code should be implemented in the ColumnShifter abstract class to avoid duplication with
// {@link org.apache.poi.xssf.usermodel.helpers.XSSFColumnShifter}
/**
* Class for code common to {@link RowShifter} and {@link ColumnShifter}
* Helper for shifting rows up or down and columns left and right
+ *
+ * @since POI 4.0.0
*/
@Internal
public abstract class BaseRowColShifter {
+ /**
+ * Updated named ranges
+ */
+ protected abstract void updateNamedRanges(FormulaShifter formulaShifter);
+
+ /**
+ * Update formulas.
+ */
+ protected 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);
+
public static CellRangeAddress shiftRange(FormulaShifter formulaShifter, CellRangeAddress cra, int currentExternSheetIx) {
// FormulaShifter works well in terms of Ptgs - so convert CellRangeAddress to AreaPtg (and back) here
AreaPtg aptg = new AreaPtg(cra.getFirstRow(), cra.getLastRow(), cra.getFirstColumn(), cra.getLastColumn(), false, false, false, false);
/**
* Helper for shifting columns up or down
+ *
+ * @since POI 4.0.0
*/
// non-Javadoc: This abstract class exists to consolidate duplicated code between XSSFColumnShifter and HSSFColumnShifter
// (currently methods sprinkled throughout HSSFSheet)
import java.util.List;
import java.util.Set;
-import org.apache.poi.ss.formula.FormulaShifter;
-import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.util.Internal;
/**
* Helper for shifting rows up or down
// 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);
-
- /**
- * Update the formulas in specified row using the formula shifting policy specified by shifter
- *
- * @param row the row to update the formulas on
- * @param formulaShifter the formula shifting policy
- */
- //@Internal
- //public abstract void updateRowFormulas(Row row, 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);
-
}
/**
* Helper for shifting columns up or down
+ *
+ * @since POI 4.0.0
*/
// non-Javadoc: When possible, code should be implemented in the ColumnShifter abstract class to avoid duplication with
// {@link org.apache.poi.hssf.usermodel.helpers.HSSFColumnShifter}
/**
* Class for code common to {@link XSSFRowShifter} and {@link XSSFColumnShifter}
+ *
+ * @since POI 4.0.0
*/
@Internal
-/*private*/ final class XSSFRowColShifter extends BaseRowColShifter {
+/*private*/ final class XSSFRowColShifter {
private static final POILogger logger = POILogFactory.getLogger(XSSFRowColShifter.class);
private XSSFRowColShifter() { /*no instances for static classes*/}
boolean changed = false;
List<CellRangeAddress> temp = new ArrayList<>();
for (CellRangeAddress craOld : cellRanges) {
- CellRangeAddress craNew = shiftRange(formulaShifter, craOld, sheetIndex);
+ CellRangeAddress craNew = BaseRowColShifter.shiftRange(formulaShifter, craOld, sheetIndex);
if (craNew == null) {
changed = true;
continue;
XSSFHyperlink xhyperlink = (XSSFHyperlink) hyperlink;
String cellRef = xhyperlink.getCellRef();
CellRangeAddress cra = CellRangeAddress.valueOf(cellRef);
- CellRangeAddress shiftedRange = shiftRange(formulaShifter, cra, sheetIndex);
+ CellRangeAddress shiftedRange = BaseRowColShifter.shiftRange(formulaShifter, cra, sheetIndex);
if (shiftedRange != null && shiftedRange != cra) {
// shiftedRange should not be null. If shiftedRange is null, that means
// that a hyperlink wasn't deleted at the beginning of shiftRows when
XSSFRowColShifter.updateFormulas(sheet, formulaShifter);
}
+ /**
+ * Update the formulas in specified row using the formula shifting policy specified by shifter
+ *
+ * @param row the row to update the formulas on
+ * @param formulaShifter the formula shifting policy
+ */
@Internal(since="3.15 beta 2")
public void updateRowFormulas(XSSFRow row, FormulaShifter formulaShifter) {
XSSFRowColShifter.updateRowFormulas(row, formulaShifter);