Package org.apache.poi.hssf.record

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


    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

    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 ) );
View Full Code Here

    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 ) );
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

     */
    private static ProtectRecord createProtect() {
        if (log.check( POILogger.DEBUG )) {
            log.log(POILogger.DEBUG, "create protect record with protection disabled");
        }
        ProtectRecord retval = new ProtectRecord();
        retval.setProtect(false); // TODO - supply param to constructor
        return retval;
    }
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 r;
  }

  private ProtectRecord createProtectRecord()
  {
    ProtectRecord r = new ProtectRecord();
    r.setProtect(false);
    return r;
  }
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.