Skip to content

Commit

Permalink
Merge pull request #133 from ivanlanin/develop
Browse files Browse the repository at this point in the history
New unit test for ODText\Content and some test fixes
  • Loading branch information
ivanlanin committed Mar 15, 2014
2 parents c2a6c78 + d04e600 commit 542451d
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 162 deletions.
25 changes: 11 additions & 14 deletions Classes/PHPWord/Writer/ODText/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,24 +254,24 @@ public function writeContent(PHPWord $pPHPWord = null)
} elseif ($element instanceof PHPWord_Section_TextBreak) {
$this->_writeTextBreak($objWriter);
} elseif ($element instanceof PHPWord_Section_Link) {
$this->writeUnsupportedElement($objWriter, 'link');
$this->writeUnsupportedElement($objWriter, 'Link');
} elseif ($element instanceof PHPWord_Section_Title) {
$this->writeUnsupportedElement($objWriter, 'title');
$this->writeUnsupportedElement($objWriter, 'Title');
} elseif ($element instanceof PHPWord_Section_PageBreak) {
$this->writeUnsupportedElement($objWriter, 'page break');
$this->writeUnsupportedElement($objWriter, 'Page Break');
} elseif ($element instanceof PHPWord_Section_Table) {
$this->writeUnsupportedElement($objWriter, 'table');
$this->writeUnsupportedElement($objWriter, 'Table');
} elseif ($element instanceof PHPWord_Section_ListItem) {
$this->writeUnsupportedElement($objWriter, 'list item');
$this->writeUnsupportedElement($objWriter, 'List Item');
} elseif ($element instanceof PHPWord_Section_Image ||
$element instanceof PHPWord_Section_MemoryImage) {
$this->writeUnsupportedElement($objWriter, 'image');
$this->writeUnsupportedElement($objWriter, 'Image');
} elseif ($element instanceof PHPWord_Section_Object) {
$this->writeUnsupportedElement($objWriter, 'object');
$this->writeUnsupportedElement($objWriter, 'Object');
} elseif ($element instanceof PHPWord_TOC) {
$this->writeUnsupportedElement($objWriter, 'TOC');
} else {
$this->writeUnsupportedElement($objWriter, 'other');
$this->writeUnsupportedElement($objWriter, 'Element');
}
}

Expand Down Expand Up @@ -372,18 +372,15 @@ protected function _writeTextBreak(PHPWord_Shared_XMLWriter $objWriter = null)
$objWriter->endElement();
}

// @codeCoverageIgnoreStart
private function _writeEndSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
{
}

/**
* Dummy function just to make all samples produce ODT
*
* @todo Create the real function
*/
private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWord_Section $section = null)
{
}
// @codeCoverageIgnoreEnd

/**
* Write unsupported element
Expand All @@ -394,7 +391,7 @@ private function _writeSection(PHPWord_Shared_XMLWriter $objWriter = null, PHPWo
private function writeUnsupportedElement($objWriter, $element)
{
$objWriter->startElement('text:p');
$objWriter->writeRaw("Cannot write content. This version of PHPWord has not supported {$element} element in ODText.");
$objWriter->writeRaw("{$element}");
$objWriter->endElement();
}
}
18 changes: 9 additions & 9 deletions Classes/PHPWord/Writer/RTF.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,24 @@ private function getDataContent()
} elseif ($element instanceof PHPWord_Section_TextRun) {
$sRTFBody .= $this->getDataContentTextRun($element);
} elseif ($element instanceof PHPWord_Section_Link) {
$sRTFBody .= $this->getDataContentUnsupportedElement('link');
$sRTFBody .= $this->getDataContentUnsupportedElement('Link');
} elseif ($element instanceof PHPWord_Section_Title) {
$sRTFBody .= $this->getDataContentUnsupportedElement('title');
$sRTFBody .= $this->getDataContentUnsupportedElement('Title');
} elseif ($element instanceof PHPWord_Section_PageBreak) {
$sRTFBody .= $this->getDataContentUnsupportedElement('page break');
$sRTFBody .= $this->getDataContentUnsupportedElement('Page Break');
} elseif ($element instanceof PHPWord_Section_Table) {
$sRTFBody .= $this->getDataContentUnsupportedElement('table');
$sRTFBody .= $this->getDataContentUnsupportedElement('Table');
} elseif ($element instanceof PHPWord_Section_ListItem) {
$sRTFBody .= $this->getDataContentUnsupportedElement('list item');
$sRTFBody .= $this->getDataContentUnsupportedElement('List Item');
} elseif ($element instanceof PHPWord_Section_Image ||
$element instanceof PHPWord_Section_MemoryImage) {
$sRTFBody .= $this->getDataContentUnsupportedElement('image');
$sRTFBody .= $this->getDataContentUnsupportedElement('Image');
} elseif ($element instanceof PHPWord_Section_Object) {
$sRTFBody .= $this->getDataContentUnsupportedElement('object');
$sRTFBody .= $this->getDataContentUnsupportedElement('Object');
} elseif ($element instanceof PHPWord_TOC) {
$sRTFBody .= $this->getDataContentUnsupportedElement('TOC');
} else {
$sRTFBody .= $this->getDataContentUnsupportedElement('other');
$sRTFBody .= $this->getDataContentUnsupportedElement('Other');
}
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ private function getDataContentUnsupportedElement($element)
{
$sRTFText = '';
$sRTFText .= '\pard\nowidctlpar' . PHP_EOL;
$sRTFText .= "Cannot write content. This version of PHPWord has not supported {$element} element in RTF.";
$sRTFText .= "{$element}";
$sRTFText .= '\par' . PHP_EOL;

return $sRTFText;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ We're reorganizing our documentation. Below are some of the most important thing
<a name="basic-usage"></a>
#### Basic usage

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

```php
$PHPWord = new PHPWord();
Expand Down
Loading

0 comments on commit 542451d

Please sign in to comment.