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

Documentation generated on Sun, 27 Feb 2011 16:33:31 -0800 by phpDocumentor 1.4.3