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 2017/11/04 09:07:33 UTC

svn commit: r1814261 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/helpers/ java/org/apache/poi/ss/usermodel/helpers/ ooxml/java/org/apache/poi/xssf/usermodel/helpers/

Author: onealj
Date: Sat Nov  4 09:07:32 2017
New Revision: 1814261

URL: http://svn.apache.org/viewvc?rev=1814261&view=rev
Log:
bug 61474, github #81: pull up methods from RowShifter to BaseRowColShifter, since both row and column shifting should be able to shift formulas, comments, merged regions, conditional formatting, etc; add @since decorators for new *ColumnShifter and *RowColShifter classes

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFColumnShifter.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/BaseRowColShifter.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/ColumnShifter.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFColumnShifter.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFColumnShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFColumnShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFColumnShifter.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFColumnShifter.java Sat Nov  4 09:07:32 2017
@@ -28,6 +28,8 @@ import org.apache.poi.util.POILogger;
 
 /**
  * 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}

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/BaseRowColShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/BaseRowColShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/BaseRowColShifter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/BaseRowColShifter.java Sat Nov  4 09:07:32 2017
@@ -28,10 +28,34 @@ import org.apache.poi.util.Internal;
 /**
  * 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);

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/ColumnShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/ColumnShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/ColumnShifter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/ColumnShifter.java Sat Nov  4 09:07:32 2017
@@ -29,6 +29,8 @@ import org.apache.poi.util.Beta;
 
 /**
  * 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)

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.java Sat Nov  4 09:07:32 2017
@@ -22,11 +22,8 @@ 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.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
@@ -118,35 +115,4 @@ public abstract class RowShifter extends
         // 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);
-
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFColumnShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFColumnShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFColumnShifter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFColumnShifter.java Sat Nov  4 09:07:32 2017
@@ -26,6 +26,8 @@ import org.apache.poi.xssf.usermodel.XSS
 
 /**
  * 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}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowColShifter.java Sat Nov  4 09:07:32 2017
@@ -37,9 +37,11 @@ import java.util.List;
 
 /**
  * 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*/}
@@ -189,7 +191,7 @@ import java.util.List;
             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;
@@ -234,7 +236,7 @@ import java.util.List;
             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

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java?rev=1814261&r1=1814260&r2=1814261&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java Sat Nov  4 09:07:32 2017
@@ -47,6 +47,12 @@ public final class XSSFRowShifter extend
         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);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org