PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/branches/v1.1.0/Classes/PHPExcel/Style/Border.php

#
PHP | 149 lines | 53 code | 14 blank | 82 comment | 2 complexity | 384bbfa2081d06d4f4bb8955a4bf96e4 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, LGPL-2.1, GPL-3.0, LGPL-3.0
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2007 PHPExcel, Maarten Balliauw
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Style
  23. * @copyright Copyright (c) 2006 - 2007 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/gpl.txt GPL
  25. */
  26. /** PHPExcel_Style_Color */
  27. require_once 'PHPExcel/Style/Color.php';
  28. /** PHPExcel_IComparable */
  29. require_once 'PHPExcel/IComparable.php';
  30. /**
  31. * PHPExcel_Style_Border
  32. *
  33. * @category PHPExcel
  34. * @package PHPExcel_Style
  35. * @copyright Copyright (c) 2006 - 2007 PHPExcel (http://www.codeplex.com/PHPExcel)
  36. */
  37. class PHPExcel_Style_Border implements PHPExcel_IComparable
  38. {
  39. /* Border style */
  40. const BORDER_NONE = 'none';
  41. const BORDER_DASHDOT = 'dashDot';
  42. const BORDER_DASHDOTDOT = 'dashDotDot';
  43. const BORDER_DASHED = 'dashed';
  44. const BORDER_DOTTED = 'dotted';
  45. const BORDER_DOUBLE = 'double';
  46. const BORDER_HAIR = 'hair';
  47. const BORDER_MEDIUM = 'medium';
  48. const BORDER_MEDIUMDASHDOT = 'mediumDashDot';
  49. const BORDER_MEDIUMDASHDOTDOT = 'mediumDashDotDot';
  50. const BORDER_MEDIUMDASHED = 'mediumDashed';
  51. const BORDER_SLANTDASHDOT = 'slantDashDot';
  52. const BORDER_THICK = 'thick';
  53. const BORDER_THIN = 'thin';
  54. /**
  55. * Border style
  56. *
  57. * @var string
  58. */
  59. private $_borderStyle;
  60. /**
  61. * Border color
  62. *
  63. * @var PHPExcel_Style_Color
  64. */
  65. private $_borderColor;
  66. /**
  67. * Create a new PHPExcel_Style_Border
  68. */
  69. public function __construct()
  70. {
  71. // Initialise values
  72. $this->_borderStyle = PHPExcel_Style_Border::BORDER_NONE;
  73. $this->_borderColor = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
  74. }
  75. /**
  76. * Get Border style
  77. *
  78. * @return string
  79. */
  80. public function getBorderStyle() {
  81. return $this->_borderStyle;
  82. }
  83. /**
  84. * Set Border style
  85. *
  86. * @param string $pValue
  87. */
  88. public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
  89. $this->_borderStyle = $pValue;
  90. }
  91. /**
  92. * Get Border Color
  93. *
  94. * @return PHPExcel_Style_Color
  95. */
  96. public function getColor() {
  97. return $this->_borderColor;
  98. }
  99. /**
  100. * Set Border Color
  101. *
  102. * @param PHPExcel_Style_Color $pValue
  103. * @throws Exception
  104. */
  105. public function setColor($pValue = null) {
  106. if ($pValue instanceof PHPExcel_Style_Color) {
  107. $this->_borderColor = $pValue;
  108. } else {
  109. throw new Exception("Invalid PHPExcel_Style_Color passed.");
  110. }
  111. }
  112. /**
  113. * Get hash code
  114. *
  115. * @return string Hash code
  116. */
  117. public function getHashCode() {
  118. return md5(
  119. $this->_borderStyle
  120. . $this->_borderColor->getHashCode()
  121. . __CLASS__
  122. );
  123. }
  124. /**
  125. * Duplicate object
  126. *
  127. * Duplicates the current object, also duplicating referenced objects (deep cloning).
  128. * Standard PHP clone does not copy referenced objects!
  129. *
  130. * @return PHPExcel_Style_Border
  131. */
  132. public function duplicate() {
  133. return unserialize(serialize($this));
  134. }
  135. }