Fix Travis test errors

This commit is contained in:
Ivan Lanin 2014-05-08 22:42:56 +07:00
parent f7dd9dd07c
commit 8a1d07f71a
14 changed files with 47 additions and 32 deletions

View File

@ -31,7 +31,7 @@ This release changed PHPWord license from LGPL 2.1 to LGPL 3.
- Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin - Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin
- Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154 - Docs: Create gh-pages branch for API documentation - @Progi1984 GH-154
- QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186 - QA: Add `.scrutinizer.yml` and include `composer.lock` for preparation to Scrutinizer - @ivanlanin GH-186
- Word2007 Writer: Refactor writer parts using composite pattern - @ivanlanin - Writer: Refactor writer parts using composite pattern - @ivanlanin
- Docs: Show code quality and test code coverage badge on README - Docs: Show code quality and test code coverage badge on README
## 0.10.0 - 4 May 2014 ## 0.10.0 - 4 May 2014

View File

@ -1,10 +1,10 @@
{ {
"name": "phpoffice/phpword", "name": "phpoffice/phpword",
"description": "PHPWord - Read, Create, and Write DOCX, ODT, and RTF documents in PHP", "description": "PHPWord - A pure PHP library for reading and writing word processing documents (DOCX, ODT, RTF, HTML, PDF)",
"keywords": [ "keywords": [
"PHP", "PhpOffice", "office", "PhpWord", "word", "template", "reader", "writer", "PHP", "PhpOffice", "office", "PhpWord", "word", "template", "reader", "writer",
"docx", "OOXML", "OpenXML", "Office Open XML", "ISO IEC 29500", "WordprocessingML", "docx", "OOXML", "OpenXML", "Office Open XML", "ISO IEC 29500", "WordprocessingML",
"RTF", "Rich Text Format", "doc", "odt", "OpenDocument" "RTF", "Rich Text Format", "doc", "odt", "OpenDocument", "PDF", "HTML"
], ],
"homepage": "http://phpoffice.github.io", "homepage": "http://phpoffice.github.io",
"type": "library", "type": "library",

View File

@ -36,8 +36,6 @@ class TextBox extends AbstractContainer
/** /**
* Create a new textbox * Create a new textbox
* *
* @param string $docPart
* @param integer $docPartId
* @param mixed $style * @param mixed $style
*/ */
public function __construct($style = null) public function __construct($style = null)

View File

@ -230,9 +230,9 @@ abstract class AbstractStyle
*/ */
protected function setEnumVal($value = null, $enum = array(), $default = null) protected function setEnumVal($value = null, $enum = array(), $default = null)
{ {
if (!is_null($value) && !empty($enum) && !in_array($value, $enum)) { if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
throw new \InvalidArgumentException('Invalid style value.'); throw new \InvalidArgumentException('Invalid style value.');
} elseif (is_null($value)) { } elseif (is_null($value) || trim($value) == '') {
$value = $default; $value = $default;
} }

View File

@ -17,7 +17,6 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exception\InvalidStyleException;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
/** /**
@ -652,7 +651,7 @@ class Font extends AbstractStyle
/** /**
* Toggle $target property to false when $source true * Toggle $target property to false when $source true
* *
* @param mixed $target Target property * @param bool $target Target property
* @param bool $sourceValue * @param bool $sourceValue
*/ */
private function toggleFalse(&$target, $sourceValue) private function toggleFalse(&$target, $sourceValue)

View File

@ -377,10 +377,11 @@ class NumberingLevel extends AbstractStyle
* @param string $value * @param string $value
* @return self * @return self
*/ */
public function setHint($value) public function setHint($value = null)
{ {
$enum = array('default', 'eastAsia', 'cs'); $enum = array('default', 'eastAsia', 'cs');
$this->hint = $this->setEnumVal($value, $enum, $this->hint); $this->hint = $this->setEnumVal($value, $enum, $this->hint);
return $this; return $this;
} }
} }

View File

@ -169,6 +169,24 @@ class TextBox extends Image
return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom); return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom);
} }
/**
* Has inner margin?
*
* @return bool
*/
public function hasInnerMargins()
{
$hasInnerMargins = false;
$margins = $this->getInnerMargins();
for ($i = 0; $i < count($margins); $i++) {
if (!is_null($margins[$i])) {
$hasInnerMargins = true;
}
}
return $hasInnerMargins;
}
/** /**
* Set border size * Set border size
* *

View File

@ -17,9 +17,6 @@
namespace PhpOffice\PhpWord\Writer\ODText\Element; namespace PhpOffice\PhpWord\Writer\ODText\Element;
use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement;
use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter;
/** /**
* Table element writer * Table element writer
* *

View File

@ -17,7 +17,6 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\TextBox as TextBoxStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\TextBox as TextBoxStyleWriter;
/** /**
@ -35,11 +34,7 @@ class TextBox extends AbstractElement
$xmlWriter = $this->getXmlWriter(); $xmlWriter = $this->getXmlWriter();
$element = $this->getElement(); $element = $this->getElement();
$style = $element->getStyle(); $style = $element->getStyle();
$styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
if ($style instanceof TextBoxStyle) {
$styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
$styleWriter->write();
}
if (!$this->withoutP) { if (!$this->withoutP) {
$xmlWriter->startElement('w:p'); $xmlWriter->startElement('w:p');
@ -57,20 +52,15 @@ class TextBox extends AbstractElement
$xmlWriter->startElement('v:shape'); $xmlWriter->startElement('v:shape');
$xmlWriter->writeAttribute('type', '#_x0000_t0202'); $xmlWriter->writeAttribute('type', '#_x0000_t0202');
$styleWriter->write(); $styleWriter->write();
$xmlWriter->startElement('v:textbox'); $xmlWriter->startElement('v:textbox');
$margins = implode(', ', $style->getInnerMargin()); $styleWriter->writeInnerMargin();
$xmlWriter->writeAttribute('inset', $margins);
$xmlWriter->startElement('w:txbxContent'); $xmlWriter->startElement('w:txbxContent');
$xmlWriter->startElement('w:p'); $xmlWriter->startElement('w:p');
$containerWriter = new Container($xmlWriter, $element); $containerWriter = new Container($xmlWriter, $element);
$containerWriter->write(); $containerWriter->write();
$xmlWriter->endElement(); // w:p $xmlWriter->endElement(); // w:p
$xmlWriter->endElement(); // w:txbxContent $xmlWriter->endElement(); // w:txbxContent
$xmlWriter->endElement(); // v: textbox $xmlWriter->endElement(); // v: textbox
$styleWriter->writeW10Wrap(); $styleWriter->writeW10Wrap();
$xmlWriter->endElement(); // v:shape $xmlWriter->endElement(); // v:shape
$xmlWriter->endElement(); // w:pict $xmlWriter->endElement(); // w:pict

View File

@ -17,8 +17,6 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
/** /**
* TextRun element writer * TextRun element writer
* *

View File

@ -62,7 +62,7 @@ class Styles extends AbstractPart
// Font style // Font style
if ($style instanceof Font) { if ($style instanceof Font) {
$paragraphStyle = $style->getParagraphStyle(); $paragraphStyle = $style->getParagraph();
$styleType = $style->getStyleType(); $styleType = $style->getStyleType();
$type = ($styleType == 'title') ? 'paragraph' : 'character'; $type = ($styleType == 'title') ? 'paragraph' : 'character';
if (!is_null($paragraphStyle)) { if (!is_null($paragraphStyle)) {

View File

@ -94,8 +94,6 @@ class Table extends AbstractStyle
/** /**
* Write row style * Write row style
*
* @param string $type
*/ */
private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style) private function writeFirstRow(\PhpOffice\PhpWord\Style\Table $style)
{ {

View File

@ -48,6 +48,7 @@ class TextBox extends Image
if (is_null($this->w10wrap)) { if (is_null($this->w10wrap)) {
return; return;
} }
$style = $this->getStyle();
$relativePositions = array( $relativePositions = array(
TextBoxStyle::POSITION_RELATIVE_TO_MARGIN => 'margin', TextBoxStyle::POSITION_RELATIVE_TO_MARGIN => 'margin',
@ -80,6 +81,21 @@ class TextBox extends Image
$xmlWriter->endElement(); // w10:wrap $xmlWriter->endElement(); // w10:wrap
} }
/**
* Writer inner margin
*/
public function writeInnerMargin()
{
$style = $this->getStyle();
if (!$style->hasInnerMargins()) {
return;
}
$xmlWriter = $this->getXmlWriter();
$margins = implode(', ', $style->getInnerMargin());
$xmlWriter->writeAttribute('inset', $margins);
}
/** /**
* Writer border * Writer border
*/ */

View File

@ -35,7 +35,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
$object = new Cell(); $object = new Cell();
$attributes = array( $attributes = array(
'valign' => 'left', 'valign' => Cell::VALIGN_TOP,
'textDirection' => Cell::TEXT_DIR_BTLR, 'textDirection' => Cell::TEXT_DIR_BTLR,
'bgColor' => 'FFFF00', 'bgColor' => 'FFFF00',
'borderTopSize' => 120, 'borderTopSize' => 120,
@ -47,7 +47,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
'borderBottomSize' => 120, 'borderBottomSize' => 120,
'borderBottomColor' => 'FFFF00', 'borderBottomColor' => 'FFFF00',
'gridSpan' => 2, 'gridSpan' => 2,
'vMerge' => 2, 'vMerge' => Cell::VMERGE_RESTART,
); );
foreach ($attributes as $key => $value) { foreach ($attributes as $key => $value) {
$set = "set{$key}"; $set = "set{$key}";