]> source.dussan.org Git - poi.git/commitdiff
Update the XSSF getExternalSheet method signature, to start to prepare for sheet...
authorNick Burch <nick@apache.org>
Fri, 25 Jul 2014 14:23:21 +0000 (14:23 +0000)
committerNick Burch <nick@apache.org>
Fri, 25 Jul 2014 14:23:21 +0000 (14:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613439 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java
src/java/org/apache/poi/ss/formula/EvaluationWorkbook.java
src/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java

index aed26b66fb763b2c23fa8c0b570b6ffb1b0b3f30..79a59627a0836c417771f0bd5cc2de9e3a1478e9 100644 (file)
@@ -149,7 +149,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
         }
         return sheet;
     }
-    public ExternalSheet getExternalSheet(String sheetName, int externalWorkbookNumber) {
+    public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber) {
         throw new IllegalStateException("XSSF-style external references are not supported for HSSF");
     }
 
index 23474e87fc61743f7d7a00c8069a58d15357c8d5..b0a3c76060fcc27caa6d75ec16057ae7ba185e5c 100644 (file)
@@ -52,7 +52,7 @@ public interface EvaluationWorkbook {
      * XSSF Only - fetch the external-style sheet details
      * <p>Return will have no workbook set if it's actually in our own workbook</p>
      */
-    ExternalSheet getExternalSheet(String sheetName, int externalWorkbookNumber);
+    ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber);
     /**
      * HSSF Only - convert an external sheet index to an internal sheet index,
      *  for an external-style reference to one of this workbook's own sheets 
index 96eb89c9b397be392d98bd0b75d6201d0b1bffd0..6cbc9c95b7029cba136afcea0e147968d121df57 100644 (file)
@@ -79,7 +79,7 @@ public final class OperationEvaluationContext {
                return createExternSheetRefEvaluator(ptg.getExternSheetIndex());
        }
     SheetRefEvaluator createExternSheetRefEvaluator(String sheetName, int externalWorkbookNumber) {
-        ExternalSheet externalSheet = _workbook.getExternalSheet(sheetName, externalWorkbookNumber);
+        ExternalSheet externalSheet = _workbook.getExternalSheet(sheetName, null, externalWorkbookNumber);
         return createExternSheetRefEvaluator(externalSheet);
     }
        SheetRefEvaluator createExternSheetRefEvaluator(int externSheetIndex) {
@@ -316,7 +316,7 @@ public final class OperationEvaluationContext {
         return getExternalNameXEval(externName, workbookName);
     }
        public ValueEval getNameXEval(NameXPxg nameXPxg) {
-           ExternalSheet externSheet = _workbook.getExternalSheet(nameXPxg.getSheetName(), nameXPxg.getExternalWorkbookNumber());
+           ExternalSheet externSheet = _workbook.getExternalSheet(nameXPxg.getSheetName(), null, nameXPxg.getExternalWorkbookNumber());
         if(externSheet == null || externSheet.getWorkbookName() == null) {
             // External reference to our own workbook's name
             return getLocalNameXEval(nameXPxg);
index 93d3ec556555428471317341fa9d5fda5c590d4f..a42815a07eae80b537ad76fce3b7c14f1987b144 100644 (file)
@@ -90,8 +90,8 @@ final class ForkedEvaluationWorkbook implements EvaluationWorkbook {
        public ExternalSheet getExternalSheet(int externSheetIndex) {
                return _masterBook.getExternalSheet(externSheetIndex);
        }
-       public ExternalSheet getExternalSheet(String sheetName, int externalWorkbookNumber) {
-        return _masterBook.getExternalSheet(sheetName, externalWorkbookNumber);
+       public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber) {
+        return _masterBook.getExternalSheet(firstSheetName, lastSheetName, externalWorkbookNumber);
     }
 
     public Ptg[] getFormulaTokens(EvaluationCell cell) {
index d51d9a6a6d1cc2fcfecfd9ab62d8d4f960e8502b..396e5cc13666539af2015ee9ee330a5ccf1e77ef 100644 (file)
@@ -233,15 +233,22 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
        public ExternalSheet getExternalSheet(int externSheetIndex) {
            throw new IllegalStateException("HSSF-style external references are not supported for XSSF");
        }
-       public ExternalSheet getExternalSheet(String sheetName, int externalWorkbookNumber) {
+       public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber) {
+           String workbookName;
            if (externalWorkbookNumber > 0) {
                // External reference - reference is 1 based, link table is 0 based
                int linkNumber = externalWorkbookNumber - 1;
                ExternalLinksTable linkTable = _uBook.getExternalLinksTable().get(linkNumber);
-               return new ExternalSheet(linkTable.getLinkedFileName(), sheetName);
+               workbookName = linkTable.getLinkedFileName();
            } else {
                // Internal reference
-               return new ExternalSheet(null, sheetName);
+               workbookName = null;
+           }
+           
+           if (lastSheetName == null || firstSheetName.equals(lastSheetName)) {
+               return new ExternalSheet(workbookName, firstSheetName);
+           } else {
+               return new ExternalSheetRange(workbookName, firstSheetName, lastSheetName);
            }
     }