phpDocumentor OpenDocumentPHP
content_body_table
[ class tree: OpenDocumentPHP ] [ index: OpenDocumentPHP ] [ all elements ]

Source for file TableCell.php

Documentation is available at TableCell.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /*
  6.  * Created on 04. Jan. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  7.  */
  8.  
  9. /**
  10.  * TableCell class file.
  11.  * 
  12.  * PHP versions 5
  13.  *   
  14.  * LICENSE:
  15.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  19.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26.  *
  27.  * This software consists of voluntary contributions made by many individuals
  28.  * and is licensed under the GPL. For more information please see
  29.  * <http://opendocumentphp.org>.
  30.  * 
  31.  * $Id: TableCell.php 250 2007-07-31 08:52:06Z nmarkgraf $
  32.  * 
  33.  * @category    File Formats
  34.  * @package     OpenDocumentPHP
  35.  * @subpackage  content_body_table
  36.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  37.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  38.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  39.  * @version     SVN: $Id: TableCell.php 250 2007-07-31 08:52:06Z nmarkgraf $
  40.  * @link        http://opendocumentphp.org
  41.  * @since       0.5.0 - 08. Feb. 2007
  42.  */
  43.  
  44. /**
  45.  * 
  46.  */
  47. require_once 'OpenDocumentPHP/OpenDocumentArchive.php';
  48. require_once 'OpenDocumentPHP/util/Namespaces.php';
  49. require_once 'OpenDocumentPHP/util/ODPElement.php';
  50.  
  51. /**
  52.  * TableCell class.
  53.  *  
  54.  * @category    File Formats
  55.  * @package     OpenDocumentPHP
  56.  * @subpackage  content_body_table
  57.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  58.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  59.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  60.  * @version     Release: @package_version@
  61.  * @link        http://opendocumentphp.org
  62.  * @since       0.5.0 - 08. Feb. 2007
  63.  * @todo        This class is highly experimental, outdated and should be updated soon.
  64.  */
  65. class TableCell extends ODPElement implements Namespaces 
  66. {
  67.     
  68.     /**
  69.      * 
  70.      */
  71.     private $x;
  72.     
  73.     /**
  74.      * 
  75.      */
  76.     private $y;
  77.     
  78.     /**     
  79.      * 
  80.      */
  81.     private $root;
  82.     
  83.     /**
  84.      * 
  85.      */
  86.     private $content;
  87.     
  88.     /**
  89.      * 
  90.      */
  91.     private $type;
  92.     
  93.     /**
  94.      * 
  95.      */
  96.     private $link;
  97.     
  98.     /**
  99.      * @access protected
  100.      * @var integer    $spannedRows Numbers of spanned rows
  101.      */
  102.     protected $spannedRows;
  103.     
  104.     /**
  105.      * @access protected
  106.      * @var integer    $spannedCols Number of spanned columns
  107.      */
  108.     protected $spannedCols;
  109.     
  110.     /**
  111.      * @access protected
  112.      * @var integer $decimal Number of decimals of a number.
  113.      */
  114.     protected $decimal;
  115.     
  116.     /**
  117.      * 
  118.      */
  119.     function __construct($elem null,$x,$y)
  120.     {  
  121.         if (is_null($elem)) {
  122.             parent::__construct('table:table-cell'''self::TABLE);
  123.         else {
  124.             parent::__construct($elem);         
  125.         }
  126.         $this->$x;
  127.         $this->$y;
  128.     }
  129.     
  130.     /**
  131.      * 
  132.      */
  133.     function setContent($content{
  134.         $this->content $content;
  135.     }
  136.     
  137.     /**
  138.      * Set a hyperlink with text $content and URI $link into a cell
  139.      * 
  140.      * @param  string $link    URI of the hyperlink where it links to
  141.      * @param  string $content text of the hyperlink which is displayed.
  142.      * @since  0.6.0 - 25. Jul. 2007
  143.      */
  144.     function setLinkContent($link$content)
  145.     {
  146.        $this->content $content;
  147.        $this->link $link;
  148.        $this->type 'hyperlink';
  149.     }
  150.     
  151.     /**
  152.      * 
  153.      */
  154.     function setDecimal($decimal{
  155.         $this->content number_format($this->content$decimal);
  156.         $this->decimal = $decimal;
  157.     }
  158.     
  159.     /**
  160.      * 
  161.      */
  162.     function getContent({
  163.         return $this->content;
  164.     }
  165.     
  166.     /**
  167.      * @todo NOT IMPLEMENTED NOW
  168.      */
  169.     function setFontBold({
  170.     }
  171.     
  172.     /**
  173.      * @todo NOT IMPLEMENTED NOW
  174.      */
  175.     function setFontItalic({
  176.     }
  177.     
  178.     /**
  179.      * @todo NOT IMPLEMENTED NOW
  180.      */
  181.     function setTextCenter({
  182.     }
  183.     
  184.     /**
  185.      *
  186.      * @access     public
  187.      * @return     integer 
  188.      */
  189.     public function getSpannedRows({
  190.         return $this->spannedRows;
  191.     }
  192.     
  193.     /**
  194.      * @access     public
  195.      * @return     integer 
  196.      */
  197.     public function getSpannedCols({
  198.         return $this->spannedCols;
  199.     }
  200.     
  201.     /**
  202.      * 
  203.      */
  204.     function getCellType({
  205.         if (isset($this->type)) {
  206.               $type $this->type;
  207.         else {       
  208.             $content $this->content;
  209.             $type 'string';
  210.             if (is_float($content|| is_numeric($content|| is_int($content)) {
  211.                 $type 'float';
  212.             else {
  213.             
  214.             }
  215.         }
  216.         return $type;
  217.     }
  218.     
  219.     /**
  220.      * 
  221.      */
  222.     function getDocumentFragment({
  223.         $content $this->content;
  224.         $type $this->getCellType();
  225.         if ($this->getSpannedRows(1{
  226.             $this->root->setAttributeNS(self :: TABLE'table:number-rows-spanned'$this->getSpannedRows());
  227.         }
  228.         if ($this->getSpannedCols(1{
  229.             $this->root->setAttributeNS(self :: TABLE'table:number-columns-spanned'$this->getSpannedCols());
  230.         }
  231.         switch ($type{
  232.             case 'float' :
  233.                 $this->root->setAttributeNS(self :: OFFICE'office:value-type'$type);
  234.                 $this->root->setAttributeNS(self :: OFFICE'office:value'$content);
  235.                 if ($content != ''{
  236.                     $text $this->domFragment->createElementNS(self :: TEXT'text:p'$content);                    
  237.                     $this->root->appendChild($text);
  238.                 }
  239.                 break;
  240.                                 
  241.             case 'hyperlink' :
  242.                 if ($content != ''{
  243.                     $this->root->setAttributeNS(self :: OFFICE'office:value-type''string');                                    
  244.                     $text $this->domFragment->createElementNS(self :: TEXT'text:p');                    
  245.                     $anchor $this->domFragment->createElementNS(self::TEXT'text:a'$content);
  246.                     $anchor->setAttributeNS(self::XLINK'link:href'$this->link);
  247.                     $text->appendChild($anchor);
  248.                     $this->root->appendChild($text);
  249.                 }
  250.                 break;                    
  251.                 
  252.             case 'string' :
  253.             default :
  254.                 if ($content != ''{
  255.                     $this->root->setAttributeNS(self :: OFFICE'office:value-type''string');                                 
  256.                     $text $this->domFragment->createElementNS(self :: TEXT'text:p'$content);                    
  257.                     $this->root->appendChild($text);
  258.                 }
  259.         }
  260.         return $this->root;
  261.     }
  262. }
  263. ?>

Documentation generated on Wed, 18 Jun 2008 06:32:44 +0200 by phpDocumentor 1.3.2