aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-01-19 20:27:00 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-01-19 20:27:00 +0000
commit5de42f466f6aed8c61c7743186d18ee128e18823 (patch)
treef0e0a150f4027dcbbfd2175eebcb08406a8dcd86 /src/ooxml/testcases/org/apache/poi
parentc67b26c138f93ac03f90d52e5c71eaa72e366fec (diff)
downloadpoi-5de42f466f6aed8c61c7743186d18ee128e18823.tar.gz
poi-5de42f466f6aed8c61c7743186d18ee128e18823.zip
github-211 - Revert addRow to behaviour before 4.1.2
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
index cbbe738406..c36035244c 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
@@ -27,18 +27,22 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
+import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Random;
+import org.apache.poi.sl.draw.DrawTableShape;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.StrokeStyle;
import org.apache.poi.sl.usermodel.TableCell.BorderEdge;
+import org.apache.poi.sl.usermodel.TextParagraph;
import org.apache.poi.sl.usermodel.VerticalAlignment;
import org.apache.poi.util.TempFile;
import org.apache.poi.xslf.XSLFTestDataSamples;
@@ -94,7 +98,7 @@ class TestXSLFTable {
while (rowIdx<data.length) {
row = tab.addRow();
for (int col=0; col<data[rowIdx].length; col++) {
- XSLFTextRun tr = tab.getCell(rowIdx, col).setText(data[rowIdx][col]);
+ XSLFTextRun tr = row.addCell().setText(data[rowIdx][col]);
tr.setFontSize(15.);
tr.setFontFamily("Arial");
}
@@ -102,8 +106,7 @@ class TestXSLFTable {
for (int col=0; col<data[rowIdx].length; col++) {
XSLFTextRun tr = tab
.getCell(rowIdx, col)
- .setText(
- data[rowIdx][col]);
+ .setText(data[rowIdx][col]);
tr.setFontSize(12.);
tr.setFontFamily("Arial");
}
@@ -333,4 +336,31 @@ class TestXSLFTable {
}
}
}
+
+ @Test
+ void simpleMerge() throws IOException {
+ // github-221
+ try (XMLSlideShow slideshow = new XMLSlideShow()) {
+ XSLFSlide slide = slideshow.createSlide();
+ XSLFTable newTable = slide.createTable(3, 3);
+ newTable.setAnchor(new Rectangle(100, 100, 100, 100));
+
+ XSLFTableRow tableRow = newTable.addRow();
+ assertEquals(0, tableRow.getCells().size());
+ XSLFTableCell cell = tableRow.addCell();
+ XSLFTextParagraph textparagraph = cell.addNewTextParagraph();
+ XSLFTextRun textrun = textparagraph.addNewTextRun();
+ textrun.setText("Any Text");
+ textrun.setFontColor(Color.BLUE);
+ textparagraph.setTextAlign(TextParagraph.TextAlign.CENTER);
+ tableRow.addCell();
+ tableRow.addCell();
+ tableRow.mergeCells(0, 1);
+
+ new DrawTableShape(newTable).setAllBorders(3., StrokeStyle.LineDash.LG_DASH_DOT, Color.BLUE);
+
+ assertEquals(3, newTable.getCTTable().getTblGrid().sizeOfGridColArray());
+ }
+ }
+
} \ No newline at end of file