Skip to content

Commit 2593e9e

Browse files
author
Javier Garcia
committed
Merge branch 'develop' of github.com:jgpATs2w/PHPWord into develop
2 parents fe647f6 + e764871 commit 2593e9e

File tree

12 files changed

+53
-27
lines changed

12 files changed

+53
-27
lines changed

.gitattributes

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# build config
2+
/.scrutinizer.yml export-ignore
3+
/.travis.yml export-ignore
4+
/php_cs.dist export-ignore
5+
/phpmd.xml.dist export-ignore
6+
/phpstan.neon export-ignore
7+
8+
/composer.lock export-ignore
9+
10+
# git files
11+
/.gitignore export-ignore
12+
/.gitattributes export-ignore
13+
14+
# project directories
15+
/build export-ignore
16+
/docs export-ignore
17+
/samples export-ignore
18+
19+
# tests
20+
/phpunit.xml.dist export-ignore
21+
/tests export-ignore

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ before_script:
3737
- composer self-update
3838
- travis_wait composer install --prefer-source
3939
## PHPDocumentor
40-
- mkdir -p build/docs
40+
##- mkdir -p build/docs
4141
- mkdir -p build/coverage
4242

4343
script:
@@ -52,7 +52,7 @@ script:
5252
## PHPLOC
5353
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phploc src/ ; fi
5454
## PHPDocumentor
55-
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
55+
##- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
5656

5757
after_success:
5858
## Coveralls

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ v0.15.0 (?? ??? 2018)
2323
- Add support for table indent (tblInd) @Trainmaster #1343
2424
- Added parsing of internal links in HTML reader @lalop #1336
2525
- Several improvements to charts @JAEK-S #1332
26+
- Add parsing of html image in base64 format @jgpATs2w #1382
2627

2728
### Fixed
2829
- Fix reading of docx default style - @troosan #1238

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@
6565
},
6666
"require-dev": {
6767
"phpunit/phpunit": "^4.8.36 || ^5.0",
68-
"phpdocumentor/phpdocumentor":"2.*",
69-
"squizlabs/php_codesniffer": "^2.7",
70-
"friendsofphp/php-cs-fixer": "^2.0",
68+
"squizlabs/php_codesniffer": "^2.9",
69+
"friendsofphp/php-cs-fixer": "^2.2",
7170
"phpmd/phpmd": "2.*",
7271
"phploc/phploc": "2.* || 3.* || 4.*",
7372
"dompdf/dompdf":"0.8.*",
7473
"tecnickcom/tcpdf": "6.*",
75-
"mpdf/mpdf": "5.* || 6.* || 7.*",
74+
"mpdf/mpdf": "5.7.4 || 6.* || 7.*",
7675
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
7776
},
7877
"suggest": {

samples/Sample_07_TemplateCloneRow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
echo date('H:i:s'), ' Saving the result document...', EOL;
5757
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
5858

59-
echo getEndingNotes(array('Word2007' => 'docx'));
59+
echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_07_TemplateCloneRow.docx');
6060
if (!CLI) {
6161
include_once 'Sample_Footer.php';
6262
}

samples/Sample_23_TemplateBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
echo date('H:i:s'), ' Saving the result document...', EOL;
1515
$templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');
1616

17-
echo getEndingNotes(array('Word2007' => 'docx'));
17+
echo getEndingNotes(array('Word2007' => 'docx'), 'results/Sample_23_TemplateBlock.docx');
1818
if (!CLI) {
1919
include_once 'Sample_Footer.php';
2020
}

src/PhpWord/Element/AbstractElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public function getParent()
347347
*
348348
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
349349
*/
350-
public function setParentContainer(AbstractElement $container)
350+
public function setParentContainer(self $container)
351351
{
352352
$this->parentContainer = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
353353
$this->parent = $container;

src/PhpWord/PhpWord.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
* @method int addChart(Element\Chart $chart)
3636
* @method int addComment(Element\Comment $comment)
3737
*
38-
* @method Style\Paragraph addParagraphStyle(string $styleName, array $styles)
38+
* @method Style\Paragraph addParagraphStyle(string $styleName, mixed $styles)
3939
* @method Style\Font addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null)
4040
* @method Style\Font addLinkStyle(string $styleName, mixed $styles)
41-
* @method Style\Font addTitleStyle(int $depth, mixed $fontStyle, mixed $paragraphStyle = null)
41+
* @method Style\Font addTitleStyle(mixed $depth, mixed $fontStyle, mixed $paragraphStyle = null)
4242
* @method Style\Table addTableStyle(string $styleName, mixed $styleTable, mixed $styleFirstRow = null)
4343
* @method Style\Numbering addNumberingStyle(string $styleName, mixed $styles)
4444
*/

src/PhpWord/Shared/Html.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,10 @@ private static function parseImage($node, $element)
666666

667667
$ifp = fopen($imgFile, 'wb');
668668

669-
fwrite($ifp, base64_decode($match[2]));
670-
fclose($ifp);
669+
if ($ifp !== false) {
670+
fwrite($ifp, base64_decode($match[2]));
671+
fclose($ifp);
672+
}
671673
}
672674
$src = urldecode($src);
673675

@@ -687,8 +689,10 @@ private static function parseImage($node, $element)
687689

688690
$ifp = fopen($src, 'wb');
689691

690-
fwrite($ifp, $imgBlob);
691-
fclose($ifp);
692+
if ($ifp !== false) {
693+
fwrite($ifp, $imgBlob);
694+
fclose($ifp);
695+
}
692696
}
693697
}
694698

src/PhpWord/Style.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Style
3939
* Add paragraph style
4040
*
4141
* @param string $styleName
42-
* @param array $styles
42+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styles
4343
* @return \PhpOffice\PhpWord\Style\Paragraph
4444
*/
4545
public static function addParagraphStyle($styleName, $styles)
@@ -51,8 +51,8 @@ public static function addParagraphStyle($styleName, $styles)
5151
* Add font style
5252
*
5353
* @param string $styleName
54-
* @param array $fontStyle
55-
* @param array $paragraphStyle
54+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $fontStyle
55+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $paragraphStyle
5656
* @return \PhpOffice\PhpWord\Style\Font
5757
*/
5858
public static function addFontStyle($styleName, $fontStyle, $paragraphStyle = null)
@@ -64,7 +64,7 @@ public static function addFontStyle($styleName, $fontStyle, $paragraphStyle = nu
6464
* Add link style
6565
*
6666
* @param string $styleName
67-
* @param array $styles
67+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styles
6868
* @return \PhpOffice\PhpWord\Style\Font
6969
*/
7070
public static function addLinkStyle($styleName, $styles)
@@ -76,7 +76,7 @@ public static function addLinkStyle($styleName, $styles)
7676
* Add numbering style
7777
*
7878
* @param string $styleName
79-
* @param array $styleValues
79+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styleValues
8080
* @return \PhpOffice\PhpWord\Style\Numbering
8181
* @since 0.10.0
8282
*/
@@ -88,14 +88,14 @@ public static function addNumberingStyle($styleName, $styleValues)
8888
/**
8989
* Add title style
9090
*
91-
* @param int $depth
92-
* @param array $fontStyle
93-
* @param array $paragraphStyle
91+
* @param int|null $depth Provide null to set title font
92+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $fontStyle
93+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $paragraphStyle
9494
* @return \PhpOffice\PhpWord\Style\Font
9595
*/
9696
public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
9797
{
98-
if ($depth == null) {
98+
if (empty($depth)) {
9999
$styleName = 'Title';
100100
} else {
101101
$styleName = "Heading_{$depth}";
@@ -141,7 +141,7 @@ public static function resetStyles()
141141
/**
142142
* Set default paragraph style
143143
*
144-
* @param array $styles Paragraph style definition
144+
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styles Paragraph style definition
145145
* @return \PhpOffice\PhpWord\Style\Paragraph
146146
*/
147147
public static function setDefaultParagraphStyle($styles)

0 commit comments

Comments
 (0)