This commit is contained in:
Roman Syroeshko 2016-02-23 19:02:35 +04:00
parent 16495a0a0d
commit 28f801b5d0
7 changed files with 32 additions and 93 deletions

View File

@ -63,7 +63,8 @@ Paragraph
Available Paragraph style options: Available Paragraph style options:
- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details. - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
- ``basedOn``. Parent style. - ``basedOn``. Parent style.
- ``hanging``. Hanging by how much. - ``hanging``. Hanging by how much.
- ``indent``. Indent by how much. - ``indent``. Indent by how much.
@ -84,7 +85,8 @@ Table
Available Table style options: Available Table style options:
- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\JcTable`` class for the details. - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
- ``bgColor``. Background color, e.g. '9966CC'. - ``bgColor``. Background color, e.g. '9966CC'.
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'. - ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
- ``border(Top|Right|Bottom|Left)Size``. Border size in twips. - ``border(Top|Right|Bottom|Left)Size``. Border size in twips.
@ -129,7 +131,8 @@ Numbering level
Available NumberingLevel style options: Available NumberingLevel style options:
- ``alignment``. Supports all alignment modes provided by third edition of ISO/IEC 29500 standard. See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details. - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class for the details.
- ``font``. Font name. - ``font``. Font name.
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter. - ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
- ``hanging``. See paragraph style. - ``hanging``. See paragraph style.

View File

@ -22,8 +22,13 @@ use Zend\Validator\InArray;
/** /**
* Horizontal Alignment Type. * Horizontal Alignment Type.
* *
* Introduced in 1st Edition of ECMA-376. Initially it was intended to align paragraphs and tables.
* Since ISO/IEC-29500:2008 the type must not be used for table alignment.
*
* @since 0.13.0 * @since 0.13.0
* *
* @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008.
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
final class Jc final class Jc
@ -40,15 +45,24 @@ final class Jc
const THAI_DISTRIBUTE = 'thaiDistribute'; const THAI_DISTRIBUTE = 'thaiDistribute';
/** /**
* @deprecated 0.13.0 Use `START` instead. * Kept for compatibility with 1st edition of ECMA-376 standard.
* Microsoft Word 2007 and WPS Writer 2016 still rely on it.
*
* @deprecated 0.13.0 For documents based on ISO/IEC 29500:2008 and later use `START` instead.
*/ */
const LEFT = 'left'; const LEFT = 'left';
/** /**
* @deprecated 0.13.0 Use `END` instead. * Kept for compatibility with 1st edition of ECMA-376 standard.
* Microsoft Word 2007 and WPS Writer 2016 still rely on it.
*
* @deprecated 0.13.0 For documents based on ISO/IEC 29500:2008 and later use `END` instead.
*/ */
const RIGHT = 'right'; const RIGHT = 'right';
/** /**
* @deprecated 0.13.0 Use `BOTH` instead. * Kept for compatibility with 1st edition of ECMA-376 standard.
* Microsoft Word 2007 and WPS Writer 2016 still rely on it.
*
* @deprecated 0.13.0 For documents based on ISO/IEC 29500:2008 and later use `BOTH` instead.
*/ */
const JUSTIFY = 'justify'; const JUSTIFY = 'justify';

View File

@ -22,6 +22,8 @@ use Zend\Validator\InArray;
/** /**
* Table Alignment Type. * Table Alignment Type.
* *
* Introduced in ISO/IEC-29500:2008.
*
* @since 0.13.0 * @since 0.13.0
* *
* @codeCoverageIgnore * @codeCoverageIgnore
@ -32,19 +34,6 @@ final class JcTable
const CENTER = 'center'; const CENTER = 'center';
const END = 'end'; const END = 'end';
/**
* @deprecated 0.13.0 Use `START` instead.
*/
const LEFT = 'left';
/**
* @deprecated 0.13.0 Use `END` instead.
*/
const RIGHT = 'right';
/**
* @deprecated 0.13.0 Use `CENTER` instead.
*/
const JUSTIFY = 'justify';
/** /**
* @since 0.13.0 * @since 0.13.0
* *
@ -55,7 +44,7 @@ final class JcTable
// todo: consider caching validator instances. // todo: consider caching validator instances.
return new InArray( return new InArray(
array ( array (
'haystack' => array(self::START, self::CENTER, self::END, self::LEFT, self::RIGHT, self::JUSTIFY), 'haystack' => array(self::START, self::CENTER, self::END),
'strict' => InArray::COMPARE_STRICT, 'strict' => InArray::COMPARE_STRICT,
) )
); );

View File

@ -201,24 +201,7 @@ class Frame extends AbstractStyle
public function setAlignment($value) public function setAlignment($value)
{ {
if (Jc::getValidator()->isValid($value)) { if (Jc::getValidator()->isValid($value)) {
$alignment = ''; $this->alignment = $value;
switch ($value) {
case Jc::LEFT:
$alignment = Jc::START;
break;
case Jc::RIGHT:
$alignment = Jc::END;
break;
case Jc::JUSTIFY:
$alignment = Jc::BOTH;
break;
default:
$alignment = $value;
break;
}
$this->alignment = $alignment;
} }
return $this; return $this;

View File

@ -299,24 +299,7 @@ class NumberingLevel extends AbstractStyle
public function setAlignment($value) public function setAlignment($value)
{ {
if (Jc::getValidator()->isValid($value)) { if (Jc::getValidator()->isValid($value)) {
$alignment = ''; $this->alignment = $value;
switch ($value) {
case Jc::LEFT:
$alignment = Jc::START;
break;
case Jc::RIGHT:
$alignment = Jc::END;
break;
case Jc::JUSTIFY:
$alignment = Jc::BOTH;
break;
default:
$alignment = $value;
break;
}
$this->alignment = $alignment;
} }
return $this; return $this;

View File

@ -233,24 +233,7 @@ class Paragraph extends Border
public function setAlignment($value) public function setAlignment($value)
{ {
if (Jc::getValidator()->isValid($value)) { if (Jc::getValidator()->isValid($value)) {
$alignment = ''; $this->alignment = $value;
switch ($value) {
case Jc::LEFT:
$alignment = Jc::START;
break;
case Jc::RIGHT:
$alignment = Jc::END;
break;
case Jc::JUSTIFY:
$alignment = Jc::BOTH;
break;
default:
$alignment = $value;
break;
}
$this->alignment = $alignment;
} }
return $this; return $this;

View File

@ -17,6 +17,7 @@
namespace PhpOffice\PhpWord\Style; namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\SimpleType\Jc;
use PhpOffice\PhpWord\SimpleType\JcTable; use PhpOffice\PhpWord\SimpleType\JcTable;
class Table extends Border class Table extends Border
@ -509,25 +510,8 @@ class Table extends Border
*/ */
public function setAlignment($value) public function setAlignment($value)
{ {
if (JcTable::getValidator()->isValid($value)) { if (JcTable::getValidator()->isValid($value) || Jc::getValidator()->isValid($value)) {
$alignment = ''; $this->alignment = $value;
switch ($value) {
case JcTable::LEFT:
$alignment = JcTable::START;
break;
case JcTable::RIGHT:
$alignment = JcTable::END;
break;
case JcTable::JUSTIFY:
$alignment = JcTable::CENTER;
break;
default:
$alignment = $value;
break;
}
$this->alignment = $alignment;
} }
return $this; return $this;