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

Source for file Xf.php

Documentation is available at Xf.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_Writer_Excel5
  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.2, 2010-01-11
  26.  */
  27.  
  28. // Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class):
  29. // -----------------------------------------------------------------------------------------
  30. // /*
  31. // *  Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
  32. // *
  33. // *  The majority of this is _NOT_ my code.  I simply ported it from the
  34. // *  PERL Spreadsheet::WriteExcel module.
  35. // *
  36. // *  The author of the Spreadsheet::WriteExcel module is John McNamara 
  37. // *  <jmcnamara@cpan.org>
  38. // *
  39. // *  I _DO_ maintain this code, and John McNamara has nothing to do with the
  40. // *  porting of this code to PHP.  Any questions directly related to this
  41. // *  class library should be directed to me.
  42. // *
  43. // *  License Information:
  44. // *
  45. // *    Spreadsheet_Excel_Writer:  A library for generating Excel Spreadsheets
  46. // *    Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
  47. // *
  48. // *    This library is free software; you can redistribute it and/or
  49. // *    modify it under the terms of the GNU Lesser General Public
  50. // *    License as published by the Free Software Foundation; either
  51. // *    version 2.1 of the License, or (at your option) any later version.
  52. // *
  53. // *    This library is distributed in the hope that it will be useful,
  54. // *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  55. // *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  56. // *    Lesser General Public License for more details.
  57. // *
  58. // *    You should have received a copy of the GNU Lesser General Public
  59. // *    License along with this library; if not, write to the Free Software
  60. // *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  61. // */
  62.  
  63.  
  64. /** PHPExcel root directory */
  65. if (!defined('PHPEXCEL_ROOT')) {
  66.     /**
  67.      * @ignore
  68.      */
  69.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../../');
  70. }
  71.  
  72. /** PHPExcel_Style_Alignment */
  73. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Alignment.php';
  74.  
  75. /** PHPExcel_Style_Border */
  76. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Border.php';
  77.  
  78. /** PHPExcel_Style_Fill */
  79. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Fill.php';
  80.  
  81. /** PHPExcel_Style_Protection */
  82. require_once PHPEXCEL_ROOT 'PHPExcel/Style/Protection.php';
  83.  
  84.  
  85. /**
  86.  * PHPExcel_Writer_Excel5_Xf
  87.  *
  88.  * @category   PHPExcel
  89.  * @package    PHPExcel_Writer_Excel5
  90.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  91.  */
  92. {
  93.     /**
  94.      * BIFF version
  95.      *
  96.      * @var int 
  97.      */
  98.     private $_BIFFVersion;
  99.  
  100.     /**
  101.      * Style XF or a cell XF ?
  102.      *
  103.      * @var boolean 
  104.      */
  105.     private $_isStyleXf;
  106.  
  107.     /**
  108.      * Index to the FONT record. Index 4 does not exist
  109.      * @var integer 
  110.      */
  111.     private $_fontIndex;
  112.  
  113.     /**
  114.      * An index (2 bytes) to a FORMAT record (number format).
  115.      * @var integer 
  116.      */
  117.     var $_numberFormatIndex;
  118.  
  119.     /**
  120.      * 1 bit, apparently not used.
  121.      * @var integer 
  122.      */
  123.     var $_text_justlast;
  124.  
  125.     /**
  126.      * The cell's foreground color.
  127.      * @var integer 
  128.      */
  129.     var $_fg_color;
  130.  
  131.     /**
  132.      * The cell's background color.
  133.      * @var integer 
  134.      */
  135.     var $_bg_color;
  136.  
  137.     /**
  138.      * Color of the bottom border of the cell.
  139.      * @var integer 
  140.      */
  141.     var $_bottom_color;
  142.  
  143.     /**
  144.      * Color of the top border of the cell.
  145.      * @var integer 
  146.      */
  147.     var $_top_color;
  148.  
  149.     /**
  150.     * Color of the left border of the cell.
  151.     * @var integer 
  152.     */
  153.     var $_left_color;
  154.  
  155.     /**
  156.      * Color of the right border of the cell.
  157.      * @var integer 
  158.      */
  159.     var $_right_color;
  160.  
  161.     /**
  162.      * Constructor
  163.      *
  164.      * @access private
  165.      * @param integer $index the XF index for the format.
  166.      * @param PHPExcel_Style 
  167.      */
  168.     public function __construct(PHPExcel_Style $style null)
  169.     {
  170.         $this->_isStyleXf =     false;
  171.         $this->_BIFFVersion   = 0x0600;
  172.         $this->_fontIndex      = 0;
  173.  
  174.         $this->_numberFormatIndex     = 0;
  175.  
  176.         $this->_text_justlast  = 0;
  177.  
  178.         $this->_fg_color       = 0x40;
  179.         $this->_bg_color       = 0x41;
  180.  
  181.         $this->_diag           0;
  182.  
  183.         $this->_bottom_color   = 0x40;
  184.         $this->_top_color      = 0x40;
  185.         $this->_left_color     = 0x40;
  186.         $this->_right_color    = 0x40;
  187.         $this->_diag_color     0x40;
  188.         $this->_style $style;
  189.  
  190.     }
  191.  
  192.  
  193.     /**
  194.      * Generate an Excel BIFF XF record (style or cell).
  195.      *
  196.      * @param string $style The type of the XF record ('style' or 'cell').
  197.      * @return string The XF record
  198.      */
  199.     function writeXf()
  200.     {
  201.         // Set the type of the XF record and some of the attributes.
  202.         if ($this->_isStyleXf{
  203.             $style 0xFFF5;
  204.         else {
  205.             $style   $this->_mapLocked($this->_style->getProtection()->getLocked());
  206.             $style  |= $this->_mapHidden($this->_style->getProtection()->getHidden()) << 1;
  207.         }
  208.  
  209.         // Flags to indicate if attributes have been set.
  210.         $atr_num     ($this->_numberFormatIndex != 0)?1:0;
  211.         $atr_fnt     ($this->_fontIndex != 0)?1:0;
  212.         $atr_alc     ((int) $this->_style->getAlignment()->getWrapText())?1:0;
  213.         $atr_bdr     ($this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())   ||
  214.                         $this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())      ||
  215.                         $this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle())     ||
  216.                         $this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
  217.         $atr_pat     (($this->_fg_color != 0x40||
  218.                         ($this->_bg_color != 0x41||
  219.                         $this->_mapFillType($this->_style->getFill()->getFillType()))?1:0;
  220.         $atr_prot    $this->_mapLocked($this->_style->getProtection()->getLocked())
  221.                         | $this->_mapHidden($this->_style->getProtection()->getHidden());
  222.  
  223.         // Zero the default border colour if the border has not been set.
  224.         if ($this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0{
  225.             $this->_bottom_color = 0;
  226.         }
  227.         if ($this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())  == 0{
  228.             $this->_top_color = 0;
  229.         }
  230.         if ($this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0{
  231.             $this->_right_color = 0;
  232.         }
  233.         if ($this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0{
  234.             $this->_left_color = 0;
  235.         }
  236.         if ($this->_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0{
  237.             $this->_diag_color 0;
  238.         }
  239.  
  240.         $record         0x00E0;              // Record identifier
  241.         if ($this->_BIFFVersion == 0x0500{
  242.             $length         0x0010;              // Number of bytes to follow
  243.         }
  244.         if ($this->_BIFFVersion == 0x0600{
  245.             $length         0x0014;
  246.         }
  247.  
  248.         $ifnt           $this->_fontIndex;   // Index to FONT record
  249.         $ifmt           $this->_numberFormatIndex;  // Index to FORMAT record
  250.         if ($this->_BIFFVersion == 0x0500{
  251.             $align          $this->_mapHAlign($this->_style->getAlignment()->getHorizontal());       // Alignment
  252.             $align         |= (int) $this->_style->getAlignment()->getWrapText()     << 3;
  253.             $align         |= $this->_mapVAlign($this->_style->getAlignment()->getVertical())  << 4;
  254.             $align         |= $this->_text_justlast << 7;
  255.             $align         |= 0                       << 8// rotation
  256.             $align         |= $atr_num                << 10;
  257.             $align         |= $atr_fnt                << 11;
  258.             $align         |= $atr_alc                << 12;
  259.             $align         |= $atr_bdr                << 13;
  260.             $align         |= $atr_pat                << 14;
  261.             $align         |= $atr_prot               << 15;
  262.  
  263.             $icv            $this->_fg_color;       // fg and bg pattern colors
  264.             $icv           |= $this->_bg_color      << 7;
  265.  
  266.             $fill           $this->_mapFillType($this->_style->getFill()->getFillType());        // Fill and border line style
  267.             $fill          |= $this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())        << 6;
  268.             $fill          |= $this->_bottom_color  << 9;
  269.  
  270.             $border1        $this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle());            // Border line style and color
  271.             $border1       |= $this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle())          << 3;
  272.             $border1       |= $this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())         << 6;
  273.             $border1       |= $this->_top_color     << 9;
  274.  
  275.             $border2        $this->_left_color;     // Border color
  276.             $border2       |= $this->_right_color   << 7;
  277.  
  278.             $header      pack("vv",       $record$length);
  279.             $data        pack("vvvvvvvv"$ifnt$ifmt$style$align,
  280.                                             $icv$fill,
  281.                                             $border1$border2);
  282.         elseif ($this->_BIFFVersion == 0x0600{
  283.             $align          $this->_mapHAlign($this->_style->getAlignment()->getHorizontal());       // Alignment
  284.             $align         |= (int) $this->_style->getAlignment()->getWrapText()     << 3;
  285.             $align         |= $this->_mapVAlign($this->_style->getAlignment()->getVertical())  << 4;
  286.             $align         |= $this->_text_justlast << 7;
  287.  
  288.             $used_attrib    $atr_num              << 2;
  289.             $used_attrib   |= $atr_fnt              << 3;
  290.             $used_attrib   |= $atr_alc              << 4;
  291.             $used_attrib   |= $atr_bdr              << 5;
  292.             $used_attrib   |= $atr_pat              << 6;
  293.             $used_attrib   |= $atr_prot             << 7;
  294.  
  295.             $icv            $this->_fg_color;      // fg and bg pattern colors
  296.             $icv           |= $this->_bg_color      << 7;
  297.  
  298.             $border1        $this->_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());          // Border line style and color
  299.             $border1       |= $this->_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())         << 4;
  300.             $border1       |= $this->_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())           << 8;
  301.             $border1       |= $this->_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())        << 12;
  302.             $border1       |= $this->_left_color    << 16;
  303.             $border1       |= $this->_right_color   << 23;
  304.  
  305.             $diagonalDirection $this->_style->getBorders()->getDiagonalDirection();
  306.             $diag_tl_to_rb $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
  307.                                 || $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
  308.             $diag_tr_to_lb $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
  309.                                 || $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
  310.             $border1       |= $diag_tl_to_rb        << 30;
  311.             $border1       |= $diag_tr_to_lb        << 31;
  312.  
  313.             $border2        $this->_top_color;    // Border color
  314.             $border2       |= $this->_bottom_color   << 7;
  315.             $border2       |= $this->_diag_color     << 14;
  316.             $border2       |= $this->_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle())           << 21;
  317.             $border2       |= $this->_mapFillType($this->_style->getFill()->getFillType())        << 26;
  318.  
  319.             $header      pack("vv",       $record$length);
  320.  
  321.             //BIFF8 options: identation, shrinkToFit and  text direction
  322.             $biff8_options  $this->_style->getAlignment()->getIndent();
  323.             $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit(<< 4;
  324.  
  325.             $data  pack("vvvC"$ifnt$ifmt$style$align);
  326.             $data .= pack("CCC"
  327.                 $this->_mapTextRotation($this->_style->getAlignment()->getTextRotation())
  328.                 $biff8_options
  329.                 $used_attrib
  330.                 );
  331.             $data .= pack("VVv"$border1$border2$icv);
  332.         }
  333.  
  334.         return($header $data);
  335.     }
  336.  
  337.     /**
  338.      * Set BIFF version
  339.      *
  340.      * @param int $BIFFVersion 
  341.      */
  342.     public function setBIFFVersion($BIFFVersion)
  343.     {
  344.         $this->_BIFFVersion = $BIFFVersion;
  345.     }
  346.  
  347.     /**
  348.      * Is this a style XF ?
  349.      *
  350.      * @param boolean $value 
  351.      */
  352.     public function setIsStyleXf($value)
  353.     {
  354.         $this->_isStyleXf = $value;
  355.     }
  356.  
  357.     /**
  358.      * Sets the cell's bottom border color
  359.      *
  360.      * @access public
  361.      * @param int $colorIndex Color index
  362.      */
  363.     function setBottomColor($colorIndex)
  364.     {
  365.         $this->_bottom_color = $colorIndex;
  366.     }
  367.  
  368.     /**
  369.      * Sets the cell's top border color
  370.      *
  371.      * @access public
  372.      * @param int $colorIndex Color index
  373.      */
  374.     function setTopColor($colorIndex)
  375.     {
  376.         $this->_top_color = $colorIndex;
  377.     }
  378.  
  379.     /**
  380.      * Sets the cell's left border color
  381.      *
  382.      * @access public
  383.      * @param int $colorIndex Color index
  384.      */
  385.     function setLeftColor($colorIndex)
  386.     {
  387.         $this->_left_color = $colorIndex;
  388.     }
  389.  
  390.     /**
  391.      * Sets the cell's right border color
  392.      *
  393.      * @access public
  394.      * @param int $colorIndex Color index
  395.      */
  396.     function setRightColor($colorIndex)
  397.     {
  398.         $this->_right_color = $colorIndex;
  399.     }
  400.  
  401.     /**
  402.      * Sets the cell's diagonal border color
  403.      *
  404.      * @access public
  405.      * @param int $colorIndex Color index
  406.      */
  407.     function setDiagColor($colorIndex)
  408.     {
  409.         $this->_diag_color $colorIndex;
  410.     }
  411.  
  412.  
  413.     /**
  414.      * Sets the cell's foreground color
  415.      *
  416.      * @access public
  417.      * @param int $colorIndex Color index
  418.      */
  419.     function setFgColor($colorIndex)
  420.     {
  421.         $this->_fg_color = $colorIndex;
  422.     }
  423.  
  424.     /**
  425.      * Sets the cell's background color
  426.      *
  427.      * @access public
  428.      * @param int $colorIndex Color index
  429.      */
  430.     function setBgColor($colorIndex)
  431.     {
  432.         $this->_bg_color = $colorIndex;
  433.     }
  434.  
  435.     /**
  436.      * Sets the index to the number format record
  437.      * It can be date, time, currency, etc...
  438.      *
  439.      * @access public
  440.      * @param integer $numberFormatIndex Index to format record
  441.      */
  442.     function setNumberFormatIndex($numberFormatIndex)
  443.     {
  444.         $this->_numberFormatIndex = $numberFormatIndex;
  445.     }
  446.  
  447.     /**
  448.      * Set the font index.
  449.      *
  450.      * @param int $value Font index, note that value 4 does not exist
  451.      */
  452.     public function setFontIndex($value)
  453.     {
  454.         $this->_fontIndex = $value;
  455.     }
  456.  
  457.     /**
  458.      * Map border style
  459.      */
  460.     private function _mapBorderStyle($borderStyle{
  461.         switch ($borderStyle{
  462.             case PHPExcel_Style_Border::BORDER_NONE:                return 0x00;
  463.             case PHPExcel_Style_Border::BORDER_THIN;                return 0x01;
  464.             case PHPExcel_Style_Border::BORDER_MEDIUM;                return 0x02;
  465.             case PHPExcel_Style_Border::BORDER_DASHED;                return 0x03;
  466.             case PHPExcel_Style_Border::BORDER_DOTTED;                return 0x04;
  467.             case PHPExcel_Style_Border::BORDER_THICK;                return 0x05;
  468.             case PHPExcel_Style_Border::BORDER_DOUBLE;                return 0x06;
  469.             case PHPExcel_Style_Border::BORDER_HAIR;                return 0x07;
  470.             case PHPExcel_Style_Border::BORDER_MEDIUMDASHED;        return 0x08;
  471.             case PHPExcel_Style_Border::BORDER_DASHDOT;                return 0x09;
  472.             case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT;        return 0x0A;
  473.             case PHPExcel_Style_Border::BORDER_DASHDOTDOT;            return 0x0B;
  474.             case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;    return 0x0C;
  475.             case PHPExcel_Style_Border::BORDER_SLANTDASHDOT;        return 0x0D;
  476.             default:                                                return 0x00;
  477.         }
  478.     }
  479.  
  480.     /**
  481.      * Map fill type
  482.      */
  483.     private function _mapFillType($fillType{
  484.         switch ($fillType{
  485.             case PHPExcel_Style_Fill::FILL_NONE:                    return 0x00;
  486.             case PHPExcel_Style_Fill::FILL_SOLID:                    return 0x01;
  487.             case PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY:        return 0x02;
  488.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY:        return 0x03;
  489.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY:        return 0x04;
  490.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL:    return 0x05;
  491.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL:    return 0x06;
  492.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN:        return 0x07;
  493.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKUP:            return 0x08;
  494.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID:        return 0x09;
  495.             case PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS:        return 0x0A;
  496.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL:    return 0x0B;
  497.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL:    return 0x0C;
  498.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN:        return 0x0D;
  499.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP:            return 0x0E;
  500.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID:        return 0x0F;
  501.             case PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS:    return 0x10;
  502.             case PHPExcel_Style_Fill::FILL_PATTERN_GRAY125:            return 0x11;
  503.             case PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625:        return 0x12;
  504.             case PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR:        // does not exist in BIFF8
  505.             case PHPExcel_Style_Fill::FILL_GRADIENT_PATH:        // does not exist in BIFF8
  506.             default:                                                return 0x00;
  507.         }
  508.     }
  509.  
  510.     /**
  511.      * Map to BIFF2-BIFF8 codes for horizontal alignment
  512.      *
  513.      * @param string $hAlign 
  514.      * @return int 
  515.      */
  516.     private function _mapHAlign($hAlign)
  517.     {
  518.         switch ($hAlign{
  519.             case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL:                return 0;
  520.             case PHPExcel_Style_Alignment::HORIZONTAL_LEFT:                    return 1;
  521.             case PHPExcel_Style_Alignment::HORIZONTAL_CENTER:                return 2;
  522.             case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT:                return 3;
  523.             case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY:                return 5;
  524.             case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS:    return 6;
  525.             default:                                                        return 0;
  526.         }
  527.     }
  528.  
  529.     /**
  530.      * Map to BIFF2-BIFF8 codes for vertical alignment
  531.      *
  532.      * @param string $vAlign 
  533.      * @return int 
  534.      */
  535.     private function _mapVAlign($vAlign{
  536.         switch ($vAlign{
  537.             case PHPExcel_Style_Alignment::VERTICAL_TOP:        return 0;
  538.             case PHPExcel_Style_Alignment::VERTICAL_CENTER:        return 1;
  539.             case PHPExcel_Style_Alignment::VERTICAL_BOTTOM:        return 2;
  540.             case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY:    return 3;
  541.             default:                                            return 2;
  542.         }
  543.     }
  544.  
  545.     /**
  546.      * Map to BIFF8 codes for text rotation angle
  547.      *
  548.      * @param int $textRotation 
  549.      * @return int 
  550.      */
  551.     private function _mapTextRotation($textRotation{
  552.         if ($textRotation >= 0{
  553.             return $textRotation;
  554.         }
  555.         if ($textRotation == -165{
  556.             return 255;
  557.         }
  558.         if ($textRotation 0{
  559.             return 90 $textRotation;
  560.         }
  561.     }
  562.  
  563.     /**
  564.      * Map locked
  565.      *
  566.      * @param string 
  567.      * @return int 
  568.      */
  569.     private function _mapLocked($locked{
  570.         switch ($locked{
  571.             case PHPExcel_Style_Protection::PROTECTION_INHERIT:        return 1;
  572.             case PHPExcel_Style_Protection::PROTECTION_PROTECTED:    return 1;
  573.             case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED:    return 0;
  574.             default:                                                return 1;
  575.         }
  576.     }
  577.  
  578.     /**
  579.      * Map hidden
  580.      *
  581.      * @param string 
  582.      * @return int 
  583.      */
  584.     private function _mapHidden($hidden{
  585.         switch ($hidden{
  586.             case PHPExcel_Style_Protection::PROTECTION_INHERIT:        return 0;
  587.             case PHPExcel_Style_Protection::PROTECTION_PROTECTED:    return 1;
  588.             case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED:    return 0;
  589.             default:                                                return 0;
  590.         }
  591.     }
  592.  
  593. }

Documentation generated on Mon, 11 Jan 2010 08:19:20 +0100 by phpDocumentor 1.4.1