Renamed model.Workbook to InternalWorkbook to alleviate name clash.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893050 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-12-22 00:51:29 +00:00
parent 66d86cb8da
commit 1fd52310cd
22 changed files with 267 additions and 299 deletions

View File

@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.BoundSheetRecord; import org.apache.poi.hssf.record.BoundSheetRecord;
import org.apache.poi.hssf.record.EOFRecord; import org.apache.poi.hssf.record.EOFRecord;
import org.apache.poi.hssf.record.ExternSheetRecord; import org.apache.poi.hssf.record.ExternSheetRecord;
@ -32,15 +32,15 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/** /**
* When working with the EventUserModel, if you want to * When working with the EventUserModel, if you want to
* process formulas, you need an instance of * process formulas, you need an instance of
* {@link Workbook} to pass to a {@link HSSFWorkbook}, * {@link InternalWorkbook} to pass to a {@link HSSFWorkbook},
* to finally give to {@link HSSFFormulaParser}, * to finally give to {@link HSSFFormulaParser},
* and this will build you stub ones. * and this will build you stub ones.
* Since you're working with the EventUserModel, you * Since you're working with the EventUserModel, you
* wouldn't want to get a full {@link Workbook} and * wouldn't want to get a full {@link InternalWorkbook} and
* {@link HSSFWorkbook}, as they would eat too much memory. * {@link HSSFWorkbook}, as they would eat too much memory.
* Instead, you should collect a few key records as they * Instead, you should collect a few key records as they
* go past, then call this once you have them to build a * go past, then call this once you have them to build a
* stub {@link Workbook}, and from that a stub * stub {@link InternalWorkbook}, and from that a stub
* {@link HSSFWorkbook}, to use with the {@link HSSFFormulaParser}. * {@link HSSFWorkbook}, to use with the {@link HSSFFormulaParser}.
* *
* The records you should collect are: * The records you should collect are:
@ -53,15 +53,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
* that will do the collecting for you. * that will do the collecting for you.
*/ */
public class EventWorkbookBuilder { public class EventWorkbookBuilder {
/**
* Wraps up your stub {@link Workbook} as a stub
* {@link HSSFWorkbook}, ready for passing to
* {@link HSSFFormulaParser}
* @param workbook A stub {@link Workbook}
*/
public static HSSFWorkbook createStubHSSFWorkbook(Workbook workbook) {
return new StubHSSFWorkbook(workbook);
}
/** /**
* Creates a stub Workbook from the supplied records, * Creates a stub Workbook from the supplied records,
@ -71,7 +63,7 @@ public class EventWorkbookBuilder {
* @param sst The SSTRecord in your file. * @param sst The SSTRecord in your file.
* @return A stub Workbook suitable for use with {@link HSSFFormulaParser} * @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
*/ */
public static Workbook createStubWorkbook(ExternSheetRecord[] externs, public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs,
BoundSheetRecord[] bounds, SSTRecord sst) { BoundSheetRecord[] bounds, SSTRecord sst) {
List wbRecords = new ArrayList(); List wbRecords = new ArrayList();
@ -98,7 +90,7 @@ public class EventWorkbookBuilder {
// Finally we need an EoF record // Finally we need an EoF record
wbRecords.add(EOFRecord.instance); wbRecords.add(EOFRecord.instance);
return Workbook.createWorkbook(wbRecords); return InternalWorkbook.createWorkbook(wbRecords);
} }
/** /**
@ -108,7 +100,7 @@ public class EventWorkbookBuilder {
* @param bounds The BoundSheetRecords in your file * @param bounds The BoundSheetRecords in your file
* @return A stub Workbook suitable for use with {@link HSSFFormulaParser} * @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
*/ */
public static Workbook createStubWorkbook(ExternSheetRecord[] externs, public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs,
BoundSheetRecord[] bounds) { BoundSheetRecord[] bounds) {
return createStubWorkbook(externs, bounds, null); return createStubWorkbook(externs, bounds, null);
} }
@ -117,7 +109,7 @@ public class EventWorkbookBuilder {
/** /**
* A wrapping HSSFListener which will collect * A wrapping HSSFListener which will collect
* {@link BoundSheetRecord}s and {@link ExternSheetRecord}s as * {@link BoundSheetRecord}s and {@link ExternSheetRecord}s as
* they go past, so you can create a Stub {@link Workbook} from * they go past, so you can create a Stub {@link InternalWorkbook} from
* them once required. * them once required.
*/ */
public static class SheetRecordCollectingListener implements HSSFListener { public static class SheetRecordCollectingListener implements HSSFListener {
@ -146,11 +138,9 @@ public class EventWorkbookBuilder {
} }
public HSSFWorkbook getStubHSSFWorkbook() { public HSSFWorkbook getStubHSSFWorkbook() {
return createStubHSSFWorkbook( return HSSFWorkbook.create(getStubWorkbook());
getStubWorkbook()
);
} }
public Workbook getStubWorkbook() { public InternalWorkbook getStubWorkbook() {
return createStubWorkbook( return createStubWorkbook(
getExternSheetRecords(), getBoundSheetRecords(), getExternSheetRecords(), getBoundSheetRecords(),
getSSTRecord() getSSTRecord()
@ -186,14 +176,4 @@ public class EventWorkbookBuilder {
} }
} }
} }
/**
* Let us at the {@link Workbook} constructor on
* {@link HSSFWorkbook}
*/
private static class StubHSSFWorkbook extends HSSFWorkbook {
private StubHSSFWorkbook(Workbook wb) {
super(wb);
}
}
} }

View File

@ -82,6 +82,7 @@ import org.apache.poi.hssf.record.formula.FormulaShifter;
import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet; import org.apache.poi.ss.formula.EvaluationWorkbook.ExternalSheet;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
@ -108,7 +109,8 @@ import org.apache.poi.util.POILogger;
* @author Glen Stampoultzis (glens at apache.org) * @author Glen Stampoultzis (glens at apache.org)
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook * @see org.apache.poi.hssf.usermodel.HSSFWorkbook
*/ */
public final class Workbook { @Internal
public final class InternalWorkbook {
/** /**
* Excel silently truncates long sheet names to 31 chars. * Excel silently truncates long sheet names to 31 chars.
* This constant is used to ensure uniqueness in the first 31 chars * This constant is used to ensure uniqueness in the first 31 chars
@ -116,7 +118,7 @@ public final class Workbook {
private static final int MAX_SENSITIVE_SHEET_NAME_LEN = 31; private static final int MAX_SENSITIVE_SHEET_NAME_LEN = 31;
private static final POILogger log = POILogFactory.getLogger(Workbook.class); private static final POILogger log = POILogFactory.getLogger(InternalWorkbook.class);
private static final int DEBUG = POILogger.DEBUG; private static final int DEBUG = POILogger.DEBUG;
/** /**
@ -162,7 +164,7 @@ public final class Workbook {
private WriteAccessRecord writeAccess; private WriteAccessRecord writeAccess;
private WriteProtectRecord writeProtect; private WriteProtectRecord writeProtect;
private Workbook() { private InternalWorkbook() {
records = new WorkbookRecordList(); records = new WorkbookRecordList();
boundsheets = new ArrayList<BoundSheetRecord>(); boundsheets = new ArrayList<BoundSheetRecord>();
@ -187,11 +189,11 @@ public final class Workbook {
* @param recs an array of Record objects * @param recs an array of Record objects
* @return Workbook object * @return Workbook object
*/ */
public static Workbook createWorkbook(List<Record> recs) { public static InternalWorkbook createWorkbook(List<Record> recs) {
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "Workbook (readfile) created with reclen=", log.log(DEBUG, "Workbook (readfile) created with reclen=",
Integer.valueOf(recs.size())); Integer.valueOf(recs.size()));
Workbook retval = new Workbook(); InternalWorkbook retval = new InternalWorkbook();
List<Record> records = new ArrayList<Record>(recs.size() / 3); List<Record> records = new ArrayList<Record>(recs.size() / 3);
retval.records.setRecords(records); retval.records.setRecords(records);
@ -329,11 +331,11 @@ public final class Workbook {
* Creates an empty workbook object with three blank sheets and all the empty * Creates an empty workbook object with three blank sheets and all the empty
* fields. Use this to create a workbook from scratch. * fields. Use this to create a workbook from scratch.
*/ */
public static Workbook createWorkbook() public static InternalWorkbook createWorkbook()
{ {
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log( DEBUG, "creating new workbook from scratch" ); log.log( DEBUG, "creating new workbook from scratch" );
Workbook retval = new Workbook(); InternalWorkbook retval = new InternalWorkbook();
List<Record> records = new ArrayList<Record>( 30 ); List<Record> records = new ArrayList<Record>( 30 );
retval.records.setRecords(records); retval.records.setRecords(records);
List<FormatRecord> formats = retval.formats; List<FormatRecord> formats = retval.formats;

View File

@ -91,7 +91,7 @@ import org.apache.poi.util.POILogger;
* @author Brian Sanders (kestrel at burdell dot org) Active Cell support * @author Brian Sanders (kestrel at burdell dot org) Active Cell support
* @author Jean-Pierre Paris (jean-pierre.paris at m4x dot org) (Just a little) * @author Jean-Pierre Paris (jean-pierre.paris at m4x dot org) (Just a little)
* *
* @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.usermodel.HSSFSheet * @see org.apache.poi.hssf.usermodel.HSSFSheet
*/ */
public final class Sheet { public final class Sheet {
@ -151,7 +151,7 @@ public final class Sheet {
* *
* @return Sheet object with all values set to those read from the file * @return Sheet object with all values set to those read from the file
* *
* @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.record.Record * @see org.apache.poi.hssf.record.Record
*/ */
public static Sheet createSheet(RecordStream rs) { public static Sheet createSheet(RecordStream rs) {

View File

@ -58,7 +58,7 @@ public final class FormatRecord extends StandardRecord {
* get the format index code (for built in formats) * get the format index code (for built in formats)
* *
* @return the format index code * @return the format index code
* @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.model.InternalWorkbook
*/ */
public int getIndexCode() { public int getIndexCode() {
return field_1_index_code; return field_1_index_code;

View File

@ -35,34 +35,31 @@ public final class PaletteRecord extends StandardRecord {
/** The byte index of the first color */ /** The byte index of the first color */
public final static short FIRST_COLOR_INDEX = (short) 0x8; public final static short FIRST_COLOR_INDEX = (short) 0x8;
private List<PColor> field_2_colors; private final List<PColor> _colors;
public PaletteRecord() public PaletteRecord() {
{
PColor[] defaultPalette = createDefaultPalette(); PColor[] defaultPalette = createDefaultPalette();
field_2_colors = new ArrayList<PColor>(defaultPalette.length); _colors = new ArrayList<PColor>(defaultPalette.length);
for (int i = 0; i < defaultPalette.length; i++) { for (int i = 0; i < defaultPalette.length; i++) {
field_2_colors.add(defaultPalette[i]); _colors.add(defaultPalette[i]);
} }
} }
public PaletteRecord(RecordInputStream in) public PaletteRecord(RecordInputStream in) {
{
int field_1_numcolors = in.readShort(); int field_1_numcolors = in.readShort();
field_2_colors = new ArrayList<PColor>(field_1_numcolors); _colors = new ArrayList<PColor>(field_1_numcolors);
for (int k = 0; k < field_1_numcolors; k++) { for (int k = 0; k < field_1_numcolors; k++) {
field_2_colors.add(new PColor(in)); _colors.add(new PColor(in));
} }
} }
public String toString() public String toString() {
{
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append("[PALETTE]\n"); buffer.append("[PALETTE]\n");
buffer.append(" numcolors = ").append(field_2_colors.size()).append('\n'); buffer.append(" numcolors = ").append(_colors.size()).append('\n');
for (int i = 0; i < field_2_colors.size(); i++) { for (int i = 0; i < _colors.size(); i++) {
PColor c = field_2_colors.get(i); PColor c = _colors.get(i);
buffer.append("* colornum = ").append(i).append('\n'); buffer.append("* colornum = ").append(i).append('\n');
buffer.append(c.toString()); buffer.append(c.toString());
buffer.append("/*colornum = ").append(i).append('\n'); buffer.append("/*colornum = ").append(i).append('\n');
@ -71,20 +68,18 @@ public final class PaletteRecord extends StandardRecord {
return buffer.toString(); return buffer.toString();
} }
public void serialize(LittleEndianOutput out) public void serialize(LittleEndianOutput out) {
{ out.writeShort(_colors.size());
out.writeShort(field_2_colors.size()); for (int i = 0; i < _colors.size(); i++) {
for (int i = 0; i < field_2_colors.size(); i++) { _colors.get(i).serialize(out);
field_2_colors.get(i).serialize(out);
} }
} }
protected int getDataSize() { protected int getDataSize() {
return 2 + field_2_colors.size() * PColor.ENCODED_SIZE; return 2 + _colors.size() * PColor.ENCODED_SIZE;
} }
public short getSid() public short getSid() {
{
return sid; return sid;
} }
@ -94,14 +89,12 @@ public final class PaletteRecord extends StandardRecord {
* @return the RGB triplet for the color, or <code>null</code> if the specified index * @return the RGB triplet for the color, or <code>null</code> if the specified index
* does not exist * does not exist
*/ */
public byte[] getColor(short byteIndex) { public byte[] getColor(int byteIndex) {
int i = byteIndex - FIRST_COLOR_INDEX; int i = byteIndex - FIRST_COLOR_INDEX;
if (i < 0 || i >= field_2_colors.size()) if (i < 0 || i >= _colors.size()) {
{
return null; return null;
} }
PColor color = field_2_colors.get(i); return _colors.get(i).getTriplet();
return new byte[] { color.red, color.green, color.blue };
} }
/** /**
@ -120,18 +113,16 @@ public final class PaletteRecord extends StandardRecord {
{ {
return; return;
} }
// may need to grow - fill intervening pallette entries with black // may need to grow - fill intervening palette entries with black
while (field_2_colors.size() <= i) { while (_colors.size() <= i) {
field_2_colors.add(new PColor(0, 0, 0)); _colors.add(new PColor(0, 0, 0));
} }
PColor custColor = new PColor(red, green, blue); PColor custColor = new PColor(red, green, blue);
field_2_colors.set(i, custColor); _colors.set(i, custColor);
} }
/** /**
* Creates the default palette as PaletteRecord binary data * Creates the default palette as PaletteRecord binary data
*
* @see org.apache.poi.hssf.model.Workbook#createPalette
*/ */
private static PColor[] createDefaultPalette() private static PColor[] createDefaultPalette()
{ {
@ -200,39 +191,43 @@ public final class PaletteRecord extends StandardRecord {
} }
/** /**
* PColor - element in the list of colors - consider it a "struct" * PColor - element in the list of colors
*/ */
private static final class PColor { private static final class PColor {
public static final short ENCODED_SIZE = 4; public static final short ENCODED_SIZE = 4;
public byte red; private int _red;
public byte green; private int _green;
public byte blue; private int _blue;
public PColor(int red, int green, int blue) { public PColor(int red, int green, int blue) {
this.red=(byte) red; _red = red;
this.green=(byte) green; _green = green;
this.blue=(byte) blue; _blue = blue;
}
public byte[] getTriplet() {
return new byte[] { (byte) _red, (byte) _green, (byte) _blue };
} }
public PColor(RecordInputStream in) { public PColor(RecordInputStream in) {
red=in.readByte(); _red = in.readByte();
green=in.readByte(); _green = in.readByte();
blue=in.readByte(); _blue = in.readByte();
in.readByte(); // unused in.readByte(); // unused
} }
public void serialize(LittleEndianOutput out) { public void serialize(LittleEndianOutput out) {
out.writeByte(red); out.writeByte(_red);
out.writeByte(green); out.writeByte(_green);
out.writeByte(blue); out.writeByte(_blue);
out.writeByte(0); out.writeByte(0);
} }
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
buffer.append(" red = ").append(red & 0xff).append('\n'); buffer.append(" red = ").append(_red & 0xff).append('\n');
buffer.append(" green = ").append(green & 0xff).append('\n'); buffer.append(" green = ").append(_green & 0xff).append('\n');
buffer.append(" blue = ").append(blue & 0xff).append('\n'); buffer.append(" blue = ").append(_blue & 0xff).append('\n');
return buffer.toString(); return buffer.toString();
} }
} }

View File

@ -29,8 +29,6 @@ import org.apache.poi.util.LittleEndianOutput;
* and <code>0x60 0x69 0x01 0x00</code> have been seen.<p/> * and <code>0x60 0x69 0x01 0x00</code> have been seen.<p/>
* REFERENCE: http://chicago.sourceforge.net/devel/docs/excel/biff8.html<p/> * REFERENCE: http://chicago.sourceforge.net/devel/docs/excel/biff8.html<p/>
* @author Luc Girardin (luc dot girardin at macrofocus dot com) * @author Luc Girardin (luc dot girardin at macrofocus dot com)
*
* @see org.apache.poi.hssf.model.Workbook
*/ */
public final class RecalcIdRecord extends StandardRecord { public final class RecalcIdRecord extends StandardRecord {
public final static short sid = 0x01C1; public final static short sid = 0x01C1;

View File

@ -23,7 +23,7 @@ import java.util.*;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.BlankRecord; import org.apache.poi.hssf.record.BlankRecord;
import org.apache.poi.hssf.record.BoolErrRecord; import org.apache.poi.hssf.record.BoolErrRecord;
import org.apache.poi.hssf.record.CellValueRecordInterface; import org.apache.poi.hssf.record.CellValueRecordInterface;
@ -229,7 +229,7 @@ public class HSSFCell implements Cell {
/** /**
* Returns the Workbook that this Cell is bound to * Returns the Workbook that this Cell is bound to
*/ */
protected Workbook getBoundWorkbook() { protected InternalWorkbook getBoundWorkbook() {
return _book.getWorkbook(); return _book.getWorkbook();
} }

View File

@ -18,7 +18,7 @@
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.ExtendedFormatRecord; import org.apache.poi.hssf.record.ExtendedFormatRecord;
import org.apache.poi.hssf.record.FontRecord; import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.record.StyleRecord; import org.apache.poi.hssf.record.StyleRecord;
@ -38,7 +38,7 @@ import org.apache.poi.ss.usermodel.Font;
public final class HSSFCellStyle implements CellStyle { public final class HSSFCellStyle implements CellStyle {
private ExtendedFormatRecord _format = null; private ExtendedFormatRecord _format = null;
private short _index = 0; private short _index = 0;
private Workbook _workbook = null; private InternalWorkbook _workbook = null;
/** Creates new HSSFCellStyle why would you want to do this?? */ /** Creates new HSSFCellStyle why would you want to do this?? */
@ -46,7 +46,7 @@ public final class HSSFCellStyle implements CellStyle {
{ {
this(index, rec, workbook.getWorkbook()); this(index, rec, workbook.getWorkbook());
} }
protected HSSFCellStyle(short index, ExtendedFormatRecord rec, Workbook workbook) protected HSSFCellStyle(short index, ExtendedFormatRecord rec, InternalWorkbook workbook)
{ {
_workbook = workbook; _workbook = workbook;
_index = index; _index = index;
@ -125,7 +125,7 @@ public final class HSSFCellStyle implements CellStyle {
* the DataFormat against the supplied low level workbook * the DataFormat against the supplied low level workbook
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
*/ */
public String getDataFormatString(org.apache.poi.hssf.model.Workbook workbook) { public String getDataFormatString(org.apache.poi.hssf.model.InternalWorkbook workbook) {
HSSFDataFormat format = new HSSFDataFormat( workbook ); HSSFDataFormat format = new HSSFDataFormat( workbook );
return format.getFormat(getDataFormat()); return format.getFormat(getDataFormat());

View File

@ -29,7 +29,7 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Vector; import java.util.Vector;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.FormatRecord; import org.apache.poi.hssf.record.FormatRecord;
import org.apache.poi.ss.usermodel.BuiltinFormats; import org.apache.poi.ss.usermodel.BuiltinFormats;
import org.apache.poi.ss.usermodel.DataFormat; import org.apache.poi.ss.usermodel.DataFormat;
@ -53,7 +53,7 @@ public final class HSSFDataFormat implements DataFormat {
private static final String[] _builtinFormats = BuiltinFormats.getAll(); private static final String[] _builtinFormats = BuiltinFormats.getAll();
private final Vector<String> _formats = new Vector<String>(); private final Vector<String> _formats = new Vector<String>();
private final Workbook _workbook; private final InternalWorkbook _workbook;
private boolean _movedBuiltins = false; // Flag to see if need to private boolean _movedBuiltins = false; // Flag to see if need to
// check the built in list // check the built in list
// or if the regular list // or if the regular list
@ -64,7 +64,7 @@ public final class HSSFDataFormat implements DataFormat {
* access to the workbooks format records. * access to the workbooks format records.
* @param workbook the workbook the formats are tied to. * @param workbook the workbook the formats are tied to.
*/ */
public HSSFDataFormat(Workbook workbook) { HSSFDataFormat(InternalWorkbook workbook) {
_workbook = workbook; _workbook = workbook;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -18,7 +18,7 @@
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
import org.apache.poi.hssf.record.formula.NamePtg; import org.apache.poi.hssf.record.formula.NamePtg;
@ -42,7 +42,7 @@ import org.apache.poi.ss.formula.FormulaType;
public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook { public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, EvaluationWorkbook, FormulaParsingWorkbook {
private final HSSFWorkbook _uBook; private final HSSFWorkbook _uBook;
private final Workbook _iBook; private final InternalWorkbook _iBook;
public static HSSFEvaluationWorkbook create(HSSFWorkbook book) { public static HSSFEvaluationWorkbook create(HSSFWorkbook book) {
if (book == null) { if (book == null) {

View File

@ -18,7 +18,7 @@
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.ss.formula.FormulaType; import org.apache.poi.ss.formula.FormulaType;
@ -114,7 +114,7 @@ public final class HSSFName implements Name {
public void setNameName(String nameName){ public void setNameName(String nameName){
validateName(nameName); validateName(nameName);
Workbook wb = _book.getWorkbook(); InternalWorkbook wb = _book.getWorkbook();
_definedNameRec.setNameText(nameName); _definedNameRec.setNameText(nameName);
int sheetNumber = _definedNameRec.getSheetNumber(); int sheetNumber = _definedNameRec.getSheetNumber();
@ -251,7 +251,5 @@ public final class HSSFName implements Name {
*/ */
public void setFunction(boolean value) { public void setFunction(boolean value) {
_definedNameRec.setFunction(value); _definedNameRec.setFunction(value);
} }
} }

View File

@ -19,7 +19,7 @@ package org.apache.poi.hssf.usermodel;
import java.util.Iterator; import java.util.Iterator;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.LabelSSTRecord; import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.UnicodeString; import org.apache.poi.hssf.record.UnicodeString;
import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Font;
@ -74,7 +74,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
public static final short NO_FONT = 0; public static final short NO_FONT = 0;
private UnicodeString _string; private UnicodeString _string;
private Workbook _book; private InternalWorkbook _book;
private LabelSSTRecord _record; private LabelSSTRecord _record;
public HSSFRichTextString() public HSSFRichTextString()
@ -90,7 +90,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
} }
} }
HSSFRichTextString(Workbook book, LabelSSTRecord record) { HSSFRichTextString(InternalWorkbook book, LabelSSTRecord record) {
setWorkbookReferences(book, record); setWorkbookReferences(book, record);
_string = book.getSSTString(record.getSSTIndex()); _string = book.getSSTString(record.getSSTIndex());
@ -99,7 +99,7 @@ public final class HSSFRichTextString implements Comparable<HSSFRichTextString>,
/** This must be called to setup the internal work book references whenever /** This must be called to setup the internal work book references whenever
* a RichTextString is added to a cell * a RichTextString is added to a cell
*/ */
void setWorkbookReferences(Workbook book, LabelSSTRecord record) { void setWorkbookReferences(InternalWorkbook book, LabelSSTRecord record) {
_book = book; _book = book;
_record = record; _record = record;
} }

View File

@ -32,7 +32,7 @@ import java.util.TreeMap;
import org.apache.poi.ddf.EscherRecord; import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.CellValueRecordInterface; import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.DVRecord; import org.apache.poi.hssf.record.DVRecord;
import org.apache.poi.hssf.record.EscherAggregate; import org.apache.poi.hssf.record.EscherAggregate;
@ -82,7 +82,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
private final Sheet _sheet; private final Sheet _sheet;
/** stores rows by zero-based row number */ /** stores rows by zero-based row number */
private final TreeMap<Integer, HSSFRow> _rows; private final TreeMap<Integer, HSSFRow> _rows;
protected final Workbook _book; protected final InternalWorkbook _book;
protected final HSSFWorkbook _workbook; protected final HSSFWorkbook _workbook;
private int _firstrow; private int _firstrow;
private int _lastrow; private int _lastrow;
@ -1693,7 +1693,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
FontRenderContext frc = new FontRenderContext(null, true, true); FontRenderContext frc = new FontRenderContext(null, true, true);
HSSFWorkbook wb = new HSSFWorkbook(_book); HSSFWorkbook wb = HSSFWorkbook.create(_book); // TODO - is it important to not use _workbook?
HSSFFont defaultFont = wb.getFontAt((short) 0); HSSFFont defaultFont = wb.getFontAt((short) 0);
str = new AttributedString("" + defaultChar); str = new AttributedString("" + defaultChar);

View File

@ -38,7 +38,7 @@ import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.RecordStream; import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.AbstractEscherHolderRecord; import org.apache.poi.hssf.record.AbstractEscherHolderRecord;
import org.apache.poi.hssf.record.BackupRecord; import org.apache.poi.hssf.record.BackupRecord;
import org.apache.poi.hssf.record.DrawingGroupRecord; import org.apache.poi.hssf.record.DrawingGroupRecord;
@ -78,13 +78,13 @@ import org.apache.poi.util.POILogger;
* will construct whether they are reading or writing a workbook. It is also the * will construct whether they are reading or writing a workbook. It is also the
* top level object for creating new sheets/etc. * top level object for creating new sheets/etc.
* *
* @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.usermodel.HSSFSheet * @see org.apache.poi.hssf.usermodel.HSSFSheet
* @author Andrew C. Oliver (acoliver at apache dot org) * @author Andrew C. Oliver (acoliver at apache dot org)
* @author Glen Stampoultzis (glens at apache.org) * @author Glen Stampoultzis (glens at apache.org)
* @author Shawn Laubach (slaubach at apache dot org) * @author Shawn Laubach (slaubach at apache dot org)
*/ */
public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.usermodel.Workbook { public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.usermodel.Workbook {
private static final Pattern COMMA_PATTERN = Pattern.compile(","); private static final Pattern COMMA_PATTERN = Pattern.compile(",");
private static final int MAX_ROW = 0xFFFF; private static final int MAX_ROW = 0xFFFF;
private static final short MAX_COLUMN = (short)0x00FF; private static final short MAX_COLUMN = (short)0x00FF;
@ -104,7 +104,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
* this is the reference to the low level Workbook object * this is the reference to the low level Workbook object
*/ */
private Workbook workbook; private InternalWorkbook workbook;
/** /**
* this holds the HSSFSheet objects attached to this workbook * this holds the HSSFSheet objects attached to this workbook
@ -162,17 +162,18 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class); private static POILogger log = POILogFactory.getLogger(HSSFWorkbook.class);
public static HSSFWorkbook create(InternalWorkbook book) {
return new HSSFWorkbook(book);
}
/** /**
* Creates new HSSFWorkbook from scratch (start here!) * Creates new HSSFWorkbook from scratch (start here!)
* *
*/ */
public HSSFWorkbook() public HSSFWorkbook() {
{ this(InternalWorkbook.createWorkbook());
this(Workbook.createWorkbook());
} }
protected HSSFWorkbook( Workbook book ) private HSSFWorkbook(InternalWorkbook book) {
{
super(null, null); super(null, null);
workbook = book; workbook = book;
_sheets = new ArrayList(INITIAL_CAPACITY); _sheets = new ArrayList(INITIAL_CAPACITY);
@ -275,7 +276,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
List records = RecordFactory.createRecords(stream); List records = RecordFactory.createRecords(stream);
workbook = Workbook.createWorkbook(records); workbook = InternalWorkbook.createWorkbook(records);
setPropertiesFromWorkbook(workbook); setPropertiesFromWorkbook(workbook);
int recOffset = workbook.getNumRecords(); int recOffset = workbook.getNumRecords();
int sheetNum = 0; int sheetNum = 0;
@ -321,7 +322,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
* used internally to set the workbook properties. * used internally to set the workbook properties.
*/ */
private void setPropertiesFromWorkbook(Workbook book) private void setPropertiesFromWorkbook(InternalWorkbook book)
{ {
this.workbook = book; this.workbook = book;
@ -1225,7 +1226,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
* @return byte[] array containing the binary representation of this workbook and all contained * @return byte[] array containing the binary representation of this workbook and all contained
* sheets, rows, cells, etc. * sheets, rows, cells, etc.
* *
* @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.model.Sheet * @see org.apache.poi.hssf.model.Sheet
*/ */
public byte[] getBytes() { public byte[] getBytes() {
@ -1290,8 +1291,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
return workbook.getSSTString(index).getString(); return workbook.getSSTString(index).getString();
} }
protected Workbook getWorkbook() InternalWorkbook getWorkbook() {
{
return workbook; return workbook;
} }

View File

@ -27,7 +27,7 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener; import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.FormulaRecord; import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.formula.Ptg; import org.apache.poi.hssf.record.formula.Ptg;
@ -76,7 +76,7 @@ public final class TestEventWorkbookBuilder extends TestCase {
assertEquals(3, listener.getStubWorkbook().getNumSheets()); assertEquals(3, listener.getStubWorkbook().getNumSheets());
Workbook ref = listener.getStubWorkbook(); InternalWorkbook ref = listener.getStubWorkbook();
assertEquals("Sh3", ref.findSheetNameFromExternSheet(0)); assertEquals("Sh3", ref.findSheetNameFromExternSheet(0));
assertEquals("Sheet1", ref.findSheetNameFromExternSheet(1)); assertEquals("Sheet1", ref.findSheetNameFromExternSheet(1));
assertEquals("S2", ref.findSheetNameFromExternSheet(2)); assertEquals("S2", ref.findSheetNameFromExternSheet(2));
@ -89,7 +89,7 @@ public final class TestEventWorkbookBuilder extends TestCase {
// Check our formula records // Check our formula records
assertEquals(6, fRecs.length); assertEquals(6, fRecs.length);
Workbook stubWB = listener.getStubWorkbook(); InternalWorkbook stubWB = listener.getStubWorkbook();
assertNotNull(stubWB); assertNotNull(stubWB);
HSSFWorkbook stubHSSF = listener.getStubHSSFWorkbook(); HSSFWorkbook stubHSSF = listener.getStubHSSFWorkbook();
assertNotNull(stubHSSF); assertNotNull(stubHSSF);

View File

@ -17,10 +17,11 @@
package org.apache.poi.hssf.model; package org.apache.poi.hssf.model;
import junit.framework.TestCase;
import org.apache.poi.hssf.record.FontRecord; import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.TestHSSFWorkbook;
import junit.framework.TestCase;
/** /**
* Unit test for the Workbook class. * Unit test for the Workbook class.
@ -29,7 +30,7 @@ import junit.framework.TestCase;
*/ */
public final class TestWorkbook extends TestCase { public final class TestWorkbook extends TestCase {
public void testFontStuff() { public void testFontStuff() {
Workbook wb = (new HW()).getWorkbook(); InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(new HSSFWorkbook());
assertEquals(4, wb.getNumberOfFontRecords()); assertEquals(4, wb.getNumberOfFontRecords());
assertEquals(68, wb.getRecords().size()); assertEquals(68, wb.getRecords().size());
@ -82,13 +83,4 @@ public final class TestWorkbook extends TestCase {
assertEquals(6, wb.getFontIndex(n7)); assertEquals(6, wb.getFontIndex(n7));
assertEquals(n7, wb.getFontRecordAt(6)); assertEquals(n7, wb.getFontRecordAt(6));
} }
private static final class HW extends HSSFWorkbook {
public HW() {
super();
}
protected Workbook getWorkbook() {
return super.getWorkbook();
}
}
} }

View File

@ -21,7 +21,7 @@ package org.apache.poi.hssf.usermodel;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.PageSettingsBlock; import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
@ -208,7 +208,7 @@ public class SanityChecker
new CheckRecord(EOFRecord.class, '1') new CheckRecord(EOFRecord.class, '1')
}; };
private void checkWorkbookRecords(Workbook workbook) private void checkWorkbookRecords(InternalWorkbook workbook)
{ {
List records = workbook.getRecords(); List records = workbook.getRecords();
assertTrue(records.get(0) instanceof BOFRecord); assertTrue(records.get(0) instanceof BOFRecord);

View File

@ -31,7 +31,7 @@ import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.OldExcelFormatException; import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.CellValueRecordInterface; import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord; import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
@ -844,7 +844,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Check all names fit within range, and use // Check all names fit within range, and use
// DeletedArea3DPtg // DeletedArea3DPtg
Workbook w = wb.getWorkbook(); InternalWorkbook w = wb.getWorkbook();
for(int i=0; i<w.getNumNames(); i++) { for(int i=0; i<w.getNumNames(); i++) {
NameRecord r = w.getNameRecord(i); NameRecord r = w.getNameRecord(i);
assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets()); assertTrue(r.getSheetNumber() <= wb.getNumberOfSheets());

View File

@ -25,7 +25,7 @@ import java.util.TimeZone;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
/** /**
* Class TestHSSFDateUtil * Class TestHSSFDateUtil
@ -306,7 +306,7 @@ public final class TestHSSFDateUtil extends TestCase {
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls"); HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("DateFormats.xls");
HSSFSheet sheet = workbook.getSheetAt(0); HSSFSheet sheet = workbook.getSheetAt(0);
Workbook wb = workbook.getWorkbook(); InternalWorkbook wb = workbook.getWorkbook();
HSSFRow row; HSSFRow row;
HSSFCell cell; HSSFCell cell;

View File

@ -25,6 +25,7 @@ import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
@ -48,6 +49,13 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
return HSSFITestDataProvider.getInstance(); return HSSFITestDataProvider.getInstance();
} }
/**
* gives test code access to the {@link InternalWorkbook} within {@link HSSFWorkbook}
*/
public static InternalWorkbook getInternalWorkbook(HSSFWorkbook wb) {
return wb.getWorkbook();
}
public void testSetRepeatingRowsAndColumns() { public void testSetRepeatingRowsAndColumns() {
// Test bug 29747 // Test bug 29747
HSSFWorkbook b = new HSSFWorkbook( ); HSSFWorkbook b = new HSSFWorkbook( );

View File

@ -25,7 +25,7 @@ import java.io.IOException;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.BackupRecord; import org.apache.poi.hssf.record.BackupRecord;
import org.apache.poi.hssf.record.LabelSSTRecord; import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.Record;
@ -449,7 +449,7 @@ public final class TestWorkbook extends TestCase {
public void testBackupRecord() { public void testBackupRecord() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
wb.createSheet(); wb.createSheet();
Workbook workbook = wb.getWorkbook(); InternalWorkbook workbook = wb.getWorkbook();
BackupRecord record = workbook.getBackupRecord(); BackupRecord record = workbook.getBackupRecord();
assertEquals(0, record.getBackup()); assertEquals(0, record.getBackup());

View File

@ -17,14 +17,13 @@
package org.apache.poi.hssf.util; package org.apache.poi.hssf.util;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.HSSFFormulaParser; import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.formula.Area3DPtg; import org.apache.poi.hssf.record.formula.Area3DPtg;
import org.apache.poi.hssf.record.formula.MemFuncPtg; import org.apache.poi.hssf.record.formula.MemFuncPtg;
@ -36,6 +35,7 @@ import org.apache.poi.hssf.usermodel.HSSFName;
import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.TestHSSFWorkbook;
import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
/** /**
@ -108,16 +108,6 @@ public final class TestAreaReference extends TestCase {
TestCellReference.confirmCell(allCells[2], "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7"); TestCellReference.confirmCell(allCells[2], "Tabelle1", 6, 1, true, true, "Tabelle1!$B$7");
} }
// TODO - remove this sub-class
private static final class HSSFWB extends HSSFWorkbook {
public HSSFWB(InputStream in) throws IOException {
super(in);
}
public Workbook getWorkbook() {
return super.getWorkbook();
}
}
public void testContiguousReferences() { public void testContiguousReferences() {
String refSimple = "$C$10:$C$10"; String refSimple = "$C$10:$C$10";
String ref2D = "$C$10:$D$11"; String ref2D = "$C$10:$D$11";
@ -138,15 +128,21 @@ public final class TestAreaReference extends TestCase {
try { try {
new AreaReference(refDCSimple); new AreaReference(refDCSimple);
fail(); fail();
} catch(IllegalArgumentException e) {} } catch(IllegalArgumentException e) {
// expected during successful test
}
try { try {
new AreaReference(refDC2D); new AreaReference(refDC2D);
fail(); fail();
} catch(IllegalArgumentException e) {} } catch(IllegalArgumentException e) {
// expected during successful test
}
try { try {
new AreaReference(refDC3D); new AreaReference(refDC3D);
fail(); fail();
} catch(IllegalArgumentException e) {} } catch(IllegalArgumentException e) {
// expected during successful test
}
// Test that we split as expected // Test that we split as expected
AreaReference[] refs; AreaReference[] refs;
@ -193,8 +189,8 @@ public final class TestAreaReference extends TestCase {
public void testDiscontinousReference() throws Exception { public void testDiscontinousReference() throws Exception {
InputStream is = HSSFTestDataSamples.openSampleFileStream("44167.xls"); InputStream is = HSSFTestDataSamples.openSampleFileStream("44167.xls");
HSSFWB wb = new HSSFWB(is); HSSFWorkbook wb = new HSSFWorkbook(is);
Workbook workbook = wb.getWorkbook(); InternalWorkbook workbook = TestHSSFWorkbook.getInternalWorkbook(wb);
HSSFEvaluationWorkbook eb = HSSFEvaluationWorkbook.create(wb); HSSFEvaluationWorkbook eb = HSSFEvaluationWorkbook.create(wb);
assertEquals(1, wb.getNumberOfNames()); assertEquals(1, wb.getNumberOfNames());
@ -278,7 +274,6 @@ public final class TestAreaReference extends TestCase {
confirmWholeColumnRef("A:A", 0, 0, false, false); confirmWholeColumnRef("A:A", 0, 0, false, false);
confirmWholeColumnRef("$C:D", 2, 3, true, false); confirmWholeColumnRef("$C:D", 2, 3, true, false);
confirmWholeColumnRef("AD:$AE", 29, 30, false, true); confirmWholeColumnRef("AD:$AE", 29, 30, false, true);
} }
private static void confirmWholeColumnRef(String ref, int firstCol, int lastCol, boolean firstIsAbs, boolean lastIsAbs) { private static void confirmWholeColumnRef(String ref, int firstCol, int lastCol, boolean firstIsAbs, boolean lastIsAbs) {