Set the Biff PROTECT record to indicate that the worksheet is protected.
508792
private function _writeProtect()
	{
		// Exit unless sheet protection has been specified
		if (!$this->_phpSheet->getProtection()->getSheet()) {
			return;
		}

		$record	  = 0x0012;			 // Record identifier
		$length	  = 0x0002;			 // Bytes to follow

		$fLock	  = 1;	// Worksheet is protected

		$header	  = pack("vv", $record, $length);
		$data	  = pack("v",  $fLock);

		$this->_append($header.$data);
	}
1034537
private void onProtectedHit(Node node) {
    admittor.record(node.key);
    node.moveToTail(headProtected);
  }
513038
def save(self):
        """"""
        if self._sheet.readonly:
            raise ReadOnlyException
        if not self._changed:
            # nothing to save
            return
        gd_client = self._sheet.client
        assert gd_client is not None
        try:
            entry = gd_client.UpdateRow(self._entry, self._data)
        except RequestError as e:
            error_data = e.args[0]
            if error_data.status == 403:
                #  Forbidden
                raise
            if error_data.status == 409:
                # conflict
                raise
            else:
                raise
        self._entry = entry
        # reset `_changed` flag
        self._changed = False
        return entry
920198
public static int setProtected(int modifier, boolean b) {
        if (b) {
            return (modifier | PROTECTED) & (~PUBLIC & ~PRIVATE);
        }
        else {
            return modifier & ~PROTECTED;
        }
    }
404408
public static void setPerformMXRecordCheck (final boolean bPerformMXRecordCheck)
  {
    s_aPerformMXRecordCheck.set (bPerformMXRecordCheck);

    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Email address record check is " + (bPerformMXRecordCheck ? "enabled" : "disabled"));
  }
980217
private function _readProtect()
	{
		$length = self::_GetInt2d($this->_data, $this->_pos + 2);
		$recordData = substr($this->_data, $this->_pos + 4, $length);

		// move stream pointer to next record
		$this->_pos += 4 + $length;

		if ($this->_readDataOnly) {
			return;
		}

		// offset: 0; size: 2;

		// bit 0, mask 0x01; 1 = sheet is protected
		$bool = (0x01 & self::_GetInt2d($recordData, 0)) >> 0;
		$this->_phpSheet->getProtection()->setSheet((bool)$bool);
	}
541764
private void initializeShowBottomSheetPreference() {
        Preference showBottomSheetPreference =
                findPreference(getString(R.string.show_bottom_sheet_preference_key));
        showBottomSheetPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(final Preference preference) {
                initializeBottomSheet();
                bottomSheet.show();
                return true;
            }

        });
    }
61317
public void setEnabled(boolean bEnable)
    {
        super.setEnabled(bEnable);
        if (m_recordReference != null)
        {
            Record recReference = this.getReferenceRecord();
            for (int iIndex = 0 + 1; iIndex < recReference.getKeyAreaCount(); iIndex++)
            {
                KeyArea keyArea = recReference.getKeyArea(iIndex);
                BaseField fieldKey = keyArea.getField(DBConstants.MAIN_KEY_FIELD);
                if (fieldKey.getListener(MainReadOnlyHandler.class.getName()) != null)
                    fieldKey.setEnabled(bEnable);
            }
        }
    }
1260167
def is_set_on(self, xblock):
        
        # pylint: disable=protected-access
        return self._is_dirty(xblock) or xblock._field_data.has(xblock, self.name)
657541
def save(self):
        
        record = self.record()
        if not record:
            logger.warning('No record has been defined for %s.' % self)
            return False
        
        if not self.signalsBlocked():
            self.aboutToSaveRecord.emit(record)
            self.aboutToSave.emit()
        
        values = self.saveValues()
        
        # ignore columns that are the same (fixes bugs in encrypted columns)
        check = values.copy()
        for column_name, value in check.items():
            try:
                equals = value == record.recordValue(column_name)
            except UnicodeWarning:
                equals = False
            
            if equals:
                check.pop(column_name)
        
        # check to see if nothing has changed
        if not check and record.isRecord():
            if not self.signalsBlocked():
                self.recordSaved.emit(record)
                self.saved.emit()
                self._saveSignalBlocked = False
            else:
                self._saveSignalBlocked = True
            
            if self.autoCommitOnSave():
                status, result = record.commit()
                if status == 'errored':
                    if 'db_error' in result:
                        msg = nativestring(result['db_error'])
                    else:
                        msg = 'An unknown database error has occurred.'
                    
                    QMessageBox.information(self,
                                            'Commit Error',
                                            msg)
                    return False
            return True
        
        # validate the modified values
        success, msg = record.validateValues(check)
        if ( not success ):
            QMessageBox.information(None, 'Could Not Save', msg)
            return False
        
        record.setRecordValues(**values)
        success, msg = record.validateRecord()
        if not success:
            QMessageBox.information(None, 'Could Not Save', msg)
            return False
        
        if ( self.autoCommitOnSave() ):
            result = record.commit()
            if 'errored' in result:
                QMessageBox.information(None, 'Could Not Save', msg)
                return False
        
        if ( not self.signalsBlocked() ):
            self.recordSaved.emit(record)
            self.saved.emit()
            self._saveSignalBlocked = False
        else:
            self._saveSignalBlocked = True
        
        return True
874852
public function setProtection(PHPExcel_Worksheet_Protection $pValue)
    {
        $this->_protection = $pValue;
        $this->_dirty = true;

        return $this;
    }
165408
public boolean setProtection(int level, String pwd) {
    	boolean result = false;
    	if(this.protectionHash == null) {
    		if(!setProtectionLevel(level)) {
    			result = false;
    		}
    		else
    		{
	    		protectionHash = RtfProtection.generateHash(pwd);
	    		result = true;
    		}
    	}
    	else {
	    	if(this.protectionHash.equals(RtfProtection.generateHash(pwd))) {
	    		if(!setProtectionLevel(level)) {
	    			result = false;
	    		}
	    		else
	    		{
		    		protectionHash = RtfProtection.generateHash(pwd);
		    		result = true;
	    		}
	    	}
    	}
    	return result;
    }
1293045
def write_sheet_protection #:nodoc:
      return unless protect?

      attributes = []
      attributes << ["password",         @protect[:password]] if ptrue?(@protect[:password])
      attributes << ["sheet",            1] if ptrue?(@protect[:sheet])
      attributes << ["content",          1] if ptrue?(@protect[:content])
      attributes << ["objects",          1] unless ptrue?(@protect[:objects])
      attributes << ["scenarios",        1] unless ptrue?(@protect[:scenarios])
      attributes << ["formatCells",      0] if ptrue?(@protect[:format_cells])
      attributes << ["formatColumns",    0] if ptrue?(@protect[:format_columns])
      attributes << ["formatRows",       0] if ptrue?(@protect[:format_rows])
      attributes << ["insertColumns",    0] if ptrue?(@protect[:insert_columns])
      attributes << ["insertRows",       0] if ptrue?(@protect[:insert_rows])
      attributes << ["insertHyperlinks", 0] if ptrue?(@protect[:insert_hyperlinks])
      attributes << ["deleteColumns",    0] if ptrue?(@protect[:delete_columns])
      attributes << ["deleteRows",       0] if ptrue?(@protect[:delete_rows])

      attributes << ["selectLockedCells", 1] unless ptrue?(@protect[:select_locked_cells])

      attributes << ["sort",        0] if ptrue?(@protect[:sort])
      attributes << ["autoFilter",  0] if ptrue?(@protect[:autofilter])
      attributes << ["pivotTables", 0] if ptrue?(@protect[:pivot_tables])

      attributes << ["selectUnlockedCells", 1] unless ptrue?(@protect[:select_unlocked_cells])

      @writer.empty_tag('sheetProtection', attributes)
    end
154211
public void doValidRecord(boolean bDisplayOption)
    {
        if (m_fldMain == null)
            m_fldMain = this.getOwner().getField(mainFieldName);
        if (m_fldMain == null)
            return;     // Error - Field not found?
        if (fileKeyFieldName != null)
            m_FileToRead.getField(fileKeyFieldName).moveFieldToThis(m_fldMain, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE);  // SCREEN_MOVE says this is coming from here
        else
            m_FileToRead.getField(m_iFileKeyField).moveFieldToThis(m_fldMain, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE);  // SCREEN_MOVE says this is coming from here
        try   {
            boolean bSuccess = m_FileToRead.seek("=");
            if (!bSuccess)
            {
                m_FileToRead.initRecord(bDisplayOption);    // Put's record in an indeterminate state (so this record won't be written) and clears the fields.
                BaseField nextField = m_FileToRead.getField(m_FileToRead.getDefaultDisplayFieldName());
                String strRecNotFound = this.getOwner().getTable().getString(RECORD_NOT_FOUND_MESSAGE);
                if (nextField instanceof StringField)
                    nextField.setString(strRecNotFound, bDisplayOption, DBConstants.SCREEN_MOVE);
            }
        } catch (DBException ex)    {
            ex.printStackTrace();
        }
        super.doValidRecord(bDisplayOption);
    }
135341
function Spreadsheet_Excel_Writer_BIFFwriter()
    {
        $this->_byte_order = '';
        $this->_data       = '';
        $this->_datasize   = 0;
        $this->_limit      = 2080;
        $this->_tmp_dir    = '';
        // Set the byte order
        $this->_setByteOrder();
    }
1135200
def set_safe(self, is_safe, **kwargs):
        ''' 
        '''
        self.safe = is_safe
        self.get_last_args.update(**kwargs)
        return self
1322549
def store_shtprops   # :nodoc:
    record      = 0x1044     # Record identifier.
    length      = 0x0004     # Number of bytes to follow.
    grbit       = 0x000E     # Option flags.
    empty_cells = 0x0000     # Empty cell handling.

    grbit = 0x000A if @embedded

    store_simple(record, length, grbit, empty_cells)
  end