poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1814258 - in /poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers: XSSFColumnShifter.java XSSFRowColShifter.java XSSFRowShifter.java
Date Sat, 04 Nov 2017 07:42:33 GMT
Author: onealj
Date: Sat Nov  4 07:42:33 2017
New Revision: 1814258

URL: http://svn.apache.org/viewvc?rev=1814258&view=rev
Log:
bug 61474, github #81: implement updateNamedRanges for ColumnShifter

Modified:
    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/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=1814258&r1=1814257&r2=1814258&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 07:42:33 2017
@@ -43,10 +43,9 @@ public final class XSSFColumnShifter ext
     /**
      * Updated named ranges
      */
-    @NotImplemented
     @Override
     public void updateNamedRanges(FormulaShifter formulaShifter) {
-        throw new NotImplementedException("updateNamedRanges");
+        XSSFRowColShifter.updateNamedRanges(sheet, formulaShifter);
     }
 
     /**

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=1814258&r1=1814257&r2=1814258&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 07:42:33 2017
@@ -18,6 +18,7 @@
 package org.apache.poi.xssf.usermodel.helpers;
 
 import org.apache.poi.ss.formula.*;
+import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.helpers.BaseRowColShifter;
 import org.apache.poi.ss.util.CellRangeAddress;
@@ -37,6 +38,25 @@ import java.util.List;
 
     private XSSFRowColShifter() { /*no instances for static classes*/}
 
+    /**
+     * Updated named ranges
+     */
+    /*package*/ static void updateNamedRanges(Sheet sheet, FormulaShifter formulaShifter)
{
+        Workbook wb = sheet.getWorkbook();
+        XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create((XSSFWorkbook) wb);
+        for (Name name : wb.getAllNames()) {
+            String formula = name.getRefersToFormula();
+            int sheetIndex = name.getSheetIndex();
+            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 (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
+                String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
+                name.setRefersToFormula(shiftedFmla);
+            }
+        }
+    }
+
     /*package*/ static void updateHyperlinks(Sheet sheet, FormulaShifter formulaShifter)
{
         int sheetIndex = sheet.getWorkbook().getSheetIndex(sheet);
         List<? extends Hyperlink> hyperlinkList = sheet.getHyperlinkList();

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=1814258&r1=1814257&r2=1814258&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 07:42:33 2017
@@ -65,19 +65,7 @@ public final class XSSFRowShifter extend
      */
     @Override
     public void updateNamedRanges(FormulaShifter formulaShifter) {
-        Workbook wb = sheet.getWorkbook();
-        XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create((XSSFWorkbook) wb);
-        for (Name name : wb.getAllNames()) {
-            String formula = name.getRefersToFormula();
-            int sheetIndex = name.getSheetIndex();
-            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 (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
-                String shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
-                name.setRefersToFormula(shiftedFmla);
-            }
-        }
+        XSSFRowColShifter.updateNamedRanges(sheet, formulaShifter);
     }
 
     /**



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


Mime
View raw message