]> source.dussan.org Git - poi.git/commitdiff
[bug-68703] fix issue with XSLFTextRuns in XSLFTableCells
authorPJ Fanning <fanningpj@apache.org>
Mon, 4 Mar 2024 12:49:02 +0000 (12:49 +0000)
committerPJ Fanning <fanningpj@apache.org>
Mon, 4 Mar 2024 12:49:02 +0000 (12:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1916105 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
poi-ooxml/src/test/java/org/apache/poi/xslf/usermodel/TestXSLFTableCell.java
test-data/slideshow/bug68703.pptx [new file with mode: 0644]

index 60b648244b2e4bf300d6e3d0eb65a7c12c31611d..d8bcd25f1de0902b687f28f2b98c8fed1a840849 100644 (file)
@@ -75,7 +75,7 @@ public class XSLFTextParagraph implements TextParagraph<XSLFShape,XSLFTextParagr
                     if (r instanceof CTTextLineBreak) {
                         _runs.add(new XSLFLineBreak((CTTextLineBreak)r, this));
                     } else if (r instanceof CTRegularTextRun || r instanceof CTTextField) {
-                        _runs.add(this.newTextRun(r));
+                        _runs.add(new XSLFTextRun(r, this));
                     }
                 } while (c.toNextSibling());
             }
index f7df4ed611361d4895c87a31a1a67a8b180d92a6..87bb0ce6a272c34cd74ac99b1e3a4661f8e833e5 100644 (file)
@@ -228,4 +228,19 @@ class TestXSLFTableCell
         ppt.close();
     }
 
+    @Test
+    void testBug68703() throws IOException {
+        try(XMLSlideShow pptx = XSLFTestDataSamples.openSampleDocument("bug68703.pptx")) {
+            XSLFSlide firstSlide = pptx.getSlides().get(0);
+            XSLFTable table = (XSLFTable) firstSlide.getShapes().get(0);
+            XSLFTableCell cell = table.getCell(0, 0);
+            List<XSLFTextParagraph> cellParagraphs = cell.getTextParagraphs();
+            List<XSLFTextRun> cellTextRuns = cellParagraphs.get(0).getTextRuns();
+            PaintStyle fontColor = cellTextRuns.get(0).getFontColor();
+            assertNotNull(fontColor);
+            assertTrue(fontColor instanceof PaintStyle.SolidPaint);
+            assertEquals(Color.black, ((PaintStyle.SolidPaint) fontColor).getSolidColor().getColor());
+        }
+    }
+
 }
diff --git a/test-data/slideshow/bug68703.pptx b/test-data/slideshow/bug68703.pptx
new file mode 100644 (file)
index 0000000..ac62bce
Binary files /dev/null and b/test-data/slideshow/bug68703.pptx differ