Update the XSSF getExternalSheet method signature, to start to prepare for sheet ranges

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613439 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-07-25 14:23:21 +00:00
parent 4c8f3ab160
commit 3e2e01c149
5 changed files with 16 additions and 9 deletions

View 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");
}

View 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

View 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);

View 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) {

View 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);
}
}