PHPExcel_Worksheet
[ class tree: PHPExcel_Worksheet ] [ index: PHPExcel_Worksheet ] [ all elements ]

Source for file Protection.php

Documentation is available at Protection.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2010 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Worksheet
  23.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.3c, 2010-06-01
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_Worksheet_Protection
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Worksheet
  34.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36. {
  37.     /**
  38.      * Sheet
  39.      *
  40.      * @var boolean 
  41.      */
  42.     private $_sheet;
  43.  
  44.     /**
  45.      * Objects
  46.      *
  47.      * @var boolean 
  48.      */
  49.     private $_objects;
  50.  
  51.     /**
  52.      * Scenarios
  53.      *
  54.      * @var boolean 
  55.      */
  56.     private $_scenarios;
  57.  
  58.     /**
  59.      * Format cells
  60.      *
  61.      * @var boolean 
  62.      */
  63.     private $_formatCells;
  64.  
  65.     /**
  66.      * Format columns
  67.      *
  68.      * @var boolean 
  69.      */
  70.     private $_formatColumns;
  71.  
  72.     /**
  73.      * Format rows
  74.      *
  75.      * @var boolean 
  76.      */
  77.     private $_formatRows;
  78.  
  79.     /**
  80.      * Insert columns
  81.      *
  82.      * @var boolean 
  83.      */
  84.     private $_insertColumns;
  85.  
  86.     /**
  87.      * Insert rows
  88.      *
  89.      * @var boolean 
  90.      */
  91.     private $_insertRows;
  92.  
  93.     /**
  94.      * Insert hyperlinks
  95.      *
  96.      * @var boolean 
  97.      */
  98.     private $_insertHyperlinks;
  99.  
  100.     /**
  101.      * Delete columns
  102.      *
  103.      * @var boolean 
  104.      */
  105.     private $_deleteColumns;
  106.  
  107.     /**
  108.      * Delete rows
  109.      *
  110.      * @var boolean 
  111.      */
  112.     private $_deleteRows;
  113.  
  114.     /**
  115.      * Select locked cells
  116.      *
  117.      * @var boolean 
  118.      */
  119.     private $_selectLockedCells;
  120.  
  121.     /**
  122.      * Sort
  123.      *
  124.      * @var boolean 
  125.      */
  126.     private $_sort;
  127.  
  128.     /**
  129.      * AutoFilter
  130.      *
  131.      * @var boolean 
  132.      */
  133.     private $_autoFilter;
  134.  
  135.     /**
  136.      * Pivot tables
  137.      *
  138.      * @var boolean 
  139.      */
  140.     private $_pivotTables;
  141.  
  142.     /**
  143.      * Select unlocked cells
  144.      *
  145.      * @var boolean 
  146.      */
  147.     private $_selectUnlockedCells;
  148.  
  149.     /**
  150.      * Password
  151.      *
  152.      * @var string 
  153.      */
  154.     private $_password;
  155.  
  156.     /**
  157.      * Create a new PHPExcel_Worksheet_Protection
  158.      */
  159.     public function __construct()
  160.     {
  161.         // Initialise values
  162.         $this->_sheet                    false;
  163.         $this->_objects                    false;
  164.         $this->_scenarios                false;
  165.         $this->_formatCells                false;
  166.         $this->_formatColumns            false;
  167.         $this->_formatRows                false;
  168.         $this->_insertColumns            false;
  169.         $this->_insertRows                false;
  170.         $this->_insertHyperlinks        false;
  171.         $this->_deleteColumns            false;
  172.         $this->_deleteRows                false;
  173.         $this->_selectLockedCells        false;
  174.         $this->_sort                    false;
  175.         $this->_autoFilter                false;
  176.         $this->_pivotTables                false;
  177.         $this->_selectUnlockedCells        false;
  178.         $this->_password                '';
  179.     }
  180.  
  181.     /**
  182.      * Is some sort of protection enabled?
  183.      *
  184.      * @return boolean 
  185.      */
  186.     function isProtectionEnabled({
  187.         return     $this->_sheet ||
  188.                 $this->_objects ||
  189.                 $this->_scenarios ||
  190.                 $this->_formatCells ||
  191.                 $this->_formatColumns ||
  192.                 $this->_formatRows ||
  193.                 $this->_insertColumns ||
  194.                 $this->_insertRows ||
  195.                 $this->_insertHyperlinks ||
  196.                 $this->_deleteColumns ||
  197.                 $this->_deleteRows ||
  198.                 $this->_selectLockedCells ||
  199.                 $this->_sort ||
  200.                 $this->_autoFilter ||
  201.                 $this->_pivotTables ||
  202.                 $this->_selectUnlockedCells;
  203.     }
  204.  
  205.     /**
  206.      * Get Sheet
  207.      *
  208.      * @return boolean 
  209.      */
  210.     function getSheet({
  211.         return $this->_sheet;
  212.     }
  213.  
  214.     /**
  215.      * Set Sheet
  216.      *
  217.      * @param boolean $pValue 
  218.      * @return PHPExcel_Worksheet_Protection 
  219.      */
  220.     function setSheet($pValue false{
  221.         $this->_sheet $pValue;
  222.         return $this;
  223.     }
  224.  
  225.     /**
  226.      * Get Objects
  227.      *
  228.      * @return boolean 
  229.      */
  230.     function getObjects({
  231.         return $this->_objects;
  232.     }
  233.  
  234.     /**
  235.      * Set Objects
  236.      *
  237.      * @param boolean $pValue 
  238.      * @return PHPExcel_Worksheet_Protection 
  239.      */
  240.     function setObjects($pValue false{
  241.         $this->_objects $pValue;
  242.         return $this;
  243.     }
  244.  
  245.     /**
  246.      * Get Scenarios
  247.      *
  248.      * @return boolean 
  249.      */
  250.     function getScenarios({
  251.         return $this->_scenarios;
  252.     }
  253.  
  254.     /**
  255.      * Set Scenarios
  256.      *
  257.      * @param boolean $pValue 
  258.      * @return PHPExcel_Worksheet_Protection 
  259.      */
  260.     function setScenarios($pValue false{
  261.         $this->_scenarios $pValue;
  262.         return $this;
  263.     }
  264.  
  265.     /**
  266.      * Get FormatCells
  267.      *
  268.      * @return boolean 
  269.      */
  270.     function getFormatCells({
  271.         return $this->_formatCells;
  272.     }
  273.  
  274.     /**
  275.      * Set FormatCells
  276.      *
  277.      * @param boolean $pValue 
  278.      * @return PHPExcel_Worksheet_Protection 
  279.      */
  280.     function setFormatCells($pValue false{
  281.         $this->_formatCells $pValue;
  282.         return $this;
  283.     }
  284.  
  285.     /**
  286.      * Get FormatColumns
  287.      *
  288.      * @return boolean 
  289.      */
  290.     function getFormatColumns({
  291.         return $this->_formatColumns;
  292.     }
  293.  
  294.     /**
  295.      * Set FormatColumns
  296.      *
  297.      * @param boolean $pValue 
  298.      * @return PHPExcel_Worksheet_Protection 
  299.      */
  300.     function setFormatColumns($pValue false{
  301.         $this->_formatColumns $pValue;
  302.         return $this;
  303.     }
  304.  
  305.     /**
  306.      * Get FormatRows
  307.      *
  308.      * @return boolean 
  309.      */
  310.     function getFormatRows({
  311.         return $this->_formatRows;
  312.     }
  313.  
  314.     /**
  315.      * Set FormatRows
  316.      *
  317.      * @param boolean $pValue 
  318.      * @return PHPExcel_Worksheet_Protection 
  319.      */
  320.     function setFormatRows($pValue false{
  321.         $this->_formatRows $pValue;
  322.         return $this;
  323.     }
  324.  
  325.     /**
  326.      * Get InsertColumns
  327.      *
  328.      * @return boolean 
  329.      */
  330.     function getInsertColumns({
  331.         return $this->_insertColumns;
  332.     }
  333.  
  334.     /**
  335.      * Set InsertColumns
  336.      *
  337.      * @param boolean $pValue 
  338.      * @return PHPExcel_Worksheet_Protection 
  339.      */
  340.     function setInsertColumns($pValue false{
  341.         $this->_insertColumns $pValue;
  342.         return $this;
  343.     }
  344.  
  345.     /**
  346.      * Get InsertRows
  347.      *
  348.      * @return boolean 
  349.      */
  350.     function getInsertRows({
  351.         return $this->_insertRows;
  352.     }
  353.  
  354.     /**
  355.      * Set InsertRows
  356.      *
  357.      * @param boolean $pValue 
  358.      * @return PHPExcel_Worksheet_Protection 
  359.      */
  360.     function setInsertRows($pValue false{
  361.         $this->_insertRows $pValue;
  362.         return $this;
  363.     }
  364.  
  365.     /**
  366.      * Get InsertHyperlinks
  367.      *
  368.      * @return boolean 
  369.      */
  370.     function getInsertHyperlinks({
  371.         return $this->_insertHyperlinks;
  372.     }
  373.  
  374.     /**
  375.      * Set InsertHyperlinks
  376.      *
  377.      * @param boolean $pValue 
  378.      * @return PHPExcel_Worksheet_Protection 
  379.      */
  380.     function setInsertHyperlinks($pValue false{
  381.         $this->_insertHyperlinks $pValue;
  382.         return $this;
  383.     }
  384.  
  385.     /**
  386.      * Get DeleteColumns
  387.      *
  388.      * @return boolean 
  389.      */
  390.     function getDeleteColumns({
  391.         return $this->_deleteColumns;
  392.     }
  393.  
  394.     /**
  395.      * Set DeleteColumns
  396.      *
  397.      * @param boolean $pValue 
  398.      * @return PHPExcel_Worksheet_Protection 
  399.      */
  400.     function setDeleteColumns($pValue false{
  401.         $this->_deleteColumns $pValue;
  402.         return $this;
  403.     }
  404.  
  405.     /**
  406.      * Get DeleteRows
  407.      *
  408.      * @return boolean 
  409.      */
  410.     function getDeleteRows({
  411.         return $this->_deleteRows;
  412.     }
  413.  
  414.     /**
  415.      * Set DeleteRows
  416.      *
  417.      * @param boolean $pValue 
  418.      * @return PHPExcel_Worksheet_Protection 
  419.      */
  420.     function setDeleteRows($pValue false{
  421.         $this->_deleteRows $pValue;
  422.         return $this;
  423.     }
  424.  
  425.     /**
  426.      * Get SelectLockedCells
  427.      *
  428.      * @return boolean 
  429.      */
  430.     function getSelectLockedCells({
  431.         return $this->_selectLockedCells;
  432.     }
  433.  
  434.     /**
  435.      * Set SelectLockedCells
  436.      *
  437.      * @param boolean $pValue 
  438.      * @return PHPExcel_Worksheet_Protection 
  439.      */
  440.     function setSelectLockedCells($pValue false{
  441.         $this->_selectLockedCells $pValue;
  442.         return $this;
  443.     }
  444.  
  445.     /**
  446.      * Get Sort
  447.      *
  448.      * @return boolean 
  449.      */
  450.     function getSort({
  451.         return $this->_sort;
  452.     }
  453.  
  454.     /**
  455.      * Set Sort
  456.      *
  457.      * @param boolean $pValue 
  458.      * @return PHPExcel_Worksheet_Protection 
  459.      */
  460.     function setSort($pValue false{
  461.         $this->_sort $pValue;
  462.         return $this;
  463.     }
  464.  
  465.     /**
  466.      * Get AutoFilter
  467.      *
  468.      * @return boolean 
  469.      */
  470.     function getAutoFilter({
  471.         return $this->_autoFilter;
  472.     }
  473.  
  474.     /**
  475.      * Set AutoFilter
  476.      *
  477.      * @param boolean $pValue 
  478.      * @return PHPExcel_Worksheet_Protection 
  479.      */
  480.     function setAutoFilter($pValue false{
  481.         $this->_autoFilter $pValue;
  482.         return $this;
  483.     }
  484.  
  485.     /**
  486.      * Get PivotTables
  487.      *
  488.      * @return boolean 
  489.      */
  490.     function getPivotTables({
  491.         return $this->_pivotTables;
  492.     }
  493.  
  494.     /**
  495.      * Set PivotTables
  496.      *
  497.      * @param boolean $pValue 
  498.      * @return PHPExcel_Worksheet_Protection 
  499.      */
  500.     function setPivotTables($pValue false{
  501.         $this->_pivotTables $pValue;
  502.         return $this;
  503.     }
  504.  
  505.     /**
  506.      * Get SelectUnlockedCells
  507.      *
  508.      * @return boolean 
  509.      */
  510.     function getSelectUnlockedCells({
  511.         return $this->_selectUnlockedCells;
  512.     }
  513.  
  514.     /**
  515.      * Set SelectUnlockedCells
  516.      *
  517.      * @param boolean $pValue 
  518.      * @return PHPExcel_Worksheet_Protection 
  519.      */
  520.     function setSelectUnlockedCells($pValue false{
  521.         $this->_selectUnlockedCells $pValue;
  522.         return $this;
  523.     }
  524.  
  525.     /**
  526.      * Get Password (hashed)
  527.      *
  528.      * @return string 
  529.      */
  530.     function getPassword({
  531.         return $this->_password;
  532.     }
  533.  
  534.     /**
  535.      * Set Password
  536.      *
  537.      * @param string     $pValue 
  538.      * @param boolean     $pAlreadyHashed If the password has already been hashed, set this to true
  539.      * @return PHPExcel_Worksheet_Protection 
  540.      */
  541.     function setPassword($pValue ''$pAlreadyHashed false{
  542.         if (!$pAlreadyHashed{
  543.             $pValue PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
  544.         }
  545.         $this->_password $pValue;
  546.         return $this;
  547.     }
  548.  
  549.     /**
  550.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  551.      */
  552.     public function __clone({
  553.         $vars get_object_vars($this);
  554.         foreach ($vars as $key => $value{
  555.             if (is_object($value)) {
  556.                 $this->$key clone $value;
  557.             else {
  558.                 $this->$key $value;
  559.             }
  560.         }
  561.     }
  562. }

Documentation generated on Tue, 01 Jun 2010 17:05:46 +0200 by phpDocumentor 1.4.3