git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1721930 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_14_FINAL
@@ -1322,11 +1322,10 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss | |||
* get the number of styles the workbook contains | |||
* @return count of cell styles | |||
*/ | |||
@Override | |||
public short getNumCellStyles() | |||
public int getNumCellStyles() | |||
{ | |||
return (short) workbook.getNumExFormats(); | |||
return workbook.getNumExFormats(); | |||
} | |||
/** | |||
@@ -1335,10 +1334,10 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss | |||
* @return HSSFCellStyle object at the index | |||
*/ | |||
@Override | |||
public HSSFCellStyle getCellStyleAt(short idx) | |||
public HSSFCellStyle getCellStyleAt(int idx) | |||
{ | |||
ExtendedFormatRecord xfr = workbook.getExFormatAt(idx); | |||
HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this); | |||
HSSFCellStyle style = new HSSFCellStyle((short)idx, xfr, this); | |||
return style; | |||
} |
@@ -344,7 +344,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> { | |||
* | |||
* @return count of cell styles | |||
*/ | |||
short getNumCellStyles(); | |||
int getNumCellStyles(); | |||
/** | |||
* Get the cell style object at the given index | |||
@@ -352,7 +352,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> { | |||
* @param idx index within the set of styles (0-based) | |||
* @return CellStyle object at the index | |||
*/ | |||
CellStyle getCellStyleAt(short idx); | |||
CellStyle getCellStyleAt(int idx); | |||
/** | |||
* Write out this workbook to an Outputstream. |
@@ -189,9 +189,9 @@ public final class CellUtil { | |||
// index seems like what index the cellstyle is in the list of styles for a workbook. | |||
// not good to compare on! | |||
short numberCellStyles = workbook.getNumCellStyles(); | |||
int numberCellStyles = workbook.getNumCellStyles(); | |||
for (short i = 0; i < numberCellStyles; i++) { | |||
for (int i = 0; i < numberCellStyles; i++) { | |||
CellStyle wbStyle = workbook.getCellStyleAt(i); | |||
Map<String, Object> wbStyleMap = getFormatProperties(wbStyle); | |||
@@ -877,7 +877,7 @@ public class SXSSFWorkbook implements Workbook { | |||
* @return count of cell styles | |||
*/ | |||
@Override | |||
public short getNumCellStyles() | |||
public int getNumCellStyles() | |||
{ | |||
return _wb.getNumCellStyles(); | |||
} | |||
@@ -889,7 +889,7 @@ public class SXSSFWorkbook implements Workbook { | |||
* @return CellStyle object at the index | |||
*/ | |||
@Override | |||
public CellStyle getCellStyleAt(short idx) | |||
public CellStyle getCellStyleAt(int idx) | |||
{ | |||
return _wb.getCellStyleAt(idx); | |||
} |
@@ -853,16 +853,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { | |||
return pictures; //YK: should return Collections.unmodifiableList(pictures); | |||
} | |||
/** | |||
* Get the cell style object at the given index | |||
* | |||
* @param idx index within the set of styles | |||
* @return XSSFCellStyle object at the index | |||
*/ | |||
@Override | |||
public XSSFCellStyle getCellStyleAt(short idx) { | |||
return getCellStyleAt(idx&0xffff); | |||
} | |||
/** | |||
* Get the cell style object at the given index | |||
* | |||
@@ -931,9 +921,8 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { | |||
* | |||
* @return count of cell styles | |||
*/ | |||
@Override | |||
public short getNumCellStyles() { | |||
return (short) (stylesSource).getNumCellStyles(); | |||
public int getNumCellStyles() { | |||
return stylesSource.getNumCellStyles(); | |||
} | |||
/** |
@@ -2507,6 +2507,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { | |||
XSSFCellStyle style = wb.createCellStyle(); | |||
assertEquals(i, style.getUIndex()); | |||
} | |||
assertEquals(numStyles, wb.getNumCellStyles()); | |||
// avoid OOM in gump run | |||
File file = XSSFTestDataSamples.writeOutAndClose(wb, "bug57880"); | |||
@@ -2522,6 +2523,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { | |||
//Assume identical cell styles aren't consolidated | |||
//If XSSFWorkbooks ever implicitly optimize/consolidate cell styles (such as when the workbook is written to disk) | |||
//then this unit test should be updated | |||
assertEquals(numStyles, wb.getNumCellStyles()); | |||
for (int i=1; i<numStyles; i++) { | |||
XSSFCellStyle style = wb.getCellStyleAt(i); | |||
assertNotNull(style); |
@@ -1019,9 +1019,9 @@ public class TestXSSFCellStyle { | |||
} | |||
public static void copyStyles(Workbook reference, Workbook target) { | |||
final short numberOfStyles = reference.getNumCellStyles(); | |||
final int numberOfStyles = reference.getNumCellStyles(); | |||
// don't copy default style (style index 0) | |||
for (short i = 1; i < numberOfStyles; i++) { | |||
for (int i = 1; i < numberOfStyles; i++) { | |||
final CellStyle referenceStyle = reference.getCellStyleAt(i); | |||
final CellStyle targetStyle = target.createCellStyle(); | |||
targetStyle.cloneStyleFrom(referenceStyle); |
@@ -225,9 +225,8 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook { | |||
public void getNumCellStyles() throws IOException{ | |||
XSSFWorkbook workbook = new XSSFWorkbook(); | |||
try { | |||
short i = workbook.getNumCellStyles(); | |||
//get default cellStyles | |||
assertEquals(1, i); | |||
assertEquals(1, workbook.getNumCellStyles()); | |||
} finally { | |||
workbook.close(); | |||
} |
@@ -2006,7 +2006,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { | |||
@Test | |||
public void bug49751() throws Exception { | |||
HSSFWorkbook wb = openSample("49751.xls"); | |||
short numCellStyles = wb.getNumCellStyles(); | |||
int numCellStyles = wb.getNumCellStyles(); | |||
List<String> namedStyles = Arrays.asList( | |||
"20% - Accent1", "20% - Accent2", "20% - Accent3", "20% - Accent4", "20% - Accent5", | |||
"20% - Accent6", "40% - Accent1", "40% - Accent2", "40% - Accent3", "40% - Accent4", | |||
@@ -2017,7 +2017,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { | |||
"Neutral", "Note", "Output", "Title", "Total", "Warning Text"); | |||
List<String> collecteddStyles = new ArrayList<String>(); | |||
for (short i = 0; i < numCellStyles; i++) { | |||
for (int i = 0; i < numCellStyles; i++) { | |||
HSSFCellStyle cellStyle = wb.getCellStyleAt(i); | |||
String styleName = cellStyle.getUserStyleName(); | |||
if (styleName != null) { |