Renamed model.Sheet to InternalSheet to alleviate name clash.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-12-22 01:08:33 +00:00
parent ea80e22b2b
commit f11c66506d
15 changed files with 128 additions and 125 deletions

View File

@ -70,6 +70,7 @@ import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
import org.apache.poi.hssf.record.formula.FormulaShifter;
import org.apache.poi.hssf.util.PaneInformation;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
@ -94,13 +95,14 @@ import org.apache.poi.util.POILogger;
* @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.usermodel.HSSFSheet
*/
public final class Sheet {
@Internal
public final class InternalSheet {
public static final short LeftMargin = 0;
public static final short RightMargin = 1;
public static final short TopMargin = 2;
public static final short BottomMargin = 3;
private static POILogger log = POILogFactory.getLogger(Sheet.class);
private static POILogger log = POILogFactory.getLogger(InternalSheet.class);
private List<RecordBase> _records;
protected PrintGridlinesRecord printGridlines = null;
@ -154,10 +156,10 @@ public final class Sheet {
* @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.record.Record
*/
public static Sheet createSheet(RecordStream rs) {
return new Sheet(rs);
public static InternalSheet createSheet(RecordStream rs) {
return new InternalSheet(rs);
}
private Sheet(RecordStream rs) {
private InternalSheet(RecordStream rs) {
_mergedCellsTable = new MergedCellsTable();
RowRecordsAggregate rra = null;
@ -367,7 +369,7 @@ public final class Sheet {
* When adding a new record, implement a public clone method if and only if the record
* belongs to a sheet.
*/
public Sheet cloneSheet() {
public InternalSheet cloneSheet() {
List<RecordBase> clonedRecords = new ArrayList<RecordBase>(_records.size());
for (int i = 0; i < _records.size(); i++) {
RecordBase rb = _records.get(i);
@ -388,10 +390,10 @@ public final class Sheet {
*
* @return Sheet object with all values set to defaults
*/
public static Sheet createSheet() {
return new Sheet();
public static InternalSheet createSheet() {
return new InternalSheet();
}
private Sheet() {
private InternalSheet() {
_mergedCellsTable = new MergedCellsTable();
List<RecordBase> records = new ArrayList<RecordBase>(32);

View File

@ -2274,7 +2274,7 @@ public final class InternalWorkbook {
*
* @param sheet the cloned sheet
*/
public void cloneDrawings(Sheet sheet){
public void cloneDrawings(InternalSheet sheet){
findDrawingGroup();

View File

@ -25,7 +25,6 @@ package org.apache.poi.hssf.record;
* @author Andrew C. Oliver (acoliver at apache dot org)
* @author Jason Height (jheight at chariot dot net dot au)
*
* @see org.apache.poi.hssf.model.Sheet
* @see org.apache.poi.hssf.record.Record
* @see org.apache.poi.hssf.record.RecordFactory
*/

View File

@ -23,7 +23,7 @@ import java.util.List;
import java.util.Arrays;
import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.record.*;
/**
@ -404,10 +404,10 @@ public final class PageSettingsBlock extends RecordAggregate {
private Margin getMarginRec(int marginIndex) {
switch (marginIndex) {
case Sheet.LeftMargin: return _leftMargin;
case Sheet.RightMargin: return _rightMargin;
case Sheet.TopMargin: return _topMargin;
case Sheet.BottomMargin: return _bottomMargin;
case InternalSheet.LeftMargin: return _leftMargin;
case InternalSheet.RightMargin: return _rightMargin;
case InternalSheet.TopMargin: return _topMargin;
case InternalSheet.BottomMargin: return _bottomMargin;
}
throw new IllegalArgumentException( "Unknown margin constant: " + marginIndex );
}
@ -424,10 +424,10 @@ public final class PageSettingsBlock extends RecordAggregate {
return m.getMargin();
}
switch (margin) {
case Sheet.LeftMargin: return .75;
case Sheet.RightMargin: return .75;
case Sheet.TopMargin: return 1.0;
case Sheet.BottomMargin: return 1.0;
case InternalSheet.LeftMargin: return .75;
case InternalSheet.RightMargin: return .75;
case InternalSheet.TopMargin: return 1.0;
case InternalSheet.BottomMargin: return 1.0;
}
throw new IllegalArgumentException( "Unknown margin constant: " + margin );
}
@ -441,19 +441,19 @@ public final class PageSettingsBlock extends RecordAggregate {
Margin m = getMarginRec(margin);
if (m == null) {
switch (margin) {
case Sheet.LeftMargin:
case InternalSheet.LeftMargin:
_leftMargin = new LeftMarginRecord();
m = _leftMargin;
break;
case Sheet.RightMargin:
case InternalSheet.RightMargin:
_rightMargin = new RightMarginRecord();
m = _rightMargin;
break;
case Sheet.TopMargin:
case InternalSheet.TopMargin:
_topMargin = new TopMarginRecord();
m = _topMargin;
break;
case Sheet.BottomMargin:
case InternalSheet.BottomMargin:
_bottomMargin = new BottomMarginRecord();
m = _bottomMargin;
break;

View File

@ -22,7 +22,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.BlankRecord;
import org.apache.poi.hssf.record.BoolErrRecord;
@ -1056,7 +1056,7 @@ public class HSSFCell implements Cell {
*
* @return cell comment or <code>null</code> if not found
*/
protected static HSSFComment findCellComment(Sheet sheet, int row, int column) {
protected static HSSFComment findCellComment(InternalSheet sheet, int row, int column) {
// TODO - optimise this code by searching backwards, find NoteRecord first, quit if not found. Find one TXO by id
HSSFComment comment = null;
Map<Integer, TextObjectRecord> noteTxo =

View File

@ -31,7 +31,7 @@ import java.util.List;
import java.util.TreeMap;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.DVRecord;
@ -77,9 +77,9 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
public final static int INITIAL_CAPACITY = 20;
/**
* reference to the low level {@link Sheet} object
* reference to the low level {@link InternalSheet} object
*/
private final Sheet _sheet;
private final InternalSheet _sheet;
/** stores rows by zero-based row number */
private final TreeMap<Integer, HSSFRow> _rows;
protected final InternalWorkbook _book;
@ -95,7 +95,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createSheet()
*/
protected HSSFSheet(HSSFWorkbook workbook) {
_sheet = Sheet.createSheet();
_sheet = InternalSheet.createSheet();
_rows = new TreeMap<Integer, HSSFRow>();
this._workbook = workbook;
this._book = workbook.getWorkbook();
@ -109,7 +109,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
* @param sheet - lowlevel Sheet object this sheet will represent
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createSheet()
*/
protected HSSFSheet(HSSFWorkbook workbook, Sheet sheet) {
protected HSSFSheet(HSSFWorkbook workbook, InternalSheet sheet) {
this._sheet = sheet;
_rows = new TreeMap<Integer, HSSFRow>();
this._workbook = workbook;
@ -133,7 +133,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
/**
* used internally to set the properties given a Sheet object
*/
private void setPropertiesFromSheet(Sheet sheet) {
private void setPropertiesFromSheet(InternalSheet sheet) {
RowRecord row = sheet.getNextRow();
boolean rowRecordsAlreadyPresent = row!=null;
@ -714,7 +714,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
* Object.
* @return Sheet - low level representation of this HSSFSheet.
*/
Sheet getSheet() {
InternalSheet getSheet() {
return _sheet;
}
@ -1277,7 +1277,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
int nSheets = _workbook.getNumberOfSheets();
for(int i=0; i<nSheets; i++) {
Sheet otherSheet = _workbook.getSheetAt(i).getSheet();
InternalSheet otherSheet = _workbook.getSheetAt(i).getSheet();
if (otherSheet == this._sheet) {
continue;
}

View File

@ -37,7 +37,7 @@ import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.AbstractEscherHolderRecord;
import org.apache.poi.hssf.record.BackupRecord;
@ -285,7 +285,7 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
convertLabelRecords(records, recOffset);
RecordStream rs = new RecordStream(records, recOffset);
while (rs.hasNext()) {
Sheet sheet = Sheet.createSheet(rs);
InternalSheet sheet = InternalSheet.createSheet(rs);
_sheets.add(new HSSFSheet(this, sheet));
}
@ -1225,9 +1225,6 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss
*
* @return byte[] array containing the binary representation of this workbook and all contained
* sheets, rows, cells, etc.
*
* @see org.apache.poi.hssf.model.InternalWorkbook
* @see org.apache.poi.hssf.model.Sheet
*/
public byte[] getBytes() {
if (log.check( POILogger.DEBUG )) {

View File

@ -55,16 +55,16 @@ import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* Unit test for the {@link Sheet} class.
* Unit test for the {@link InternalSheet} class.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public final class TestSheet extends TestCase {
private static Sheet createSheet(List<Record> inRecs) {
return Sheet.createSheet(new RecordStream(inRecs, 0));
private static InternalSheet createSheet(List<Record> inRecs) {
return InternalSheet.createSheet(new RecordStream(inRecs, 0));
}
private static Record[] getSheetRecords(Sheet s, int offset) {
private static Record[] getSheetRecords(InternalSheet s, int offset) {
RecordCollector rc = new RecordCollector();
s.visitContainedRecords(rc, offset);
return rc.getRecords();
@ -77,7 +77,7 @@ public final class TestSheet extends TestCase {
records.add( new DimensionsRecord() );
records.add(createWindow2Record());
records.add(EOFRecord.instance);
Sheet sheet = createSheet(records);
InternalSheet sheet = createSheet(records);
Record[] outRecs = getSheetRecords(sheet, 0);
int pos = 0;
@ -116,7 +116,7 @@ public final class TestSheet extends TestCase {
}
public void testAddMergedRegion() {
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
int regionsToAdd = 4096;
//simple test that adds a load of regions
@ -156,7 +156,7 @@ public final class TestSheet extends TestCase {
}
public void testRemoveMergedRegion() {
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
int regionsToAdd = 4096;
for (int n = 0; n < regionsToAdd; n++) {
@ -201,7 +201,7 @@ public final class TestSheet extends TestCase {
records.add(EOFRecord.instance);
records.add(merged);
Sheet sheet = createSheet(records);
InternalSheet sheet = createSheet(records);
sheet.getRecords().remove(0); // TODO - what does this line do?
//stub object to throw off list INDEX operations
@ -224,7 +224,7 @@ public final class TestSheet extends TestCase {
public void testRowAggregation() {
List<Record> records = new ArrayList<Record>();
records.add(Sheet.createBOF());
records.add(InternalSheet.createBOF());
records.add(new DimensionsRecord());
records.add(new RowRecord(0));
records.add(new RowRecord(1));
@ -236,7 +236,7 @@ public final class TestSheet extends TestCase {
records.add(createWindow2Record());
records.add(EOFRecord.instance);
Sheet sheet = createSheet(records);
InternalSheet sheet = createSheet(records);
assertNotNull("Row [2] was skipped", sheet.getRow(2));
}
@ -248,7 +248,7 @@ public final class TestSheet extends TestCase {
short colFrom = 0;
short colTo = 255;
Sheet worksheet = Sheet.createSheet();
InternalSheet worksheet = InternalSheet.createSheet();
PageSettingsBlock sheet = worksheet.getPageSettings();
sheet.setRowBreak(0, colFrom, colTo);
@ -304,7 +304,7 @@ public final class TestSheet extends TestCase {
short rowFrom = 0;
short rowTo = (short)65535;
Sheet worksheet = Sheet.createSheet();
InternalSheet worksheet = InternalSheet.createSheet();
PageSettingsBlock sheet = worksheet.getPageSettings();
sheet.setColumnBreak((short)0, rowFrom, rowTo);
@ -365,7 +365,7 @@ public final class TestSheet extends TestCase {
final short TEST_IDX = 10;
final short DEFAULT_IDX = 0xF; // 15
short xfindex = Short.MIN_VALUE;
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
// without ColumnInfoRecord
xfindex = sheet.getXFIndexForColAt((short) 0);
@ -460,7 +460,7 @@ public final class TestSheet extends TestCase {
records.add(new DimensionsRecord());
records.add(createWindow2Record());
records.add(EOFRecord.instance);
Sheet sheet = createSheet(records);
InternalSheet sheet = createSheet(records);
// The original bug was due to different logic for collecting records for sizing and
// serialization. The code has since been refactored into a single method for visiting
@ -479,7 +479,7 @@ public final class TestSheet extends TestCase {
*/
public void testRowValueAggregatesOrder_bug45145() {
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
RowRecord rr = new RowRecord(5);
sheet.addRow(rr);
@ -510,7 +510,7 @@ public final class TestSheet extends TestCase {
* @return the value calculated for the position of the first DBCELL record for this sheet.
* That value is found on the IndexRecord.
*/
private static int getDbCellRecordPos(Sheet sheet) {
private static int getDbCellRecordPos(InternalSheet sheet) {
MyIndexRecordListener myIndexListener = new MyIndexRecordListener();
sheet.visitContainedRecords(myIndexListener, 0);
@ -544,7 +544,7 @@ public final class TestSheet extends TestCase {
*/
public void testGutsRecord_bug45640() {
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
sheet.addRow(new RowRecord(0));
sheet.addRow(new RowRecord(1));
sheet.groupRowRange( 0, 1, true );
@ -611,7 +611,7 @@ public final class TestSheet extends TestCase {
inRecs.add(nr);
inRecs.add(createWindow2Record());
inRecs.add(EOFRecord.instance);
Sheet sheet;
InternalSheet sheet;
try {
sheet = createSheet(inRecs);
} catch (RuntimeException e) {
@ -641,7 +641,7 @@ public final class TestSheet extends TestCase {
*/
public void testShiftFormulasAddCondFormat_bug46547() {
// Create a sheet with data validity (similar to bugzilla attachment id=23131).
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
List<RecordBase> sheetRecs = sheet.getRecords();
assertEquals(23, sheetRecs.size());
@ -659,7 +659,7 @@ public final class TestSheet extends TestCase {
*/
public void testAddCondFormatAfterDataValidation_bug46547() {
// Create a sheet with data validity (similar to bugzilla attachment id=23131).
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
sheet.getOrCreateDataValidityTable();
ConditionalFormattingTable cft;
@ -675,7 +675,7 @@ public final class TestSheet extends TestCase {
public void testCloneMulBlank_bug46776() {
Record[] recs = {
Sheet.createBOF(),
InternalSheet.createBOF(),
new DimensionsRecord(),
new RowRecord(1),
new MulBlankRecord(1, 3, new short[] { 0x0F, 0x0F, 0x0F, } ),
@ -684,9 +684,9 @@ public final class TestSheet extends TestCase {
EOFRecord.instance,
};
Sheet sheet = createSheet(Arrays.asList(recs));
InternalSheet sheet = createSheet(Arrays.asList(recs));
Sheet sheet2;
InternalSheet sheet2;
try {
sheet2 = sheet.cloneSheet();
} catch (RuntimeException e) {

View File

@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -25,44 +25,44 @@ import org.apache.poi.hssf.record.ColumnInfoRecord;
* @author Tony Poppleton
*/
public final class TestSheetAdditional extends TestCase {
public void testGetCellWidth() {
Sheet sheet = Sheet.createSheet();
InternalSheet sheet = InternalSheet.createSheet();
ColumnInfoRecord nci = new ColumnInfoRecord();
// Prepare test model
nci.setFirstColumn((short)5);
nci.setLastColumn((short)10);
nci.setColumnWidth((short)100);
nci.setFirstColumn(5);
nci.setLastColumn(10);
nci.setColumnWidth(100);
sheet._columnInfos.insertColumn(nci);
assertEquals((short)100,sheet.getColumnWidth((short)5));
assertEquals((short)100,sheet.getColumnWidth((short)6));
assertEquals((short)100,sheet.getColumnWidth((short)7));
assertEquals((short)100,sheet.getColumnWidth((short)8));
assertEquals((short)100,sheet.getColumnWidth((short)9));
assertEquals((short)100,sheet.getColumnWidth((short)10));
assertEquals(100,sheet.getColumnWidth(5));
assertEquals(100,sheet.getColumnWidth(6));
assertEquals(100,sheet.getColumnWidth(7));
assertEquals(100,sheet.getColumnWidth(8));
assertEquals(100,sheet.getColumnWidth(9));
assertEquals(100,sheet.getColumnWidth(10));
sheet.setColumnWidth((short)6,(short)200);
sheet.setColumnWidth(6,200);
assertEquals((short)100,sheet.getColumnWidth((short)5));
assertEquals((short)200,sheet.getColumnWidth((short)6));
assertEquals((short)100,sheet.getColumnWidth((short)7));
assertEquals((short)100,sheet.getColumnWidth((short)8));
assertEquals((short)100,sheet.getColumnWidth((short)9));
assertEquals((short)100,sheet.getColumnWidth((short)10));
assertEquals(100,sheet.getColumnWidth(5));
assertEquals(200,sheet.getColumnWidth(6));
assertEquals(100,sheet.getColumnWidth(7));
assertEquals(100,sheet.getColumnWidth(8));
assertEquals(100,sheet.getColumnWidth(9));
assertEquals(100,sheet.getColumnWidth(10));
}
public void testMaxColumnWidth() {
Sheet sheet = Sheet.createSheet();
sheet.setColumnWidth(0, 255*256); //the limit
try {
sheet.setColumnWidth(0, 256*256); //the limit
fail("expected exception");
} catch (Exception e){
;
}
}
public void testMaxColumnWidth() {
InternalSheet sheet = InternalSheet.createSheet();
sheet.setColumnWidth(0, 255*256); //the limit
try {
sheet.setColumnWidth(0, 256*256); //the limit
fail("expected exception");
} catch (IllegalArgumentException e){
assertEquals(e.getMessage(), "The maximum column width for an individual cell is 255 characters.");
}
}
}

View File

@ -24,7 +24,7 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFSheet;
@ -84,9 +84,9 @@ public final class TestPageSettingsBlock extends TestCase {
EOFRecord.instance,
};
RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
Sheet sheet;
InternalSheet sheet;
try {
sheet = Sheet.createSheet(rs);
sheet = InternalSheet.createSheet(rs);
} catch (RuntimeException e) {
if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
throw new AssertionFailedError("Identified bug 46480");
@ -122,7 +122,7 @@ public final class TestPageSettingsBlock extends TestCase {
EOFRecord.instance,
};
RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
Sheet sheet = Sheet.createSheet(rs);
InternalSheet sheet = InternalSheet.createSheet(rs);
RecordCollector rv = new RecordCollector();
sheet.visitContainedRecords(rv, 0);
@ -166,9 +166,9 @@ public final class TestPageSettingsBlock extends TestCase {
};
RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
Sheet sheet;
InternalSheet sheet;
try {
sheet = Sheet.createSheet(rs);
sheet = InternalSheet.createSheet(rs);
} catch (RuntimeException e) {
if (e.getMessage().equals("two Page Settings Blocks found in the same sheet")) {
throw new AssertionFailedError("Identified bug 47199a - failed to process late margings records");
@ -328,9 +328,9 @@ public final class TestPageSettingsBlock extends TestCase {
EOFRecord.instance,
};
RecordStream rs = new RecordStream(Arrays.asList(recs), 0);
Sheet sheet;
InternalSheet sheet;
try {
sheet = Sheet.createSheet(rs);
sheet = InternalSheet.createSheet(rs);
} catch (RuntimeException e) {
if (e.getMessage().equals("Duplicate PageSettingsBlock record (sid=0x89c)")) {
throw new AssertionFailedError("Identified bug 48026");

View File

@ -20,7 +20,7 @@
package org.apache.poi.hssf.usermodel;
import junit.framework.Assert;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.aggregates.PageSettingsBlock;
@ -218,8 +218,7 @@ public class SanityChecker
// checkRecordsTogether(records, workbookRecords);
}
private void checkSheetRecords(Sheet sheet)
{
private void checkSheetRecords(InternalSheet sheet) {
List records = sheet.getRecords();
assertTrue(records.get(0) instanceof BOFRecord);
assertTrue(records.get(records.size() - 1) instanceof EOFRecord);

View File

@ -23,7 +23,7 @@ import java.util.GregorianCalendar;
import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.record.DBCellRecord;
import org.apache.poi.hssf.record.FormulaRecord;
import org.apache.poi.hssf.record.Record;
@ -131,7 +131,7 @@ public final class TestHSSFCell extends BaseTestCell {
//check initial position
HSSFSheet umSheet = book.getSheetAt(0);
Sheet s = umSheet.getSheet();
InternalSheet s = umSheet.getSheet();
assertEquals("Initial active cell should be in col 0",
(short) 0, s.getActiveCellCol());
assertEquals("Initial active cell should be on row 1",

View File

@ -23,17 +23,27 @@ import java.io.FileOutputStream;
import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.record.DimensionsRecord;
import org.apache.poi.hssf.record.GridsetRecord;
import org.apache.poi.hssf.record.HCenterRecord;
import org.apache.poi.hssf.record.ObjectProtectRecord;
import org.apache.poi.hssf.record.PasswordRecord;
import org.apache.poi.hssf.record.ProtectRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.SCLRecord;
import org.apache.poi.hssf.record.ScenarioProtectRecord;
import org.apache.poi.hssf.record.VCenterRecord;
import org.apache.poi.hssf.record.WSBoolRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.util.TempFile;
/**
@ -60,11 +70,10 @@ public final class TestHSSFSheet extends BaseTestSheet {
public void testBackupRecord() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
Sheet sheet = s.getSheet();
assertEquals(true, sheet.getGridsetRecord().getGridset());
GridsetRecord gridsetRec = s.getSheet().getGridsetRecord();
assertEquals(true, gridsetRec.getGridset());
s.setGridsPrinted(true);
assertEquals(false, sheet.getGridsetRecord().getGridset());
assertEquals(false, gridsetRec.getGridset());
}
/**
@ -73,8 +82,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
public void testVerticallyCenter() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
Sheet sheet = s.getSheet();
VCenterRecord record = sheet.getPageSettings().getVCenter();
VCenterRecord record = s.getSheet().getPageSettings().getVCenter();
assertEquals(false, record.getVCenter());
s.setVerticallyCenter(true);
@ -89,8 +97,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
public void testHorizontallyCenter() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
Sheet sheet = s.getSheet();
HCenterRecord record = sheet.getPageSettings().getHCenter();
HCenterRecord record = s.getSheet().getPageSettings().getHCenter();
assertEquals(false, record.getHCenter());
s.setHorizontallyCenter(true);
@ -104,9 +111,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
public void testWSBool() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
Sheet sheet = s.getSheet();
WSBoolRecord record =
(WSBoolRecord) sheet.findFirstRecordBySid(WSBoolRecord.sid);
(WSBoolRecord) s.getSheet().findFirstRecordBySid(WSBoolRecord.sid);
// Check defaults
assertEquals(true, record.getAlternateExpression());

View File

@ -26,7 +26,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider;
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.InternalSheet;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordBase;
@ -356,7 +356,7 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
*/
public void testSheetSerializeSizeMismatch_bug45066() {
HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("Sheet1").getSheet();
InternalSheet sheet = wb.createSheet("Sheet1").getSheet();
List<RecordBase> sheetRecords = sheet.getRecords();
// one way (of many) to cause the discrepancy is with a badly behaved record:
sheetRecords.add(new BadlyBehavedRecord());

View File

@ -23,7 +23,7 @@ import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.record.BOFRecord;
import org.apache.poi.hssf.record.EOFRecord;
@ -49,7 +49,7 @@ public final class TestReadWriteChart extends TestCase {
HSSFCell cell = row.createCell(1);
cell.setCellValue(22);
Sheet newSheet = workbook.getSheetAt(0).getSheet();
InternalSheet newSheet = workbook.getSheetAt(0).getSheet();
List records = newSheet.getRecords();
assertTrue(records.get(0) instanceof BOFRecord);