You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ga...@apache.org on 2019/01/26 19:40:57 UTC

svn commit: r1852244 - in /poi/trunk/src: java/org/apache/poi/ss/usermodel/Cell.java java/org/apache/poi/ss/usermodel/CellBase.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java testcases/org/apache/poi/ss/usermodel/BaseTestCell.java

Author: gallon
Date: Sat Jan 26 19:40:56 2019
New Revision: 1852244

URL: http://svn.apache.org/viewvc?rev=1852244&view=rev
Log:
added Cell.setBlank() - as an alias, for now

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/CellBase.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java?rev=1852244&r1=1852243&r2=1852244&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java Sat Jan 26 19:40:56 2019
@@ -90,6 +90,13 @@ public interface Cell {
     void setCellType(CellType cellType);
 
     /**
+     * Removes formula and value from the cell, and sets its type to {@link CellType#BLANK}.
+     * Preserves comments and hyperlinks.
+     * While {@link #setCellType(CellType)} exists, is an alias for {@code setCellType(CellType.BLANK)}.
+     */
+    void setBlank();
+
+    /**
      * Return the cell type.
      *
      * @return the cell type

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/CellBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/CellBase.java?rev=1852244&r1=1852243&r2=1852244&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/CellBase.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/CellBase.java Sat Jan 26 19:40:56 2019
@@ -41,6 +41,14 @@ public abstract class CellBase implement
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setBlank() {
+        setCellType(CellType.BLANK);
+    }
+
+    /**
      * Implementation-specific logic
      * @param cellType new cell type. Guaranteed non-null, not _NONE.
      */

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1852244&r1=1852243&r2=1852244&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Sat Jan 26 19:40:56 2019
@@ -944,7 +944,7 @@ public final class XSSFCell extends Cell
      * Blanks this cell. Blank cells have no formula or value but may have styling.
      * This method erases all the data previously associated with this cell.
      */
-    private void setBlank(){
+    private void setBlankPrivate(){
         CTCell blank = CTCell.Factory.newInstance();
         blank.setR(_cell.getR());
         if(_cell.isSetS()) {
@@ -1010,7 +1010,7 @@ public final class XSSFCell extends Cell
                 }
                 break;
             case BLANK:
-                setBlank();
+                setBlankPrivate();
                 break;
             case BOOLEAN:
                 String newVal = convertCellValueToBoolean() ? TRUE_AS_STRING : FALSE_AS_STRING;

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1852244&r1=1852243&r2=1852244&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Sat Jan 26 19:40:56 2019
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
 
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -32,13 +35,11 @@ import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Locale;
 import java.util.TimeZone;
-import java.util.function.Consumer;
 
 import org.apache.poi.common.usermodel.HyperlinkType;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.formula.FormulaParseException;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.Test;
@@ -1357,6 +1358,16 @@ public abstract class BaseTestCell {
         assertTrue(cell.getBooleanCellValue());
     }
 
+    @Test
+    public final void setBlank_delegatesTo_setCellType_BLANK() {
+        Cell cell = mock(CellBase.class);
+        doCallRealMethod().when(cell).setBlank();
+
+        cell.setBlank();
+
+        verify(cell).setCellType(CellType.BLANK);
+    }
+
     private Cell getInstance() {
         return _testDataProvider.createWorkbook().createSheet().createRow(0).createCell(0);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org