extend test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925505 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-05-11 16:02:06 +00:00
parent ebd9a8bc9a
commit dce1a83169
2 changed files with 30 additions and 2 deletions

View File

@ -390,7 +390,7 @@ public class XSSFRichTextString implements RichTextString {
* Return a copy of the font in use at a particular index.
*
* @param index The index.
* @return A copy of the font that's currently being applied at that
* @return A copy of the font that's currently being applied at that
* index or null if no font is being applied or the
* index is out of range.
*/

View File

@ -90,7 +90,7 @@ class TestXSSFTextParagraph {
text.setBulletFontColor(color);
assertEquals(color, text.getBulletFontColor());
final byte[] colorBytes = new byte[] { (byte) 255, 127, 0 };
final byte[] colorBytes = new byte[]{(byte) 255, 127, 0};
text.setBulletFontColor(colorBytes);
assertArrayEquals(colorBytes, text.getBulletFontColorAsBytes());
@ -196,4 +196,32 @@ class TestXSSFTextParagraph {
new XSSFTextParagraph(text.getXmlObject(), shape.getCTShape());
}
}
@Test
void testXSSFTextParagraph2() throws IOException {
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet = wb.createSheet();
XSSFDrawing drawing = sheet.createDrawingPatriarch();
XSSFTextBox shape = drawing.createTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4));
XSSFTextRun run = shape.getTextParagraphs().get(0).getTextRuns().get(0);
final byte[] colorBytes = new byte[]{0, (byte) 255, (byte) 255};
run.setFont("Arial");
run.setFontColor(colorBytes);
run.setText("Test String");
List<XSSFTextParagraph> paras = shape.getTextParagraphs();
assertEquals(1, paras.size());
XSSFTextParagraph text = paras.get(0);
assertEquals("Test String", text.getText());
List<XSSFTextRun> runs = text.getTextRuns();
assertEquals(1, runs.size());
XSSFTextRun run2 = runs.get(0);
assertEquals(run.getText(), run2.getText());
assertEquals(run.getFontFamily(), run2.getFontFamily());
assertArrayEquals(run.getFontColorAsBytes(), run2.getFontColorAsBytes());
}
}
}