0
0

Run.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * PHPExcel_RichText_Run
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. *
  19. * @category PHPExcel
  20. * @package PHPExcel_RichText
  21. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  22. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  23. * @version ##VERSION##, ##DATE##
  24. */
  25. class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
  26. {
  27. /**
  28. * Font
  29. *
  30. * @var PHPExcel_Style_Font
  31. */
  32. private $font;
  33. /**
  34. * Create a new PHPExcel_RichText_Run instance
  35. *
  36. * @param string $pText Text
  37. */
  38. public function __construct($pText = '')
  39. {
  40. // Initialise variables
  41. $this->setText($pText);
  42. $this->font = new PHPExcel_Style_Font();
  43. }
  44. /**
  45. * Get font
  46. *
  47. * @return PHPExcel_Style_Font
  48. */
  49. public function getFont()
  50. {
  51. return $this->font;
  52. }
  53. /**
  54. * Set font
  55. *
  56. * @param PHPExcel_Style_Font $pFont Font
  57. * @throws PHPExcel_Exception
  58. * @return PHPExcel_RichText_ITextElement
  59. */
  60. public function setFont(PHPExcel_Style_Font $pFont = null)
  61. {
  62. $this->font = $pFont;
  63. return $this;
  64. }
  65. /**
  66. * Get hash code
  67. *
  68. * @return string Hash code
  69. */
  70. public function getHashCode()
  71. {
  72. return md5(
  73. $this->getText() .
  74. $this->font->getHashCode() .
  75. __CLASS__
  76. );
  77. }
  78. /**
  79. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  80. */
  81. public function __clone()
  82. {
  83. $vars = get_object_vars($this);
  84. foreach ($vars as $key => $value) {
  85. if (is_object($value)) {
  86. $this->$key = clone $value;
  87. } else {
  88. $this->$key = $value;
  89. }
  90. }
  91. }
  92. }