01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.poi.hwpf.usermodel;
18:
19: import java.io.ByteArrayOutputStream;
20: import java.io.FileInputStream;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: import org.apache.poi.hwpf.HWPFDocument;
25: import org.apache.poi.hwpf.model.StyleSheet;
26: import org.apache.poi.hwpf.model.TextPiece;
27: import org.apache.poi.hwpf.usermodel.Paragraph;
28: import org.apache.poi.hwpf.usermodel.Range;
29: import org.apache.poi.util.LittleEndian;
30:
31: import junit.framework.TestCase;
32:
33: /**
34: * Test various problem documents
35: *
36: * @author Nick Burch (nick at torchbox dot com)
37: */
38: public class TestProblems extends TestCase {
39: private String dirname = System.getProperty("HWPF.testdata.path");
40:
41: protected void setUp() throws Exception {
42: }
43:
44: /**
45: * ListEntry passed no ListTable
46: */
47: public void testListEntryNoListTable() throws Exception {
48: HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname
49: + "/ListEntryNoListTable.doc"));
50:
51: Range r = doc.getRange();
52: StyleSheet styleSheet = doc.getStyleSheet();
53: for (int x = 0; x < r.numSections(); x++) {
54: Section s = r.getSection(x);
55: for (int y = 0; y < s.numParagraphs(); y++) {
56: Paragraph paragraph = s.getParagraph(y);
57: //System.out.println(paragraph.getCharacterRun(0).text());
58: }
59: }
60: }
61:
62: /**
63: * AIOOB for TableSprmUncompressor.unCompressTAPOperation
64: */
65: public void testSprmAIOOB() throws Exception {
66: HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname
67: + "/AIOOB-Tap.doc"));
68:
69: Range r = doc.getRange();
70: StyleSheet styleSheet = doc.getStyleSheet();
71: for (int x = 0; x < r.numSections(); x++) {
72: Section s = r.getSection(x);
73: for (int y = 0; y < s.numParagraphs(); y++) {
74: Paragraph paragraph = s.getParagraph(y);
75: //System.out.println(paragraph.getCharacterRun(0).text());
76: }
77: }
78: }
79: }
|