poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r768389 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
Date Fri, 24 Apr 2009 18:25:19 GMT
Author: yegor
Date: Fri Apr 24 18:25:19 2009
New Revision: 768389

URL: http://svn.apache.org/viewvc?rev=768389&view=rev
Log:
fixed XSSFWorkbook.createSheet to properly increment sheetId when  sheetId sequence is not
continious

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=768389&r1=768388&r2=768389&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Apr 24 18:25:19 2009
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47089 - Fixed XSSFWorkbook.createSheet
to properly increment sheetId</action>
            <action dev="POI-DEVELOPERS" type="fix">46568 - Fixed XSLFPowerPointExtractor
to properly process line breaks</action>
            <action dev="POI-DEVELOPERS" type="fix">39056 - Fixed POIFSFileSystem to
set CLSID of root when constructing instances from InputStream</action>
            <action dev="POI-DEVELOPERS" type="fix">47054 - Fixed cloneStyleFrom to
avoid exception when cloning styles of the same family</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=768389&r1=768388&r2=768389&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Apr 24 18:25:19 2009
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47089 - Fixed XSSFWorkbook.createSheet
to properly increment sheetId</action>
            <action dev="POI-DEVELOPERS" type="fix">46568 - Fixed XSLFPowerPointExtractor
to properly process line breaks</action>
            <action dev="POI-DEVELOPERS" type="fix">39056 - Fixed POIFSFileSystem to
set CLSID of root when constructing instances from InputStream</action>
            <action dev="POI-DEVELOPERS" type="fix">47054 - Fixed cloneStyleFrom to
avoid exception when cloning styles of the same family</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=768389&r1=768388&r2=768389&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Fri Apr 24 18:25:19
2009
@@ -453,7 +453,9 @@
 
         CTSheet sheet = addSheet(sheetname);
 
-        int sheetNumber = getNumberOfSheets() + 1;
+        int sheetNumber = 1;
+        for(XSSFSheet sh : sheets) sheetNumber = (int)Math.max(sh.sheet.getSheetId() + 1,
sheetNumber);
+
         XSSFSheet wrapper = (XSSFSheet)createRelationship(XSSFRelation.WORKSHEET, XSSFFactory.getInstance(),
sheetNumber);
         wrapper.sheet = sheet;
         sheet.setId(wrapper.getPackageRelationship().getId());

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=768389&r1=768388&r2=768389&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Fri
Apr 24 18:25:19 2009
@@ -227,5 +227,18 @@
 		assertEquals(2, st.getFills().size());
 		assertEquals(1, st.getBorders().size());
 	}
-	
+
+    public void testIncrementSheetId() throws Exception {
+        XSSFWorkbook wb = getTestDataProvider().createWorkbook();
+        int sheetId = (int)wb.createSheet().sheet.getSheetId();
+        assertEquals(1, sheetId);
+        sheetId = (int)wb.createSheet().sheet.getSheetId();
+        assertEquals(2, sheetId);
+
+        //test file with gaps in the sheetId sequence
+        wb = getTestDataProvider().openSampleWorkbook("47089.xlsm");
+        int lastSheetId = (int)wb.getSheetAt(wb.getNumberOfSheets() - 1).sheet.getSheetId();
+        sheetId = (int)wb.createSheet().sheet.getSheetId();
+        assertEquals(lastSheetId+1, sheetId);
+    }
 }



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


Mime
View raw message