Inspired by bug #44958 - Record level support for Data Tables. (No formula parser...
[poi.git] / src / scratchpad / testcases / org / apache / poi / hwpf / HWPFDocFixture.java
blob1a71d1c2998e463604c7fa64a64d4fccc4337c6a
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================== */
19 package org.apache.poi.hwpf;
21 import java.io.FileInputStream;
23 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
24 import org.apache.poi.poifs.filesystem.DocumentEntry;
26 import org.apache.poi.hwpf.model.*;
27 import java.io.File;
30 public class HWPFDocFixture
32 public byte[] _tableStream;
33 public byte[] _mainStream;
34 public FileInformationBlock _fib;
36 public HWPFDocFixture(Object obj)
41 public void setUp()
43 try
45 String filename = System.getProperty("HWPF.testdata.path");
46 if (filename == null)
48 filename = "c:";
51 filename = filename + "/test.doc";
54 POIFSFileSystem filesystem = new POIFSFileSystem(new FileInputStream(
55 new File(filename)));
57 DocumentEntry documentProps =
58 (DocumentEntry) filesystem.getRoot().getEntry("WordDocument");
59 _mainStream = new byte[documentProps.getSize()];
60 filesystem.createDocumentInputStream("WordDocument").read(_mainStream);
62 // use the fib to determine the name of the table stream.
63 _fib = new FileInformationBlock(_mainStream);
65 String name = "0Table";
66 if (_fib.isFWhichTblStm())
68 name = "1Table";
71 // read in the table stream.
72 DocumentEntry tableProps =
73 (DocumentEntry) filesystem.getRoot().getEntry(name);
74 _tableStream = new byte[tableProps.getSize()];
75 filesystem.createDocumentInputStream(name).read(_tableStream);
77 _fib.fillVariableFields(_mainStream, _tableStream);
79 catch (Throwable t)
81 t.printStackTrace();
85 public void tearDown()