Skip to content

Commit b0e1e41

Browse files
authored
Merge pull request #2513 from PHPOffice/pr2491
Word2007 Reader : Check for null on $fontDefaultStyle
2 parents 45345a3 + d65be98 commit b0e1e41

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/changes/1.x/1.2.0.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- Template Processor : Fixed choose dimention for Float Value by [@gdevilbat](https://github.com/gdevilbat) in GH-2449
4242
- HTML Parser : Fix image parsing from url without extension by [@JokubasR](https://github.com/JokubasR) in GH-2459
4343
- Word2007 Reader : Fixed reading of Office365 DocX file by [@filippotoso](https://github.com/filippotoso) & [@lfglopes](https://github.com/lfglopes) in [#2506](https://github.com/PHPOffice/PHPWord/pull/2506)
44+
- Word2007 Reader : Check for null on $fontDefaultStyle by [@spatialfree](https://github.com/spatialfree) in [#2513](https://github.com/PHPOffice/PHPWord/pull/2513)
4445

4546
### Miscellaneous
4647

src/PhpWord/Reader/Word2007/Styles.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ public function read(PhpWord $phpWord): void
3939
$fontDefaults = $xmlReader->getElement('w:docDefaults/w:rPrDefault');
4040
if ($fontDefaults !== null) {
4141
$fontDefaultStyle = $this->readFontStyle($xmlReader, $fontDefaults);
42-
if (array_key_exists('name', $fontDefaultStyle)) {
43-
$phpWord->setDefaultFontName($fontDefaultStyle['name']);
44-
}
45-
if (array_key_exists('size', $fontDefaultStyle)) {
46-
$phpWord->setDefaultFontSize($fontDefaultStyle['size']);
47-
}
48-
if (array_key_exists('lang', $fontDefaultStyle)) {
49-
$phpWord->getSettings()->setThemeFontLang(new Language($fontDefaultStyle['lang']));
42+
if ($fontDefaultStyle) {
43+
if (array_key_exists('name', $fontDefaultStyle)) {
44+
$phpWord->setDefaultFontName($fontDefaultStyle['name']);
45+
}
46+
if (array_key_exists('size', $fontDefaultStyle)) {
47+
$phpWord->setDefaultFontSize($fontDefaultStyle['size']);
48+
}
49+
if (array_key_exists('lang', $fontDefaultStyle)) {
50+
$phpWord->getSettings()->setThemeFontLang(new Language($fontDefaultStyle['lang']));
51+
}
5052
}
5153
}
5254

0 commit comments

Comments
 (0)