(1) new width property for table; (2) allow table cell width to be null
This commit is contained in:
parent
d55db9da83
commit
4d94d5763c
|
|
@ -66,6 +66,13 @@ class PHPWord_Section_Table
|
||||||
*/
|
*/
|
||||||
private $_pCount;
|
private $_pCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table width
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $_width = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new table
|
* Create a new table
|
||||||
|
|
@ -113,7 +120,7 @@ class PHPWord_Section_Table
|
||||||
* @param mixed $style
|
* @param mixed $style
|
||||||
* @return PHPWord_Section_Table_Cell
|
* @return PHPWord_Section_Table_Cell
|
||||||
*/
|
*/
|
||||||
public function addCell($width, $style = null)
|
public function addCell($width = null, $style = null)
|
||||||
{
|
{
|
||||||
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
|
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
|
||||||
$i = count($this->_rows) - 1;
|
$i = count($this->_rows) - 1;
|
||||||
|
|
@ -150,4 +157,25 @@ class PHPWord_Section_Table
|
||||||
{
|
{
|
||||||
return $this->_style;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@
|
||||||
*/
|
*/
|
||||||
class PHPWord_Style_Table
|
class PHPWord_Style_Table
|
||||||
{
|
{
|
||||||
|
const WIDTH_TYPE_NIL = 'nil'; // No Width
|
||||||
|
const WIDTH_TYPE_PERCENT = 'pct'; // Width in Fiftieths of a Percent
|
||||||
|
const WIDTH_TYPE_POINT = 'dxa'; // Width in Twentieths of a Point
|
||||||
|
const WIDTH_TYPE_AUTO = 'auto'; // Automatically Determined Width
|
||||||
|
|
||||||
private $_cellMarginTop;
|
private $_cellMarginTop;
|
||||||
private $_cellMarginLeft;
|
private $_cellMarginLeft;
|
||||||
|
|
|
||||||
|
|
@ -412,6 +412,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||||
if ($_cRows > 0) {
|
if ($_cRows > 0) {
|
||||||
$objWriter->startElement('w:tbl');
|
$objWriter->startElement('w:tbl');
|
||||||
$tblStyle = $table->getStyle();
|
$tblStyle = $table->getStyle();
|
||||||
|
$tblWidth = $table->getWidth();
|
||||||
if ($tblStyle instanceof PHPWord_Style_Table) {
|
if ($tblStyle instanceof PHPWord_Style_Table) {
|
||||||
$this->_writeTableStyle($objWriter, $tblStyle);
|
$this->_writeTableStyle($objWriter, $tblStyle);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -420,6 +421,12 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||||
$objWriter->startElement('w:tblStyle');
|
$objWriter->startElement('w:tblStyle');
|
||||||
$objWriter->writeAttribute('w:val', $tblStyle);
|
$objWriter->writeAttribute('w:val', $tblStyle);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
if (!is_null($tblWidth)) {
|
||||||
|
$objWriter->startElement('w:tblW');
|
||||||
|
$objWriter->writeAttribute('w:w', $tblWidth);
|
||||||
|
$objWriter->writeAttribute('w:type', 'pct');
|
||||||
|
$objWriter->endElement();
|
||||||
|
}
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue