182 lines
3.6 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* PHPWord
*
2013-12-11 19:57:36 -05:00
* Copyright (c) 2013 PHPWord
2012-05-06 18:25:40 +02:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPWord
* @package PHPWord
2013-12-16 06:40:30 -05:00
* @copyright Copyright (c) 2013 PHPWord
2012-05-06 18:25:40 +02:00
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2013-12-11 19:57:36 -05:00
* @version 0.7.0
2012-05-06 18:25:40 +02:00
*/
/**
2013-12-11 19:57:36 -05:00
* Class PHPWord_Section_Table
2012-05-06 18:25:40 +02:00
*/
class PHPWord_Section_Table
{
/**
* Table style
*
* @var PHPWord_Style_Table
*/
private $_style;
/**
* Table rows
*
* @var array
*/
private $_rows = array();
/**
* Row heights
*
* @var array
*/
private $_rowHeights = array();
/**
* Table holder
*
* @var string
*/
private $_insideOf = null;
/**
* Table holder count
*
* @var array
*/
private $_pCount;
/**
* Table width
*
* @var int
*/
private $_width = null;
/**
* Create a new table
*
* @param string $insideOf
* @param int $pCount
* @param mixed $style
*/
public function __construct($insideOf, $pCount, $style = null)
{
$this->_insideOf = $insideOf;
$this->_pCount = $pCount;
if (!is_null($style)) {
if (is_array($style)) {
$this->_style = new PHPWord_Style_Table();
foreach ($style as $key => $value) {
if (substr($key, 0, 1) != '_') {
$key = '_' . $key;
}
$this->_style->setStyleValue($key, $value);
}
} else {
$this->_style = $style;
}
}
}
/**
* Add a row
*
* @param int $height
*/
public function addRow($height = null)
{
$this->_rows[] = array();
$this->_rowHeights[] = $height;
}
/**
* Add a cell
*
* @param int $width
* @param mixed $style
* @return PHPWord_Section_Table_Cell
*/
public function addCell($width = null, $style = null)
{
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
$i = count($this->_rows) - 1;
$this->_rows[$i][] = $cell;
return $cell;
}
/**
* Get all rows
*
* @return array
*/
public function getRows()
{
return $this->_rows;
}
/**
* Get all row heights
*
* @return array
*/
public function getRowHeights()
{
return $this->_rowHeights;
}
/**
* Get table style
*
* @return PHPWord_Style_Table
*/
public function getStyle()
{
return $this->_style;
}
/**
* Set table width
*
* @var int $width
*/
public function setWidth($width)
{
$this->_width = $width;
}
/**
* Get table width
*
* @return int
*/
public function getWidth()
{
return $this->_width;
}
2012-05-06 18:25:40 +02:00
}