poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r887160 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
Date Fri, 04 Dec 2009 11:24:02 GMT
Author: yegor
Date: Fri Dec  4 11:24:02 2009
New Revision: 887160

URL: http://svn.apache.org/viewvc?rev=887160&view=rev
Log:
fixed XSSFSheet autoSizeColumn() to tolerate empty RichTextString, see Bugzilla 48332

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=887160&r1=887159&r2=887160&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Dec  4 11:24:02 2009
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.6-beta1" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">48332 - fixed XSSFSheet autoSizeColumn()
to tolerate empty RichTextString</action>
            <action dev="POI-DEVELOPERS" type="fix">48332 - fixed ColumnInfoRecord to
tolerate missing reserved field</action>
            <action dev="POI-DEVELOPERS" type="fix">47701 - fixed RecordFormatException
when reading list subrecords (LbsDataSubRecord)</action>
            <action dev="POI-DEVELOPERS" type="add"> memory usage optimization in XSSF
- avoid creating parentless xml beans</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java?rev=887160&r1=887159&r2=887160&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java Fri Dec
 4 11:24:02 2009
@@ -366,8 +366,10 @@
                             XSSFFont fnt = rt.getFontOfFormattingRun(j);
                             if (fnt != null) {
                                 int len = rt.getLengthOfFormattingRun(j);
-                                copyAttributes(fnt, str, pos, pos + len);
-                                pos += len;
+                                if(len > 0) { //ignore degenerate zero-length runs
+                                    copyAttributes(fnt, str, pos, pos + len);
+                                    pos += len;
+                                }
                             }
                         }
                     }

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=887160&r1=887159&r2=887160&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 Fri Dec
 4 11:24:02 2009
@@ -17,9 +17,7 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import org.apache.poi.ss.usermodel.BaseTestSheet;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.XSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFTestDataSamples;
@@ -158,6 +156,24 @@
         assertTrue(col.getBestFit());
     }
 
+    /**
+     * XSSFSheet autoSizeColumn() on empty RichTextString fails
+     */
+    public void test48325() {
+        XSSFWorkbook wb = new XSSFWorkbook();
+        XSSFSheet sheet = wb.createSheet("Test");
+        CreationHelper factory = wb.getCreationHelper();
+
+        XSSFRow row = sheet.createRow(0);
+        XSSFCell cell = row.createCell(0);
+
+        XSSFFont font = wb.createFont();
+        RichTextString rts = factory.createRichTextString("");
+        rts.applyFont(font);
+        cell.setCellValue(rts);
+
+        sheet.autoSizeColumn(0);
+    }
 
     public void testGetCellComment() {
         XSSFWorkbook workbook = new XSSFWorkbook();



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


Mime
View raw message