You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by dn...@apache.org on 2015/09/23 14:53:13 UTC
svn commit: r1704839 - in /poi: site/src/documentation/content/xdocs/
trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/
trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/
trunk/src/testcases/org/apache/poi/hssf/usermodel/
Author: dnorth
Date: Wed Sep 23 12:53:13 2015
New Revision: 1704839
URL: http://svn.apache.org/viewvc?rev=1704839&view=rev
Log:
Make XSSF and HSSF consistent in getMergedRegions - return empty list if there are none, rather than an exception. Tests for this.
https://bz.apache.org/bugzilla/show_bug.cgi?id=58350
Modified:
poi/site/src/documentation/content/xdocs/status.xml
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1704839&r1=1704838&r2=1704839&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Wed Sep 23 12:53:13 2015
@@ -42,6 +42,7 @@
</release -->
<release version="3.13" date="2015-09-25">
+ <action dev="DN" type="fix" fixes-bug="58350">Make XSSF and HSSF consistent on Sheet.getMergedRegions: return empty list if there are none.</action>
<action dev="PD" type="add" fixes-bug="58216">provide picture-shape resize that maintains the aspect ratio</action>
<action dev="PD" type="add" fixes-bug="57925">Add a simple fix to avoid an NPE when Workbooks have invalid external references</action>
<action dev="PD" type="add" fixes-bug="57915">Fix Dev2Hex for numbers larger than Integer.MAX_VALUE and less than Integer.MIN_VALUE</action>
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=1704839&r1=1704838&r2=1704839&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 Wed Sep 23 12:53:13 2015
@@ -1090,7 +1090,6 @@ public class XSSFSheet extends POIXMLDoc
* this each time.
*
* @return the merged region at the specified index
- * @throws IllegalStateException if this worksheet does not contain merged regions
*/
@Override
public CellRangeAddress getMergedRegion(int index) {
@@ -1107,15 +1106,14 @@ public class XSSFSheet extends POIXMLDoc
* faster than calling {@link #getMergedRegion(int)} each time.
*
* @return the list of merged regions
- * @throws IllegalStateException if this worksheet does not contain merged regions
*/
@SuppressWarnings("deprecation")
@Override
public List<CellRangeAddress> getMergedRegions() {
+ List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>();
CTMergeCells ctMergeCells = worksheet.getMergeCells();
- if(ctMergeCells == null) throw new IllegalStateException("This worksheet does not contain merged regions");
+ if(ctMergeCells == null) return addresses;
- List<CellRangeAddress> addresses = new ArrayList<CellRangeAddress>();
for(CTMergeCell ctMergeCell : ctMergeCells.getMergeCellArray()) {
String ref = ctMergeCell.getRef();
addresses.add(CellRangeAddress.valueOf(ref));
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=1704839&r1=1704838&r2=1704839&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 Wed Sep 23 12:53:13 2015
@@ -1382,4 +1382,11 @@ public final class TestXSSFSheet extends
XSSFSheet sheet = wb.createSheet();
assertNotNull(sheet.createComment());
}
+
+ @Test
+ public void testNoMergedRegionsIsEmptyList() {
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ assertTrue(sheet.getMergedRegions().isEmpty());
+ }
}
\ No newline at end of file
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java?rev=1704839&r1=1704838&r2=1704839&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java Wed Sep 23 12:53:13 2015
@@ -657,6 +657,13 @@ public final class TestHSSFSheet extends
assertTrue(sheet3.getColumnWidth(0) >= minWithRow1And2);
assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2);
}
+
+ @Test
+ public void testNoMergedRegionsIsEmptyList() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet s = wb.createSheet("Sheet1");
+ assertTrue(s.getMergedRegions().isEmpty());
+ }
@Test
public void autoSizeDate() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org