poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1693633 - in /poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming: SXSSFCell.java SXSSFRow.java SXSSFSheet.java SXSSFWorkbook.java
Date Fri, 31 Jul 2015 17:23:01 GMT
Author: nick
Date: Fri Jul 31 17:23:01 2015
New Revision: 1693633

URL: http://svn.apache.org/r1693633
Log:
Use more specific return types in SXSSF, which avoids casts, and also fix some long-standing
TODOs on 1904 dates

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java?rev=1693633&r1=1693632&r2=1693633&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java Fri Jul 31 17:23:01
2015
@@ -33,18 +33,18 @@ import org.apache.poi.ss.usermodel.Formu
 import org.apache.poi.ss.usermodel.Hyperlink;
 import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.xssf.usermodel.XSSFHyperlink;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
 
 /**
  * Streaming version of XSSFRow implementing the "BigGridDemo" strategy.
- *
- * @author Alex Geller, Four J's Development Tools
 */
-public class SXSSFCell implements Cell 
-{
+public class SXSSFCell implements Cell {
+    private static POILogger logger = POILogFactory.getLogger(SXSSFCell.class);
 
     SXSSFRow _row;
     Value _value;
@@ -84,7 +84,7 @@ public class SXSSFCell implements Cell
      *
      * @return the sheet this cell belongs to
      */
-    public Sheet getSheet()
+    public SXSSFSheet getSheet()
     {
         return _row.getSheet();
     }
@@ -185,11 +185,8 @@ public class SXSSFCell implements Cell
      *        precalculated value, for numerics we'll set its value. For other types we
      *        will change the cell to a numerics cell and set its value.
      */
-    public void setCellValue(Date value)
-    {
-//TODO: activate this when compiling against 3.7.
-        //boolean date1904 = getSheet().getXSSFWorkbook().isDate1904();
-        boolean date1904 = false;
+    public void setCellValue(Date value) {
+        boolean date1904 = getSheet().getWorkbook().isDate1904();
         setCellValue(DateUtil.getExcelDate(value, date1904));
     }
 
@@ -209,11 +206,8 @@ public class SXSSFCell implements Cell
      *        precalculated value, for numerics we'll set its value. For othertypes we
      *        will change the cell to a numeric cell and set its value.
      */
-    public void setCellValue(Calendar value)
-    {
-//TODO: activate this when compiling against 3.7.
-        //boolean date1904 = getSheet().getXSSFWorkbook().isDate1904();
-        boolean date1904 = false;
+    public void setCellValue(Calendar value) {
+        boolean date1904 = getSheet().getWorkbook().isDate1904();
         setCellValue( DateUtil.getExcelDate(value, date1904 ));
     }
 
@@ -234,6 +228,9 @@ public class SXSSFCell implements Cell
         }
 
         ((RichTextValue)_value).setValue(value);
+        
+        if (((XSSFRichTextString)value).hasFormatting())
+            logger.log(POILogger.WARN, "SXSSF doesn't support Shared Strings, rich text formatting
information has be lost");
     }
 
     /**
@@ -343,9 +340,7 @@ public class SXSSFCell implements Cell
         }
 
         double value = getNumericCellValue();
-//TODO: activate this when compiling against 3.7.
-        //boolean date1904 = getSheet().getXSSFWorkbook().isDate1904();
-        boolean date1904 = false;
+        boolean date1904 = getSheet().getWorkbook().isDate1904();
         return DateUtil.getJavaDate(value, date1904);
     }
 
@@ -603,8 +598,7 @@ public class SXSSFCell implements Cell
         xssfobj.getCTHyperlink().setRef( ref.formatAsString()  );
 
         // Add to the lists
-        ((SXSSFSheet)getSheet())._sh.addHyperlink(xssfobj);
-
+        getSheet()._sh.addHyperlink(xssfobj);
     }
 
     /**
@@ -614,7 +608,7 @@ public class SXSSFCell implements Cell
     {
         removeProperty(Property.HYPERLINK);
 
-        ((SXSSFSheet) getSheet())._sh.removeHyperlink(getRowIndex(), getColumnIndex());
+        getSheet()._sh.removeHyperlink(getRowIndex(), getColumnIndex());
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java?rev=1693633&r1=1693632&r2=1693633&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java Fri Jul 31 17:23:01
2015
@@ -420,7 +420,7 @@ public class SXSSFRow implements Row
      *
      * @return the Sheet that owns this row
      */
-    public Sheet getSheet()
+    public SXSSFSheet getSheet()
     {
         return _sheet;
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1693633&r1=1693632&r2=1693633&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java Fri Jul 31 17:23:01
2015
@@ -1344,7 +1344,7 @@ public class SXSSFSheet implements Sheet
      *
      * @return the parent workbook
      */
-    public Workbook getWorkbook()
+    public SXSSFWorkbook getWorkbook()
     {
         return _workbook;
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java?rev=1693633&r1=1693632&r2=1693633&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java Fri Jul 31 17:23:01
2015
@@ -622,7 +622,7 @@ public class SXSSFWorkbook implements Wo
      * @return Sheet representing the new sheet.
      */
     @Override
-    public Sheet createSheet()
+    public SXSSFSheet createSheet()
     {
         return createAndRegisterSXSSFSheet(_wb.createSheet());
     }
@@ -1122,6 +1122,10 @@ public class SXSSFWorkbook implements Wo
         return _wb.getCreationHelper();
     }
 
+    protected boolean isDate1904() {
+        return _wb.isDate1904();
+    }
+    
     /**
      * @return <code>false</code> if this workbook is not visible in the GUI
      */



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


Mime
View raw message