use of org.apache.poi.hssf.record.CountryRecord in project poi by apache.
the class InternalWorkbook method createCountry.
/**
* Creates the Country record with the default country set to 1
* and current country set to 7 in case of russian locale ("ru_RU") and 1 otherwise
*/
private static CountryRecord createCountry() {
CountryRecord retval = new CountryRecord();
retval.setDefaultCountry((short) 1);
// from Russia with love ;)
if ("ru_RU".equals(LocaleUtil.getUserLocale().toString())) {
retval.setCurrentCountry((short) 7);
} else {
retval.setCurrentCountry((short) 1);
}
return retval;
}
use of org.apache.poi.hssf.record.CountryRecord in project poi by apache.
the class TestLinkTable method testAddNameX.
public void testAddNameX() {
WorkbookRecordList wrl = new WorkbookRecordList();
wrl.add(0, new BOFRecord());
wrl.add(1, new CountryRecord());
wrl.add(2, EOFRecord.instance);
int numberOfSheets = 3;
LinkTable tbl = new LinkTable(numberOfSheets, wrl);
// creation of a new LinkTable insert two new records: SupBookRecord followed by ExternSheetRecord
// assure they are in place:
// [BOFRecord]
// [CountryRecord]
// [SUPBOOK Internal References nSheets= 3]
// [EXTERNSHEET]
// [EOFRecord]
assertEquals(5, wrl.getRecords().size());
assertTrue(wrl.get(2) instanceof SupBookRecord);
SupBookRecord sup1 = (SupBookRecord) wrl.get(2);
assertEquals(numberOfSheets, sup1.getNumberOfSheets());
assertTrue(wrl.get(3) instanceof ExternSheetRecord);
ExternSheetRecord extSheet = (ExternSheetRecord) wrl.get(3);
assertEquals(0, extSheet.getNumOfRefs());
assertNull(tbl.getNameXPtg("ISODD", -1));
//still have five records
assertEquals(5, wrl.getRecords().size());
// adds two new rercords
NameXPtg namex1 = tbl.addNameXPtg("ISODD");
assertEquals(0, namex1.getSheetRefIndex());
assertEquals(0, namex1.getNameIndex());
assertEquals(namex1.toString(), tbl.getNameXPtg("ISODD", -1).toString());
// Can only find on the right sheet ref, if restricting
assertEquals(namex1.toString(), tbl.getNameXPtg("ISODD", 0).toString());
assertNull(tbl.getNameXPtg("ISODD", 1));
assertNull(tbl.getNameXPtg("ISODD", 2));
// assure they are in place:
// [BOFRecord]
// [CountryRecord]
// [SUPBOOK Internal References nSheets= 3]
// [SUPBOOK Add-In Functions nSheets= 1]
// [EXTERNALNAME .name = ISODD]
// [EXTERNSHEET]
// [EOFRecord]
assertEquals(7, wrl.getRecords().size());
assertTrue(wrl.get(3) instanceof SupBookRecord);
SupBookRecord sup2 = (SupBookRecord) wrl.get(3);
assertTrue(sup2.isAddInFunctions());
assertTrue(wrl.get(4) instanceof ExternalNameRecord);
ExternalNameRecord ext1 = (ExternalNameRecord) wrl.get(4);
assertEquals("ISODD", ext1.getText());
assertTrue(wrl.get(5) instanceof ExternSheetRecord);
assertEquals(1, extSheet.getNumOfRefs());
//check that
assertEquals(0, tbl.resolveNameXIx(namex1.getSheetRefIndex(), namex1.getNameIndex()));
assertEquals("ISODD", tbl.resolveNameXText(namex1.getSheetRefIndex(), namex1.getNameIndex(), null));
assertNull(tbl.getNameXPtg("ISEVEN", -1));
// adds two new rercords
NameXPtg namex2 = tbl.addNameXPtg("ISEVEN");
assertEquals(0, namex2.getSheetRefIndex());
// name index increased by one
assertEquals(1, namex2.getNameIndex());
assertEquals(namex2.toString(), tbl.getNameXPtg("ISEVEN", -1).toString());
assertEquals(8, wrl.getRecords().size());
// assure they are in place:
// [BOFRecord]
// [CountryRecord]
// [SUPBOOK Internal References nSheets= 3]
// [SUPBOOK Add-In Functions nSheets= 1]
// [EXTERNALNAME .name = ISODD]
// [EXTERNALNAME .name = ISEVEN]
// [EXTERNSHEET]
// [EOFRecord]
assertTrue(wrl.get(3) instanceof SupBookRecord);
assertTrue(wrl.get(4) instanceof ExternalNameRecord);
assertTrue(wrl.get(5) instanceof ExternalNameRecord);
assertEquals("ISODD", ((ExternalNameRecord) wrl.get(4)).getText());
assertEquals("ISEVEN", ((ExternalNameRecord) wrl.get(5)).getText());
assertTrue(wrl.get(6) instanceof ExternSheetRecord);
assertTrue(wrl.get(7) instanceof EOFRecord);
assertEquals(0, tbl.resolveNameXIx(namex2.getSheetRefIndex(), namex2.getNameIndex()));
assertEquals("ISEVEN", tbl.resolveNameXText(namex2.getSheetRefIndex(), namex2.getNameIndex(), null));
}
Aggregations