Skip to content

Commit c7dd41c

Browse files
authored
Word2007 Reader: Fixed panose with 20 characters (#842)
1 parent 6e9da89 commit c7dd41c

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

docs/changes/1.2.0.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
- `phpoffice/phpspreadsheet`: Allow version 1.9 or 2.0 by [@Progi1984](https://github.com/Progi1984) fixing [#790](https://github.com/PHPOffice/PHPPresentation/pull/790), [#812](https://github.com/PHPOffice/PHPPresentation/pull/812) in [#816](https://github.com/PHPOffice/PHPPresentation/pull/816)
88
- Group Shape: moving the shape now moves all contained shapes. Offsets and size are calculated based on the contained shapes by [@DennisBirkholz](https://github.com/DennisBirkholz) in [#690](https://github.com/PHPOffice/PHPPresentation/pull/690)
9-
- Added support for PHP 8.4 - [@Progi1984](https://github.com/Progi1984) in [#839](https://github.com/PHPOffice/PHPPresentation/pull/839)
9+
- Added support for PHP 8.4 by [@Progi1984](https://github.com/Progi1984) in [#839](https://github.com/PHPOffice/PHPPresentation/pull/839)
1010
- `phpoffice/phpspreadsheet`: Allow version 3.0 by [@Progi1984](https://github.com/Progi1984) fixing [#836](https://github.com/PHPOffice/PHPPresentation/pull/836) in [#839](https://github.com/PHPOffice/PHPPresentation/pull/839)
1111

1212
## Bug fixes
1313

14-
- Word2007 Reader: Fixed cast of spacing fixing [#729](https://github.com/PHPOffice/PHPPresentation/pull/729), [#796](https://github.com/PHPOffice/PHPPresentation/pull/796) in [#818](https://github.com/PHPOffice/PHPPresentation/pull/818)
14+
- Word2007 Reader: Fixed cast of spacing by [@Progi1984](https://github.com/Progi1984) fixing [#729](https://github.com/PHPOffice/PHPPresentation/pull/729), [#796](https://github.com/PHPOffice/PHPPresentation/pull/796) in [#818](https://github.com/PHPOffice/PHPPresentation/pull/818)
1515
- CI : Fixed PHPCSFixer by [@kw-pr](https://github.com/kw-pr) in [#835](https://github.com/PHPOffice/PHPPresentation/pull/835)
16-
- Word2007 Reader: Fixed cast of color fixing [#826](https://github.com/PHPOffice/PHPPresentation/pull/826) in [#840](https://github.com/PHPOffice/PHPPresentation/pull/840)
16+
- Word2007 Reader: Fixed cast of color by [@Progi1984](https://github.com/Progi1984) fixing [#826](https://github.com/PHPOffice/PHPPresentation/pull/826) in [#840](https://github.com/PHPOffice/PHPPresentation/pull/840)
17+
- Word2007 Reader: Fixed panose with 20 characters by [@Progi1984](https://github.com/Progi1984) fixing [#798](https://github.com/PHPOffice/PHPPresentation/pull/798) in [#842](https://github.com/PHPOffice/PHPPresentation/pull/842)
1718

1819
## Miscellaneous
1920

src/PhpPresentation/Style/Font.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ public function getPanose(): string
215215
*/
216216
public function setPanose(string $pValue): self
217217
{
218+
if (mb_strlen($pValue) === 20) {
219+
$pValue = preg_replace('/.(.)/', '$1', $pValue);
220+
}
221+
218222
if (mb_strlen($pValue) !== 10) {
219-
throw new InvalidParameterException('pValue', $pValue, 'The length is not equals to 10');
223+
throw new InvalidParameterException('pValue', $pValue, 'The length is not correct');
220224
}
221225

222226
$allowedChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];

tests/PhpPresentation/Tests/Style/FontTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function testPanose(): void
168168
self::assertEquals('', $object->getPanose());
169169
self::assertInstanceOf(Font::class, $object->setPanose('4494D72242'));
170170
self::assertEquals('4494D72242', $object->getPanose());
171+
self::assertInstanceOf(Font::class, $object->setPanose('020B0604030504040204'));
172+
self::assertEquals('2B64354424', $object->getPanose());
171173
}
172174

173175
/**
@@ -176,7 +178,7 @@ public function testPanose(): void
176178
public function testPanoseExceptionInvalidLength(): void
177179
{
178180
$this->expectException(InvalidParameterException::class);
179-
$this->expectExceptionMessage('The parameter pValue can\'t have the value "12345" (Validation: The length is not equals to 10)');
181+
$this->expectExceptionMessage('The parameter pValue can\'t have the value "12345" (Validation: The length is not correct)');
180182

181183
$object = new Font();
182184
$object->setPanose('12345');

0 commit comments

Comments
 (0)