From 19bf8b23d5dacee226c70cece3a315e5f1e47616 Mon Sep 17 00:00:00 2001 From: Vladislav Galas Date: Sat, 26 Jan 2019 19:41:10 +0000 Subject: [PATCH] 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 --- src/java/org/apache/poi/hssf/usermodel/HSSFCell.java | 7 +++---- .../org/apache/poi/hssf/usermodel/HSSFSheet.java | 2 +- .../ss/formula/eval/forked/ForkedEvaluationCell.java | 2 +- .../org/apache/poi/ss/usermodel/RangeCopier.java | 2 +- .../org/apache/poi/xssf/streaming/SXSSFCell.java | 8 ++++---- .../java/org/apache/poi/xssf/usermodel/XSSFCell.java | 6 +++--- .../org/apache/poi/xssf/usermodel/XSSFSheet.java | 2 +- .../org/apache/poi/xssf/usermodel/XSSFTable.java | 2 +- .../org/apache/poi/xssf/streaming/TestSXSSFCell.java | 4 ++-- .../org/apache/poi/xssf/usermodel/TestXSSFBugs.java | 2 +- .../poi/hssf/record/TestSharedFormulaRecord.java | 2 +- .../org/apache/poi/hssf/usermodel/TestHSSFCell.java | 2 +- .../apache/poi/ss/formula/TestEvaluationCache.java | 6 +++--- .../apache/poi/ss/formula/atp/TestRandBetween.java | 4 ++-- .../org/apache/poi/ss/usermodel/BaseTestCell.java | 12 ++++++------ 15 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index dbeaba8b48..eb92d5bddb 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -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.ptg.ExpPtg; 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.CellStyle; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.Comment; 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.RichTextString; import org.apache.poi.ss.util.CellAddress; @@ -492,7 +490,7 @@ public class HSSFCell extends CellBase { public void setCellValue(Date value) { if(value == null) { - setCellType(CellType.BLANK); + setBlank(); return; } @@ -517,7 +515,7 @@ public class HSSFCell extends CellBase { public void setCellValue(Calendar value) { if(value == null) { - setCellType(CellType.BLANK); + setBlank(); return; } @@ -1302,3 +1300,4 @@ public class HSSFCell extends CellBase { return styleIndex; } } + diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 48a9095907..84d13ca0b9 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -2389,7 +2389,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet { CellRange result = getCellRange(range); // clear all cells in the range for (Cell c : result) { - c.setCellType(CellType.BLANK); + c.setBlank(); } return result; } diff --git a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java index 88beb361d4..21897a98bf 100644 --- a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java +++ b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java @@ -91,7 +91,7 @@ final class ForkedEvaluationCell implements EvaluationCell { } public void copyValue(Cell destCell) { switch (_cellType) { - case BLANK: destCell.setCellType(CellType.BLANK); return; + case BLANK: destCell.setBlank(); return; case NUMERIC: destCell.setCellValue(_numberValue); return; case BOOLEAN: destCell.setCellValue(_booleanValue); return; case STRING: destCell.setCellValue(_stringValue); return; diff --git a/src/java/org/apache/poi/ss/usermodel/RangeCopier.java b/src/java/org/apache/poi/ss/usermodel/RangeCopier.java index ea3bc4e225..162100240f 100644 --- a/src/java/org/apache/poi/ss/usermodel/RangeCopier.java +++ b/src/java/org/apache/poi/ss/usermodel/RangeCopier.java @@ -140,7 +140,7 @@ public abstract class RangeCopier { destCell.setCellValue(srcCell.getNumericCellValue()); break; case BLANK: - destCell.setCellType(CellType.BLANK); + destCell.setBlank(); break; case BOOLEAN: destCell.setCellValue(srcCell.getBooleanCellValue()); diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java index 3f67266f21..797c39bba6 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java @@ -224,7 +224,7 @@ public class SXSSFCell extends CellBase { @Override public void setCellValue(Date value) { if(value == null) { - setCellType(CellType.BLANK); + setBlank(); return; } @@ -251,7 +251,7 @@ public class SXSSFCell extends CellBase { @Override public void setCellValue(Calendar value) { if(value == null) { - setCellType(CellType.BLANK); + setBlank(); return; } @@ -283,7 +283,7 @@ public class SXSSFCell extends CellBase { ((RichTextValue) _value).setValue(value); } } else { - setCellType(CellType.BLANK); + setBlank(); } } @@ -311,7 +311,7 @@ public class SXSSFCell extends CellBase { ((PlainStringValue) _value).setValue(value); } } else { - setCellType(CellType.BLANK); + setBlank(); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 66061f4c64..a45ae4c629 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -431,7 +431,7 @@ public final class XSSFCell extends CellBase { @Override public void setCellValue(RichTextString str) { if(str == null || str.getString() == null){ - setCellType(CellType.BLANK); + setBlank(); return; } @@ -830,7 +830,7 @@ public final class XSSFCell extends CellBase { @Override public void setCellValue(Date value) { if(value == null) { - setCellType(CellType.BLANK); + setBlank(); return; } @@ -857,7 +857,7 @@ public final class XSSFCell extends CellBase { @Override public void setCellValue(Calendar value) { if(value == null) { - setCellType(CellType.BLANK); + setBlank(); return; } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index d95decccef..8f3e411644 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -3993,7 +3993,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { arrayFormulas.remove(range); CellRange cr = getCellRange(range); for (XSSFCell c : cr) { - c.setCellType(CellType.BLANK); + c.setBlank(); } return cr; } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java index 16a21f0d6a..de560ddd2e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java @@ -766,7 +766,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table { if (row != null) { XSSFCell cell = row.getCell(cellRef.getCol()); if (cell != null) { - cell.setCellType(CellType.BLANK); + cell.setBlank(); cell.setCellStyle(null); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java index 8ecbce0544..e696378667 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java @@ -154,7 +154,7 @@ public class TestSXSSFCell extends BaseTestXCell { */ @Override @Ignore - public void setCellType_BLANK_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() { + public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() { } /** @@ -164,7 +164,7 @@ public class TestSXSSFCell extends BaseTestXCell { @Override @Ignore @Test // <- annotation is necessary to override expected exception - public void setCellType_BLANK_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() { + public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() { } @Override diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 610ac7b22f..7ed41f9c6d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -637,7 +637,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { validateCells(sheet); XSSFTestDataSamples.writeOutAndReadBack(wb1).close(); - sheet.getRow(6).getCell(0).setCellType(CellType.BLANK); // go + sheet.getRow(6).getCell(0).setBlank(); // go XSSFTestDataSamples.writeOutAndReadBack(wb1).close(); sheet.getRow(7).getCell(0).setCellValue((String) null); // go diff --git a/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java index fd8a9c03a7..b061221fb4 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java @@ -204,7 +204,7 @@ public final class TestSharedFormulaRecord extends TestCase { assertEquals("A$1*2", sheet.getRow(ROW_IX).getCell(1).getCellFormula()); cell = sheet.getRow(ROW_IX).getCell(1); - cell.setCellType(CellType.BLANK); + cell.setBlank(); assertEquals(3, countSharedFormulas(sheet)); wb = HSSFTestDataSamples.writeOutAndReadBack(wb); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index b4200df087..5f37ad44fd 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -436,7 +436,7 @@ public final class TestHSSFCell extends BaseTestCell { Row row = sheet.createRow(0); Cell cell = row.createCell(0); - cell.setCellType(CellType.BLANK); + cell.setBlank(); assertNull(null, cell.getDateCellValue()); assertFalse(cell.getBooleanCellValue()); assertEquals("", cell.toString()); diff --git a/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java b/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java index db6d96c77f..c2abe42e24 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java +++ b/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java @@ -232,14 +232,14 @@ public class TestEvaluationCache extends TestCase { public void setCellValue(String cellRefText, double value) { HSSFCell cell = getOrCreateCell(cellRefText); // 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; cell.setCellValue(value); _evaluator.notifyUpdateCell(wrapCell(cell)); } public void clearCell(String cellRefText) { HSSFCell cell = getOrCreateCell(cellRefText); - cell.setCellType(CellType.BLANK); + cell.setBlank(); _evaluator.notifyUpdateCell(wrapCell(cell)); } @@ -606,7 +606,7 @@ public class TestEvaluationCache extends TestCase { cv = fe.evaluate(cellA1); assertEquals(3.7, cv.getNumberValue(), 0.0); - cellB1.setCellType(CellType.BLANK); + cellB1.setBlank(); fe.notifyUpdateCell(cellB1); cv = fe.evaluate(cellA1); // B1 was used to evaluate A1 assertEquals(2.2, cv.getNumberValue(), 0.0); diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java b/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java index 206d17016d..5a922080c0 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java @@ -119,7 +119,7 @@ public class TestRandBetween extends TestCase { public void testRandBetweenTopBlank() { bottomValueCell.setCellValue(-1); - topValueCell.setCellType(CellType.BLANK); + topValueCell.setBlank(); formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); @@ -174,7 +174,7 @@ public class TestRandBetween extends TestCase { assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue()); bottomValueCell.setCellValue(1); - topValueCell.setCellType(CellType.BLANK); + topValueCell.setBlank(); formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java index 94a003dcb1..3190c62f03 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -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 public void testSetBlank_bug47028() throws Exception { @@ -651,7 +651,7 @@ public abstract class BaseTestCell { Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0); cell.setCellStyle(style); int i1 = cell.getCellStyle().getIndex(); - cell.setCellType(CellType.BLANK); + cell.setBlank(); int i2 = cell.getCellStyle().getIndex(); assertEquals(i1, i2); wb.close(); @@ -1219,7 +1219,7 @@ public abstract class BaseTestCell { @Test - public void setCellType_BLANK_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() { + public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() { Cell cell = getInstance(); cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1")); @@ -1227,18 +1227,18 @@ public abstract class BaseTestCell { assertTrue(cell.isPartOfArrayFormulaGroup()); assertEquals("1", cell.getCellFormula()); - cell.setCellType(CellType.BLANK); + cell.setBlank(); assertEquals(CellType.BLANK, cell.getCellType()); assertFalse(cell.isPartOfArrayFormulaGroup()); } @Test(expected = IllegalStateException.class) - public void setCellType_BLANK_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() { + public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() { Cell cell = getInstance(); cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1:B1")); cell.setCellValue("foo"); - cell.setCellType(CellType.BLANK); + cell.setBlank(); } @Test(expected = IllegalStateException.class) -- 2.39.5