Exemplo n.º 1
0
        public override Object Clone()
        {
            ScenarioProtectRecord rec = new ScenarioProtectRecord();

            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 a ScenarioProtect record with protect set to false.
        /// </summary>
        /// <returns></returns>
        private static ScenarioProtectRecord CreateScenarioProtect() {
		ScenarioProtectRecord retval = new ScenarioProtectRecord();
		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()
 {
     ScenarioProtectRecord rec = new ScenarioProtectRecord();
     rec.field_1_protect = field_1_protect;
     return rec;
 }
Exemplo n.º 6
0
        /**
         * Creates a ScenarioProtect record with protect Set to false.
         * @see org.apache.poi.hssf.record.ScenarioProtectRecord
         * @see org.apache.poi.hssf.record.Record
         * @return a ScenarioProtectRecord
         */
        
        protected ScenarioProtectRecord CreateScenarioProtect()
        {
            //if (log.Check(POILogger.DEBUG))
            //    log.Log(POILogger.DEBUG, "Create protect record with protection disabled");
            ScenarioProtectRecord retval = new ScenarioProtectRecord();

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