Skip to content

Commit af4f834

Browse files
authored
Merge branch 'develop' into develop
2 parents c93880b + 9ee99d2 commit af4f834

38 files changed

+454
-414
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ v0.15.0 (?? ??? 2018)
2424
- Added parsing of internal links in HTML reader @lalop #1336
2525
- Several improvements to charts @JAEK-S #1332
2626
- Add parsing of html image in base64 format @jgpATs2w #1382
27+
- Added Support for Indentation & Tabs on RTF Writer. @smaug1985 #1405
2728

2829
### Fixed
2930
- Fix reading of docx default style - @troosan #1238
@@ -36,6 +37,9 @@ v0.15.0 (?? ??? 2018)
3637
- Fix colspan and rowspan for tables in HTML Writer @mattbolt #1292
3738
- Fix parsing of Heading and Title formating @troosan @gthomas2 #465
3839
- Fix Dateformat typo, fix hours casing, add Month-Day-Year formats @ComputerTinker #591
40+
- Support reading of w:drawing for documents produced by word 2011+ @gthomas2 #464 #1324
41+
- Fix missing column width in ODText writer @potofcoffee #413
42+
- Disable entity loader before parsing XML to avoid XXE injection @Tom4t0 #1427
3943

4044
### Changed
4145
- Remove zend-stdlib dependency @Trainmaster #1284

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
6161
"php": "^5.3.3 || ^7.0",
6262
"ext-xml": "*",
6363
"zendframework/zend-escaper": "^2.2",
64-
"phpoffice/common": "^0.2"
64+
"phpoffice/common": "^0.2.9"
6565
},
6666
"require-dev": {
67-
"phpunit/phpunit": "^4.8.36 || ^5.0",
67+
"ext-zip": "*",
68+
"ext-gd": "*",
69+
"phpunit/phpunit": "^4.8.36 || ^7.0",
6870
"squizlabs/php_codesniffer": "^2.9",
6971
"friendsofphp/php-cs-fixer": "^2.2",
7072
"phpmd/phpmd": "2.*",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
includes:
22
- vendor/phpstan/phpstan/conf/config.level1.neon
33
parameters:
4-
memory-limit: 200000
4+
memory-limit: 20000000
55
autoload_directories:
66
- tests
77
autoload_files:

phpunit.xml.dist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
convertNoticesToExceptions="true"
77
convertWarningsToExceptions="true"
88
processIsolation="false"
9-
stopOnFailure="false"
10-
syntaxCheck="false">
9+
stopOnFailure="false">
1110
<testsuites>
1211
<testsuite name="PhpWord Test Suite">
1312
<directory>./tests/PhpWord</directory>
@@ -22,7 +21,7 @@
2221
</whitelist>
2322
</filter>
2423
<logging>
25-
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
24+
<log type="coverage-html" target="./build/coverage" />
2625
<log type="coverage-clover" target="./build/logs/clover.xml" />
2726
</logging>
2827
</phpunit>

samples/Sample_01_SimpleText.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22
use PhpOffice\PhpWord\Style\Font;
3-
use PhpOffice\PhpWord\Style\Paragraph;
43

54
include_once 'Sample_Header.php';
65

src/PhpWord/Element/AbstractContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @method TOC addTOC(mixed $fontStyle = null, mixed $tocStyle = null, int $minDepth = 1, int $maxDepth = 9)
3636
* @method PageBreak addPageBreak()
3737
* @method Table addTable(mixed $style = null)
38-
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
38+
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false, $name = null)
3939
* @method OLEObject addOLEObject(string $source, mixed $style = null)
4040
* @method TextBox addTextBox(mixed $style = null)
4141
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)

src/PhpWord/Element/Image.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class Image extends AbstractElement
6565
*/
6666
private $watermark;
6767

68+
/**
69+
* Name of image
70+
*
71+
* @var string
72+
*/
73+
private $name;
74+
6875
/**
6976
* Image type
7077
*
@@ -127,15 +134,17 @@ class Image extends AbstractElement
127134
* @param string $source
128135
* @param mixed $style
129136
* @param bool $watermark
137+
* @param string $name
130138
*
131139
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
132140
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
133141
*/
134-
public function __construct($source, $style = null, $watermark = false)
142+
public function __construct($source, $style = null, $watermark = false, $name = null)
135143
{
136144
$this->source = $source;
137-
$this->setIsWatermark($watermark);
138145
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
146+
$this->setIsWatermark($watermark);
147+
$this->setName($name);
139148

140149
$this->checkImage();
141150
}
@@ -170,6 +179,26 @@ public function getSourceType()
170179
return $this->sourceType;
171180
}
172181

182+
/**
183+
* Sets the image name
184+
*
185+
* @param string $value
186+
*/
187+
public function setName($value)
188+
{
189+
$this->name = $value;
190+
}
191+
192+
/**
193+
* Get image name
194+
*
195+
* @return null|string
196+
*/
197+
public function getName()
198+
{
199+
return $this->name;
200+
}
201+
173202
/**
174203
* Get image media ID
175204
*

src/PhpWord/Element/OLEObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function __construct($source, $style = null)
8383
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
8484
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
8585

86-
return $this;
86+
return;
8787
}
8888

8989
throw new InvalidObjectException();

src/PhpWord/Element/PreserveText.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PreserveText extends AbstractElement
2929
/**
3030
* Text content
3131
*
32-
* @var string
32+
* @var string|array
3333
*/
3434
private $text;
3535

@@ -64,8 +64,6 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n
6464
if (isset($matches[0])) {
6565
$this->text = $matches;
6666
}
67-
68-
return $this;
6967
}
7068

7169
/**
@@ -91,7 +89,7 @@ public function getParagraphStyle()
9189
/**
9290
* Get Text content
9391
*
94-
* @return string
92+
* @return string|array
9593
*/
9694
public function getText()
9795
{

src/PhpWord/Element/Table.php

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,40 @@ public function setWidth($width)
135135
public function countColumns()
136136
{
137137
$columnCount = 0;
138-
if (is_array($this->rows)) {
139-
$rowCount = count($this->rows);
140-
for ($i = 0; $i < $rowCount; $i++) {
141-
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
142-
$row = $this->rows[$i];
143-
$cellCount = count($row->getCells());
144-
if ($columnCount < $cellCount) {
145-
$columnCount = $cellCount;
146-
}
138+
139+
$rowCount = count($this->rows);
140+
for ($i = 0; $i < $rowCount; $i++) {
141+
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
142+
$row = $this->rows[$i];
143+
$cellCount = count($row->getCells());
144+
if ($columnCount < $cellCount) {
145+
$columnCount = $cellCount;
147146
}
148147
}
149148

150149
return $columnCount;
151150
}
151+
152+
/**
153+
* The first declared cell width for each column
154+
*
155+
* @return int[]
156+
*/
157+
public function findFirstDefinedCellWidths()
158+
{
159+
$cellWidths = array();
160+
161+
foreach ($this->rows as $row) {
162+
$cells = $row->getCells();
163+
if (count($cells) <= count($cellWidths)) {
164+
continue;
165+
}
166+
$cellWidths = array();
167+
foreach ($cells as $cell) {
168+
$cellWidths[] = $cell->getWidth();
169+
}
170+
}
171+
172+
return $cellWidths;
173+
}
152174
}

0 commit comments

Comments
 (0)