You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2011/03/04 18:06:01 UTC
svn commit: r1078057 -
/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
Author: nick
Date: Fri Mar 4 17:06:01 2011
New Revision: 1078057
URL: http://svn.apache.org/viewvc?rev=1078057&view=rev
Log:
Add unit test showing that bug #48877 no longer applies
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=1078057&r1=1078056&r2=1078057&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 Mar 4 17:06:01 2011
@@ -26,8 +26,19 @@ import org.apache.poi.hssf.usermodel.HSS
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.formula.eval.NotImplementedException;
+import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+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;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.CalculationChain;
@@ -767,4 +778,47 @@ public final class TestXSSFBugs extends
assertNotNull( colt.getRgb() );
assertEquals( themeC.getARGBHex(), colt.getARGBHex() ); // The same colour
}
+
+ /**
+ * New lines were being eaten when setting a font on
+ * a rich text string
+ */
+ public void test48877() throws Exception {
+ 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();
+
+ Font font1 = wb.createFont();
+ font1.setColor((short) 20);
+
+ Row row = sheet.createRow(2);
+ Cell cell = row.createCell(2);
+
+ RichTextString richTextString =
+ wb.getCreationHelper().createRichTextString(text);
+
+ // Check the text has the newline
+ assertEquals(text, richTextString.getString());
+
+ // Apply the font
+ richTextString.applyFont(0, 3, font1);
+ cell.setCellValue(richTextString);
+
+ // To enable newlines you need set a cell styles with wrap=true
+ CellStyle cs = wb.createCellStyle();
+ cs.setWrapText(true);
+ cell.setCellStyle(cs);
+
+ // Check the text has the
+ assertEquals(text, cell.getStringCellValue());
+
+ // Save the file and re-read it
+ wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+ sheet = wb.getSheetAt(0);
+ row = sheet.getRow(2);
+ cell = row.getCell(2);
+ assertEquals(text, cell.getStringCellValue());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org