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

Source for file Style.php

Documentation is available at Style.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_Style
  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_Style
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Style
  34.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36. class PHPExcel_Style implements PHPExcel_IComparable
  37. {
  38.     /**
  39.      * Font
  40.      *
  41.      * @var PHPExcel_Style_Font 
  42.      */
  43.     private $_font;
  44.  
  45.     /**
  46.      * Fill
  47.      *
  48.      * @var PHPExcel_Style_Fill 
  49.      */
  50.     private $_fill;
  51.  
  52.     /**
  53.      * Borders
  54.      *
  55.      * @var PHPExcel_Style_Borders 
  56.      */
  57.     private $_borders;
  58.  
  59.     /**
  60.      * Alignment
  61.      *
  62.      * @var PHPExcel_Style_Alignment 
  63.      */
  64.     private $_alignment;
  65.  
  66.     /**
  67.      * Number Format
  68.      *
  69.      * @var PHPExcel_Style_NumberFormat 
  70.      */
  71.     private $_numberFormat;
  72.  
  73.     /**
  74.      * Conditional styles
  75.      *
  76.      * @var PHPExcel_Style_Conditional[] 
  77.      */
  78.     private $_conditionalStyles;
  79.  
  80.     /**
  81.      * Protection
  82.      *
  83.      * @var PHPExcel_Style_Protection 
  84.      */
  85.     private $_protection;
  86.  
  87.     /**
  88.      * Style supervisor?
  89.      *
  90.      * @var boolean 
  91.      */
  92.     private $_isSupervisor;
  93.  
  94.     /**
  95.      * Parent. Only used for style supervisor
  96.      *
  97.      * @var PHPExcel 
  98.      */
  99.     private $_parent;
  100.  
  101.     /**
  102.      * Index of style in collection. Only used for real style.
  103.      *
  104.      * @var int 
  105.      */
  106.     private $_index;
  107.  
  108.     /**
  109.      * Create a new PHPExcel_Style
  110.      *
  111.      * @param boolean $isSupervisor 
  112.      */
  113.     public function __construct($isSupervisor false)
  114.     {
  115.         // Supervisor?
  116.         $this->_isSupervisor $isSupervisor;
  117.  
  118.         // Initialise values
  119.         $this->_conditionalStyles     array();
  120.         $this->_font                new PHPExcel_Style_Font($isSupervisor);
  121.         $this->_fill                new PHPExcel_Style_Fill($isSupervisor);
  122.         $this->_borders                new PHPExcel_Style_Borders($isSupervisor);
  123.         $this->_alignment            new PHPExcel_Style_Alignment($isSupervisor);
  124.         $this->_numberFormat        new PHPExcel_Style_NumberFormat($isSupervisor);
  125.         $this->_protection            new PHPExcel_Style_Protection($isSupervisor);
  126.  
  127.         // bind parent if we are a supervisor
  128.         if ($isSupervisor{
  129.             $this->_font->bindParent($this);
  130.             $this->_fill->bindParent($this);
  131.             $this->_borders->bindParent($this);
  132.             $this->_alignment->bindParent($this);
  133.             $this->_numberFormat->bindParent($this);
  134.             $this->_protection->bindParent($this);
  135.         }
  136.     }
  137.  
  138.     /**
  139.      * Bind parent. Only used for supervisor
  140.      *
  141.      * @param PHPExcel $parent 
  142.      * @return PHPExcel_Style 
  143.      */
  144.     public function bindParent($parent)
  145.     {
  146.         $this->_parent $parent;
  147.         return $this;
  148.     }
  149.  
  150.     /**
  151.      * Is this a supervisor or a real style component?
  152.      *
  153.      * @return boolean 
  154.      */
  155.     public function getIsSupervisor()
  156.     {
  157.         return $this->_isSupervisor;
  158.     }
  159.  
  160.     /**
  161.      * Get the shared style component for the currently active cell in currently active sheet.
  162.      * Only used for style supervisor
  163.      *
  164.      * @return PHPExcel_Style 
  165.      */
  166.     public function getSharedComponent()
  167.     {
  168.         $activeSheet $this->getActiveSheet();
  169.         $selectedCell $this->getActiveCell()// e.g. 'A1'
  170.  
  171.         if ($activeSheet->cellExists($selectedCell)) {
  172.             $cell $activeSheet->getCell($selectedCell);
  173.             $xfIndex $cell->getXfIndex();
  174.         else {
  175.             $xfIndex 0;
  176.         }
  177.  
  178.         $activeStyle $this->_parent->getCellXfByIndex($xfIndex);
  179.         return $activeStyle;
  180.     }
  181.  
  182.     /**
  183.      * Get the currently active sheet. Only used for supervisor
  184.      *
  185.      * @return PHPExcel_Worksheet 
  186.      */
  187.     public function getActiveSheet()
  188.     {
  189.         return $this->_parent->getActiveSheet();
  190.     }
  191.  
  192.     /**
  193.      * Get the currently active cell coordinate in currently active sheet.
  194.      * Only used for supervisor
  195.      *
  196.      * @return string E.g. 'A1'
  197.      */
  198.     public function getSelectedCells()
  199.     {
  200.         return $this->_parent->getActiveSheet()->getSelectedCells();
  201.     }
  202.  
  203.     /**
  204.      * Get the currently active cell coordinate in currently active sheet.
  205.      * Only used for supervisor
  206.      *
  207.      * @return string E.g. 'A1'
  208.      */
  209.     public function getActiveCell()
  210.     {
  211.         return $this->_parent->getActiveSheet()->getActiveCell();
  212.     }
  213.  
  214.     /**
  215.      * Get parent. Only used for style supervisor
  216.      *
  217.      * @return PHPExcel 
  218.      */
  219.     public function getParent()
  220.     {
  221.         return $this->_parent;
  222.     }
  223.  
  224.     /**
  225.      * Apply styles from array
  226.      *
  227.      * <code>
  228.      * $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
  229.      *         array(
  230.      *             'font'    => array(
  231.      *                 'name'      => 'Arial',
  232.      *                 'bold'      => true,
  233.      *                 'italic'    => false,
  234.      *                 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
  235.      *                 'strike'    => false,
  236.      *                 'color'     => array(
  237.      *                     'rgb' => '808080'
  238.      *                 )
  239.      *             ),
  240.      *             'borders' => array(
  241.      *                 'bottom'     => array(
  242.      *                     'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
  243.      *                     'color' => array(
  244.      *                         'rgb' => '808080'
  245.      *                     )
  246.      *                 ),
  247.      *                 'top'     => array(
  248.      *                     'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
  249.      *                     'color' => array(
  250.      *                         'rgb' => '808080'
  251.      *                     )
  252.      *                 )
  253.      *             )
  254.      *         )
  255.      * );
  256.      * </code>
  257.      *
  258.      * @param    array    $pStyles    Array containing style information
  259.      * @param     boolean        $pAdvanced    Advanced mode for setting borders.
  260.      * @throws    Exception
  261.      * @return PHPExcel_Style 
  262.      */
  263.     public function applyFromArray($pStyles null$pAdvanced true{
  264.         if (is_array($pStyles)) {
  265.             if ($this->_isSupervisor{
  266.  
  267.                 $pRange $this->getSelectedCells();
  268.  
  269.                 // Uppercase coordinate
  270.                 $pRange strtoupper($pRange);
  271.  
  272.                 // Is it a cell range or a single cell?
  273.                 $rangeA     '';
  274.                 $rangeB     '';
  275.                 if (strpos($pRange':'=== false{
  276.                     $rangeA $pRange;
  277.                     $rangeB $pRange;
  278.                 else {
  279.                     list($rangeA$rangeBexplode(':'$pRange);
  280.                 }
  281.  
  282.                 // Calculate range outer borders
  283.                 $rangeStart PHPExcel_Cell::coordinateFromString($rangeA);
  284.                 $rangeEnd     PHPExcel_Cell::coordinateFromString($rangeB);
  285.  
  286.                 // Translate column into index
  287.                 $rangeStart[0]    PHPExcel_Cell::columnIndexFromString($rangeStart[0]1;
  288.                 $rangeEnd[0]    PHPExcel_Cell::columnIndexFromString($rangeEnd[0]1;
  289.  
  290.                 // Make sure we can loop upwards on rows and columns
  291.                 if ($rangeStart[0$rangeEnd[0&& $rangeStart[1$rangeEnd[1]{
  292.                     $tmp $rangeStart;
  293.                     $rangeStart $rangeEnd;
  294.                     $rangeEnd $tmp;
  295.                 }
  296.  
  297.                 // ADVANCED MODE:
  298.  
  299.                 if ($pAdvanced && isset($pStyles['borders'])) {
  300.  
  301.                     // 'allborders' is a shorthand property for 'outline' and 'inside' and
  302.                     //        it applies to components that have not been set explicitly
  303.                     if (isset($pStyles['borders']['allborders'])) {
  304.                         foreach (array('outline''inside'as $component{
  305.                             if (!isset($pStyles['borders'][$component])) {
  306.                                 $pStyles['borders'][$component$pStyles['borders']['allborders'];
  307.                             }
  308.                         }
  309.                         unset($pStyles['borders']['allborders'])// not needed any more
  310.                     }
  311.  
  312.                     // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
  313.                     //        it applies to components that have not been set explicitly
  314.                     if (isset($pStyles['borders']['outline'])) {
  315.                         foreach (array('top''right''bottom''left'as $component{
  316.                             if (!isset($pStyles['borders'][$component])) {
  317.                                 $pStyles['borders'][$component$pStyles['borders']['outline'];
  318.                             }
  319.                         }
  320.                         unset($pStyles['borders']['outline'])// not needed any more
  321.                     }
  322.  
  323.                     // 'inside' is a shorthand property for 'vertical' and 'horizontal'
  324.                     //        it applies to components that have not been set explicitly
  325.                     if (isset($pStyles['borders']['inside'])) {
  326.                         foreach (array('vertical''horizontal'as $component{
  327.                             if (!isset($pStyles['borders'][$component])) {
  328.                                 $pStyles['borders'][$component$pStyles['borders']['inside'];
  329.                             }
  330.                         }
  331.                         unset($pStyles['borders']['inside'])// not needed any more
  332.                     }
  333.  
  334.                     // width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
  335.                     $xMax min($rangeEnd[0$rangeStart[013);
  336.                     $yMax min($rangeEnd[1$rangeStart[113);
  337.  
  338.                     // loop through up to 3 x 3 = 9 regions
  339.                     for ($x 1$x <= $xMax++$x{
  340.                         // start column index for region
  341.                         $colStart ($x == 3?
  342.                             PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
  343.                                 : PHPExcel_Cell::stringFromColumnIndex($rangeStart[0$x 1);
  344.  
  345.                         // end column index for region
  346.                         $colEnd ($x == 1?
  347.                             PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
  348.                                 : PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0$xMax $x);
  349.  
  350.                         for ($y 1$y <= $yMax++$y{
  351.  
  352.                             // which edges are touching the region
  353.                             $edges array();
  354.  
  355.                             // are we at left edge
  356.                             if ($x == 1{
  357.                                 $edges['left';
  358.                             }
  359.  
  360.                             // are we at right edge
  361.                             if ($x == $xMax{
  362.                                 $edges['right';
  363.                             }
  364.  
  365.                             // are we at top edge?
  366.                             if ($y == 1{
  367.                                 $edges['top';
  368.                             }
  369.  
  370.                             // are we at bottom edge?
  371.                             if ($y == $yMax{
  372.                                 $edges['bottom';
  373.                             }
  374.  
  375.                             // start row index for region
  376.                             $rowStart ($y == 3?
  377.                                 $rangeEnd[1$rangeStart[1$y 1;
  378.  
  379.                             // end row index for region
  380.                             $rowEnd ($y == 1?
  381.                                 $rangeStart[1$rangeEnd[1$yMax $y;
  382.  
  383.                             // build range for region
  384.                             $range $colStart $rowStart ':' $colEnd $rowEnd;
  385.  
  386.                             // retrieve relevant style array for region
  387.                             $regionStyles $pStyles;
  388.                             unset($regionStyles['borders']['inside']);
  389.  
  390.                             // what are the inner edges of the region when looking at the selection
  391.                             $innerEdges array_diffarray('top''right''bottom''left')$edges );
  392.  
  393.                             // inner edges that are not touching the region should take the 'inside' border properties if they have been set
  394.                             foreach ($innerEdges as $innerEdge{
  395.                                 switch ($innerEdge{
  396.                                     case 'top':
  397.                                     case 'bottom':
  398.                                         // should pick up 'horizontal' border property if set
  399.                                         if (isset($pStyles['borders']['horizontal'])) {
  400.                                             $regionStyles['borders'][$innerEdge$pStyles['borders']['horizontal'];
  401.                                         else {
  402.                                             unset($regionStyles['borders'][$innerEdge]);
  403.                                         }
  404.                                         break;
  405.                                     case 'left':
  406.                                     case 'right':
  407.                                         // should pick up 'vertical' border property if set
  408.                                         if (isset($pStyles['borders']['vertical'])) {
  409.                                             $regionStyles['borders'][$innerEdge$pStyles['borders']['vertical'];
  410.                                         else {
  411.                                             unset($regionStyles['borders'][$innerEdge]);
  412.                                         }
  413.                                         break;
  414.                                 }
  415.                             }
  416.  
  417.                             // apply region style to region by calling applyFromArray() in simple mode
  418.                             $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStylesfalse);
  419.                         }
  420.                     }
  421.                     return;
  422.                 }
  423.  
  424.                 // SIMPLE MODE:
  425.  
  426.                 // Selection type, inspect
  427.                 if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/'$pRange)) {
  428.                     $selectionType 'COLUMN';
  429.                 else if (preg_match('/^A[0-9]+:XFD[0-9]+$/'$pRange)) {
  430.                     $selectionType 'ROW';
  431.                 else {
  432.                     $selectionType 'CELL';
  433.                 }
  434.  
  435.                 // First loop through columns, rows, or cells to find out which styles are affected by this operation
  436.                 switch ($selectionType{
  437.                     case 'COLUMN':
  438.                         $oldXfIndexes array();
  439.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  440.                             $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()true;
  441.                         }
  442.                         break;
  443.  
  444.                     case 'ROW':
  445.                         $oldXfIndexes array();
  446.                         for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  447.                             if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex(== null{
  448.                                 $oldXfIndexes[0true// row without explicit style should be formatted based on default style
  449.                             else {
  450.                                 $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()true;
  451.                             }
  452.                         }
  453.                         break;
  454.  
  455.                     case 'CELL':
  456.                         $oldXfIndexes array();
  457.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  458.                             for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  459.                                 $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col$row)->getXfIndex()true;
  460.                             }
  461.                         }
  462.                         break;
  463.                 }
  464.  
  465.                 // clone each of the affected styles, apply the style arrray, and add the new styles to the workbook
  466.                 $workbook $this->getActiveSheet()->getParent();
  467.                 foreach ($oldXfIndexes as $oldXfIndex => $dummy{
  468.                     $style $workbook->getCellXfByIndex($oldXfIndex);
  469.                     $newStyle clone $style;
  470.                     $newStyle->applyFromArray($pStyles);
  471.  
  472.                     if ($existingStyle $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
  473.                         // there is already such cell Xf in our collection
  474.                         $newXfIndexes[$oldXfIndex$existingStyle->getIndex();
  475.                     else {
  476.                         // we don't have such a cell Xf, need to add
  477.                         $workbook->addCellXf($newStyle);
  478.                         $newXfIndexes[$oldXfIndex$newStyle->getIndex();
  479.                     }
  480.                 }
  481.  
  482.                 // Loop through columns, rows, or cells again and update the XF index
  483.                 switch ($selectionType{
  484.                     case 'COLUMN':
  485.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  486.                             $columnDimension $this->getActiveSheet()->getColumnDimensionByColumn($col);
  487.                             $oldXfIndex $columnDimension->getXfIndex();
  488.                             $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
  489.                         }
  490.                         break;
  491.  
  492.                     case 'ROW':
  493.                         for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  494.                             $rowDimension $this->getActiveSheet()->getRowDimension($row);
  495.                             $oldXfIndex $rowDimension->getXfIndex(=== null ?
  496.                                 $rowDimension->getXfIndex()// row without explicit style should be formatted based on default style
  497.                             $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
  498.                         }
  499.                         break;
  500.  
  501.                     case 'CELL':
  502.                         for ($col $rangeStart[0]$col <= $rangeEnd[0]++$col{
  503.                             for ($row $rangeStart[1]$row <= $rangeEnd[1]++$row{
  504.                                 $cell $this->getActiveSheet()->getCellByColumnAndRow($col$row);
  505.                                 $oldXfIndex $cell->getXfIndex();
  506.                                 $cell->setXfIndex($newXfIndexes[$oldXfIndex]);
  507.                             }
  508.                         }
  509.                         break;
  510.                 }
  511.  
  512.             else {
  513.                 // not a supervisor, just apply the style array directly on style object
  514.                 if (array_key_exists('fill'$pStyles)) {
  515.                     $this->getFill()->applyFromArray($pStyles['fill']);
  516.                 }
  517.                 if (array_key_exists('font'$pStyles)) {
  518.                     $this->getFont()->applyFromArray($pStyles['font']);
  519.                 }
  520.                 if (array_key_exists('borders'$pStyles)) {
  521.                     $this->getBorders()->applyFromArray($pStyles['borders']);
  522.                 }
  523.                 if (array_key_exists('alignment'$pStyles)) {
  524.                     $this->getAlignment()->applyFromArray($pStyles['alignment']);
  525.                 }
  526.                 if (array_key_exists('numberformat'$pStyles)) {
  527.                     $this->getNumberFormat()->applyFromArray($pStyles['numberformat']);
  528.                 }
  529.                 if (array_key_exists('protection'$pStyles)) {
  530.                     $this->getProtection()->applyFromArray($pStyles['protection']);
  531.                 }
  532.             }
  533.         else {
  534.             throw new Exception("Invalid style array passed.");
  535.         }
  536.         return $this;
  537.     }
  538.  
  539.     /**
  540.      * Get Fill
  541.      *
  542.      * @return PHPExcel_Style_Fill 
  543.      */
  544.     public function getFill({
  545.         return $this->_fill;
  546.     }
  547.  
  548.     /**
  549.      * Get Font
  550.      *
  551.      * @return PHPExcel_Style_Font 
  552.      */
  553.     public function getFont({
  554.         return $this->_font;
  555.     }
  556.  
  557.     /**
  558.      * Set font
  559.      *
  560.      * @param PHPExcel_Style_Font $font 
  561.      * @return PHPExcel_Style 
  562.      */
  563.     public function setFont(PHPExcel_Style_Font $font)
  564.     {
  565.         $this->_font $font;
  566.         return $this;
  567.     }
  568.  
  569.     /**
  570.      * Get Borders
  571.      *
  572.      * @return PHPExcel_Style_Borders 
  573.      */
  574.     public function getBorders({
  575.         return $this->_borders;
  576.     }
  577.  
  578.     /**
  579.      * Get Alignment
  580.      *
  581.      * @return PHPExcel_Style_Alignment 
  582.      */
  583.     public function getAlignment({
  584.         return $this->_alignment;
  585.     }
  586.  
  587.     /**
  588.      * Get Number Format
  589.      *
  590.      * @return PHPExcel_Style_NumberFormat 
  591.      */
  592.     public function getNumberFormat({
  593.         return $this->_numberFormat;
  594.     }
  595.  
  596.     /**
  597.      * Get Conditional Styles. Only used on supervisor.
  598.      *
  599.      * @return PHPExcel_Style_Conditional[] 
  600.      */
  601.     public function getConditionalStyles({
  602.         return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
  603.     }
  604.  
  605.     /**
  606.      * Set Conditional Styles. Only used on supervisor.
  607.      *
  608.      * @param PHPExcel_Style_Conditional[]    $pValue    Array of condtional styles
  609.      * @return PHPExcel_Style 
  610.      */
  611.     public function setConditionalStyles($pValue null{
  612.         if (is_array($pValue)) {
  613.             foreach (PHPExcel_Cell::extractAllCellReferencesInRange($this->getSelectedCells()) as $cellReference{
  614.                 $this->getActiveSheet()->setConditionalStyles($cellReference$pValue);
  615.             }
  616.         }
  617.         return $this;
  618.     }
  619.  
  620.     /**
  621.      * Get Protection
  622.      *
  623.      * @return PHPExcel_Style_Protection 
  624.      */
  625.     public function getProtection({
  626.         return $this->_protection;
  627.     }
  628.  
  629.     /**
  630.      * Get hash code
  631.      *
  632.      * @return string    Hash code
  633.      */
  634.     public function getHashCode({
  635.         $hashConditionals '';
  636.         foreach ($this->_conditionalStyles as $conditional{
  637.             $hashConditionals .= $conditional->getHashCode();
  638.         }
  639.  
  640.         return md5(
  641.               $this->getFill()->getHashCode()
  642.             . $this->getFont()->getHashCode()
  643.             . $this->getBorders()->getHashCode()
  644.             . $this->getAlignment()->getHashCode()
  645.             . $this->getNumberFormat()->getHashCode()
  646.             . $hashConditionals
  647.             . $this->getProtection()->getHashCode()
  648.             . __CLASS__
  649.         );
  650.     }
  651.  
  652.     /**
  653.      * Get own index in style collection
  654.      *
  655.      * @return int 
  656.      */
  657.     public function getIndex()
  658.     {
  659.         return $this->_index;
  660.     }
  661.  
  662.     /**
  663.      * Set own index in style collection
  664.      *
  665.      * @param int $pValue 
  666.      */
  667.     public function setIndex($pValue)
  668.     {
  669.         $this->_index $pValue;
  670.     }
  671.  
  672.     /**
  673.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  674.      */
  675.     public function __clone({
  676.         $vars get_object_vars($this);
  677.         foreach ($vars as $key => $value{
  678.             if (is_object($value)) {
  679.                 $this->$key clone $value;
  680.             else {
  681.                 $this->$key $value;
  682.             }
  683.         }
  684.     }
  685. }

Documentation generated on Tue, 01 Jun 2010 17:06:13 +0200 by phpDocumentor 1.4.3