purged calls to cell.setCellType(CellType.BLANK) from the project, replaced with setBlank()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1852245 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vladislav Galas 2019-01-26 19:41:10 +00:00
parent d60cb3a18c
commit 19bf8b23d5
15 changed files with 31 additions and 32 deletions

View File

@ -42,14 +42,12 @@ import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.ptg.ExpPtg; import org.apache.poi.ss.formula.ptg.ExpPtg;
import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellBase; import org.apache.poi.ss.usermodel.CellBase;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.Comment; import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.FormulaError; import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Hyperlink; import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.RichTextString; import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellAddress;
@ -492,7 +490,7 @@ public class HSSFCell extends CellBase {
public void setCellValue(Date value) public void setCellValue(Date value)
{ {
if(value == null) { if(value == null) {
setCellType(CellType.BLANK); setBlank();
return; return;
} }
@ -517,7 +515,7 @@ public class HSSFCell extends CellBase {
public void setCellValue(Calendar value) public void setCellValue(Calendar value)
{ {
if(value == null) { if(value == null) {
setCellType(CellType.BLANK); setBlank();
return; return;
} }
@ -1302,3 +1300,4 @@ public class HSSFCell extends CellBase {
return styleIndex; return styleIndex;
} }
} }

View File

@ -2389,7 +2389,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
CellRange<HSSFCell> result = getCellRange(range); CellRange<HSSFCell> result = getCellRange(range);
// clear all cells in the range // clear all cells in the range
for (Cell c : result) { for (Cell c : result) {
c.setCellType(CellType.BLANK); c.setBlank();
} }
return result; return result;
} }

View File

@ -91,7 +91,7 @@ final class ForkedEvaluationCell implements EvaluationCell {
} }
public void copyValue(Cell destCell) { public void copyValue(Cell destCell) {
switch (_cellType) { switch (_cellType) {
case BLANK: destCell.setCellType(CellType.BLANK); return; case BLANK: destCell.setBlank(); return;
case NUMERIC: destCell.setCellValue(_numberValue); return; case NUMERIC: destCell.setCellValue(_numberValue); return;
case BOOLEAN: destCell.setCellValue(_booleanValue); return; case BOOLEAN: destCell.setCellValue(_booleanValue); return;
case STRING: destCell.setCellValue(_stringValue); return; case STRING: destCell.setCellValue(_stringValue); return;

View File

@ -140,7 +140,7 @@ public abstract class RangeCopier {
destCell.setCellValue(srcCell.getNumericCellValue()); destCell.setCellValue(srcCell.getNumericCellValue());
break; break;
case BLANK: case BLANK:
destCell.setCellType(CellType.BLANK); destCell.setBlank();
break; break;
case BOOLEAN: case BOOLEAN:
destCell.setCellValue(srcCell.getBooleanCellValue()); destCell.setCellValue(srcCell.getBooleanCellValue());

View File

@ -224,7 +224,7 @@ public class SXSSFCell extends CellBase {
@Override @Override
public void setCellValue(Date value) { public void setCellValue(Date value) {
if(value == null) { if(value == null) {
setCellType(CellType.BLANK); setBlank();
return; return;
} }
@ -251,7 +251,7 @@ public class SXSSFCell extends CellBase {
@Override @Override
public void setCellValue(Calendar value) { public void setCellValue(Calendar value) {
if(value == null) { if(value == null) {
setCellType(CellType.BLANK); setBlank();
return; return;
} }
@ -283,7 +283,7 @@ public class SXSSFCell extends CellBase {
((RichTextValue) _value).setValue(value); ((RichTextValue) _value).setValue(value);
} }
} else { } else {
setCellType(CellType.BLANK); setBlank();
} }
} }
@ -311,7 +311,7 @@ public class SXSSFCell extends CellBase {
((PlainStringValue) _value).setValue(value); ((PlainStringValue) _value).setValue(value);
} }
} else { } else {
setCellType(CellType.BLANK); setBlank();
} }
} }

View File

@ -431,7 +431,7 @@ public final class XSSFCell extends CellBase {
@Override @Override
public void setCellValue(RichTextString str) { public void setCellValue(RichTextString str) {
if(str == null || str.getString() == null){ if(str == null || str.getString() == null){
setCellType(CellType.BLANK); setBlank();
return; return;
} }
@ -830,7 +830,7 @@ public final class XSSFCell extends CellBase {
@Override @Override
public void setCellValue(Date value) { public void setCellValue(Date value) {
if(value == null) { if(value == null) {
setCellType(CellType.BLANK); setBlank();
return; return;
} }
@ -857,7 +857,7 @@ public final class XSSFCell extends CellBase {
@Override @Override
public void setCellValue(Calendar value) { public void setCellValue(Calendar value) {
if(value == null) { if(value == null) {
setCellType(CellType.BLANK); setBlank();
return; return;
} }

View File

@ -3993,7 +3993,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
arrayFormulas.remove(range); arrayFormulas.remove(range);
CellRange<XSSFCell> cr = getCellRange(range); CellRange<XSSFCell> cr = getCellRange(range);
for (XSSFCell c : cr) { for (XSSFCell c : cr) {
c.setCellType(CellType.BLANK); c.setBlank();
} }
return cr; return cr;
} }

View File

@ -766,7 +766,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
if (row != null) { if (row != null) {
XSSFCell cell = row.getCell(cellRef.getCol()); XSSFCell cell = row.getCell(cellRef.getCol());
if (cell != null) { if (cell != null) {
cell.setCellType(CellType.BLANK); cell.setBlank();
cell.setCellStyle(null); cell.setCellStyle(null);
} }
} }

View File

@ -154,7 +154,7 @@ public class TestSXSSFCell extends BaseTestXCell {
*/ */
@Override @Override
@Ignore @Ignore
public void setCellType_BLANK_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() { public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
} }
/** /**
@ -164,7 +164,7 @@ public class TestSXSSFCell extends BaseTestXCell {
@Override @Override
@Ignore @Ignore
@Test // <- annotation is necessary to override expected exception @Test // <- annotation is necessary to override expected exception
public void setCellType_BLANK_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() { public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
} }
@Override @Override

View File

@ -637,7 +637,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
validateCells(sheet); validateCells(sheet);
XSSFTestDataSamples.writeOutAndReadBack(wb1).close(); XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
sheet.getRow(6).getCell(0).setCellType(CellType.BLANK); // go sheet.getRow(6).getCell(0).setBlank(); // go
XSSFTestDataSamples.writeOutAndReadBack(wb1).close(); XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
sheet.getRow(7).getCell(0).setCellValue((String) null); // go sheet.getRow(7).getCell(0).setCellValue((String) null); // go

View File

@ -204,7 +204,7 @@ public final class TestSharedFormulaRecord extends TestCase {
assertEquals("A$1*2", sheet.getRow(ROW_IX).getCell(1).getCellFormula()); assertEquals("A$1*2", sheet.getRow(ROW_IX).getCell(1).getCellFormula());
cell = sheet.getRow(ROW_IX).getCell(1); cell = sheet.getRow(ROW_IX).getCell(1);
cell.setCellType(CellType.BLANK); cell.setBlank();
assertEquals(3, countSharedFormulas(sheet)); assertEquals(3, countSharedFormulas(sheet));
wb = HSSFTestDataSamples.writeOutAndReadBack(wb); wb = HSSFTestDataSamples.writeOutAndReadBack(wb);

View File

@ -436,7 +436,7 @@ public final class TestHSSFCell extends BaseTestCell {
Row row = sheet.createRow(0); Row row = sheet.createRow(0);
Cell cell = row.createCell(0); Cell cell = row.createCell(0);
cell.setCellType(CellType.BLANK); cell.setBlank();
assertNull(null, cell.getDateCellValue()); assertNull(null, cell.getDateCellValue());
assertFalse(cell.getBooleanCellValue()); assertFalse(cell.getBooleanCellValue());
assertEquals("", cell.toString()); assertEquals("", cell.toString());

View File

@ -232,14 +232,14 @@ public class TestEvaluationCache extends TestCase {
public void setCellValue(String cellRefText, double value) { public void setCellValue(String cellRefText, double value) {
HSSFCell cell = getOrCreateCell(cellRefText); HSSFCell cell = getOrCreateCell(cellRefText);
// be sure to blank cell, in case it is currently a formula // be sure to blank cell, in case it is currently a formula
cell.setCellType(CellType.BLANK); cell.setBlank();
// otherwise this line will only set the formula cached result; // otherwise this line will only set the formula cached result;
cell.setCellValue(value); cell.setCellValue(value);
_evaluator.notifyUpdateCell(wrapCell(cell)); _evaluator.notifyUpdateCell(wrapCell(cell));
} }
public void clearCell(String cellRefText) { public void clearCell(String cellRefText) {
HSSFCell cell = getOrCreateCell(cellRefText); HSSFCell cell = getOrCreateCell(cellRefText);
cell.setCellType(CellType.BLANK); cell.setBlank();
_evaluator.notifyUpdateCell(wrapCell(cell)); _evaluator.notifyUpdateCell(wrapCell(cell));
} }
@ -606,7 +606,7 @@ public class TestEvaluationCache extends TestCase {
cv = fe.evaluate(cellA1); cv = fe.evaluate(cellA1);
assertEquals(3.7, cv.getNumberValue(), 0.0); assertEquals(3.7, cv.getNumberValue(), 0.0);
cellB1.setCellType(CellType.BLANK); cellB1.setBlank();
fe.notifyUpdateCell(cellB1); fe.notifyUpdateCell(cellB1);
cv = fe.evaluate(cellA1); // B1 was used to evaluate A1 cv = fe.evaluate(cellA1); // B1 was used to evaluate A1
assertEquals(2.2, cv.getNumberValue(), 0.0); assertEquals(2.2, cv.getNumberValue(), 0.0);

View File

@ -119,7 +119,7 @@ public class TestRandBetween extends TestCase {
public void testRandBetweenTopBlank() { public void testRandBetweenTopBlank() {
bottomValueCell.setCellValue(-1); bottomValueCell.setCellValue(-1);
topValueCell.setCellType(CellType.BLANK); topValueCell.setBlank();
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues(); evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCell(formulaCell); evaluator.evaluateFormulaCell(formulaCell);
@ -174,7 +174,7 @@ public class TestRandBetween extends TestCase {
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue()); assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
bottomValueCell.setCellValue(1); bottomValueCell.setCellValue(1);
topValueCell.setCellType(CellType.BLANK); topValueCell.setBlank();
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues(); evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCell(formulaCell); evaluator.evaluateFormulaCell(formulaCell);

View File

@ -642,7 +642,7 @@ public abstract class BaseTestCell {
} }
/** /**
* Make sure that cell.setCellType(CellType.BLANK) preserves the cell style * Make sure that cell.setBlank() preserves the cell style
*/ */
@Test @Test
public void testSetBlank_bug47028() throws Exception { public void testSetBlank_bug47028() throws Exception {
@ -651,7 +651,7 @@ public abstract class BaseTestCell {
Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0); Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
cell.setCellStyle(style); cell.setCellStyle(style);
int i1 = cell.getCellStyle().getIndex(); int i1 = cell.getCellStyle().getIndex();
cell.setCellType(CellType.BLANK); cell.setBlank();
int i2 = cell.getCellStyle().getIndex(); int i2 = cell.getCellStyle().getIndex();
assertEquals(i1, i2); assertEquals(i1, i2);
wb.close(); wb.close();
@ -1219,7 +1219,7 @@ public abstract class BaseTestCell {
@Test @Test
public void setCellType_BLANK_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() { public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
Cell cell = getInstance(); Cell cell = getInstance();
cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1")); cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1"));
@ -1227,18 +1227,18 @@ public abstract class BaseTestCell {
assertTrue(cell.isPartOfArrayFormulaGroup()); assertTrue(cell.isPartOfArrayFormulaGroup());
assertEquals("1", cell.getCellFormula()); assertEquals("1", cell.getCellFormula());
cell.setCellType(CellType.BLANK); cell.setBlank();
assertEquals(CellType.BLANK, cell.getCellType()); assertEquals(CellType.BLANK, cell.getCellType());
assertFalse(cell.isPartOfArrayFormulaGroup()); assertFalse(cell.isPartOfArrayFormulaGroup());
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
public void setCellType_BLANK_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() { public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
Cell cell = getInstance(); Cell cell = getInstance();
cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1:B1")); cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1:B1"));
cell.setCellValue("foo"); cell.setCellValue("foo");
cell.setCellType(CellType.BLANK); cell.setBlank();
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)