use of org.apache.poi.hssf.record.ProtectRecord in project poi by apache.
the class WorksheetProtectionBlock method protectSheet.
/**
* protect a spreadsheet with a password (not encrypted, just sets protect
* flags and the password.
*
* @param password to set. Pass <code>null</code> to remove all protection
* @param shouldProtectObjects are protected
* @param shouldProtectScenarios are protected
*/
public void protectSheet(String password, boolean shouldProtectObjects, boolean shouldProtectScenarios) {
if (password == null) {
_passwordRecord = null;
_protectRecord = null;
_objectProtectRecord = null;
_scenarioProtectRecord = null;
return;
}
ProtectRecord prec = getProtect();
PasswordRecord pass = getPassword();
prec.setProtect(true);
pass.setPassword((short) CryptoFunctions.createXorVerifier1(password));
if (_objectProtectRecord == null && shouldProtectObjects) {
ObjectProtectRecord rec = createObjectProtect();
rec.setProtect(true);
_objectProtectRecord = rec;
}
if (_scenarioProtectRecord == null && shouldProtectScenarios) {
ScenarioProtectRecord srec = createScenarioProtect();
srec.setProtect(true);
_scenarioProtectRecord = srec;
}
}
use of org.apache.poi.hssf.record.ProtectRecord in project poi by apache.
the class HSSFChart method createBarChart.
/**
* Creates a bar chart. API needs some work. :)
* <p>
* NOTE: Does not yet work... checking it in just so others
* can take a look.
*/
public void createBarChart(HSSFWorkbook workbook, HSSFSheet parentSheet) {
List<Record> records = new ArrayList<Record>();
records.add(createMSDrawingObjectRecord());
records.add(createOBJRecord());
records.add(createBOFRecord());
records.add(new HeaderRecord(""));
records.add(new FooterRecord(""));
records.add(createHCenterRecord());
records.add(createVCenterRecord());
records.add(createPrintSetupRecord());
// unknown 33
records.add(createFontBasisRecord1());
records.add(createFontBasisRecord2());
records.add(new ProtectRecord(false));
records.add(createUnitsRecord());
records.add(createChartRecord(0, 0, 30434904, 19031616));
records.add(createBeginRecord());
records.add(createSCLRecord((short) 1, (short) 1));
records.add(createPlotGrowthRecord(65536, 65536));
records.add(createFrameRecord1());
records.add(createBeginRecord());
records.add(createLineFormatRecord(true));
records.add(createAreaFormatRecord1());
records.add(createEndRecord());
records.add(createSeriesRecord());
records.add(createBeginRecord());
records.add(createTitleLinkedDataRecord());
records.add(createValuesLinkedDataRecord());
records.add(createCategoriesLinkedDataRecord());
records.add(createDataFormatRecord());
// records.add(createBeginRecord());
// unknown
// records.add(createEndRecord());
records.add(createSeriesToChartGroupRecord());
records.add(createEndRecord());
records.add(createSheetPropsRecord());
records.add(createDefaultTextRecord(DefaultDataLabelTextPropertiesRecord.CATEGORY_DATA_TYPE_ALL_TEXT_CHARACTERISTIC));
records.add(createAllTextRecord());
records.add(createBeginRecord());
// unknown
records.add(createFontIndexRecord(5));
records.add(createDirectLinkRecord());
records.add(createEndRecord());
// eek, undocumented text type
records.add(createDefaultTextRecord((short) 3));
records.add(createUnknownTextRecord());
records.add(createBeginRecord());
records.add(createFontIndexRecord((short) 6));
records.add(createDirectLinkRecord());
records.add(createEndRecord());
records.add(createAxisUsedRecord((short) 1));
createAxisRecords(records);
records.add(createEndRecord());
records.add(createDimensionsRecord());
records.add(createSeriesIndexRecord(2));
records.add(createSeriesIndexRecord(1));
records.add(createSeriesIndexRecord(3));
records.add(EOFRecord.instance);
parentSheet.insertChartRecords(records);
workbook.insertChartRecord();
}
Aggregations