diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java index 019679f9bf..c43483912a 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java @@ -438,7 +438,8 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell shapes = ppt.getSlides().get(0).getShapes(); + assertEquals(1, shapes.size()); + assertTrue(shapes.get(0) instanceof XSLFTable); + XSLFTable tbl = (XSLFTable)shapes.get(0); + assertEquals(4, tbl.getNumberOfColumns()); + assertEquals(4, tbl.getNumberOfRows()); + assertNotNull(tbl.getCTTable()); + + // Yellow font color due to "first row" table style + verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(0), "Text 1", + new Color(255, 255, 0), new Color(21, 96, 130)); + // Dark green font color due to direct format + verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(2), "Text 3", + new Color(0, 176, 80), new Color(21, 96, 130)); + // Grey font color due to "even row" table style + fallback + verifyTableCellStyleColors(tbl.getRows().get(1).getCells().get(0), "Text 5", + new Color(119, 119, 119), new Color(204, 210, 216)); + // Light blue font color due to "odd row" table style + verifyTableCellStyleColors(tbl.getRows().get(2).getCells().get(0), "Text 9", + new Color(0, 255, 255), new Color(231, 234, 237)); + // Red font color due to direct format + verifyTableCellStyleColors(tbl.getRows().get(2).getCells().get(2), "Text 11", + new Color(255, 0, 0), new Color(231, 234, 237)); + // Blue font color due to "last row" table style + verifyTableCellStyleColors(tbl.getRows().get(3).getCells().get(0), "Text 13", + new Color(0, 0, 255), new Color(21, 96, 130)); + + // Second slide: test column-related table styles + + shapes = ppt.getSlides().get(1).getShapes(); + assertEquals(1, shapes.size()); + assertTrue(shapes.get(0) instanceof XSLFTable); + tbl = (XSLFTable)shapes.get(0); + assertEquals(4, tbl.getNumberOfColumns()); + assertEquals(4, tbl.getNumberOfRows()); + assertNotNull(tbl.getCTTable()); + + // Green font color due to "first column" table style + verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(0), "Text 1", + new Color(0, 255, 0), new Color(21, 96, 130)); + // Grey font color due to "even column" table style + fallback + verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(1), "Text 2", + new Color(119, 119, 119), new Color(204, 210, 216)); + // Light blue font color due to "odd column" table style + verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(2), "Text 3", + new Color(0, 255, 255), new Color(231, 234, 237)); + // Red font color due to "last column" table style + verifyTableCellStyleColors(tbl.getRows().get(0).getCells().get(3), "Text 4", + new Color(255, 0, 0), new Color(21, 96, 130)); + + ppt.close(); + } +} diff --git a/test-data/slideshow/table-with-different-font-colors.pptx b/test-data/slideshow/table-with-different-font-colors.pptx new file mode 100644 index 0000000000..6272f055eb Binary files /dev/null and b/test-data/slideshow/table-with-different-font-colors.pptx differ