poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1502749 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/streaming/SXSSFSheet.java java/org/apache/poi/xssf/usermodel/XSSFSheet.java testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
Date Sat, 13 Jul 2013 05:37:41 GMT
Author: centic
Date: Sat Jul 13 05:37:41 2013
New Revision: 1502749

URL: http://svn.apache.org/r1502749
Log:
Bug 55248: Add methods for showInPane() using int and unit test to verify it can handle more
than 32767 rows

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java

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=1502749&r1=1502748&r2=1502749&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 Sat Jul 13 05:37:41
2013
@@ -778,6 +778,20 @@ public class SXSSFSheet implements Sheet
      * @param toprow the top row to show in desktop window pane
      * @param leftcol the left column to show in desktop window pane
      */
+    public void showInPane(int toprow, int leftcol)
+    {
+        _sh.showInPane(toprow, leftcol);
+    }
+
+    /**
+     * Sets desktop window pane display area, when the
+     * file is first opened in a viewer.
+     *
+     * @param toprow the top row to show in desktop window pane
+     * @param leftcol the left column to show in desktop window pane
+     * 
+     * @deprecated Use the version of showInPane() with ints as there can be more than 32767
rows. 
+     */
     public void showInPane(short toprow, short leftcol)
     {
         _sh.showInPane(toprow, leftcol);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1502749&r1=1502748&r2=1502749&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sat Jul 13 05:37:41
2013
@@ -2386,12 +2386,25 @@ public class XSSFSheet extends POIXMLDoc
      * @param toprow the top row to show in desktop window pane
      * @param leftcol the left column to show in desktop window pane
      */
-    public void showInPane(short toprow, short leftcol) {
+    public void showInPane(int toprow, int leftcol) {
         CellReference cellReference = new CellReference(toprow, leftcol);
         String cellRef = cellReference.formatAsString();
         getPane().setTopLeftCell(cellRef);
     }
 
+    /**
+     * Location of the top left visible cell Location of the top left visible cell in the
bottom right
+     * pane (when in Left-to-Right mode).
+     *
+     * @param toprow the top row to show in desktop window pane
+     * @param leftcol the left column to show in desktop window pane
+     * 
+     * @deprecated Use the version of showInPane() with ints as there can be more than 32767
rows. 
+     */
+    public void showInPane(short toprow, short leftcol) {
+        showInPane((int)toprow, (int)leftcol);
+    }
+
     public void ungroupColumn(int fromColumn, int toColumn) {
         CTCols cols = worksheet.getColsArray(0);
         for (int index = fromColumn; index <= toColumn; index++) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1502749&r1=1502748&r2=1502749&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Sat Jul
13 05:37:41 2013
@@ -17,10 +17,6 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
@@ -33,11 +29,13 @@ import org.apache.poi.ss.usermodel.Sheet
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.HexDump;
+import org.apache.poi.xssf.SXSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.model.CalculationChain;
 import org.apache.poi.xssf.model.CommentsTable;
 import org.apache.poi.xssf.model.StylesTable;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
@@ -46,6 +44,8 @@ import org.openxmlformats.schemas.spread
 @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans
with JDK 1.5 support
 public final class TestXSSFSheet extends BaseTestSheet {
 
+    private static final int ROW_COUNT = 40000;
+
     public TestXSSFSheet() {
         super(XSSFITestDataProvider.instance);
     }
@@ -1079,28 +1079,28 @@ public final class TestXSSFSheet extends
      * Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr
      */
     public void testSetForceFormulaRecalculation() {
-    	   XSSFWorkbook workbook = new XSSFWorkbook();
-         XSSFSheet sheet = workbook.createSheet("Sheet 1");
-
-         // Set
-         sheet.setForceFormulaRecalculation(true);
-         assertEquals(true, sheet.getForceFormulaRecalculation());
-
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
+        
+        // Set
+        sheet.setForceFormulaRecalculation(true);
+        assertEquals(true, sheet.getForceFormulaRecalculation());
+        
         // calcMode="manual" is unset when forceFormulaRecalculation=true
         CTCalcPr calcPr = workbook.getCTWorkbook().addNewCalcPr();
         calcPr.setCalcMode(STCalcMode.MANUAL);
         sheet.setForceFormulaRecalculation(true);
         assertEquals(STCalcMode.AUTO, calcPr.getCalcMode());
-
+        
         // Check
-         sheet.setForceFormulaRecalculation(false);
-         assertEquals(false, sheet.getForceFormulaRecalculation());
-
-
-         // Save, re-load, and re-check
-         workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
-         sheet = workbook.getSheet("Sheet 1");
-         assertEquals(false, sheet.getForceFormulaRecalculation());
+        sheet.setForceFormulaRecalculation(false);
+        assertEquals(false, sheet.getForceFormulaRecalculation());
+        
+        
+        // Save, re-load, and re-check
+        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        sheet = workbook.getSheet("Sheet 1");
+        assertEquals(false, sheet.getForceFormulaRecalculation());
 	}
 
     public void test54607() {
@@ -1164,4 +1164,49 @@ public final class TestXSSFSheet extends
 	    	}
     	}
 	}
+	
+	public void testShowInPaneManyRowsBug55248() {
+	    XSSFWorkbook workbook = new XSSFWorkbook();
+	    XSSFSheet sheet = workbook.createSheet("Sheet 1");
+
+	    sheet.showInPane(0, 0);
+	    
+        for(int i = ROW_COUNT/2;i < ROW_COUNT;i++) {
+            sheet.createRow(i);
+            sheet.showInPane(i, 0);
+            // this one fails: sheet.showInPane((short)i, 0);
+        }
+        
+        short i = 0;
+        sheet.showInPane(i, i);
+        
+        XSSFWorkbook wb = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        checkRowCount(wb);
+	}
+
+    public void testShowInPaneManyRowsBug55248SXSSF() {
+        SXSSFWorkbook workbook = new SXSSFWorkbook(new XSSFWorkbook());
+        SXSSFSheet sheet = (SXSSFSheet) workbook.createSheet("Sheet 1");
+        
+        sheet.showInPane(0, 0);
+        
+        for(int i = ROW_COUNT/2;i < ROW_COUNT;i++) {
+            sheet.createRow(i);
+            sheet.showInPane(i, 0);
+            // this one fails: sheet.showInPane((short)i, 0);
+        }
+        
+        short i = 0;
+        sheet.showInPane(i, i);
+        
+        Workbook wb = SXSSFITestDataProvider.instance.writeOutAndReadBack(workbook);
+        checkRowCount(wb);
+    }
+
+    private void checkRowCount(Workbook wb) {
+        assertNotNull(wb);
+        final Sheet sh = wb.getSheet("Sheet 1");
+        assertNotNull(sh);
+        assertEquals(ROW_COUNT-1, sh.getLastRowNum());
+    }
 }



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


Mime
View raw message