Merge pull request #2294 from Progi1984/htmlTableBorder
HTML Reader : Use `border` attribute for tables
This commit is contained in:
commit
7df75b2efe
|
|
@ -372,17 +372,11 @@ class Html
|
||||||
|
|
||||||
$newElement = $element->addTable($elementStyles);
|
$newElement = $element->addTable($elementStyles);
|
||||||
|
|
||||||
// $attributes = $node->attributes;
|
$attributes = $node->attributes;
|
||||||
// if ($attributes->getNamedItem('width') !== null) {
|
if ($attributes->getNamedItem('border') !== null) {
|
||||||
// $newElement->setWidth($attributes->getNamedItem('width')->value);
|
$border = (int) $attributes->getNamedItem('border')->value;
|
||||||
// }
|
$newElement->getStyle()->setBorderSize(Converter::pixelToTwip($border));
|
||||||
|
}
|
||||||
// if ($attributes->getNamedItem('height') !== null) {
|
|
||||||
// $newElement->setHeight($attributes->getNamedItem('height')->value);
|
|
||||||
// }
|
|
||||||
// if ($attributes->getNamedItem('width') !== null) {
|
|
||||||
// $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $newElement;
|
return $newElement;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,35 @@ class HtmlTest extends AbstractWebServerEmbeddedTest
|
||||||
$this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:pBdr'));
|
$this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:pBdr'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test parsing table (attribute border)
|
||||||
|
*/
|
||||||
|
public function testParseTableAttributeBorder()
|
||||||
|
{
|
||||||
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
$html = '<table border="10">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Header</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr><td>Cell 1</td></tr>
|
||||||
|
<tr><td>Cell 2</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>';
|
||||||
|
Html::addHtml($section, $html);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||||
|
$this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl'));
|
||||||
|
$this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tblPr'));
|
||||||
|
$this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tblPr/w:tblBorders'));
|
||||||
|
$this->assertTrue($doc->elementExists('/w:document/w:body/w:tbl/w:tblPr/w:tblBorders/w:top'));
|
||||||
|
// 10 pixels = 150 twips
|
||||||
|
$this->assertEquals(150, $doc->getElementAttribute('/w:document/w:body/w:tbl/w:tblPr/w:tblBorders/w:top', 'w:sz'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests parsing of ul/li
|
* Tests parsing of ul/li
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue