poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1717972 - in /poi/trunk/src: examples/src/org/apache/poi/hssf/usermodel/examples/ ooxml/testcases/org/apache/poi/xssf/streaming/ ooxml/testcases/org/apache/poi/xssf/usermodel/ scratchpad/src/org/apache/poi/hwpf/model/ scratchpad/testcases/...
Date Fri, 04 Dec 2015 14:38:15 GMT
Author: centic
Date: Fri Dec  4 14:38:14 2015
New Revision: 1717972

URL: http://svn.apache.org/viewvc?rev=1717972&view=rev
Log:
Eclipse warnings, code formatting, javadoc, ...

Modified:
    poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java

Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java?rev=1717972&r1=1717971&r2=1717972&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
(original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
Fri Dec  4 14:38:14 2015
@@ -26,11 +26,11 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
 import org.apache.poi.hssf.usermodel.HSSFPatriarch;
-import org.apache.poi.hssf.util.CellReference;
 import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
 
 
@@ -721,7 +721,6 @@ public class AddDimensionedImage {
         String imageFile = null;
         String outputFile = null;
         FileOutputStream fos = null;
-        HSSFWorkbook workbook = null;
         HSSFSheet sheet = null;
         try {
             if(args.length < 2){
@@ -731,13 +730,14 @@ public class AddDimensionedImage {
             imageFile = args[0];
             outputFile = args[1];
 
-            workbook = new HSSFWorkbook();
+            HSSFWorkbook workbook = new HSSFWorkbook();
             sheet = workbook.createSheet("Picture Test");
             new AddDimensionedImage().addImageToSheet("A1", sheet,
                     imageFile, 125, 125,
                     AddDimensionedImage.EXPAND_ROW_AND_COLUMN);
             fos = new FileOutputStream(outputFile);
             workbook.write(fos);
+            workbook.close();
         }
         catch(FileNotFoundException fnfEx) {
             System.out.println("Caught an: " + fnfEx.getClass().getName());
@@ -753,13 +753,6 @@ public class AddDimensionedImage {
         }
         finally {
             try {
-                if (workbook != null) {
-                    workbook.close();
-                }
-            } catch(IOException ioEx) {
-                // I G N O R E
-            }
-            try {
                 if(fos != null) {
                     fos.close();
                     fos = null;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java?rev=1717972&r1=1717971&r2=1717972&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java Fri
Dec  4 14:38:14 2015
@@ -38,6 +38,7 @@ import org.apache.poi.ss.usermodel.Workb
 import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.SXSSFITestDataProvider;
+import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.model.SharedStringsTable;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.After;
@@ -85,12 +86,10 @@ public final class TestSXSSFWorkbook ext
     public void existingWorkbook() throws IOException {
     	XSSFWorkbook xssfWb1 = new XSSFWorkbook();
     	xssfWb1.createSheet("S1");
-    	@SuppressWarnings("resource")
         SXSSFWorkbook wb1 = new SXSSFWorkbook(xssfWb1);
-    	XSSFWorkbook xssfWb2 = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb1);
+    	XSSFWorkbook xssfWb2 = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb1);
     	assertTrue(wb1.dispose());
 
-        @SuppressWarnings("resource")
         SXSSFWorkbook wb2 = new SXSSFWorkbook(xssfWb2);
     	assertEquals(1, wb2.getNumberOfSheets());
     	Sheet sheet  = wb2.getSheetAt(0);
@@ -99,11 +98,12 @@ public final class TestSXSSFWorkbook ext
 	    assertTrue(wb2.dispose());
 	    xssfWb2.close();
 	    xssfWb1.close();
+	    
+	    wb2.close();
     }
 
     @Test
     public void useSharedStringsTable() throws Exception {
-        @SuppressWarnings("resource")
         SXSSFWorkbook wb = new SXSSFWorkbook(null, 10, false, true);
 
         SharedStringsTable sss =  POITestCase.getFieldValue(SXSSFWorkbook.class, wb, SharedStringsTable.class,
"_sharedStringSource");
@@ -116,7 +116,7 @@ public final class TestSXSSFWorkbook ext
         row.createCell(1).setCellValue("B");
         row.createCell(2).setCellValue("A");
 
-        XSSFWorkbook xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
+        XSSFWorkbook xssfWorkbook = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
         sss = POITestCase.getFieldValue(SXSSFWorkbook.class, wb, SharedStringsTable.class,
"_sharedStringSource");
         assertEquals(2, sss.getUniqueCount());
         assertTrue(wb.dispose());
@@ -147,9 +147,8 @@ public final class TestSXSSFWorkbook ext
     	Row row = sheet.createRow(1);
     	Cell cell = row.createCell(1);
     	cell.setCellValue("value 2_1_1");
-    	@SuppressWarnings("resource")
         SXSSFWorkbook wb1 = new SXSSFWorkbook(xssfWb1);
-    	XSSFWorkbook xssfWb2 = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb1);
+    	XSSFWorkbook xssfWb2 = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb1);
         assertTrue(wb1.dispose());
         xssfWb1.close();
 
@@ -172,7 +171,7 @@ public final class TestSXSSFWorkbook ext
     	Cell cell3_1_1 = row3_1.createCell(1);
     	cell3_1_1.setCellValue("value 3_1_1");
 
-    	XSSFWorkbook xssfWb3 = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb2);
+    	XSSFWorkbook xssfWb3 = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb2);
     	wb2.close();
     	
     	assertEquals(3, xssfWb3.getNumberOfSheets());
@@ -239,7 +238,7 @@ public final class TestSXSSFWorkbook ext
         //Test escaping of Unicode control characters
         wb = new SXSSFWorkbook();
         wb.createSheet("S1").createRow(0).createCell(0).setCellValue("value\u0019");
-        XSSFWorkbook xssfWorkbook = (XSSFWorkbook) SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
+        XSSFWorkbook xssfWorkbook = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
         Cell cell = xssfWorkbook.getSheet("S1").getRow(0).getCell(0);
         assertEquals("value?", cell.getStringCellValue());
 
@@ -250,7 +249,6 @@ public final class TestSXSSFWorkbook ext
 
     @Test
     public void gzipSheetdataWriter() throws IOException {
-        @SuppressWarnings("resource")
         SXSSFWorkbook wb = new SXSSFWorkbook();
         wb.setCompressTempFiles(true);
         int rowNum = 1000;
@@ -270,7 +268,7 @@ public final class TestSXSSFWorkbook ext
             }
         }
 
-        XSSFWorkbook xwb = (XSSFWorkbook)SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
+        XSSFWorkbook xwb = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb);
         for(int i = 0; i < sheetNum; i++){
             Sheet sh = xwb.getSheetAt(i);
             assertEquals("sheet" + i, sh.getSheetName());
@@ -322,7 +320,6 @@ public final class TestSXSSFWorkbook ext
         }
     }
 
-    @SuppressWarnings("resource")
     @Test
     public void workbookDispose()
     {
@@ -337,8 +334,8 @@ public final class TestSXSSFWorkbook ext
 
     }
 
-    // currently writing the same sheet multiple times is not supported...
-    @Ignore
+    @Ignore("currently writing the same sheet multiple times is not supported...")
+    @Test
     public void bug53515() throws Exception {
         Workbook wb1 = new SXSSFWorkbook(10);
         populateWorkbook(wb1);
@@ -350,10 +347,9 @@ public final class TestSXSSFWorkbook ext
         wb1.close();
     }
 
-    // Crashes the JVM because of documented JVM behavior with concurrent writing/reading
of zip-files
-    // See http://www.oracle.com/technetwork/java/javase/documentation/overview-156328.html
-    @SuppressWarnings("resource")
-    @Ignore
+    @Ignore("Crashes the JVM because of documented JVM behavior with concurrent writing/reading
of zip-files, "
+            + "see http://www.oracle.com/technetwork/java/javase/documentation/overview-156328.html")
+    @Test
     public void bug53515a() throws Exception {
         File out = new File("Test.xlsx");
         out.delete();
@@ -412,4 +408,31 @@ public final class TestSXSSFWorkbook ext
             }
         }
     }
+
+    @Ignore("Just a local test for http://stackoverflow.com/questions/33627329/apache-poi-streaming-api-using-xssf-template")
+    @Test
+    public void testTemplateFile() throws IOException {
+        XSSFWorkbook workBook = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
+        SXSSFWorkbook streamingWorkBook = new SXSSFWorkbook(workBook,10);
+        Sheet sheet = streamingWorkBook.getSheet("Sheet1");
+        for(int rowNum = 10;rowNum < 1000000;rowNum++) {
+            Row row = sheet.createRow(rowNum);
+            for(int cellNum = 0;cellNum < 700;cellNum++) {
+                Cell cell = row.createCell(cellNum);
+                cell.setCellValue("somevalue");
+            }
+            
+            if(rowNum % 100 == 0) {
+                System.out.print(".");
+                if(rowNum % 10000 == 0) {
+                    System.out.println(rowNum);
+                }
+            }
+        }
+
+        streamingWorkBook.write(new FileOutputStream("C:\\temp\\streaming.xlsx"));
+        
+        streamingWorkBook.close();
+        workBook.close();
+    }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1717972&r1=1717971&r2=1717972&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Fri Dec
 4 14:38:14 2015
@@ -2130,7 +2130,6 @@ public final class TestXSSFBugs extends
      *  in read-only mode
      * @throws InvalidFormatException 
      */
-    @SuppressWarnings("resource")
     @Test
     public void bug57482() throws IOException, InvalidFormatException {
         for (PackageAccess access : new PackageAccess[] {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java?rev=1717972&r1=1717971&r2=1717972&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java Fri Dec  4 14:38:14
2015
@@ -177,8 +177,8 @@ public abstract class PropertyNode<T ext
     return false;
   }
 
-  public T clone()
-    throws CloneNotSupportedException
+  @SuppressWarnings("unchecked")
+  public T clone() throws CloneNotSupportedException
   {
     return (T) super.clone();
   }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java?rev=1717972&r1=1717971&r2=1717972&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/TestReWriteSanity.java Fri Dec
 4 14:38:14 2015
@@ -60,8 +60,8 @@ public final class TestReWriteSanity ext
 		// Find the location of the PersistPtrIncrementalBlocks and
 		// UserEditAtoms
 		Record[] r = wss.getRecords();
-		Hashtable pp = new Hashtable();
-		Hashtable ue = new Hashtable();
+		Map<Integer,Record> pp = new Hashtable<Integer,Record>();
+		Map<Integer,Object> ue = new Hashtable<Integer,Object>();
 		ue.put(Integer.valueOf(0),Integer.valueOf(0)); // Will show 0 if first
 		int pos = 0;
 		int lastUEPos = -1;



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


Mime
View raw message