Skip to content

Commit 612ad85

Browse files
author
Julien Carignan
committed
changed heightRule string to exactHeight bool
1 parent 772017d commit 612ad85

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

Classes/PHPWord/Style/Row.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class PHPWord_Style_Row
4646
private $_cantSplit = false;
4747

4848
/**
49-
* Table row height rule (auto, exact, atLeast)
49+
* Table row exact height
5050
*
51-
* @var String
51+
* @var bool
5252
*/
53-
private $_heightRule = null;
53+
private $_exactHeight = false;
5454

5555
/**
5656
* Create a new row style
@@ -121,27 +121,27 @@ public function getCantSplit()
121121
}
122122

123123
/**
124-
* Set heightRule
124+
* Set exactHeight
125125
*
126-
* @param String $pValue
126+
* @param bool $pValue
127127
* @return PHPWord_Style_Row
128128
*/
129-
public function setHeightRule($pValue = false)
129+
public function setExactHeight($pValue = false)
130130
{
131-
if (!is_string($pValue)) {
132-
$pValue = null;
131+
if (!is_bool($pValue)) {
132+
$pValue = false;
133133
}
134-
$this->_heightRule = $pValue;
134+
$this->_exactHeight = $pValue;
135135
return $this;
136136
}
137137

138138
/**
139-
* Get heightRule
139+
* Get exactHeight
140140
*
141-
* @return heightRule
141+
* @return boolean
142142
*/
143-
public function getHeightRule()
143+
public function getExactHeight()
144144
{
145-
return $this->_heightRule;
145+
return $this->_exactHeight;
146146
}
147147
}

Classes/PHPWord/Writer/Word2007/Base.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,17 @@ protected function _writeTable(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo
573573
$rowStyle = $row->getStyle();
574574
$tblHeader = $rowStyle->getTblHeader();
575575
$cantSplit = $rowStyle->getCantSplit();
576-
$heightRule = $rowStyle->getHeightRule();
576+
$exactHeight = $rowStyle->getExactHeight();
577577

578578
$objWriter->startElement('w:tr');
579579

580580
if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) {
581581
$objWriter->startElement('w:trPr');
582582
if (!is_null($height)) {
583583
$objWriter->startElement('w:trHeight');
584-
if(!is_null($heightRule)) {
584+
if($exactHeight) {
585585
$objWriter->startAttribute('w:hRule');
586-
$objWriter->text($heightRule);
586+
$objWriter->text("exact");
587587
$objWriter->endAttribute();
588588
}
589589
$objWriter->writeAttribute('w:val', $height);

samples/Sample_21_TableRowRules.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@
1919
$cell1->addImage("./resources/_earth.jpg", array("width" => 250, "height" => 250, "align" => "center"));
2020

2121
$section->addTextBreak();
22-
$section->addText("But if we set the rowStyle hRule \"exact\", the real row height is used, removing the textbreak:");
22+
$section->addText("But if we set the rowStyle 'exactHeight' to true, the real row height is used, removing the textbreak:");
2323

2424
$table2 = $section->addTable(array("cellMargin"=> 0, "cellMarginRight"=> 0, "cellMarginBottom"=> 0, "cellMarginLeft"=> 0));
25-
$table2->addRow(3750, array("heightRule"=>"exact"));
25+
$table2->addRow(3750, array("exactHeight"=>));
2626
$cell2 = $table2->addCell(null, array("valign" => "top", "borderSize" => 30, "borderColor" => "00ff00"));
2727
$cell2->addImage("./resources/_earth.jpg", array("width" => 250, "height" => 250, "align" => "center"));
2828

2929
$section->addTextBreak();
3030
$section->addText("In this example, image is 250px height. Rows are calculated in twips, and 1px = 15twips.");
31-
$section->addText("So: $"."table2->addRow(3750, array('heightRule'=>'exact'));");
32-
$section->addText("heightRule defaults to 'atLeast' when the row has an height set, and default to 'auto' otherwise");
31+
$section->addText("So: $"."table2->addRow(3750, array('exactHeight'=>true));");
3332

3433
// Save file
3534
$name = basename(__FILE__, '.php');

0 commit comments

Comments
 (0)