poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1814255 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/helpers/HSSFRowShifter.java java/org/apache/poi/ss/usermodel/helpers/RowShifter.java ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFRowShifter.java
Date Sat, 04 Nov 2017 05:48:19 GMT
Author: onealj
Date: Sat Nov  4 05:48:18 2017
New Revision: 1814255

URL: http://svn.apache.org/viewvc?rev=1814255&view=rev
Log:
bug 61474, #81 on github: add @Override annotation; rename FormulaShifter shifter to FormulaShifter
formulaShifter to reduce confusion with the shifter variable referring to the RowShifter

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowShifter.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/helpers/RowShifter.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/HSSFRowShifter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowShifter.java?rev=1814255&r1=1814254&r2=1814255&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowShifter.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/helpers/HSSFRowShifter.java Sat Nov 
4 05:48:18 2017
@@ -39,29 +39,34 @@ public final class HSSFRowShifter extend
         super(sh);
     }
 
+    @Override
     @NotImplemented
-    public void updateNamedRanges(FormulaShifter shifter) {
+    public void updateNamedRanges(FormulaShifter formulaShifter) {
         throw new NotImplementedException("HSSFRowShifter.updateNamedRanges");
     }
 
+    @Override
     @NotImplemented
-    public void updateFormulas(FormulaShifter shifter) {
+    public void updateFormulas(FormulaShifter formulaShifter) {
         throw new NotImplementedException("updateFormulas");
     }
 
+    @Override
     @Internal
     @NotImplemented
-    public void updateRowFormulas(Row row, FormulaShifter shifter) {
+    public void updateRowFormulas(Row row, FormulaShifter formulaShifter) {
         throw new NotImplementedException("updateRowFormulas");
     }
 
+    @Override
     @NotImplemented
-    public void updateConditionalFormatting(FormulaShifter shifter) {
+    public void updateConditionalFormatting(FormulaShifter formulaShifter) {
         throw new NotImplementedException("updateConditionalFormatting");
     }
-    
+
+    @Override
     @NotImplemented
-    public void updateHyperlinks(FormulaShifter shifter) {
+    public void updateHyperlinks(FormulaShifter formulaShifter) {
         throw new NotImplementedException("updateHyperlinks");
     }
 

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=1814255&r1=1814254&r2=1814255&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 05:48:18
2017
@@ -114,31 +114,31 @@ public abstract class RowShifter {
     /**
      * Updated named ranges
      */
-    public abstract void updateNamedRanges(FormulaShifter shifter);
+    public abstract void updateNamedRanges(FormulaShifter formulaShifter);
 
     /**
      * Update formulas.
      */
-    public abstract void updateFormulas(FormulaShifter shifter);
+    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 shifter the formula shifting policy
+     * @param formulaShifter the formula shifting policy
      */
     @Internal
-    public abstract void updateRowFormulas(Row row, FormulaShifter shifter);
+    public abstract void updateRowFormulas(Row row, FormulaShifter formulaShifter);
 
-    public abstract void updateConditionalFormatting(FormulaShifter shifter);
+    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 shifter the formula shifting policy
+     * @param formulaShifter the formula shifting policy
      */
-    public abstract void updateHyperlinks(FormulaShifter shifter);
+    public abstract void updateHyperlinks(FormulaShifter formulaShifter);
 
 }

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=1814255&r1=1814254&r2=1814255&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 05:48:18 2017
@@ -67,7 +67,8 @@ public final class XSSFRowShifter extend
     /**
      * Updated named ranges
      */
-    public void updateNamedRanges(FormulaShifter shifter) {
+    @Override
+    public void updateNamedRanges(FormulaShifter formulaShifter) {
         Workbook wb = sheet.getWorkbook();
         XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create((XSSFWorkbook) wb);
         for (Name name : wb.getAllNames()) {
@@ -76,7 +77,7 @@ public final class XSSFRowShifter extend
             final int rowIndex = -1; //don't care, named ranges are not allowed to include
structured references
 
             Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.NAMEDRANGE, sheetIndex,
rowIndex);
-            if (shifter.adjustFormula(ptgs, sheetIndex)) {
+            if (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
                 String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
                 name.setRefersToFormula(shiftedFmla);
             }
@@ -86,22 +87,23 @@ public final class XSSFRowShifter extend
     /**
      * Update formulas.
      */
-    public void updateFormulas(FormulaShifter shifter) {
+    @Override
+    public void updateFormulas(FormulaShifter formulaShifter) {
         //update formulas on the parent sheet
-        updateSheetFormulas(sheet, shifter);
+        updateSheetFormulas(sheet, formulaShifter);
 
         //update formulas on other sheets
         Workbook wb = sheet.getWorkbook();
         for (Sheet sh : wb) {
             if (sheet == sh) continue;
-            updateSheetFormulas(sh, shifter);
+            updateSheetFormulas(sh, formulaShifter);
         }
     }
 
-    private void updateSheetFormulas(Sheet sh, FormulaShifter shifter) {
+    private void updateSheetFormulas(Sheet sh, FormulaShifter formulashifter) {
         for (Row r : sh) {
             XSSFRow row = (XSSFRow) r;
-            updateRowFormulas(row, shifter);
+            updateRowFormulas(row, formulashifter);
         }
     }
 
@@ -109,10 +111,11 @@ public final class XSSFRowShifter extend
      * Update the formulas in specified row using the formula shifting policy specified by
shifter
      *
      * @param row the row to update the formulas on
-     * @param shifter the formula shifting policy
+     * @param formulaShifter the formula shifting policy
      */
     @Internal
-    public void updateRowFormulas(Row row, FormulaShifter shifter) {
+    @Override
+    public void updateRowFormulas(Row row, FormulaShifter formulaShifter) {
         XSSFSheet sheet = (XSSFSheet) row.getSheet();
         for (Cell c : row) {
             XSSFCell cell = (XSSFCell) c;
@@ -122,30 +125,30 @@ public final class XSSFRowShifter extend
                 CTCellFormula f = ctCell.getF();
                 String formula = f.getStringValue();
                 if (formula.length() > 0) {
-                    String shiftedFormula = shiftFormula(row, formula, shifter);
+                    String shiftedFormula = shiftFormula(row, formula, formulaShifter);
                     if (shiftedFormula != null) {
                         f.setStringValue(shiftedFormula);
                         if(f.getT() == STCellFormulaType.SHARED){
                             int si = (int)f.getSi();
                             CTCellFormula sf = sheet.getSharedFormula(si);
                             sf.setStringValue(shiftedFormula);
-                            updateRefInCTCellFormula(row, shifter, sf);
+                            updateRefInCTCellFormula(row, formulaShifter, sf);
                         }
                     }
 
                 }
 
                 //Range of cells which the formula applies to.
-                updateRefInCTCellFormula(row, shifter, f);
+                updateRefInCTCellFormula(row, formulaShifter, f);
             }
 
         }
     }
 
-    private void updateRefInCTCellFormula(Row row, FormulaShifter shifter, CTCellFormula
f) {
+    private void updateRefInCTCellFormula(Row row, FormulaShifter formulaShifter, CTCellFormula
f) {
         if (f.isSetRef()) { //Range of cells which the formula applies to.
             String ref = f.getRef();
-            String shiftedRef = shiftFormula(row, ref, shifter);
+            String shiftedRef = shiftFormula(row, ref, formulaShifter);
             if (shiftedRef != null) f.setRef(shiftedRef);
         }
     }
@@ -155,11 +158,11 @@ public final class XSSFRowShifter extend
      *
      * @param row     the row of the cell this formula belongs to. Used to get a reference
to the parent workbook.
      * @param formula the formula to shift
-     * @param shifter the FormulaShifter object that operates on the parsed formula tokens
+     * @param formulaShifter the FormulaShifter object that operates on the parsed formula
tokens
      * @return the shifted formula if the formula was changed,
      *         <code>null</code> if the formula wasn't modified
      */
-    private static String shiftFormula(Row row, String formula, FormulaShifter shifter) {
+    private static String shiftFormula(Row row, String formula, FormulaShifter formulaShifter)
{
         Sheet sheet = row.getSheet();
         Workbook wb = sheet.getWorkbook();
         int sheetIndex = wb.getSheetIndex(sheet);
@@ -169,7 +172,7 @@ public final class XSSFRowShifter extend
         try {
             Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex,
rowIndex);
             String shiftedFmla = null;
-            if (shifter.adjustFormula(ptgs, sheetIndex)) {
+            if (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
                 shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
             }
             return shiftedFmla;
@@ -180,7 +183,8 @@ public final class XSSFRowShifter extend
         }
     }
 
-    public void updateConditionalFormatting(FormulaShifter shifter) {
+    @Override
+    public void updateConditionalFormatting(FormulaShifter formulaShifter) {
         XSSFSheet xsheet = (XSSFSheet) sheet;
         XSSFWorkbook wb = xsheet.getWorkbook();
         int sheetIndex = wb.getSheetIndex(sheet);
@@ -204,7 +208,7 @@ public final class XSSFRowShifter extend
             boolean changed = false;
             List<CellRangeAddress> temp = new ArrayList<>();
             for (CellRangeAddress craOld : cellRanges) {
-                CellRangeAddress craNew = shiftRange(shifter, craOld, sheetIndex);
+                CellRangeAddress craNew = shiftRange(formulaShifter, craOld, sheetIndex);
                 if (craNew == null) {
                     changed = true;
                     continue;
@@ -231,7 +235,7 @@ public final class XSSFRowShifter extend
                 for (int i = 0; i < formulaArray.length; i++) {
                     String formula = formulaArray[i];
                     Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex,
rowIndex);
-                    if (shifter.adjustFormula(ptgs, sheetIndex)) {
+                    if (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
                         String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
                         cfRule.setFormulaArray(i, shiftedFmla);
                     }
@@ -245,9 +249,10 @@ public final class XSSFRowShifter extend
      * is of type LINK_DOCUMENT and refers to a cell that was shifted). Hyperlinks
      * do not track the content they point to.
      *
-     * @param shifter
+     * @param formulaShifter
      */
-    public void updateHyperlinks(FormulaShifter shifter) {
+    @Override
+    public void updateHyperlinks(FormulaShifter formulaShifter) {
         int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet);
         List<? extends Hyperlink> hyperlinkList = sheet.getHyperlinkList();
         
@@ -255,7 +260,7 @@ public final class XSSFRowShifter extend
             XSSFHyperlink xhyperlink = (XSSFHyperlink) hyperlink;
             String cellRef = xhyperlink.getCellRef();
             CellRangeAddress cra = CellRangeAddress.valueOf(cellRef);
-            CellRangeAddress shiftedRange = shiftRange(shifter, cra, sheetIndex);
+            CellRangeAddress shiftedRange = 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
@@ -265,12 +270,12 @@ public final class XSSFRowShifter extend
         }
     }
 
-    private static CellRangeAddress shiftRange(FormulaShifter shifter, CellRangeAddress cra,
int currentExternSheetIx) {
+    private 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);
         Ptg[] ptgs = { aptg, };
 
-        if (!shifter.adjustFormula(ptgs, currentExternSheetIx)) {
+        if (!formulaShifter.adjustFormula(ptgs, currentExternSheetIx)) {
             return cra;
         }
         Ptg ptg0 = ptgs[0];



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


Mime
View raw message