Code cleanup in hssf.model.Sheet. Minor re-formatting and compiler warning fixes.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@780792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bffe0432f6
commit
5fc9eb4718
@ -105,7 +105,7 @@ public final class Sheet implements Model {
|
|||||||
|
|
||||||
private static POILogger log = POILogFactory.getLogger(Sheet.class);
|
private static POILogger log = POILogFactory.getLogger(Sheet.class);
|
||||||
|
|
||||||
private List<RecordBase> records;
|
private List<RecordBase> _records;
|
||||||
protected PrintGridlinesRecord printGridlines = null;
|
protected PrintGridlinesRecord printGridlines = null;
|
||||||
protected GridsetRecord gridset = null;
|
protected GridsetRecord gridset = null;
|
||||||
private GutsRecord _gutsRecord;
|
private GutsRecord _gutsRecord;
|
||||||
@ -117,10 +117,10 @@ public final class Sheet implements Model {
|
|||||||
protected ProtectRecord protect = null;
|
protected ProtectRecord protect = null;
|
||||||
protected ObjectProtectRecord objprotect = null;
|
protected ObjectProtectRecord objprotect = null;
|
||||||
protected ScenarioProtectRecord scenprotect = null;
|
protected ScenarioProtectRecord scenprotect = null;
|
||||||
protected PasswordRecord password = null;
|
protected PasswordRecord _password = null;
|
||||||
|
|
||||||
protected WindowTwoRecord windowTwo = null;
|
protected WindowTwoRecord windowTwo = null;
|
||||||
protected SelectionRecord selection = null;
|
protected SelectionRecord _selection = null;
|
||||||
/** java object always present, but if empty no BIFF records are written */
|
/** java object always present, but if empty no BIFF records are written */
|
||||||
private final MergedCellsTable _mergedCellsTable;
|
private final MergedCellsTable _mergedCellsTable;
|
||||||
/** always present in this POI object, not always written to Excel file */
|
/** always present in this POI object, not always written to Excel file */
|
||||||
@ -164,7 +164,8 @@ public final class Sheet implements Model {
|
|||||||
_mergedCellsTable = new MergedCellsTable();
|
_mergedCellsTable = new MergedCellsTable();
|
||||||
RowRecordsAggregate rra = null;
|
RowRecordsAggregate rra = null;
|
||||||
|
|
||||||
records = new ArrayList<RecordBase>(128);
|
List<RecordBase> records = new ArrayList<RecordBase>(128);
|
||||||
|
_records = records; // needed here due to calls to findFirstRecordLocBySid before we're done
|
||||||
int dimsloc = -1;
|
int dimsloc = -1;
|
||||||
|
|
||||||
if (rs.peekNextSid() != BOFRecord.sid) {
|
if (rs.peekNextSid() != BOFRecord.sid) {
|
||||||
@ -292,7 +293,7 @@ public final class Sheet implements Model {
|
|||||||
}
|
}
|
||||||
else if ( recSid == SelectionRecord.sid )
|
else if ( recSid == SelectionRecord.sid )
|
||||||
{
|
{
|
||||||
selection = (SelectionRecord) rec;
|
_selection = (SelectionRecord) rec;
|
||||||
}
|
}
|
||||||
else if ( recSid == WindowTwoRecord.sid )
|
else if ( recSid == WindowTwoRecord.sid )
|
||||||
{
|
{
|
||||||
@ -312,7 +313,7 @@ public final class Sheet implements Model {
|
|||||||
}
|
}
|
||||||
else if ( recSid == PasswordRecord.sid )
|
else if ( recSid == PasswordRecord.sid )
|
||||||
{
|
{
|
||||||
password = (PasswordRecord) rec;
|
_password = (PasswordRecord) rec;
|
||||||
}
|
}
|
||||||
else if ( recSid == GutsRecord.sid )
|
else if ( recSid == GutsRecord.sid )
|
||||||
{
|
{
|
||||||
@ -377,9 +378,9 @@ public final class Sheet implements Model {
|
|||||||
* belongs to a sheet.
|
* belongs to a sheet.
|
||||||
*/
|
*/
|
||||||
public Sheet cloneSheet() {
|
public Sheet cloneSheet() {
|
||||||
List<RecordBase> clonedRecords = new ArrayList<RecordBase>(records.size());
|
List<RecordBase> clonedRecords = new ArrayList<RecordBase>(_records.size());
|
||||||
for (int i = 0; i < records.size(); i++) {
|
for (int i = 0; i < _records.size(); i++) {
|
||||||
RecordBase rb = records.get(i);
|
RecordBase rb = _records.get(i);
|
||||||
if (rb instanceof RecordAggregate) {
|
if (rb instanceof RecordAggregate) {
|
||||||
((RecordAggregate) rb).visitContainedRecords(new RecordCloner(clonedRecords));
|
((RecordAggregate) rb).visitContainedRecords(new RecordCloner(clonedRecords));
|
||||||
continue;
|
continue;
|
||||||
@ -402,7 +403,7 @@ public final class Sheet implements Model {
|
|||||||
}
|
}
|
||||||
private Sheet() {
|
private Sheet() {
|
||||||
_mergedCellsTable = new MergedCellsTable();
|
_mergedCellsTable = new MergedCellsTable();
|
||||||
records = new ArrayList<RecordBase>(32);
|
List<RecordBase> records = new ArrayList<RecordBase>(32);
|
||||||
|
|
||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log(POILogger.DEBUG, "Sheet createsheet from scratch called");
|
log.log(POILogger.DEBUG, "Sheet createsheet from scratch called");
|
||||||
@ -444,12 +445,13 @@ public final class Sheet implements Model {
|
|||||||
records.add(_rowsAggregate);
|
records.add(_rowsAggregate);
|
||||||
// 'Sheet View Settings'
|
// 'Sheet View Settings'
|
||||||
records.add(windowTwo = createWindowTwo());
|
records.add(windowTwo = createWindowTwo());
|
||||||
selection = createSelection();
|
_selection = createSelection();
|
||||||
records.add(selection);
|
records.add(_selection);
|
||||||
|
|
||||||
records.add(_mergedCellsTable); // MCT comes after 'Sheet View Settings'
|
records.add(_mergedCellsTable); // MCT comes after 'Sheet View Settings'
|
||||||
records.add(EOFRecord.instance);
|
records.add(EOFRecord.instance);
|
||||||
|
|
||||||
|
_records = records;
|
||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log(POILogger.DEBUG, "Sheet createsheet from scratch exit");
|
log.log(POILogger.DEBUG, "Sheet createsheet from scratch exit");
|
||||||
}
|
}
|
||||||
@ -491,8 +493,7 @@ public final class Sheet implements Model {
|
|||||||
return mrt.getNumberOfMergedRegions()-1;
|
return mrt.getNumberOfMergedRegions()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMergedRegion(int index)
|
public void removeMergedRegion(int index) {
|
||||||
{
|
|
||||||
//safety checks
|
//safety checks
|
||||||
MergedCellsTable mrt = getMergedRecords();
|
MergedCellsTable mrt = getMergedRecords();
|
||||||
if (index >= mrt.getNumberOfMergedRegions()) {
|
if (index >= mrt.getNumberOfMergedRegions()) {
|
||||||
@ -516,7 +517,7 @@ public final class Sheet implements Model {
|
|||||||
public ConditionalFormattingTable getConditionalFormattingTable() {
|
public ConditionalFormattingTable getConditionalFormattingTable() {
|
||||||
if (condFormatting == null) {
|
if (condFormatting == null) {
|
||||||
condFormatting = new ConditionalFormattingTable();
|
condFormatting = new ConditionalFormattingTable();
|
||||||
RecordOrderer.addNewSheetRecord(records, condFormatting);
|
RecordOrderer.addNewSheetRecord(_records, condFormatting);
|
||||||
}
|
}
|
||||||
return condFormatting;
|
return condFormatting;
|
||||||
}
|
}
|
||||||
@ -554,8 +555,8 @@ public final class Sheet implements Model {
|
|||||||
|
|
||||||
boolean haveSerializedIndex = false;
|
boolean haveSerializedIndex = false;
|
||||||
|
|
||||||
for (int k = 0; k < records.size(); k++) {
|
for (int k = 0; k < _records.size(); k++) {
|
||||||
RecordBase record = records.get(k);
|
RecordBase record = _records.get(k);
|
||||||
|
|
||||||
if (record instanceof RecordAggregate) {
|
if (record instanceof RecordAggregate) {
|
||||||
RecordAggregate agg = (RecordAggregate) record;
|
RecordAggregate agg = (RecordAggregate) record;
|
||||||
@ -596,8 +597,8 @@ public final class Sheet implements Model {
|
|||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
// start just after BOF record (INDEX is not present in this list)
|
// start just after BOF record (INDEX is not present in this list)
|
||||||
for (int j = bofRecordIndex + 1; j < records.size(); j++) {
|
for (int j = bofRecordIndex + 1; j < _records.size(); j++) {
|
||||||
RecordBase tmpRec = records.get(j);
|
RecordBase tmpRec = _records.get(j);
|
||||||
if (tmpRec instanceof RowRecordsAggregate) {
|
if (tmpRec instanceof RowRecordsAggregate) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -628,12 +629,10 @@ public final class Sheet implements Model {
|
|||||||
}
|
}
|
||||||
DimensionsRecord d = _dimensions;
|
DimensionsRecord d = _dimensions;
|
||||||
|
|
||||||
if (col.getColumn() > d.getLastCol())
|
if (col.getColumn() > d.getLastCol()) {
|
||||||
{
|
|
||||||
d.setLastCol(( short ) (col.getColumn() + 1));
|
d.setLastCol(( short ) (col.getColumn() + 1));
|
||||||
}
|
}
|
||||||
if (col.getColumn() < d.getFirstCol())
|
if (col.getColumn() < d.getFirstCol()) {
|
||||||
{
|
|
||||||
d.setFirstCol(col.getColumn());
|
d.setFirstCol(col.getColumn());
|
||||||
}
|
}
|
||||||
_rowsAggregate.insertCell(col);
|
_rowsAggregate.insertCell(col);
|
||||||
@ -690,18 +689,15 @@ public final class Sheet implements Model {
|
|||||||
* @param row the row record to be added
|
* @param row the row record to be added
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void addRow(RowRecord row)
|
public void addRow(RowRecord row) {
|
||||||
{
|
|
||||||
if (log.check( POILogger.DEBUG ))
|
if (log.check( POILogger.DEBUG ))
|
||||||
log.log(POILogger.DEBUG, "addRow ");
|
log.log(POILogger.DEBUG, "addRow ");
|
||||||
DimensionsRecord d = _dimensions;
|
DimensionsRecord d = _dimensions;
|
||||||
|
|
||||||
if (row.getRowNumber() >= d.getLastRow())
|
if (row.getRowNumber() >= d.getLastRow()) {
|
||||||
{
|
|
||||||
d.setLastRow(row.getRowNumber() + 1);
|
d.setLastRow(row.getRowNumber() + 1);
|
||||||
}
|
}
|
||||||
if (row.getRowNumber() < d.getFirstRow())
|
if (row.getRowNumber() < d.getFirstRow()) {
|
||||||
{
|
|
||||||
d.setFirstRow(row.getRowNumber());
|
d.setFirstRow(row.getRowNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,10 +897,11 @@ public final class Sheet implements Model {
|
|||||||
retval.setColLevelMax(( short ) 0);
|
retval.setColLevelMax(( short ) 0);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GutsRecord getGutsRecord() {
|
private GutsRecord getGutsRecord() {
|
||||||
if (_gutsRecord == null) {
|
if (_gutsRecord == null) {
|
||||||
GutsRecord result = createGuts();
|
GutsRecord result = createGuts();
|
||||||
RecordOrderer.addNewSheetRecord(records, result);
|
RecordOrderer.addNewSheetRecord(_records, result);
|
||||||
_gutsRecord = result;
|
_gutsRecord = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,17 +949,14 @@ public final class Sheet implements Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get whether gridlines are printed.
|
* @return <code>true</code> if gridlines are printed
|
||||||
* @return true if printed
|
|
||||||
*/
|
*/
|
||||||
|
public boolean isGridsPrinted() {
|
||||||
public boolean isGridsPrinted()
|
|
||||||
{
|
|
||||||
if (gridset == null) {
|
if (gridset == null) {
|
||||||
gridset = createGridset();
|
gridset = createGridset();
|
||||||
//Insert the newlycreated Gridset record at the end of the record (just before the EOF)
|
//Insert the newlycreated Gridset record at the end of the record (just before the EOF)
|
||||||
int loc = findFirstRecordLocBySid(EOFRecord.sid);
|
int loc = findFirstRecordLocBySid(EOFRecord.sid);
|
||||||
records.add(loc, gridset);
|
_records.add(loc, gridset);
|
||||||
}
|
}
|
||||||
return !gridset.getGridset();
|
return !gridset.getGridset();
|
||||||
}
|
}
|
||||||
@ -971,9 +965,7 @@ public final class Sheet implements Model {
|
|||||||
* set whether gridlines printed or not.
|
* set whether gridlines printed or not.
|
||||||
* @param value True if gridlines printed.
|
* @param value True if gridlines printed.
|
||||||
*/
|
*/
|
||||||
|
public void setGridsPrinted(boolean value) {
|
||||||
public void setGridsPrinted(boolean value)
|
|
||||||
{
|
|
||||||
gridset.setGridset(!value);
|
gridset.setGridset(!value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,9 +980,7 @@ public final class Sheet implements Model {
|
|||||||
/**
|
/**
|
||||||
* set the default row height for the sheet (if the rows do not define their own height)
|
* set the default row height for the sheet (if the rows do not define their own height)
|
||||||
*/
|
*/
|
||||||
|
public void setDefaultRowHeight(short dch) {
|
||||||
public void setDefaultRowHeight(short dch)
|
|
||||||
{
|
|
||||||
defaultrowheight.setRowHeight(dch);
|
defaultrowheight.setRowHeight(dch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,9 +988,7 @@ public final class Sheet implements Model {
|
|||||||
* get the default row height for the sheet (if the rows do not define their own height)
|
* get the default row height for the sheet (if the rows do not define their own height)
|
||||||
* @return default row height
|
* @return default row height
|
||||||
*/
|
*/
|
||||||
|
public short getDefaultRowHeight() {
|
||||||
public short getDefaultRowHeight()
|
|
||||||
{
|
|
||||||
return defaultrowheight.getRowHeight();
|
return defaultrowheight.getRowHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,7 +1000,6 @@ public final class Sheet implements Model {
|
|||||||
* @see #setColumnWidth(int, int)
|
* @see #setColumnWidth(int, int)
|
||||||
* @return column width in units of 1/256th of a character width
|
* @return column width in units of 1/256th of a character width
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int getColumnWidth(int columnIndex) {
|
public int getColumnWidth(int columnIndex) {
|
||||||
|
|
||||||
ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);
|
ColumnInfoRecord ci = _columnInfos.findColumnInfo(columnIndex);
|
||||||
@ -1159,15 +1146,12 @@ public final class Sheet implements Model {
|
|||||||
return new SelectionRecord(0, 0);
|
return new SelectionRecord(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getTopRow()
|
public short getTopRow() {
|
||||||
{
|
|
||||||
return (windowTwo==null) ? (short) 0 : windowTwo.getTopRow();
|
return (windowTwo==null) ? (short) 0 : windowTwo.getTopRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTopRow(short topRow)
|
public void setTopRow(short topRow) {
|
||||||
{
|
if (windowTwo!=null) {
|
||||||
if (windowTwo!=null)
|
|
||||||
{
|
|
||||||
windowTwo.setTopRow(topRow);
|
windowTwo.setTopRow(topRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1192,13 +1176,11 @@ public final class Sheet implements Model {
|
|||||||
* @see org.apache.poi.hssf.record.SelectionRecord
|
* @see org.apache.poi.hssf.record.SelectionRecord
|
||||||
* @return row the active row index
|
* @return row the active row index
|
||||||
*/
|
*/
|
||||||
public int getActiveCellRow()
|
public int getActiveCellRow() {
|
||||||
{
|
if (_selection == null) {
|
||||||
if (selection == null)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return selection.getActiveCellRow();
|
return _selection.getActiveCellRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1207,12 +1189,10 @@ public final class Sheet implements Model {
|
|||||||
* @param row the row index
|
* @param row the row index
|
||||||
* @see org.apache.poi.hssf.record.SelectionRecord
|
* @see org.apache.poi.hssf.record.SelectionRecord
|
||||||
*/
|
*/
|
||||||
public void setActiveCellRow(int row)
|
public void setActiveCellRow(int row) {
|
||||||
{
|
|
||||||
//shouldn't have a sheet w/o a SelectionRecord, but best to guard anyway
|
//shouldn't have a sheet w/o a SelectionRecord, but best to guard anyway
|
||||||
if (selection != null)
|
if (_selection != null) {
|
||||||
{
|
_selection.setActiveCellRow(row);
|
||||||
selection.setActiveCellRow(row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1221,10 +1201,10 @@ public final class Sheet implements Model {
|
|||||||
* @return column of the active cell
|
* @return column of the active cell
|
||||||
*/
|
*/
|
||||||
public short getActiveCellCol() {
|
public short getActiveCellCol() {
|
||||||
if (selection == null) {
|
if (_selection == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (short)selection.getActiveCellCol();
|
return (short)_selection.getActiveCellCol();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1233,24 +1213,21 @@ public final class Sheet implements Model {
|
|||||||
* @param col the column index
|
* @param col the column index
|
||||||
* @see org.apache.poi.hssf.record.SelectionRecord
|
* @see org.apache.poi.hssf.record.SelectionRecord
|
||||||
*/
|
*/
|
||||||
public void setActiveCellCol(short col)
|
public void setActiveCellCol(short col) {
|
||||||
{
|
|
||||||
//shouldn't have a sheet w/o a SelectionRecord, but best to guard anyway
|
//shouldn't have a sheet w/o a SelectionRecord, but best to guard anyway
|
||||||
if (selection != null)
|
if (_selection != null)
|
||||||
{
|
{
|
||||||
selection.setActiveCellCol(col);
|
_selection.setActiveCellCol(col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RecordBase> getRecords()
|
public List<RecordBase> getRecords() {
|
||||||
{
|
return _records;
|
||||||
return records;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the gridset record for this sheet.
|
* Gets the gridset record for this sheet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public GridsetRecord getGridsetRecord()
|
public GridsetRecord getGridsetRecord()
|
||||||
{
|
{
|
||||||
return gridset;
|
return gridset;
|
||||||
@ -1259,14 +1236,12 @@ public final class Sheet implements Model {
|
|||||||
/**
|
/**
|
||||||
* Returns the first occurrence of a record matching a particular sid.
|
* Returns the first occurrence of a record matching a particular sid.
|
||||||
*/
|
*/
|
||||||
|
public Record findFirstRecordBySid(short sid) {
|
||||||
public Record findFirstRecordBySid(short sid)
|
|
||||||
{
|
|
||||||
int ix = findFirstRecordLocBySid(sid);
|
int ix = findFirstRecordLocBySid(sid);
|
||||||
if (ix < 0) {
|
if (ix < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (Record) records.get(ix);
|
return (Record) _records.get(ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1275,20 +1250,15 @@ public final class Sheet implements Model {
|
|||||||
*
|
*
|
||||||
* @param sclRecord The record to set.
|
* @param sclRecord The record to set.
|
||||||
*/
|
*/
|
||||||
public void setSCLRecord(SCLRecord sclRecord)
|
public void setSCLRecord(SCLRecord sclRecord) {
|
||||||
{
|
|
||||||
int oldRecordLoc = findFirstRecordLocBySid(SCLRecord.sid);
|
int oldRecordLoc = findFirstRecordLocBySid(SCLRecord.sid);
|
||||||
if (oldRecordLoc == -1)
|
if (oldRecordLoc == -1) {
|
||||||
{
|
|
||||||
// Insert it after the window record
|
// Insert it after the window record
|
||||||
int windowRecordLoc = findFirstRecordLocBySid(WindowTwoRecord.sid);
|
int windowRecordLoc = findFirstRecordLocBySid(WindowTwoRecord.sid);
|
||||||
records.add(windowRecordLoc+1, sclRecord);
|
_records.add(windowRecordLoc+1, sclRecord);
|
||||||
|
} else {
|
||||||
|
_records.set(oldRecordLoc, sclRecord);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
records.set(oldRecordLoc, sclRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1299,9 +1269,9 @@ public final class Sheet implements Model {
|
|||||||
* is made.
|
* is made.
|
||||||
*/
|
*/
|
||||||
public int findFirstRecordLocBySid( short sid ) { // TODO - remove this method
|
public int findFirstRecordLocBySid( short sid ) { // TODO - remove this method
|
||||||
int max = records.size();
|
int max = _records.size();
|
||||||
for (int i=0; i< max; i++) {
|
for (int i=0; i< max; i++) {
|
||||||
Object rb = records.get(i);
|
Object rb = _records.get(i);
|
||||||
if (!(rb instanceof Record)) {
|
if (!(rb instanceof Record)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1350,11 +1320,10 @@ public final class Sheet implements Model {
|
|||||||
* @param topRow Top row visible in bottom pane
|
* @param topRow Top row visible in bottom pane
|
||||||
* @param leftmostColumn Left column visible in right pane.
|
* @param leftmostColumn Left column visible in right pane.
|
||||||
*/
|
*/
|
||||||
public void createFreezePane(int colSplit, int rowSplit, int topRow, int leftmostColumn )
|
public void createFreezePane(int colSplit, int rowSplit, int topRow, int leftmostColumn) {
|
||||||
{
|
|
||||||
int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
|
int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
|
||||||
if (paneLoc != -1)
|
if (paneLoc != -1)
|
||||||
records.remove(paneLoc);
|
_records.remove(paneLoc);
|
||||||
|
|
||||||
int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
|
int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
|
||||||
PaneRecord pane = new PaneRecord();
|
PaneRecord pane = new PaneRecord();
|
||||||
@ -1362,21 +1331,16 @@ public final class Sheet implements Model {
|
|||||||
pane.setY((short)rowSplit);
|
pane.setY((short)rowSplit);
|
||||||
pane.setTopRow((short) topRow);
|
pane.setTopRow((short) topRow);
|
||||||
pane.setLeftColumn((short) leftmostColumn);
|
pane.setLeftColumn((short) leftmostColumn);
|
||||||
if (rowSplit == 0)
|
if (rowSplit == 0) {
|
||||||
{
|
|
||||||
pane.setTopRow((short)0);
|
pane.setTopRow((short)0);
|
||||||
pane.setActivePane((short)1);
|
pane.setActivePane((short)1);
|
||||||
}
|
} else if (colSplit == 0) {
|
||||||
else if (colSplit == 0)
|
|
||||||
{
|
|
||||||
pane.setLeftColumn((short)64);
|
pane.setLeftColumn((short)64);
|
||||||
pane.setActivePane((short)2);
|
pane.setActivePane((short)2);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
pane.setActivePane((short)0);
|
pane.setActivePane((short)0);
|
||||||
}
|
}
|
||||||
records.add(loc+1, pane);
|
_records.add(loc+1, pane);
|
||||||
|
|
||||||
windowTwo.setFreezePanes(true);
|
windowTwo.setFreezePanes(true);
|
||||||
windowTwo.setFreezePanesNoSplit(true);
|
windowTwo.setFreezePanesNoSplit(true);
|
||||||
@ -1399,11 +1363,10 @@ public final class Sheet implements Model {
|
|||||||
* @see #PANE_UPPER_LEFT
|
* @see #PANE_UPPER_LEFT
|
||||||
* @see #PANE_UPPER_RIGHT
|
* @see #PANE_UPPER_RIGHT
|
||||||
*/
|
*/
|
||||||
public void createSplitPane(int xSplitPos, int ySplitPos, int topRow, int leftmostColumn, int activePane )
|
public void createSplitPane(int xSplitPos, int ySplitPos, int topRow, int leftmostColumn, int activePane) {
|
||||||
{
|
|
||||||
int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
|
int paneLoc = findFirstRecordLocBySid(PaneRecord.sid);
|
||||||
if (paneLoc != -1)
|
if (paneLoc != -1)
|
||||||
records.remove(paneLoc);
|
_records.remove(paneLoc);
|
||||||
|
|
||||||
int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
|
int loc = findFirstRecordLocBySid(WindowTwoRecord.sid);
|
||||||
PaneRecord r = new PaneRecord();
|
PaneRecord r = new PaneRecord();
|
||||||
@ -1412,7 +1375,7 @@ public final class Sheet implements Model {
|
|||||||
r.setTopRow((short) topRow);
|
r.setTopRow((short) topRow);
|
||||||
r.setLeftColumn((short) leftmostColumn);
|
r.setLeftColumn((short) leftmostColumn);
|
||||||
r.setActivePane((short) activePane);
|
r.setActivePane((short) activePane);
|
||||||
records.add(loc+1, r);
|
_records.add(loc+1, r);
|
||||||
|
|
||||||
windowTwo.setFreezePanes(false);
|
windowTwo.setFreezePanes(false);
|
||||||
windowTwo.setFreezePanesNoSplit(false);
|
windowTwo.setFreezePanesNoSplit(false);
|
||||||
@ -1424,7 +1387,7 @@ public final class Sheet implements Model {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the information regarding the currently configured pane (split or freeze).
|
* Returns the information regarding the currently configured pane (split or freeze).
|
||||||
* @return null if no pane configured, or the pane information.
|
* @return <code>null</code> if no pane configured, or the pane information.
|
||||||
*/
|
*/
|
||||||
public PaneInformation getPaneInformation() {
|
public PaneInformation getPaneInformation() {
|
||||||
PaneRecord rec = (PaneRecord)findFirstRecordBySid(PaneRecord.sid);
|
PaneRecord rec = (PaneRecord)findFirstRecordBySid(PaneRecord.sid);
|
||||||
@ -1435,14 +1398,12 @@ public final class Sheet implements Model {
|
|||||||
rec.getLeftColumn(), (byte)rec.getActivePane(), windowTwo.getFreezePanes());
|
rec.getLeftColumn(), (byte)rec.getActivePane(), windowTwo.getFreezePanes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectionRecord getSelection()
|
public SelectionRecord getSelection() {
|
||||||
{
|
return _selection;
|
||||||
return selection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection( SelectionRecord selection )
|
public void setSelection( SelectionRecord selection) {
|
||||||
{
|
_selection = selection;
|
||||||
this.selection = selection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1469,32 +1430,30 @@ public final class Sheet implements Model {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the ProtectRecord.
|
/**
|
||||||
* If one is not contained in the sheet, then one is created.
|
* @return the ProtectRecord. If one is not contained in the sheet, then one is created.
|
||||||
*/
|
*/
|
||||||
public ProtectRecord getProtect()
|
public ProtectRecord getProtect() {
|
||||||
{
|
|
||||||
if (protect == null) {
|
if (protect == null) {
|
||||||
protect = new ProtectRecord(false);
|
protect = new ProtectRecord(false);
|
||||||
// Insert the newly created protect record just before DefaultColWidthRecord
|
// Insert the newly created protect record just before DefaultColWidthRecord
|
||||||
int loc = findFirstRecordLocBySid(DefaultColWidthRecord.sid);
|
int loc = findFirstRecordLocBySid(DefaultColWidthRecord.sid);
|
||||||
records.add(loc, protect);
|
_records.add(loc, protect);
|
||||||
}
|
}
|
||||||
return protect;
|
return protect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the PasswordRecord.
|
/**
|
||||||
* If one is not contained in the sheet, then one is created.
|
* @return the PasswordRecord. If one is not contained in the sheet, then one is created.
|
||||||
*/
|
*/
|
||||||
public PasswordRecord getPassword()
|
public PasswordRecord getPassword() {
|
||||||
{
|
if (_password == null) {
|
||||||
if (password == null) {
|
_password = createPassword();
|
||||||
password = createPassword();
|
|
||||||
//Insert the newly created password record at the end of the record (just before the EOF)
|
//Insert the newly created password record at the end of the record (just before the EOF)
|
||||||
int loc = findFirstRecordLocBySid(EOFRecord.sid);
|
int loc = findFirstRecordLocBySid(EOFRecord.sid);
|
||||||
records.add(loc, password);
|
_records.add(loc, _password);
|
||||||
}
|
}
|
||||||
return password;
|
return _password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1504,8 +1463,6 @@ public final class Sheet implements Model {
|
|||||||
return new PasswordRecord(0x0000);
|
return new PasswordRecord(0x0000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the gridlines are shown in a viewer.
|
* Sets whether the gridlines are shown in a viewer.
|
||||||
* @param show whether to show gridlines or not
|
* @param show whether to show gridlines or not
|
||||||
@ -1515,8 +1472,7 @@ public final class Sheet implements Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if gridlines are displayed.
|
* @return <code>true</code> if gridlines are displayed
|
||||||
* @return whether gridlines are displayed
|
|
||||||
*/
|
*/
|
||||||
public boolean isDisplayGridlines() {
|
public boolean isDisplayGridlines() {
|
||||||
return windowTwo.getDisplayGridlines();
|
return windowTwo.getDisplayGridlines();
|
||||||
@ -1577,12 +1533,10 @@ public final class Sheet implements Model {
|
|||||||
* @param drawingManager The DrawingManager2 for our workbook
|
* @param drawingManager The DrawingManager2 for our workbook
|
||||||
* @param createIfMissing Should one be created if missing?
|
* @param createIfMissing Should one be created if missing?
|
||||||
*/
|
*/
|
||||||
public int aggregateDrawingRecords(DrawingManager2 drawingManager, boolean createIfMissing)
|
public int aggregateDrawingRecords(DrawingManager2 drawingManager, boolean createIfMissing) {
|
||||||
{
|
|
||||||
int loc = findFirstRecordLocBySid(DrawingRecord.sid);
|
int loc = findFirstRecordLocBySid(DrawingRecord.sid);
|
||||||
boolean noDrawingRecordsFound = (loc == -1);
|
boolean noDrawingRecordsFound = (loc == -1);
|
||||||
if (noDrawingRecordsFound)
|
if (noDrawingRecordsFound) {
|
||||||
{
|
|
||||||
if(!createIfMissing) {
|
if(!createIfMissing) {
|
||||||
// None found, and not allowed to add in
|
// None found, and not allowed to add in
|
||||||
return -1;
|
return -1;
|
||||||
@ -1590,19 +1544,14 @@ public final class Sheet implements Model {
|
|||||||
|
|
||||||
EscherAggregate aggregate = new EscherAggregate( drawingManager );
|
EscherAggregate aggregate = new EscherAggregate( drawingManager );
|
||||||
loc = findFirstRecordLocBySid(EscherAggregate.sid);
|
loc = findFirstRecordLocBySid(EscherAggregate.sid);
|
||||||
if (loc == -1)
|
if (loc == -1) {
|
||||||
{
|
|
||||||
loc = findFirstRecordLocBySid( WindowTwoRecord.sid );
|
loc = findFirstRecordLocBySid( WindowTwoRecord.sid );
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
getRecords().remove(loc);
|
getRecords().remove(loc);
|
||||||
}
|
}
|
||||||
getRecords().add( loc, aggregate );
|
getRecords().add( loc, aggregate );
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
List<RecordBase> records = getRecords();
|
List<RecordBase> records = getRecords();
|
||||||
EscherAggregate r = EscherAggregate.createAggregate( records, loc, drawingManager );
|
EscherAggregate r = EscherAggregate.createAggregate( records, loc, drawingManager );
|
||||||
int startloc = loc;
|
int startloc = loc;
|
||||||
@ -1619,20 +1568,18 @@ public final class Sheet implements Model {
|
|||||||
|
|
||||||
return startloc;
|
return startloc;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform any work necessary before the sheet is about to be serialized.
|
* Perform any work necessary before the sheet is about to be serialized.
|
||||||
* For instance the escher aggregates size needs to be calculated before
|
* For instance the escher aggregates size needs to be calculated before
|
||||||
* serialization so that the dgg record (which occurs first) can be written.
|
* serialization so that the dgg record (which occurs first) can be written.
|
||||||
*/
|
*/
|
||||||
public void preSerialize()
|
public void preSerialize() {
|
||||||
{
|
for (RecordBase r: getRecords()) {
|
||||||
for ( Iterator iterator = getRecords().iterator(); iterator.hasNext(); )
|
if (r instanceof EscherAggregate) {
|
||||||
{
|
// Trigger flattening of user model and corresponding update of dgg record.
|
||||||
RecordBase r = (RecordBase) iterator.next();
|
r.getRecordSize();
|
||||||
if (r instanceof EscherAggregate)
|
}
|
||||||
r.getRecordSize(); // Trigger flatterning of user model and corresponding update of dgg record.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1640,7 +1587,7 @@ public final class Sheet implements Model {
|
|||||||
public PageSettingsBlock getPageSettings() {
|
public PageSettingsBlock getPageSettings() {
|
||||||
if (_psBlock == null) {
|
if (_psBlock == null) {
|
||||||
_psBlock = new PageSettingsBlock();
|
_psBlock = new PageSettingsBlock();
|
||||||
RecordOrderer.addNewSheetRecord(records, _psBlock);
|
RecordOrderer.addNewSheetRecord(_records, _psBlock);
|
||||||
}
|
}
|
||||||
return _psBlock;
|
return _psBlock;
|
||||||
}
|
}
|
||||||
@ -1668,18 +1615,18 @@ public final class Sheet implements Model {
|
|||||||
prec.setProtect(true);
|
prec.setProtect(true);
|
||||||
pass.setPassword(PasswordRecord.hashPassword(password));
|
pass.setPassword(PasswordRecord.hashPassword(password));
|
||||||
if((objprotect == null && objects) || (scenprotect != null && scenarios)) {
|
if((objprotect == null && objects) || (scenprotect != null && scenarios)) {
|
||||||
protIdx = records.indexOf( protect );
|
protIdx = _records.indexOf( protect );
|
||||||
}
|
}
|
||||||
if(objprotect == null && objects) {
|
if(objprotect == null && objects) {
|
||||||
ObjectProtectRecord rec = createObjectProtect();
|
ObjectProtectRecord rec = createObjectProtect();
|
||||||
rec.setProtect(true);
|
rec.setProtect(true);
|
||||||
records.add(protIdx+1,rec);
|
_records.add(protIdx+1,rec);
|
||||||
objprotect = rec;
|
objprotect = rec;
|
||||||
}
|
}
|
||||||
if(scenprotect == null && scenarios) {
|
if(scenprotect == null && scenarios) {
|
||||||
ScenarioProtectRecord srec = createScenarioProtect();
|
ScenarioProtectRecord srec = createScenarioProtect();
|
||||||
srec.setProtect(true);
|
srec.setProtect(true);
|
||||||
records.add(protIdx+2,srec);
|
_records.add(protIdx+2,srec);
|
||||||
scenprotect = srec;
|
scenprotect = srec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1737,12 +1684,10 @@ public final class Sheet implements Model {
|
|||||||
recalcRowGutter();
|
recalcRowGutter();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recalcRowGutter()
|
private void recalcRowGutter() {
|
||||||
{
|
|
||||||
int maxLevel = 0;
|
int maxLevel = 0;
|
||||||
Iterator iterator = _rowsAggregate.getIterator();
|
Iterator iterator = _rowsAggregate.getIterator();
|
||||||
while ( iterator.hasNext() )
|
while (iterator.hasNext()) {
|
||||||
{
|
|
||||||
RowRecord rowRecord = (RowRecord) iterator.next();
|
RowRecord rowRecord = (RowRecord) iterator.next();
|
||||||
maxLevel = Math.max(rowRecord.getOutlineLevel(), maxLevel);
|
maxLevel = Math.max(rowRecord.getOutlineLevel(), maxLevel);
|
||||||
}
|
}
|
||||||
@ -1757,7 +1702,7 @@ public final class Sheet implements Model {
|
|||||||
public DataValidityTable getOrCreateDataValidityTable() {
|
public DataValidityTable getOrCreateDataValidityTable() {
|
||||||
if (_dataValidityTable == null) {
|
if (_dataValidityTable == null) {
|
||||||
DataValidityTable result = new DataValidityTable();
|
DataValidityTable result = new DataValidityTable();
|
||||||
RecordOrderer.addNewSheetRecord(records, result);
|
RecordOrderer.addNewSheetRecord(_records, result);
|
||||||
_dataValidityTable = result;
|
_dataValidityTable = result;
|
||||||
}
|
}
|
||||||
return _dataValidityTable;
|
return _dataValidityTable;
|
||||||
@ -1768,8 +1713,8 @@ public final class Sheet implements Model {
|
|||||||
*/
|
*/
|
||||||
public NoteRecord[] getNoteRecords() {
|
public NoteRecord[] getNoteRecords() {
|
||||||
List<NoteRecord> temp = new ArrayList<NoteRecord>();
|
List<NoteRecord> temp = new ArrayList<NoteRecord>();
|
||||||
for(int i=records.size()-1; i>=0; i--) {
|
for(int i=_records.size()-1; i>=0; i--) {
|
||||||
RecordBase rec = records.get(i);
|
RecordBase rec = _records.get(i);
|
||||||
if (rec instanceof NoteRecord) {
|
if (rec instanceof NoteRecord) {
|
||||||
temp.add((NoteRecord) rec);
|
temp.add((NoteRecord) rec);
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,7 @@ public final class TestSheet extends TestCase {
|
|||||||
try {
|
try {
|
||||||
sheet = createSheet(inRecs);
|
sheet = createSheet(inRecs);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
if (e.getMessage().equals("DimensionsRecord was not found")) {
|
if ("DimensionsRecord was not found".equals(e.getMessage())) {
|
||||||
throw new AssertionFailedError("Identified bug 46206");
|
throw new AssertionFailedError("Identified bug 46206");
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
Loading…
Reference in New Issue
Block a user