Line 0
Link Here
|
|
|
1 |
/* |
2 |
* ==================================================================== |
3 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
4 |
* contributor license agreements. See the NOTICE file distributed with |
5 |
* this work for additional information regarding copyright ownership. |
6 |
* The ASF licenses this file to You under the Apache License, Version 2.0 |
7 |
* (the "License"); you may not use this file except in compliance with |
8 |
* the License. You may obtain a copy of the License at |
9 |
* |
10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
11 |
* |
12 |
* Unless required by applicable law or agreed to in writing, software |
13 |
* distributed under the License is distributed on an "AS IS" BASIS, |
14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 |
* See the License for the specific language governing permissions and |
16 |
* limitations under the License. |
17 |
* ==================================================================== |
18 |
*/ |
19 |
|
20 |
package org.apache.poi.hslf.usermodel; |
21 |
|
22 |
import junit.framework.TestCase; |
23 |
|
24 |
import org.apache.poi.hslf.model.Shape; |
25 |
import org.apache.poi.hslf.model.Slide; |
26 |
import org.apache.poi.hslf.model.Table; |
27 |
import org.apache.poi.hslf.model.TextRun; |
28 |
import org.apache.poi.POIDataSamples; |
29 |
|
30 |
|
31 |
/** |
32 |
* Test that checks numbered list functionality. |
33 |
* |
34 |
* @author Alex Nikiforov [mailto:anikif@gmail.com] |
35 |
*/ |
36 |
public final class TestTable extends TestCase { |
37 |
private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); |
38 |
|
39 |
protected void setUp() throws Exception { |
40 |
} |
41 |
|
42 |
public void testTable() throws Exception { |
43 |
SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("table_test.ppt")); |
44 |
assertTrue("No Exceptions while reading file", true); |
45 |
|
46 |
final Slide[] slides = ppt.getSlides(); |
47 |
assertEquals(1, slides.length); |
48 |
checkSlide(slides[0]); |
49 |
} |
50 |
private void checkSlide(final Slide s) { |
51 |
TextRun[] textRuns = s.getTextRuns(); |
52 |
assertEquals(2, textRuns.length); |
53 |
|
54 |
RichTextRun textRun = textRuns[0].getRichTextRuns()[0]; |
55 |
assertEquals("Table sample", textRun.getRawText().trim()); |
56 |
assertEquals(1, textRuns[0].getRichTextRuns().length); |
57 |
assertFalse(textRun.isBullet()); |
58 |
|
59 |
assertEquals("Dummy text", textRuns[1].getRawText()); |
60 |
|
61 |
final Shape[] shapes = s.getShapes(); |
62 |
assertNotNull(shapes); |
63 |
assertEquals(3, shapes.length); |
64 |
assertTrue(shapes[2] instanceof Table); |
65 |
final Table table = (Table) shapes[2]; |
66 |
assertEquals(4, table.getNumberOfColumns()); |
67 |
assertEquals(6, table.getNumberOfRows()); |
68 |
for (int x = 0; x < 4; x ++) { |
69 |
assertEquals("TH Cell " + (x + 1), table.getCell(0, x).getTextRun().getRawText()); |
70 |
for (int y = 1; y < 6; y++) { |
71 |
assertEquals("Row " + y + ", Cell " + (x + 1), table.getCell(y, x).getText()); |
72 |
} |
73 |
} |
74 |
} |
75 |
} |