diff --git a/docs/styles.rst b/docs/styles.rst index a0e9c7ff..2b5fcbc5 100644 --- a/docs/styles.rst +++ b/docs/styles.rst @@ -63,7 +63,8 @@ Paragraph 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. - ``hanging``. Hanging by how much. - ``indent``. Indent by how much. @@ -84,7 +85,8 @@ Table 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'. - ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'. - ``border(Top|Right|Bottom|Left)Size``. Border size in twips. @@ -129,7 +131,8 @@ Numbering level 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. - ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter. - ``hanging``. See paragraph style. diff --git a/src/PhpWord/SimpleType/Jc.php b/src/PhpWord/SimpleType/Jc.php index 5cbf4752..ede2f2fc 100644 --- a/src/PhpWord/SimpleType/Jc.php +++ b/src/PhpWord/SimpleType/Jc.php @@ -22,8 +22,13 @@ use Zend\Validator\InArray; /** * 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 * + * @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008. + * * @codeCoverageIgnore */ final class Jc @@ -40,15 +45,24 @@ final class Jc 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'; /** - * @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'; /** - * @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'; diff --git a/src/PhpWord/SimpleType/JcTable.php b/src/PhpWord/SimpleType/JcTable.php index d93e56f1..38e72cc3 100644 --- a/src/PhpWord/SimpleType/JcTable.php +++ b/src/PhpWord/SimpleType/JcTable.php @@ -22,6 +22,8 @@ use Zend\Validator\InArray; /** * Table Alignment Type. * + * Introduced in ISO/IEC-29500:2008. + * * @since 0.13.0 * * @codeCoverageIgnore @@ -32,19 +34,6 @@ final class JcTable const CENTER = 'center'; 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 * @@ -55,7 +44,7 @@ final class JcTable // todo: consider caching validator instances. return new InArray( 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, ) ); diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php index ded4950a..d6ba9d0c 100644 --- a/src/PhpWord/Style/Frame.php +++ b/src/PhpWord/Style/Frame.php @@ -201,24 +201,7 @@ class Frame extends AbstractStyle public function setAlignment($value) { if (Jc::getValidator()->isValid($value)) { - $alignment = ''; - - 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; + $this->alignment = $value; } return $this; diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index bffac472..2ed8e4ec 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -299,24 +299,7 @@ class NumberingLevel extends AbstractStyle public function setAlignment($value) { if (Jc::getValidator()->isValid($value)) { - $alignment = ''; - - 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; + $this->alignment = $value; } return $this; diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 10e94a2a..50f9607c 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -233,24 +233,7 @@ class Paragraph extends Border public function setAlignment($value) { if (Jc::getValidator()->isValid($value)) { - $alignment = ''; - - 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; + $this->alignment = $value; } return $this; diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 846dd0b0..bbbd6708 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Style; +use PhpOffice\PhpWord\SimpleType\Jc; use PhpOffice\PhpWord\SimpleType\JcTable; class Table extends Border @@ -509,25 +510,8 @@ class Table extends Border */ public function setAlignment($value) { - if (JcTable::getValidator()->isValid($value)) { - $alignment = ''; - - 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; + if (JcTable::getValidator()->isValid($value) || Jc::getValidator()->isValid($value)) { + $this->alignment = $value; } return $this;