public override Object Clone()
        {
            ObjectProtectRecord rec = new ObjectProtectRecord();

            rec.field_1_protect = field_1_protect;
            return(rec);
        }
 private bool ReadARecord(RecordStream rs)
 {
     
     switch (rs.PeekNextSid())
     {
         case ProtectRecord.sid:
             CheckNotPresent(_protectRecord);
             _protectRecord = rs.GetNext() as ProtectRecord;
             break;
         case ObjectProtectRecord.sid:
             CheckNotPresent(_objectProtectRecord);
             _objectProtectRecord = rs.GetNext() as ObjectProtectRecord;
             break;
         case ScenarioProtectRecord.sid:
             CheckNotPresent(_scenarioProtectRecord);
             _scenarioProtectRecord = rs.GetNext() as ScenarioProtectRecord;
             break;
         case PasswordRecord.sid:
             CheckNotPresent(_passwordRecord);
             _passwordRecord = rs.GetNext() as PasswordRecord;
             break;
         default:
             // all other record types are not part of the PageSettingsBlock
             return false;
     }
     return true;
 }
        /// <summary>
        /// Creates an ObjectProtect record with protect set to false.
        /// </summary>
        /// <returns></returns>
        private static ObjectProtectRecord CreateObjectProtect() {
		ObjectProtectRecord retval = new ObjectProtectRecord();
		retval.Protect = (false);
		return retval;
	}
        /// <summary>
        /// protect a spreadsheet with a password (not encrypted, just sets protect flags and the password.)
        /// </summary>
        /// <param name="password">password to set;Pass <code>null</code> to remove all protection</param>
        /// <param name="shouldProtectObjects">shouldProtectObjects are protected</param>
        /// <param name="shouldProtectScenarios">shouldProtectScenarios are protected</param>
        public void ProtectSheet(String password, bool shouldProtectObjects,
                bool shouldProtectScenarios)
        {
            if (password == null)
            {
                _passwordRecord = null;
                _protectRecord = null;
                _objectProtectRecord = null;
                _scenarioProtectRecord = null;
                return;
            }

            ProtectRecord prec = this.Protect;
            PasswordRecord pass = this.Password;
            prec.Protect = true;
            pass.Password = (PasswordRecord.HashPassword(password));
            if (_objectProtectRecord == null && shouldProtectObjects)
            {
                ObjectProtectRecord rec = CreateObjectProtect();
                rec.Protect = (true);
                _objectProtectRecord = rec;
            }
            if (_scenarioProtectRecord == null && shouldProtectScenarios)
            {
                ScenarioProtectRecord srec = CreateScenarioProtect();
                srec.Protect = (true);
                _scenarioProtectRecord = srec;
            }
        }
 public override Object Clone()
 {
     ObjectProtectRecord rec = new ObjectProtectRecord();
     rec.field_1_protect = field_1_protect;
     return rec;
 }
Пример #6
0
        /**
         * Creates an ObjectProtect record with protect Set to false.
         * @see org.apache.poi.hssf.record.ObjectProtectRecord
         * @see org.apache.poi.hssf.record.Record
         * @return an ObjectProtectRecord
         */
        protected ObjectProtectRecord CreateObjectProtect()
        {
            //if (log.Check(POILogger.DEBUG))
            //    log.Log(POILogger.DEBUG, "Create protect record with protection disabled");
            ObjectProtectRecord retval = new ObjectProtectRecord();

            retval.Protect = (false);
            return retval;
        }