Merge branch 'parsing_heading2' develop
Conflicts: src/PhpWord/Reader/Word2007/Styles.php tests/PhpWord/Reader/Word2007/StyleTest.php
This commit is contained in:
commit
b2c627d57c
@ -64,12 +64,12 @@ class Styles extends AbstractPart
|
|||||||
if ($nodes->length > 0) {
|
if ($nodes->length > 0) {
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
$type = $xmlReader->getAttribute('w:type', $node);
|
$type = $xmlReader->getAttribute('w:type', $node);
|
||||||
$name = $xmlReader->getAttribute('w:styleId', $node);
|
$name = $xmlReader->getAttribute('w:val', $node, 'w:name');
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
$name = $xmlReader->getAttribute('w:val', $node, 'w:name');
|
$name = $xmlReader->getAttribute('w:styleId', $node);
|
||||||
}
|
}
|
||||||
$headingMatches = array();
|
$headingMatches = array();
|
||||||
preg_match('/Heading(\d)/', $name, $headingMatches);
|
preg_match('/Heading\s*(\d)/i', $name, $headingMatches);
|
||||||
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
|
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'paragraph':
|
case 'paragraph':
|
||||||
|
|||||||
@ -19,6 +19,7 @@ namespace PhpOffice\PhpWord\Reader\Word2007;
|
|||||||
|
|
||||||
use PhpOffice\PhpWord\AbstractTestReader;
|
use PhpOffice\PhpWord\AbstractTestReader;
|
||||||
use PhpOffice\PhpWord\SimpleType\TblWidth;
|
use PhpOffice\PhpWord\SimpleType\TblWidth;
|
||||||
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\Style\Table;
|
use PhpOffice\PhpWord\Style\Table;
|
||||||
use PhpOffice\PhpWord\Style\TablePosition;
|
use PhpOffice\PhpWord\Style\TablePosition;
|
||||||
|
|
||||||
@ -169,4 +170,29 @@ class StyleTest extends AbstractTestReader
|
|||||||
$fontStyle = $textRun->getElement(0)->getFontStyle();
|
$fontStyle = $textRun->getElement(0)->getFontStyle();
|
||||||
$this->assertTrue($fontStyle->isHidden());
|
$this->assertTrue($fontStyle->isHidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReadHeading()
|
||||||
|
{
|
||||||
|
Style::resetStyles();
|
||||||
|
|
||||||
|
$documentXml = '<w:style w:type="paragraph" w:styleId="Ttulo1">
|
||||||
|
<w:name w:val="heading 1"/>
|
||||||
|
<w:basedOn w:val="Normal"/>
|
||||||
|
<w:uiPriority w:val="1"/>
|
||||||
|
<w:qFormat/>
|
||||||
|
<w:pPr>
|
||||||
|
<w:outlineLvl w:val="0"/>
|
||||||
|
</w:pPr>
|
||||||
|
<w:rPr>
|
||||||
|
<w:rFonts w:ascii="Times New Roman" w:eastAsia="Times New Roman" w:hAnsi="Times New Roman"/>
|
||||||
|
<w:b/>
|
||||||
|
<w:bCs/>
|
||||||
|
</w:rPr>
|
||||||
|
</w:style>';
|
||||||
|
|
||||||
|
$name = 'Heading_1';
|
||||||
|
|
||||||
|
$this->getDocumentFromString(array('styles' => $documentXml));
|
||||||
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user