Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.ProtectRecord


   */
  public void testProtect() {
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet hssfSheet = workbook.createSheet();
    Sheet sheet = hssfSheet.getSheet();
    ProtectRecord protect = sheet.getProtect();

    assertFalse(protect.getProtect());

    // This will tell us that cloneSheet, and by extension,
    // the list forms of createSheet leave us with an accessible
    // ProtectRecord.
    hssfSheet.setProtect(true);
View Full Code Here


    short expected = (short)0xfef1;
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet s = wb.createSheet();
    s.protectSheet("abcdefghij");
    Sheet sheet = s.getSheet();
    ProtectRecord protect = sheet.getProtect();
    PasswordRecord pass = sheet.getPassword();
    assertTrue("protection should be on",protect.getProtect());
    assertTrue("object protection should be on",sheet.isProtected()[1]);
    assertTrue("scenario protection should be on",sheet.isProtected()[2]);
    assertEquals("well known value for top secret hash should be "+Integer.toHexString(expected).substring(4),expected,pass.getPassword());
  }
View Full Code Here

     * @return a new Protect record with protect set to false.
     */
    private static ProtectRecord createProtect() {
        // by default even when we support it we won't
        // want it to be protected
        return new ProtectRecord(false);
    }
View Full Code Here

   */
  public void testProtect() {
    HSSFWorkbook workbook = new HSSFWorkbook();
    HSSFSheet hssfSheet = workbook.createSheet();
    Sheet sheet = hssfSheet.getSheet();
    ProtectRecord protect = sheet.getProtect();
    
    assertFalse(protect.getProtect());

    // This will tell us that cloneSheet, and by extension,
    // the list forms of createSheet leave us with an accessible
    // ProtectRecord.
    hssfSheet.setProtect(true);
View Full Code Here

     * @return a new Protect record with protect set to false.
     */
    private static ProtectRecord createProtect() {
        // by default even when we support it we won't
        // want it to be protected
        return new ProtectRecord(false);
    }
View Full Code Here

    /**
     * @return the ProtectRecord. If one is not contained in the sheet, then one is created.
     */
    public ProtectRecord getProtect() {
        if (protect == null) {
            protect = new ProtectRecord(false);
            // Insert the newly created protect record just before DefaultColWidthRecord
            int loc = findFirstRecordLocBySid(DefaultColWidthRecord.sid);
            _records.add(loc, protect);
        }
        return protect;
View Full Code Here

     * @param objects are protected
     * @param scenarios are protected
     */
    public void protectSheet( String password, boolean objects, boolean scenarios ) {
        int protIdx = -1;
        ProtectRecord prec = getProtect();
        PasswordRecord pass = getPassword();
        prec.setProtect(true);
        pass.setPassword(PasswordRecord.hashPassword(password));
        if((objprotect == null && objects) || (scenprotect != null && scenarios)) {
            protIdx = _records.indexOf( protect );
        }
        if(objprotect == null && objects) {
View Full Code Here

     * @param scenarios are unprotected (false = unprotect)
     */
    public void unprotectSheet( boolean sheet, boolean objects, boolean scenarios ) {

        if (!sheet) {
           ProtectRecord prec = getProtect();
           prec.setProtect(sheet);
           PasswordRecord pass = getPassword();
           pass.setPassword((short)00);
        }
        if(objprotect != null && !objects) {
            objprotect.setProtect(false);
View Full Code Here

     * @return a new Protect record with protect set to false.
     */
    private static ProtectRecord createProtect() {
        // by default even when we support it we won't
        // want it to be protected
        return new ProtectRecord(false);
    }
View Full Code Here

     * @return a new Protect record with protect set to false.
     */
    private static ProtectRecord createProtect() {
        // by default even when we support it we won't
        // want it to be protected
        return new ProtectRecord(false);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.ProtectRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.