use of org.apache.poi.hssf.record.WindowOneRecord in project poi by apache.
the class InternalWorkbook method createWindowOne.
/**
* creates the WindowOne record with the following magic values: <P>
* horizontal hold - 0x168 <P>
* vertical hold - 0x10e <P>
* width - 0x3a5c <P>
* height - 0x23be <P>
* options - 0x38 <P>
* selected tab - 0 <P>
* displayed tab - 0 <P>
* num selected tab- 0 <P>
* tab width ratio - 0x258 <P>
*/
private static WindowOneRecord createWindowOne() {
WindowOneRecord retval = new WindowOneRecord();
retval.setHorizontalHold((short) 0x168);
retval.setVerticalHold((short) 0x10e);
retval.setWidth((short) 0x3a5c);
retval.setHeight((short) 0x23be);
retval.setOptions((short) 0x38);
retval.setActiveSheetIndex(0x0);
retval.setFirstVisibleTab(0x0);
retval.setNumSelectedTabs((short) 1);
retval.setTabWidthRatio((short) 0x258);
return retval;
}
use of org.apache.poi.hssf.record.WindowOneRecord in project poi by apache.
the class InternalWorkbook method createWorkbook.
/**
* read support for low level
* API. Pass in an array of Record objects, A Workbook
* object is constructed and passed back with all of its initialization set
* to the passed in records and references to those records held. Unlike Sheet
* workbook does not use an offset (its assumed to be 0) since its first in a file.
* If you need an offset then construct a new array with a 0 offset or write your
* own ;-p.
*
* @param recs an array of Record objects
* @return Workbook object
*/
public static InternalWorkbook createWorkbook(List<Record> recs) {
LOG.log(DEBUG, "Workbook (readfile) created with reclen=", recs.size());
InternalWorkbook retval = new InternalWorkbook();
List<Record> records = new ArrayList<Record>(recs.size() / 3);
retval.records.setRecords(records);
boolean eofPassed = false;
for (int k = 0; k < recs.size(); k++) {
Record rec = recs.get(k);
String logObj;
switch(rec.getSid()) {
case EOFRecord.sid:
logObj = "workbook eof";
break;
case BoundSheetRecord.sid:
logObj = "boundsheet";
retval.boundsheets.add((BoundSheetRecord) rec);
retval.records.setBspos(k);
break;
case SSTRecord.sid:
logObj = "sst";
retval.sst = (SSTRecord) rec;
break;
case FontRecord.sid:
logObj = "font";
retval.records.setFontpos(k);
retval.numfonts++;
break;
case ExtendedFormatRecord.sid:
logObj = "XF";
retval.records.setXfpos(k);
retval.numxfs++;
break;
case TabIdRecord.sid:
logObj = "tabid";
retval.records.setTabpos(k);
break;
case ProtectRecord.sid:
logObj = "protect";
retval.records.setProtpos(k);
break;
case BackupRecord.sid:
logObj = "backup";
retval.records.setBackuppos(k);
break;
case ExternSheetRecord.sid:
throw new RecordFormatException("Extern sheet is part of LinkTable");
case NameRecord.sid:
case SupBookRecord.sid:
// LinkTable can start with either of these
LOG.log(DEBUG, "found SupBook record at " + k);
retval.linkTable = new LinkTable(recs, k, retval.records, retval.commentRecords);
k += retval.linkTable.getRecordCount() - 1;
continue;
case FormatRecord.sid:
logObj = "format";
FormatRecord fr = (FormatRecord) rec;
retval.formats.add(fr);
retval.maxformatid = retval.maxformatid >= fr.getIndexCode() ? retval.maxformatid : fr.getIndexCode();
break;
case DateWindow1904Record.sid:
logObj = "datewindow1904";
retval.uses1904datewindowing = ((DateWindow1904Record) rec).getWindowing() == 1;
break;
case PaletteRecord.sid:
logObj = "palette";
retval.records.setPalettepos(k);
break;
case WindowOneRecord.sid:
logObj = "WindowOneRecord";
retval.windowOne = (WindowOneRecord) rec;
break;
case WriteAccessRecord.sid:
logObj = "WriteAccess";
retval.writeAccess = (WriteAccessRecord) rec;
break;
case WriteProtectRecord.sid:
logObj = "WriteProtect";
retval.writeProtect = (WriteProtectRecord) rec;
break;
case FileSharingRecord.sid:
logObj = "FileSharing";
retval.fileShare = (FileSharingRecord) rec;
break;
case NameCommentRecord.sid:
logObj = "NameComment";
final NameCommentRecord ncr = (NameCommentRecord) rec;
retval.commentRecords.put(ncr.getNameText(), ncr);
break;
case HyperlinkRecord.sid:
// Look for other interesting values that follow the EOFRecord
logObj = "Hyperlink";
retval.hyperlinks.add((HyperlinkRecord) rec);
break;
default:
logObj = "(sid=" + rec.getSid() + ")";
break;
}
if (!eofPassed) {
records.add(rec);
}
LOG.log(DEBUG, "found " + logObj + " record at " + k);
if (rec.getSid() == EOFRecord.sid) {
eofPassed = true;
}
}
if (retval.windowOne == null) {
retval.windowOne = createWindowOne();
}
LOG.log(DEBUG, "exit create workbook from existing file function");
return retval;
}
use of org.apache.poi.hssf.record.WindowOneRecord in project poi by apache.
the class TestHSSFWorkbook method hidden.
/**
* Tests for {@link HSSFWorkbook#isHidden()} etc
* @throws IOException
*/
@Test
public void hidden() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
WindowOneRecord w1 = wb.getWorkbook().getWindowOne();
assertEquals(false, wb.isHidden());
assertEquals(false, w1.getHidden());
wb.setHidden(true);
assertEquals(true, wb.isHidden());
assertEquals(true, w1.getHidden());
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
w1 = wbBack.getWorkbook().getWindowOne();
wbBack.setHidden(true);
assertEquals(true, wbBack.isHidden());
assertEquals(true, w1.getHidden());
wbBack.setHidden(false);
assertEquals(false, wbBack.isHidden());
assertEquals(false, w1.getHidden());
wbBack.close();
wb.close();
}
Aggregations