basedOn not correctly set if FontStyle is based on other FontStyle
This commit is contained in:
parent
c50e3c581a
commit
09e669f9e9
@ -182,7 +182,11 @@ class Styles extends AbstractPart
|
||||
|
||||
// Parent style
|
||||
if (!is_null($paragraphStyle)) {
|
||||
$xmlWriter->writeElementBlock('w:basedOn', 'w:val', $paragraphStyle->getStyleName());
|
||||
if ($paragraphStyle->getStyleName() != null) {
|
||||
$xmlWriter->writeElementBlock('w:basedOn', 'w:val', $paragraphStyle->getStyleName());
|
||||
} elseif ($paragraphStyle->getBasedOn() != null) {
|
||||
$xmlWriter->writeElementBlock('w:basedOn', 'w:val', $paragraphStyle->getBasedOn());
|
||||
}
|
||||
}
|
||||
|
||||
// w:pPr
|
||||
|
||||
@ -114,4 +114,32 @@ class StylesTest extends \PHPUnit_Framework_TestCase
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertNull($element);
|
||||
}
|
||||
|
||||
function testFontStyleBasedOnOtherFontStyle() {
|
||||
$phpWord = new PhpWord();
|
||||
|
||||
$styleGenerationP = new Paragraph();
|
||||
$styleGenerationP->setAlignment(Jc::BOTH);
|
||||
|
||||
$styleGeneration = new Font();
|
||||
$styleGeneration->setParagraph($styleGenerationP);
|
||||
$styleGeneration->setSize(9.5);
|
||||
$phpWord->addFontStyle('Generation', $styleGeneration);
|
||||
|
||||
$styleGenerationEteinteP = new Paragraph();
|
||||
$styleGenerationEteinteP->setBasedOn('Generation');
|
||||
|
||||
$styleGenerationEteinte = new Font();
|
||||
$styleGenerationEteinte->setParagraph($styleGenerationEteinteP);
|
||||
$styleGenerationEteinte->setSize(8.5);
|
||||
$phpWord->addFontStyle('GeneratEteinte', $styleGenerationEteinte);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
$file = 'word/styles.xml';
|
||||
|
||||
$path = '/w:styles/w:style[@w:styleId="GeneratEteinte"]/w:basedOn';
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertEquals('Generation', $element->getAttribute('w:val'));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user