mirror of https://github.com/apache/poi.git
More internal method signature updates, for HSSF external sheets being possible ranges, for #55906
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1613307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
904d73c847
commit
c40ed2f754
|
@ -1851,13 +1851,24 @@ public final class InternalWorkbook {
|
|||
}
|
||||
|
||||
/**
|
||||
* Finds the sheet index for a particular external sheet number.
|
||||
* Finds the (first) sheet index for a particular external sheet number.
|
||||
* @param externSheetNumber The external sheet number to convert
|
||||
* @return The index to the sheet found.
|
||||
*/
|
||||
public int getSheetIndexFromExternSheetIndex(int externSheetNumber)
|
||||
public int getFirstSheetIndexFromExternSheetIndex(int externSheetNumber)
|
||||
{
|
||||
return linkTable.getSheetIndexFromExternSheetIndex(externSheetNumber);
|
||||
return linkTable.getFirstInternalSheetIndexForExtIndex(externSheetNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the last sheet index for a particular external sheet number,
|
||||
* which may be the same as the first (except for multi-sheet references)
|
||||
* @param externSheetNumber The external sheet number to convert
|
||||
* @return The index to the sheet found.
|
||||
*/
|
||||
public int getLastSheetIndexFromExternSheetIndex(int externSheetNumber)
|
||||
{
|
||||
return linkTable.getLastInternalSheetIndexForExtIndex(externSheetNumber);
|
||||
}
|
||||
|
||||
/** returns the extern sheet number for specific sheet number ,
|
||||
|
|
|
@ -425,6 +425,9 @@ final class LinkTable {
|
|||
* @return -1 if the reference is to an external book
|
||||
*/
|
||||
public int getFirstInternalSheetIndexForExtIndex(int extRefIndex) {
|
||||
if (extRefIndex >= _externSheetRecord.getNumOfRefs() || extRefIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
return _externSheetRecord.getFirstSheetIndexFromRefIndex(extRefIndex);
|
||||
}
|
||||
/**
|
||||
|
@ -432,6 +435,9 @@ final class LinkTable {
|
|||
* @return -1 if the reference is to an external book
|
||||
*/
|
||||
public int getLastInternalSheetIndexForExtIndex(int extRefIndex) {
|
||||
if (extRefIndex >= _externSheetRecord.getNumOfRefs() || extRefIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
return _externSheetRecord.getLastSheetIndexFromRefIndex(extRefIndex);
|
||||
}
|
||||
|
||||
|
@ -447,13 +453,6 @@ final class LinkTable {
|
|||
_externSheetRecord.removeSheet(sheetIdx);
|
||||
}
|
||||
|
||||
public int getSheetIndexFromExternSheetIndex(int extRefIndex) {
|
||||
if (extRefIndex >= _externSheetRecord.getNumOfRefs() || extRefIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
return _externSheetRecord.getFirstSheetIndexFromRefIndex(extRefIndex);
|
||||
}
|
||||
|
||||
public int checkExternSheet(int sheetIndex) {
|
||||
int thisWbIndex = -1; // this is probably always zero
|
||||
for (int i=0; i<_externalBookBlocks.length; i++) {
|
||||
|
|
|
@ -116,7 +116,8 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
|
|||
return new HSSFEvaluationSheet(_uBook.getSheetAt(sheetIndex));
|
||||
}
|
||||
public int convertFromExternSheetIndex(int externSheetIndex) {
|
||||
return _iBook.getSheetIndexFromExternSheetIndex(externSheetIndex);
|
||||
// TODO Update this to expose first and last sheet indexes
|
||||
return _iBook.getFirstSheetIndexFromExternSheetIndex(externSheetIndex);
|
||||
}
|
||||
|
||||
public ExternalSheet getExternalSheet(int externSheetIndex) {
|
||||
|
@ -133,12 +134,17 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E
|
|||
return null;
|
||||
}
|
||||
|
||||
// Is it a single local sheet, or a range?
|
||||
// TODO
|
||||
|
||||
// Look up the local sheet
|
||||
String sheetName = getSheetName(localSheetIndex);
|
||||
sheet = new ExternalSheet(null, sheetName);
|
||||
|
||||
// Is it a single local sheet, or a range?
|
||||
int lastLocalSheetIndex = _iBook.getLastSheetIndexFromExternSheetIndex(externSheetIndex);
|
||||
if (lastLocalSheetIndex == localSheetIndex) {
|
||||
sheet = new ExternalSheet(null, sheetName);
|
||||
} else {
|
||||
String lastSheetName = getSheetName(lastLocalSheetIndex);
|
||||
sheet = new ExternalSheetRange(null, sheetName, lastSheetName);
|
||||
}
|
||||
}
|
||||
return sheet;
|
||||
}
|
||||
|
|
|
@ -845,8 +845,14 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
|
|||
return _sheets.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for POI internal use only (formula parsing). This method is likely to
|
||||
* be removed in future versions of POI.
|
||||
*/
|
||||
@Deprecated
|
||||
public int getSheetIndexFromExternSheetIndex(int externSheetNumber) {
|
||||
return workbook.getSheetIndexFromExternSheetIndex(externSheetNumber);
|
||||
// TODO - don't expose internal ugliness like externSheet indexes to the user model API
|
||||
return workbook.getFirstSheetIndexFromExternSheetIndex(externSheetNumber);
|
||||
}
|
||||
|
||||
private HSSFSheet[] getSheets() {
|
||||
|
|
Loading…
Reference in New Issue