PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/PHPExcel_1.7.8-with_documentation-msoffice_format/Classes/PHPExcel/RichText/Run.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 102 lines | 34 code | 7 blank | 61 comment | 2 complexity | 05407e3faf12505988523952a5ece0f4 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT
  1. <?php
  2. /**
  3. * PHPExcel
  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 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
  22. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  23. * @version 1.7.8, 2012-10-12
  24. */
  25. /**
  26. * PHPExcel_RichText_Run
  27. *
  28. * @category PHPExcel
  29. * @package PHPExcel_RichText
  30. * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
  31. */
  32. class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
  33. {
  34. /**
  35. * Font
  36. *
  37. * @var PHPExcel_Style_Font
  38. */
  39. private $_font;
  40. /**
  41. * Create a new PHPExcel_RichText_Run instance
  42. *
  43. * @param string $pText Text
  44. */
  45. public function __construct($pText = '')
  46. {
  47. // Initialise variables
  48. $this->setText($pText);
  49. $this->_font = new PHPExcel_Style_Font();
  50. }
  51. /**
  52. * Get font
  53. *
  54. * @return PHPExcel_Style_Font
  55. */
  56. public function getFont() {
  57. return $this->_font;
  58. }
  59. /**
  60. * Set font
  61. *
  62. * @param PHPExcel_Style_Font $pFont Font
  63. * @throws Exception
  64. * @return PHPExcel_RichText_ITextElement
  65. */
  66. public function setFont(PHPExcel_Style_Font $pFont = null) {
  67. $this->_font = $pFont;
  68. return $this;
  69. }
  70. /**
  71. * Get hash code
  72. *
  73. * @return string Hash code
  74. */
  75. public function getHashCode() {
  76. return md5(
  77. $this->getText()
  78. . $this->_font->getHashCode()
  79. . __CLASS__
  80. );
  81. }
  82. /**
  83. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  84. */
  85. public function __clone() {
  86. $vars = get_object_vars($this);
  87. foreach ($vars as $key => $value) {
  88. if (is_object($value)) {
  89. $this->$key = clone $value;
  90. } else {
  91. $this->$key = $value;
  92. }
  93. }
  94. }
  95. }