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

Documentation generated on Mon, 05 Jan 2009 20:38:24 +0100 by phpDocumentor 1.4.1