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

Source for file TableCell.php

Documentation is available at TableCell.php

  1. <?php
  2. /*
  3.  * Created on 04.01.2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  4.  *
  5.  * PHP versions 5.2 or better.
  6.  *
  7.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  8.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  10.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  11.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  12.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  17.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18.  *
  19.  * This software consists of voluntary contributions made by many individuals
  20.  * and is licensed under the GPL. For more information please see
  21.  * <http://opendocumentphp.org>.
  22.  * 
  23.  * $Id: TableCell.php 132 2007-02-25 12:06:22Z nmarkgraf $
  24.  *
  25.  */
  26. /**
  27.  * TableCell class.
  28.  * 
  29.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  30.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  31.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  32.  * @version        $Revision: 132 $
  33.  * @package        OpenDocumentPHP
  34.  * @since         0.5.0 - 08.02.2007
  35.  * @todo         This class is highly experimental, outdated and should be updated soon.
  36.  */
  37. class TableCell {
  38.     const TABLE 'urn:oasis:names:tc:opendocument:xmlns:table:1.0';
  39.     const TEXT 'urn:oasis:names:tc:opendocument:xmlns:text:1.0';
  40.     const OFFICE 'urn:oasis:names:tc:opendocument:xmlns:office:1.0';
  41.     private $domFragment;
  42.     private $x;
  43.     private $y;
  44.     private $root;
  45.     private $content;
  46.     /**
  47.      * @access protected
  48.      * @var integer    $spannedRows Numbers of spanned rows
  49.      */
  50.     protected $spannedRows;
  51.     /**
  52.      * @access protected
  53.      * @var integer    $spannedCols Number of spanned columns
  54.      */
  55.     protected $spannedCols;
  56.     /**
  57.      * @access protected
  58.      * @var integer $decimal Number of decimals of a number.
  59.      */
  60.     protected $decimal;
  61.     function __construct($domFragment$x$y{
  62.         $this->$x;
  63.         $this->$y;
  64.         $this->domFragment $domFragment;
  65.         $this->root $this->domFragment->createElementNS(self :: TABLE'table:table-cell');
  66.     }
  67.     function setContent($content{
  68.         $this->content $content;
  69.     }
  70.     function setDecimal($decimal{
  71.         $this->content number_format($this->content$decimal);
  72.         $this->decimal = $decimal;
  73.     }
  74.     function getContent({
  75.         return $this->content;
  76.     }
  77.     /**
  78.      * @todo NOT IMPLEMENTED NOW
  79.      */
  80.     function setFontBold({
  81.     }
  82.     /**
  83.      * @todo NOT IMPLEMENTED NOW
  84.      */
  85.     function setFontItalic({
  86.     }
  87.     /**
  88.      * @todo NOT IMPLEMENTED NOW
  89.      */
  90.     function setTextCenter({
  91.     }
  92.     /**
  93.      *
  94.      * @access     public
  95.      * @return     integer 
  96.      */
  97.     public function getSpannedRows({
  98.         return $this->spannedRows;
  99.     }
  100.     /**
  101.      * @access     public
  102.      * @return     integer 
  103.      */
  104.     public function getSpannedCols({
  105.         return $this->spannedCols;
  106.     }
  107.     function getCellType({
  108.         $content $this->content;
  109.         $type 'string';
  110.         if (is_float($content|| is_numeric($content|| is_int($content)) {
  111.             $type 'float';
  112.         else {
  113.         }
  114.         return $type;
  115.     }
  116.     function getDocumentFragment({
  117.         $content $this->content;
  118.         $type $this->getCellType();
  119.         if ($this->getSpannedRows(1{
  120.             $this->root->setAttributeNS(self :: TABLE'table:number-rows-spanned'$this->getSpannedRows());
  121.         }
  122.         if ($this->getSpannedCols(1{
  123.             $this->root->setAttributeNS(self :: TABLE'table:number-columns-spanned'$this->getSpannedCols());
  124.         }
  125.         switch ($type{
  126.             case 'float' :
  127.                 $this->root->setAttributeNS(self :: OFFICE'office:value-type'$type);
  128.                 $this->root->setAttributeNS(self :: OFFICE'office:value'$content);
  129.             case 'string' :
  130.             default :
  131.                 if ($content != ''{
  132.                     $text $this->domFragment->createElementNS(self :: TEXT'text:p'$content);
  133.                     $text->setAttributeNS(self :: OFFICE'office:value-type'$type);
  134.                     $this->root->appendChild($text);
  135.                 }
  136.         }
  137.         return $this->root;
  138.     }
  139. }
  140. ?>

Documentation generated on Tue, 12 Jun 2007 10:00:50 +0200 by phpDocumentor 1.3.2