From 612ad857739ff7cdb6e26fbfa8585588e33a0596 Mon Sep 17 00:00:00 2001 From: Julien Carignan Date: Fri, 28 Mar 2014 15:21:01 -0400 Subject: [PATCH] changed heightRule string to exactHeight bool --- Classes/PHPWord/Style/Row.php | 26 ++++++++++++------------ Classes/PHPWord/Writer/Word2007/Base.php | 6 +++--- samples/Sample_21_TableRowRules.php | 7 +++---- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Classes/PHPWord/Style/Row.php b/Classes/PHPWord/Style/Row.php index aae7e851..d779d3cc 100644 --- a/Classes/PHPWord/Style/Row.php +++ b/Classes/PHPWord/Style/Row.php @@ -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; } } diff --git a/Classes/PHPWord/Writer/Word2007/Base.php b/Classes/PHPWord/Writer/Word2007/Base.php index 16680ae2..1cf3bad3 100755 --- a/Classes/PHPWord/Writer/Word2007/Base.php +++ b/Classes/PHPWord/Writer/Word2007/Base.php @@ -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); diff --git a/samples/Sample_21_TableRowRules.php b/samples/Sample_21_TableRowRules.php index 18c67be3..1082f99f 100644 --- a/samples/Sample_21_TableRowRules.php +++ b/samples/Sample_21_TableRowRules.php @@ -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');