changed heightRule string to exactHeight bool
This commit is contained in:
parent
772017d8e3
commit
612ad85773
|
|
@ -46,11 +46,11 @@ class PHPWord_Style_Row
|
|||
private $_cantSplit = false;
|
||||
|
||||
/**
|
||||
* Table row height rule (auto, exact, atLeast)
|
||||
* Table row exact height
|
||||
*
|
||||
* @var String
|
||||
* @var bool
|
||||
*/
|
||||
private $_heightRule = null;
|
||||
private $_exactHeight = false;
|
||||
|
||||
/**
|
||||
* Create a new row style
|
||||
|
|
@ -121,27 +121,27 @@ class PHPWord_Style_Row
|
|||
}
|
||||
|
||||
/**
|
||||
* Set heightRule
|
||||
* Set exactHeight
|
||||
*
|
||||
* @param String $pValue
|
||||
* @param bool $pValue
|
||||
* @return PHPWord_Style_Row
|
||||
*/
|
||||
public function setHeightRule($pValue = false)
|
||||
public function setExactHeight($pValue = false)
|
||||
{
|
||||
if (!is_string($pValue)) {
|
||||
$pValue = null;
|
||||
if (!is_bool($pValue)) {
|
||||
$pValue = false;
|
||||
}
|
||||
$this->_heightRule = $pValue;
|
||||
$this->_exactHeight = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get heightRule
|
||||
* Get exactHeight
|
||||
*
|
||||
* @return heightRule
|
||||
* @return boolean
|
||||
*/
|
||||
public function getHeightRule()
|
||||
public function getExactHeight()
|
||||
{
|
||||
return $this->_heightRule;
|
||||
return $this->_exactHeight;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$rowStyle = $row->getStyle();
|
||||
$tblHeader = $rowStyle->getTblHeader();
|
||||
$cantSplit = $rowStyle->getCantSplit();
|
||||
$heightRule = $rowStyle->getHeightRule();
|
||||
$exactHeight = $rowStyle->getExactHeight();
|
||||
|
||||
$objWriter->startElement('w:tr');
|
||||
|
||||
|
|
@ -581,9 +581,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
|||
$objWriter->startElement('w:trPr');
|
||||
if (!is_null($height)) {
|
||||
$objWriter->startElement('w:trHeight');
|
||||
if(!is_null($heightRule)) {
|
||||
if($exactHeight) {
|
||||
$objWriter->startAttribute('w:hRule');
|
||||
$objWriter->text($heightRule);
|
||||
$objWriter->text("exact");
|
||||
$objWriter->endAttribute();
|
||||
}
|
||||
$objWriter->writeAttribute('w:val', $height);
|
||||
|
|
|
|||
|
|
@ -19,17 +19,16 @@ $cell1 = $table1->addCell(null, array("valign" => "top", "borderSize" => 30, "bo
|
|||
$cell1->addImage("./resources/_earth.jpg", array("width" => 250, "height" => 250, "align" => "center"));
|
||||
|
||||
$section->addTextBreak();
|
||||
$section->addText("But if we set the rowStyle hRule \"exact\", the real row height is used, removing the textbreak:");
|
||||
$section->addText("But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:");
|
||||
|
||||
$table2 = $section->addTable(array("cellMargin"=> 0, "cellMarginRight"=> 0, "cellMarginBottom"=> 0, "cellMarginLeft"=> 0));
|
||||
$table2->addRow(3750, array("heightRule"=>"exact"));
|
||||
$table2->addRow(3750, array("exactHeight"=>));
|
||||
$cell2 = $table2->addCell(null, array("valign" => "top", "borderSize" => 30, "borderColor" => "00ff00"));
|
||||
$cell2->addImage("./resources/_earth.jpg", array("width" => 250, "height" => 250, "align" => "center"));
|
||||
|
||||
$section->addTextBreak();
|
||||
$section->addText("In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.");
|
||||
$section->addText("So: $"."table2->addRow(3750, array('heightRule'=>'exact'));");
|
||||
$section->addText("heightRule defaults to 'atLeast' when the row has an height set, and default to 'auto' otherwise");
|
||||
$section->addText("So: $"."table2->addRow(3750, array('exactHeight'=>true));");
|
||||
|
||||
// Save file
|
||||
$name = basename(__FILE__, '.php');
|
||||
|
|
|
|||
Loading…
Reference in New Issue