aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.project2
-rw-r--r--src/ooxml/testcases/org/apache/poi/sl/TestTable.java54
-rw-r--r--src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java20
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/XSLFTestDataSamples.java22
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java10
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java15
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java4
7 files changed, 101 insertions, 26 deletions
diff --git a/.project b/.project
index 274051f30a..e6dc28da20 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>ApachePOI</name>
+ <name>ApachePOI-bug58365</name>
<comment></comment>
<projects>
</projects>
diff --git a/src/ooxml/testcases/org/apache/poi/sl/TestTable.java b/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
index d9a3717be8..2d123cb56a 100644
--- a/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
+++ b/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
@@ -22,43 +22,71 @@ package org.apache.poi.sl;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.poi.POIDataSamples;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.SlideShowFactory;
import org.apache.poi.sl.usermodel.TableShape;
+import org.apache.poi.xslf.XSLFTestDataSamples;
+import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.junit.Test;
public class TestTable {
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
+ /** a generic way to open a sample slideshow document **/
+ public static SlideShow<?,?> openSampleSlideshow(String sampleName) throws IOException {
+ InputStream is = _slTests.openResourceAsStream(sampleName);
+ try {
+ return SlideShowFactory.create(is);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ is.close();
+ }
+ }
+
@Test
public void testColWidthRowHeight() throws IOException {
// Test of table dimensions of same slideshow saved as ppt/x
// to check if both return similar (points) value
- SlideShow<?,?> ppt = SlideShowFactory.create(_slTests.getFile("table_test.ppt"));
+ SlideShow<?,?> ppt = openSampleSlideshow("table_test.ppt");
TableShape<?,?> ts = (TableShape<?,?>)ppt.getSlides().get(0).getShapes().get(0);
- int cols = ts.getNumberOfColumns();
- int rows = ts.getNumberOfRows();
- SlideShow<?,?> pptx = SlideShowFactory.create(_slTests.getFile("table_test.pptx"));
+ SlideShow<?,?> pptx = openSampleSlideshow("table_test.pptx");
TableShape<?,?> tsx = (TableShape<?,?>)pptx.getSlides().get(0).getShapes().get(0);
- int colsx = tsx.getNumberOfColumns();
- int rowsx = tsx.getNumberOfRows();
- assertEquals(cols, colsx);
- assertEquals(rows, rowsx);
+ // assume table shape should be equal to itself
+ confirmTableShapeEqual(ts, ts);
+ confirmTableShapeEqual(tsx, tsx);
+
+ // assert ppt and pptx versions of the same table have the same shape
+ confirmTableShapeEqual(ts, tsx);
+
+ pptx.close();
+ ppt.close();
+ }
+
+ private void confirmTableShapeEqual(TableShape<?,?> tableA, TableShape<?,?> tableB) {
+ int cols = tableA.getNumberOfColumns();
+ int rows = tableA.getNumberOfRows();
+
+ int colsx = tableB.getNumberOfColumns();
+ int rowsx = tableB.getNumberOfRows();
+
+ assertEquals("tables should have same number of columns", cols, colsx);
+ assertEquals("tables should have same number of rows", rows, rowsx);
for (int i=0; i<cols; i++) {
- assertEquals(ts.getColumnWidth(i), tsx.getColumnWidth(i), 0.2);
+ assertEquals("Width of column " + i + " should be equal",
+ tableA.getColumnWidth(i), tableB.getColumnWidth(i), 0.2);
}
for (int i=0; i<rows; i++) {
- assertEquals(ts.getRowHeight(i), tsx.getRowHeight(i), 0.3);
+ assertEquals("Height of row " + i + " should be equal",
+ tableA.getRowHeight(i), tableB.getRowHeight(i), 0.3);
}
-
- pptx.close();
- ppt.close();
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java b/src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java
index 7d681e4b05..dcde2382cd 100644
--- a/src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java
+++ b/src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java
@@ -23,8 +23,11 @@ import static org.junit.Assert.assertNotNull;
import java.awt.Dimension;
import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.io.InputStream;
import org.apache.poi.POIDataSamples;
+import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.sl.usermodel.PictureShape;
import org.apache.poi.sl.usermodel.RectAlign;
@@ -33,16 +36,31 @@ import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.SlideShowFactory;
import org.apache.poi.util.Units;
+import org.apache.poi.xslf.XSLFTestDataSamples;
+import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.junit.Test;
public class TestDrawPictureShape {
final static POIDataSamples ssSamples = POIDataSamples.getSlideShowInstance();
+
+ /** a generic way to open a sample slideshow document **/
+ public static SlideShow<?,?> openSampleDocument(String sampleName) throws IOException {
+ InputStream is = ssSamples.openResourceAsStream(sampleName);
+ try {
+ return SlideShowFactory.create(is);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ is.close();
+ }
+ }
@Test
public void testResize() throws Exception {
String files[] = { "pictures.ppt", "shapes.pptx" };
for (String file : files) {
- SlideShow<?,?> ss = SlideShowFactory.create(ssSamples.getFile(file));
+ SlideShow<?,?> ss = openSampleDocument(file);
+
Slide<?,?> slide = ss.getSlides().get(0);
PictureShape<?,?> picShape = null;
for (Shape<?,?> shape : slide.getShapes()) {
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/XSLFTestDataSamples.java b/src/ooxml/testcases/org/apache/poi/xslf/XSLFTestDataSamples.java
index b307144ff3..e106c4c8f8 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/XSLFTestDataSamples.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/XSLFTestDataSamples.java
@@ -22,30 +22,44 @@ import org.apache.poi.xslf.usermodel.XMLSlideShow;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
/**
* @author Yegor Kozlov
*/
public class XSLFTestDataSamples {
- public static XMLSlideShow openSampleDocument(String sampleName) {
+ public static XMLSlideShow openSampleDocument(String sampleName) throws IOException {
InputStream is = POIDataSamples.getSlideShowInstance().openResourceAsStream(sampleName);
try {
return new XMLSlideShow(OPCPackage.open(is));
} catch (Exception e) {
throw new RuntimeException(e);
+ } finally {
+ is.close();
}
}
- public static XMLSlideShow writeOutAndReadBack(XMLSlideShow doc) {
+ public static XMLSlideShow writeOutAndReadBack(XMLSlideShow doc) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
doc.write(baos);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ InputStream bais;
+ bais = new ByteArrayInputStream(baos.toByteArray());
+ try {
return new XMLSlideShow(OPCPackage.open(bais));
} catch (Exception e) {
throw new RuntimeException(e);
+ } finally {
+ baos.close();
+ bais.close();
}
+
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
index b919eab011..8a2f3c6cc3 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java
@@ -19,9 +19,11 @@ package org.apache.poi.xslf.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import java.io.IOException;
import java.net.URI;
import java.util.List;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.xslf.XSLFTestDataSamples;
@@ -33,7 +35,7 @@ import org.junit.Test;
public class TestXSLFHyperlink {
@Test
- public void testRead(){
+ public void testRead() throws IOException{
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("shapes.pptx");
XSLFSlide slide = ppt.getSlides().get(4);
@@ -56,10 +58,12 @@ public class TestXSLFHyperlink {
XSLFHyperlink link3 = cell3.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
assertNotNull(link3);
assertEquals(URI.create("mailto:dev@poi.apache.org?subject=Hi%20There"), link3.getTargetURI());
+
+ ppt.close();
}
@Test
- public void testCreate() throws Exception {
+ public void testCreate() throws IOException, InvalidFormatException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide1 = ppt.createSlide();
XSLFSlide slide2 = ppt.createSlide();
@@ -97,5 +101,7 @@ public class TestXSLFHyperlink {
assertEquals(id2, rel2.getId());
assertEquals(TargetMode.INTERNAL, rel2.getTargetMode());
assertEquals(XSLFRelation.SLIDE.getRelation(), rel2.getRelationshipType());
+
+ ppt.close();
}
} \ No newline at end of file
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java
index 3983d0b392..fa56117893 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java
@@ -22,6 +22,7 @@ import org.apache.poi.xslf.XSLFTestDataSamples;
import org.junit.Test;
import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
+import java.io.IOException;
import java.util.List;
/**
@@ -30,7 +31,7 @@ import java.util.List;
public class TestXSLFShape {
@Test
- public void testReadTextShapes() {
+ public void testReadTextShapes() throws IOException {
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("shapes.pptx");
List<XSLFSlide> slides = ppt.getSlides();
@@ -79,9 +80,12 @@ public class TestXSLFShape {
assertEquals("Subtitle", paragraphs2.get(0).getTextRuns().get(0).getRawText());
assertTrue(paragraphs2.get(0).getTextRuns().get(0).getXmlObject().getRPr().getB());
assertEquals("And second line", paragraphs2.get(1).getTextRuns().get(0).getRawText());
+
+ ppt.close();
}
- public void testCreateShapes() {
+ @Test
+ public void testCreateShapes() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
assertTrue(slide.getShapes().isEmpty());
@@ -92,11 +96,14 @@ public class TestXSLFShape {
assertSame(textBox, slide.getShapes().get(0));
assertEquals("", textBox.getText());
- assertEquals(0, textBox.getTextParagraphs().size());
+ // FIXME: is this correct? Should it be starting out with 0 or 1 text paragraphs?
+ assertEquals(1, textBox.getTextParagraphs().size());
textBox.addNewTextParagraph().addNewTextRun().setText("Apache");
textBox.addNewTextParagraph().addNewTextRun().setText("POI");
assertEquals("Apache\nPOI", textBox.getText());
- assertEquals(2, textBox.getTextParagraphs().size());
+ assertEquals(3, textBox.getTextParagraphs().size());
+
+ ppt.close();
}
} \ No newline at end of file
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
index 691d9941ad..fad3f82a00 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java
@@ -36,7 +36,7 @@ import org.junit.Test;
public class TestXSLFSlide {
@Test
- public void testReadShapes(){
+ public void testReadShapes() throws IOException {
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("shapes.pptx");
List<XSLFSlide> slides = ppt.getSlides();
@@ -101,6 +101,8 @@ public class TestXSLFSlide {
XSLFTable tbl = (XSLFTable)shapes4.get(0);
assertEquals(3, tbl.getNumberOfColumns());
assertEquals(6, tbl.getNumberOfRows());
+
+ ppt.close();
}
@Test
ckport/48632/stable30'>backport/48632/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/settings/l10n/en_GB.js
blob: 74c11b72fbd2ef596c804d68b2cc761982b3c7e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270