Skip to content

Commit 56ea8c0

Browse files
authored
Merge branch 'master' into wordunimplemented2
2 parents 346ac92 + 1be7a80 commit 56ea8c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1796
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ _build
1212
/build
1313
phpunit.xml
1414
composer.phar
15+
composer.lock
1516
vendor
1617
/report
1718
/build

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
"php": "^7.1|^8.0",
110110
"ext-dom": "*",
111111
"ext-gd": "*",
112-
"ext-xml": "*",
113112
"ext-zip": "*",
113+
"ext-xml": "*",
114114
"phpoffice/math": "^0.2"
115115
},
116116
"require-dev": {

docs/changes/1.x/1.4.0.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
- Writer HTML: Support Default font color by [@MichaelPFrey](https://github.com/MichaelPFrey) in [#2731](https://github.com/PHPOffice/PHPWord/pull/2731)
1616
- Writer ODText: Support Default font color by [@MichaelPFrey](https://github.com/MichaelPFrey) in [#2735](https://github.com/PHPOffice/PHPWord/pull/2735)
1717
- Add basic ruby text (phonetic guide) support for Word2007 and HTML Reader/Writer, RTF Writer, basic support for ODT writing by [@Deadpikle](https://github.com/Deadpikle) in [#2727](https://github.com/PHPOffice/PHPWord/pull/2727)
18-
18+
- Reader HTML: Support font styles for h1/h6 by [@Progi1984](https://github.com/Progi1984) fixing [#2619](https://github.com/PHPOffice/PHPWord/issues/2619) in [#2737](https://github.com/PHPOffice/PHPWord/pull/2737)
19+
- Writer EPub3: Basic support by [@Sambit003](https://github.com/Sambit003) fixing [#55](https://github.com/PHPOffice/PHPWord/issues/55) in [#2724](https://github.com/PHPOffice/PHPWord/pull/2724)
20+
1921
### Bug fixes
2022

2123
- Writer ODText: Support for images inside a textRun by [@Progi1984](https://github.com/Progi1984) fixing [#2240](https://github.com/PHPOffice/PHPWord/issues/2240) in [#2668](https://github.com/PHPOffice/PHPWord/pull/2668)
@@ -24,6 +26,7 @@
2426
- Reader Word2007: Respect paragraph indent units by [@tugmaks](https://github.com/tugmaks) & [@Progi1984](https://github.com/Progi1984) fixing [#507](https://github.com/PHPOffice/PHPWord/issues/507) in [#2726](https://github.com/PHPOffice/PHPWord/pull/2726)
2527
- Reader Word2007: Support Header elements within Title elements by [@SpraxDev](https://github.com/SpraxDev) fixing [#2616](https://github.com/PHPOffice/PHPWord/issues/2616), [#2426](https://github.com/PHPOffice/PHPWord/issues/2426) in [#2674](https://github.com/PHPOffice/PHPWord/pull/2674)
2628
- Reader HTML: Support for inherit value for property line-height by [@Progi1984](https://github.com/Progi1984) fixing [#2683](https://github.com/PHPOffice/PHPWord/issues/2683) in [#2733](https://github.com/PHPOffice/PHPWord/pull/2733)
29+
- Writer HTML: Fixed null string for Text Elements by [@armagedon007](https://github.com/armagedon007) and [@Progi1984](https://github.com/Progi1984) in [#2738](https://github.com/PHPOffice/PHPWord/pull/2738)
2730

2831
### Miscellaneous
2932

samples/Sample_Header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232

3333
// Set writers
34-
$writers = ['Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf'];
34+
$writers = ['Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf', 'EPub3' => 'epub'];
3535

3636
// Set PDF renderer
3737
if (null === Settings::getPdfRendererPath()) {

src/PhpWord/Element/Link.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ public function getSource()
9999

100100
/**
101101
* Get link text.
102-
*
103-
* @return string
104102
*/
105-
public function getText()
103+
public function getText(): string
106104
{
107105
return $this->text;
108106
}

src/PhpWord/Element/Text.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ public function setText($text)
147147

148148
/**
149149
* Get Text content.
150-
*
151-
* @return ?string
152150
*/
153-
public function getText()
151+
public function getText(): ?string
154152
{
155153
return $this->text;
156154
}

src/PhpWord/IOFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class IOFactory
3636
*/
3737
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
3838
{
39-
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF'], true)) {
39+
if ($name !== 'WriterInterface' && !in_array($name, ['ODText', 'RTF', 'Word2007', 'HTML', 'PDF', 'EPub3'], true)) {
4040
throw new Exception("\"{$name}\" is not a valid writer.");
4141
}
4242

src/PhpWord/Shared/Html.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,16 @@ protected static function parseNode($node, $element, $styles = [], $data = []):
326326

327327
// Node mapping table
328328
$nodes = [
329-
// $method $node $element $styles $data $argument1 $argument2
330-
'p' => ['Paragraph', $node, $element, $styles, null, null, null],
331-
'h1' => ['Heading', $node, $element, $styles, null, 'Heading1', null],
332-
'h2' => ['Heading', $node, $element, $styles, null, 'Heading2', null],
333-
'h3' => ['Heading', $node, $element, $styles, null, 'Heading3', null],
334-
'h4' => ['Heading', $node, $element, $styles, null, 'Heading4', null],
335-
'h5' => ['Heading', $node, $element, $styles, null, 'Heading5', null],
336-
'h6' => ['Heading', $node, $element, $styles, null, 'Heading6', null],
337-
'#text' => ['Text', $node, $element, $styles, null, null, null],
338-
'strong' => ['Property', null, null, $styles, null, 'bold', true],
329+
// $method $node $element $styles $data $argument1 $argument2
330+
'p' => ['Paragraph', $node, $element, $styles, null, null, null],
331+
'h1' => ['Heading', $node, $element, $styles, null, 'Heading1', null],
332+
'h2' => ['Heading', $node, $element, $styles, null, 'Heading2', null],
333+
'h3' => ['Heading', $node, $element, $styles, null, 'Heading3', null],
334+
'h4' => ['Heading', $node, $element, $styles, null, 'Heading4', null],
335+
'h5' => ['Heading', $node, $element, $styles, null, 'Heading5', null],
336+
'h6' => ['Heading', $node, $element, $styles, null, 'Heading6', null],
337+
'#text' => ['Text', $node, $element, $styles, null, null, null],
338+
'strong' => ['Property', null, null, $styles, null, 'bold', true],
339339
'b' => ['Property', null, null, $styles, null, 'bold', true],
340340
'em' => ['Property', null, null, $styles, null, 'italic', true],
341341
'i' => ['Property', null, null, $styles, null, 'italic', true],

src/PhpWord/Shared/ZipArchive.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,4 +423,15 @@ public function pclzipLocateName($filename)
423423

424424
return ($listIndex > -1) ? $listIndex : false;
425425
}
426+
427+
/**
428+
* Add an empty directory to the zip archive (emulate \ZipArchive).
429+
*
430+
* @param string $dirname Directory name to add to the zip archive
431+
*/
432+
public function addEmptyDir(string $dirname): bool
433+
{
434+
// Create a directory entry by adding an empty file with trailing slash
435+
return $this->addFromString(rtrim($dirname, '/') . '/', '');
436+
}
426437
}

src/PhpWord/Style/Font.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Font extends AbstractStyle
109109
/**
110110
* Font color.
111111
*
112-
* @var string
112+
* @var null|string
113113
*/
114114
private $color;
115115

@@ -426,10 +426,8 @@ public function setSize($value = null)
426426

427427
/**
428428
* Get font color.
429-
*
430-
* @return string
431429
*/
432-
public function getColor()
430+
public function getColor(): ?string
433431
{
434432
return $this->color;
435433
}

0 commit comments

Comments
 (0)