poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1100122 - /poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Date Fri, 06 May 2011 07:58:36 GMT
Author: nick
Date: Fri May  6 07:58:35 2011
New Revision: 1100122

URL: http://svn.apache.org/viewvc?rev=1100122&view=rev
Log:
More testing around bug #48877

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java

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=1100122&r1=1100121&r2=1100122&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 May
 6 07:58:35 2011
@@ -37,7 +37,6 @@ import org.apache.poi.ss.usermodel.Formu
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.IndexedColors;
 import org.apache.poi.ss.usermodel.Name;
-import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -804,22 +803,26 @@ public final class TestXSSFBugs extends 
        String text = "Use \n with word wrap on to create a new line.\n" +
           "This line finishes with two trailing spaces.  ";
        
-       Workbook wb = new XSSFWorkbook();
-       Sheet sheet = wb.createSheet();
+       XSSFWorkbook wb = new XSSFWorkbook();
+       XSSFSheet sheet = wb.createSheet();
 
        Font font1 = wb.createFont();
        font1.setColor((short) 20);
+       Font font2 = wb.createFont();
+       font2.setColor(Font.COLOR_RED);
+       Font font3 = wb.getFontAt((short)0);
 
-       Row row = sheet.createRow(2);
-       Cell cell = row.createCell(2);
+       XSSFRow row = sheet.createRow(2);
+       XSSFCell cell = row.createCell(2);
 
-       RichTextString richTextString =
+       XSSFRichTextString richTextString =
           wb.getCreationHelper().createRichTextString(text);
        
        // Check the text has the newline
        assertEquals(text, richTextString.getString());
        
        // Apply the font
+       richTextString.applyFont(font3);
        richTextString.applyFont(0, 3, font1);
        cell.setCellValue(richTextString);
 
@@ -837,6 +840,28 @@ public final class TestXSSFBugs extends 
        row = sheet.getRow(2);
        cell = row.getCell(2);
        assertEquals(text, cell.getStringCellValue());
+       
+       // Now add a 2nd, and check again
+       int fontAt = text.indexOf("\n", 6);
+       cell.getRichStringCellValue().applyFont(10, fontAt+1, font2);
+       assertEquals(text, cell.getStringCellValue());
+       
+       assertEquals(4, cell.getRichStringCellValue().numFormattingRuns());
+       assertEquals("Use", cell.getRichStringCellValue().getCTRst().getRList().get(0).getT());
+       
+       String r3 = cell.getRichStringCellValue().getCTRst().getRList().get(2).getT();
+       assertEquals("line.\n", r3.substring(r3.length()-6));
+       
+       // Save and re-check
+       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+       sheet = wb.getSheetAt(0);
+       row = sheet.getRow(2);
+       cell = row.getCell(2);
+       assertEquals(text, cell.getStringCellValue());
+       
+//       FileOutputStream out = new FileOutputStream("/tmp/test48877.xlsx");
+//       wb.write(out);
+//       out.close();
     }
     
     /**



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


Mime
View raw message