Skip to content

Commit 542451d

Browse files
committed
Merge pull request #133 from ivanlanin/develop
New unit test for ODText\Content and some test fixes
2 parents c2a6c78 + d04e600 commit 542451d

File tree

9 files changed

+281
-162
lines changed

9 files changed

+281
-162
lines changed

Classes/PHPWord/Writer/ODText/Content.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,24 +254,24 @@ public function writeContent(PHPWord $pPHPWord = null)
254254
} elseif ($element instanceof PHPWord_Section_TextBreak) {
255255
$this->_writeTextBreak($objWriter);
256256
} elseif ($element instanceof PHPWord_Section_Link) {
257-
$this->writeUnsupportedElement($objWriter, 'link');
257+
$this->writeUnsupportedElement($objWriter, 'Link');
258258
} elseif ($element instanceof PHPWord_Section_Title) {
259-
$this->writeUnsupportedElement($objWriter, 'title');
259+
$this->writeUnsupportedElement($objWriter, 'Title');
260260
} elseif ($element instanceof PHPWord_Section_PageBreak) {
261-
$this->writeUnsupportedElement($objWriter, 'page break');
261+
$this->writeUnsupportedElement($objWriter, 'Page Break');
262262
} elseif ($element instanceof PHPWord_Section_Table) {
263-
$this->writeUnsupportedElement($objWriter, 'table');
263+
$this->writeUnsupportedElement($objWriter, 'Table');
264264
} elseif ($element instanceof PHPWord_Section_ListItem) {
265-
$this->writeUnsupportedElement($objWriter, 'list item');
265+
$this->writeUnsupportedElement($objWriter, 'List Item');
266266
} elseif ($element instanceof PHPWord_Section_Image ||
267267
$element instanceof PHPWord_Section_MemoryImage) {
268-
$this->writeUnsupportedElement($objWriter, 'image');
268+
$this->writeUnsupportedElement($objWriter, 'Image');
269269
} elseif ($element instanceof PHPWord_Section_Object) {
270-
$this->writeUnsupportedElement($objWriter, 'object');
270+
$this->writeUnsupportedElement($objWriter, 'Object');
271271
} elseif ($element instanceof PHPWord_TOC) {
272272
$this->writeUnsupportedElement($objWriter, 'TOC');
273273
} else {
274-
$this->writeUnsupportedElement($objWriter, 'other');
274+
$this->writeUnsupportedElement($objWriter, 'Element');
275275
}
276276
}
277277

@@ -372,18 +372,15 @@ protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null)
372372
$objWriter->endElement();
373373
}
374374

375+
// @codeCoverageIgnoreStart
375376
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
376377
{
377378
}
378379

379-
/**
380-
* Dummy function just to make all samples produce ODT
381-
*
382-
* @todo Create the real function
383-
*/
384380
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
385381
{
386382
}
383+
// @codeCoverageIgnoreEnd
387384

388385
/**
389386
* Write unsupported element
@@ -394,7 +391,7 @@ private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo
394391
private function writeUnsupportedElement($objWriter, $element)
395392
{
396393
$objWriter->startElement('text:p');
397-
$objWriter->writeRaw("Cannot write content. This version of PHPWord has not supported {$element} element in ODText.");
394+
$objWriter->writeRaw("{$element}");
398395
$objWriter->endElement();
399396
}
400397
}

Classes/PHPWord/Writer/RTF.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,24 +315,24 @@ private function getDataContent()
315315
} elseif ($element instanceof PHPWord_Section_TextRun) {
316316
$sRTFBody .= $this->getDataContentTextRun($element);
317317
} elseif ($element instanceof PHPWord_Section_Link) {
318-
$sRTFBody .= $this->getDataContentUnsupportedElement('link');
318+
$sRTFBody .= $this->getDataContentUnsupportedElement('Link');
319319
} elseif ($element instanceof PHPWord_Section_Title) {
320-
$sRTFBody .= $this->getDataContentUnsupportedElement('title');
320+
$sRTFBody .= $this->getDataContentUnsupportedElement('Title');
321321
} elseif ($element instanceof PHPWord_Section_PageBreak) {
322-
$sRTFBody .= $this->getDataContentUnsupportedElement('page break');
322+
$sRTFBody .= $this->getDataContentUnsupportedElement('Page Break');
323323
} elseif ($element instanceof PHPWord_Section_Table) {
324-
$sRTFBody .= $this->getDataContentUnsupportedElement('table');
324+
$sRTFBody .= $this->getDataContentUnsupportedElement('Table');
325325
} elseif ($element instanceof PHPWord_Section_ListItem) {
326-
$sRTFBody .= $this->getDataContentUnsupportedElement('list item');
326+
$sRTFBody .= $this->getDataContentUnsupportedElement('List Item');
327327
} elseif ($element instanceof PHPWord_Section_Image ||
328328
$element instanceof PHPWord_Section_MemoryImage) {
329-
$sRTFBody .= $this->getDataContentUnsupportedElement('image');
329+
$sRTFBody .= $this->getDataContentUnsupportedElement('Image');
330330
} elseif ($element instanceof PHPWord_Section_Object) {
331-
$sRTFBody .= $this->getDataContentUnsupportedElement('object');
331+
$sRTFBody .= $this->getDataContentUnsupportedElement('Object');
332332
} elseif ($element instanceof PHPWord_TOC) {
333333
$sRTFBody .= $this->getDataContentUnsupportedElement('TOC');
334334
} else {
335-
$sRTFBody .= $this->getDataContentUnsupportedElement('other');
335+
$sRTFBody .= $this->getDataContentUnsupportedElement('Other');
336336
}
337337
}
338338
}
@@ -468,7 +468,7 @@ private function getDataContentUnsupportedElement($element)
468468
{
469469
$sRTFText = '';
470470
$sRTFText .= '\pard\nowidctlpar' . PHP_EOL;
471-
$sRTFText .= "Cannot write content. This version of PHPWord has not supported {$element} element in RTF.";
471+
$sRTFText .= "{$element}";
472472
$sRTFText .= '\par' . PHP_EOL;
473473

474474
return $sRTFText;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ We're reorganizing our documentation. Below are some of the most important thing
7979
<a name="basic-usage"></a>
8080
#### Basic usage
8181

82-
The following is a basic example of the PHPWord library. More examples are provided in the (sample folder)[samples/].
82+
The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/).
8383

8484
```php
8585
$PHPWord = new PHPWord();

0 commit comments

Comments
 (0)