You are here

private function PHPExcel_Reader_Excel5::_readSheetProtection in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_readSheetProtection()

* Read SHEETPROTECTION record (FEATHEADR)

1 call to PHPExcel_Reader_Excel5::_readSheetProtection()
PHPExcel_Reader_Excel5::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php
* Loads PHPExcel from file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php, line 4877

Class

PHPExcel_Reader_Excel5
PHPExcel_Reader_Excel5

Code

private function _readSheetProtection() {
  $length = self::_GetInt2d($this->_data, $this->_pos + 2);
  $recordData = $this
    ->_readRecordData($this->_data, $this->_pos + 4, $length);

  // move stream pointer to next record
  $this->_pos += 4 + $length;
  if ($this->_readDataOnly) {
    return;
  }

  // offset: 0; size: 2; repeated record header
  // offset: 2; size: 2; FRT cell reference flag (=0 currently)
  // offset: 4; size: 8; Currently not used and set to 0
  // offset: 12; size: 2; Shared feature type index (2=Enhanced Protetion, 4=SmartTag)
  $isf = self::_GetInt2d($recordData, 12);
  if ($isf != 2) {
    return;
  }

  // offset: 14; size: 1; =1 since this is a feat header
  // offset: 15; size: 4; size of rgbHdrSData
  // rgbHdrSData, assume "Enhanced Protection"
  // offset: 19; size: 2; option flags
  $options = self::_GetInt2d($recordData, 19);

  // bit: 0; mask 0x0001; 1 = user may edit objects, 0 = users must not edit objects
  $bool = (0x1 & $options) >> 0;
  $this->_phpSheet
    ->getProtection()
    ->setObjects(!$bool);

  // bit: 1; mask 0x0002; edit scenarios
  $bool = (0x2 & $options) >> 1;
  $this->_phpSheet
    ->getProtection()
    ->setScenarios(!$bool);

  // bit: 2; mask 0x0004; format cells
  $bool = (0x4 & $options) >> 2;
  $this->_phpSheet
    ->getProtection()
    ->setFormatCells(!$bool);

  // bit: 3; mask 0x0008; format columns
  $bool = (0x8 & $options) >> 3;
  $this->_phpSheet
    ->getProtection()
    ->setFormatColumns(!$bool);

  // bit: 4; mask 0x0010; format rows
  $bool = (0x10 & $options) >> 4;
  $this->_phpSheet
    ->getProtection()
    ->setFormatRows(!$bool);

  // bit: 5; mask 0x0020; insert columns
  $bool = (0x20 & $options) >> 5;
  $this->_phpSheet
    ->getProtection()
    ->setInsertColumns(!$bool);

  // bit: 6; mask 0x0040; insert rows
  $bool = (0x40 & $options) >> 6;
  $this->_phpSheet
    ->getProtection()
    ->setInsertRows(!$bool);

  // bit: 7; mask 0x0080; insert hyperlinks
  $bool = (0x80 & $options) >> 7;
  $this->_phpSheet
    ->getProtection()
    ->setInsertHyperlinks(!$bool);

  // bit: 8; mask 0x0100; delete columns
  $bool = (0x100 & $options) >> 8;
  $this->_phpSheet
    ->getProtection()
    ->setDeleteColumns(!$bool);

  // bit: 9; mask 0x0200; delete rows
  $bool = (0x200 & $options) >> 9;
  $this->_phpSheet
    ->getProtection()
    ->setDeleteRows(!$bool);

  // bit: 10; mask 0x0400; select locked cells
  $bool = (0x400 & $options) >> 10;
  $this->_phpSheet
    ->getProtection()
    ->setSelectLockedCells(!$bool);

  // bit: 11; mask 0x0800; sort cell range
  $bool = (0x800 & $options) >> 11;
  $this->_phpSheet
    ->getProtection()
    ->setSort(!$bool);

  // bit: 12; mask 0x1000; auto filter
  $bool = (0x1000 & $options) >> 12;
  $this->_phpSheet
    ->getProtection()
    ->setAutoFilter(!$bool);

  // bit: 13; mask 0x2000; pivot tables
  $bool = (0x2000 & $options) >> 13;
  $this->_phpSheet
    ->getProtection()
    ->setPivotTables(!$bool);

  // bit: 14; mask 0x4000; select unlocked cells
  $bool = (0x4000 & $options) >> 14;
  $this->_phpSheet
    ->getProtection()
    ->setSelectUnlockedCells(!$bool);

  // offset: 21; size: 2; not used
}