From dce1a83169922a0e8ff92a86542fa9cfbc4d3e2f Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sun, 11 May 2025 16:02:06 +0000 Subject: [PATCH] extend test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925505 13f79535-47bb-0310-9956-ffa450edef68 --- .../xssf/usermodel/XSSFRichTextString.java | 2 +- .../xssf/usermodel/TestXSSFTextParagraph.java | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java index fe3e27b10d..d1fdf6b4b6 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java @@ -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. */ diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java index 8244ca2d91..17daaf102c 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java @@ -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 paras = shape.getTextParagraphs(); + assertEquals(1, paras.size()); + + XSSFTextParagraph text = paras.get(0); + assertEquals("Test String", text.getText()); + + List 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()); + } + } }