Brak opisu

Alignment.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Style;
  18. /**
  19. * Alignment style
  20. *
  21. * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Jc.html
  22. * @since 0.11.0
  23. */
  24. class Alignment extends AbstractStyle
  25. {
  26. /**
  27. * @const string Alignment http://www.schemacentral.com/sc/ooxml/t-w_ST_Jc.html
  28. */
  29. const ALIGN_LEFT = 'left'; // Align left
  30. const ALIGN_RIGHT = 'right'; // Align right
  31. const ALIGN_CENTER = 'center'; // Align center
  32. const ALIGN_BOTH = 'both'; // Align both
  33. const ALIGN_JUSTIFY = 'justify'; // Alias for align both
  34. /**
  35. * @var string Alignment
  36. */
  37. private $value = null;
  38. /**
  39. * Create a new instance
  40. *
  41. * @param array $style
  42. */
  43. public function __construct($style = array())
  44. {
  45. $this->setStyleByArray($style);
  46. }
  47. /**
  48. * Get alignment
  49. *
  50. * @return string
  51. */
  52. public function getValue()
  53. {
  54. return $this->value;
  55. }
  56. /**
  57. * Set alignment
  58. *
  59. * @param string $value
  60. * @return self
  61. */
  62. public function setValue($value = null)
  63. {
  64. if (strtolower($value) == self::ALIGN_JUSTIFY) {
  65. $value = self::ALIGN_BOTH;
  66. }
  67. $enum = array(self::ALIGN_LEFT, self::ALIGN_RIGHT, self::ALIGN_CENTER, self::ALIGN_BOTH, self::ALIGN_JUSTIFY);
  68. $this->value = $this->setEnumVal($value, $enum, $this->value);
  69. return $this;
  70. }
  71. }