Skip to content

Commit 4db75c3

Browse files
committed
QA: Additional tests for Word2007 writer
1 parent 306c354 commit 4db75c3

File tree

17 files changed

+174
-20
lines changed

17 files changed

+174
-20
lines changed

src/PhpWord/Element/AbstractElement.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
namespace PhpOffice\PhpWord\Element;
1111

12-
use PhpOffice\PhpWord\Element\Element;
13-
use PhpOffice\PhpWord\Element\Footnote as FootnoteElement;
1412
use PhpOffice\PhpWord\Endnotes;
15-
use PhpOffice\PhpWord\Exception\InvalidObjectException;
1613
use PhpOffice\PhpWord\Footnotes;
1714
use PhpOffice\PhpWord\Media;
18-
use PhpOffice\PhpWord\Shared\String;
1915
use PhpOffice\PhpWord\Style;
2016
use PhpOffice\PhpWord\TOC;
17+
use PhpOffice\PhpWord\Exception\InvalidObjectException;
18+
use PhpOffice\PhpWord\Shared\String;
2119

2220
/**
2321
* Container abstract class
@@ -323,13 +321,13 @@ public function addObject($src, $style = null)
323321
* Add footnote element
324322
*
325323
* @param mixed $paragraphStyle
326-
* @return FootnoteElement
324+
* @return Footnote
327325
*/
328326
public function addFootnote($paragraphStyle = null)
329327
{
330328
$this->checkValidity('footnote');
331329

332-
$footnote = new FootnoteElement($paragraphStyle);
330+
$footnote = new Footnote($paragraphStyle);
333331
$rId = Footnotes::addElement($footnote);
334332

335333
$footnote->setDocPart('footnote', $this->getDocPartId());

src/PhpWord/Element/Row.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* Table row element
16+
*
17+
* @since 0.8.0
1618
*/
1719
class Row extends AbstractElement
1820
{

src/PhpWord/Reader/Word2007.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* Reader for Word2007
2222
*
23-
* @since 0.10.0
23+
* @since 0.8.0
2424
* @todo title, list, watermark, checkbox, toc
2525
* @todo Partly done: image, object
2626
*/

src/PhpWord/Settings.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
namespace PhpOffice\PhpWord;
1111

1212
/**
13-
* Settings
13+
* PHPWord settings class
14+
*
15+
* @since 0.8.0
1416
*/
1517
class Settings
1618
{

src/PhpWord/Style/Row.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* Table row style
14+
*
15+
* @since 0.8.0
1416
*/
1517
class Row extends AbstractStyle
1618
{

src/PhpWord/Template.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ public function save()
298298
* Save XML to defined name
299299
*
300300
* @param string $strFilename
301+
* @since 0.8.0
301302
*/
302303
public function saveAs($strFilename)
303304
{

src/PhpWord/Writer/HTML.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
namespace PhpOffice\PhpWord\Writer;
1111

12+
use PhpOffice\PhpWord\Endnotes;
13+
use PhpOffice\PhpWord\Footnotes;
14+
use PhpOffice\PhpWord\PhpWord;
15+
use PhpOffice\PhpWord\Style;
1216
use PhpOffice\PhpWord\Element\Endnote;
1317
use PhpOffice\PhpWord\Element\Footnote;
1418
use PhpOffice\PhpWord\Element\Image;
@@ -22,11 +26,7 @@
2226
use PhpOffice\PhpWord\Element\TextBreak;
2327
use PhpOffice\PhpWord\Element\TextRun;
2428
use PhpOffice\PhpWord\Element\Title;
25-
use PhpOffice\PhpWord\Endnotes;
2629
use PhpOffice\PhpWord\Exception\Exception;
27-
use PhpOffice\PhpWord\Footnotes;
28-
use PhpOffice\PhpWord\PhpWord;
29-
use PhpOffice\PhpWord\Style;
3030
use PhpOffice\PhpWord\Style\Font;
3131
use PhpOffice\PhpWord\Style\Paragraph;
3232

@@ -703,12 +703,14 @@ private function assembleCss($css, $curlyBracket = false)
703703
*/
704704
private function getBase64ImageData(Image $element)
705705
{
706-
$imageData = null;
707-
$imageBinary = null;
708706
$source = $element->getSource();
709707
$imageType = $element->getImageType();
708+
$imageData = null;
709+
$imageBinary = null;
710+
$actualSource = null;
710711

711-
// Get actual source from archive image
712+
// Get actual source from archive image or other source
713+
// Return null if not found
712714
if ($element->getSourceType() == Image::SOURCE_ARCHIVE) {
713715
$source = substr($source, 6);
714716
list($zipFilename, $imageFilename) = explode('#', $source);
@@ -723,6 +725,9 @@ private function getBase64ImageData(Image $element)
723725
} else {
724726
$actualSource = $source;
725727
}
728+
if (is_null($actualSource)) {
729+
return null;
730+
}
726731

727732
// Read image binary data and convert into Base64
728733
if ($element->getSourceType() == Image::SOURCE_GD) {

src/PhpWord/Writer/ODText.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
/**
2121
* ODText writer
22+
*
23+
* @since 0.7.0
2224
*/
2325
class ODText extends AbstractWriter implements WriterInterface
2426
{

src/PhpWord/Writer/RTF.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
/**
3030
* RTF writer
31+
*
32+
* @since 0.7.0
3133
*/
3234
class RTF extends AbstractWriter implements WriterInterface
3335
{

src/PhpWord/Writer/Word2007/DocProps.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PhpOffice\PhpWord\Writer\Word2007;
1111

1212
use PhpOffice\PhpWord\PhpWord;
13+
use PhpOffice\PhpWord\Exception\Exception;
1314

1415
/**
1516
* Word2007 document properties part writer
@@ -46,7 +47,7 @@ public function writeDocPropsApp(PhpWord $phpWord = null)
4647
*
4748
* @param \PhpOffice\PhpWord\PhpWord $phpWord
4849
*/
49-
public function writeDocPropsCore(PhpWord $phpWord)
50+
public function writeDocPropsCore(PhpWord $phpWord = null)
5051
{
5152
if (is_null($phpWord)) {
5253
throw new Exception("No PhpWord assigned.");

0 commit comments

Comments
 (0)