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
- 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
- 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
## 0.10.0 - 4 May 2014

View File

@ -1,10 +1,10 @@
{
"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": [
"PHP", "PhpOffice", "office", "PhpWord", "word", "template", "reader", "writer",
"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",
"type": "library",

View File

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

View File

@ -230,9 +230,9 @@ abstract class AbstractStyle
*/
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.');
} elseif (is_null($value)) {
} elseif (is_null($value) || trim($value) == '') {
$value = $default;
}

View File

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

View File

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

View File

@ -169,6 +169,24 @@ class TextBox extends Image
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
*

View File

@ -17,9 +17,6 @@
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
*

View File

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

View File

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

View File

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

View File

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

View File

@ -48,6 +48,7 @@ class TextBox extends Image
if (is_null($this->w10wrap)) {
return;
}
$style = $this->getStyle();
$relativePositions = array(
TextBoxStyle::POSITION_RELATIVE_TO_MARGIN => 'margin',
@ -80,6 +81,21 @@ class TextBox extends Image
$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
*/

View File

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