ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RichText.php
Go to the documentation of this file.
1 <?php
37 {
44 
51  public function __construct(PHPExcel_Cell $pCell = null)
52  {
53  // Initialise variables
54  $this->_richTextElements = array();
55 
56  // Rich-Text string attached to cell?
57  if ($pCell !== NULL) {
58  // Add cell text and style
59  if ($pCell->getValue() != "") {
60  $objRun = new PHPExcel_RichText_Run($pCell->getValue());
61  $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
62  $this->addText($objRun);
63  }
64 
65  // Set parent value
66  $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
67  }
68  }
69 
77  public function addText(PHPExcel_RichText_ITextElement $pText = null)
78  {
79  $this->_richTextElements[] = $pText;
80  return $this;
81  }
82 
90  public function createText($pText = '')
91  {
92  $objText = new PHPExcel_RichText_TextElement($pText);
93  $this->addText($objText);
94  return $objText;
95  }
96 
104  public function createTextRun($pText = '')
105  {
106  $objText = new PHPExcel_RichText_Run($pText);
107  $this->addText($objText);
108  return $objText;
109  }
110 
116  public function getPlainText()
117  {
118  // Return value
119  $returnValue = '';
120 
121  // Loop through all PHPExcel_RichText_ITextElement
122  foreach ($this->_richTextElements as $text) {
123  $returnValue .= $text->getText();
124  }
125 
126  // Return
127  return $returnValue;
128  }
129 
135  public function __toString()
136  {
137  return $this->getPlainText();
138  }
139 
145  public function getRichTextElements()
146  {
148  }
149 
157  public function setRichTextElements($pElements = null)
158  {
159  if (is_array($pElements)) {
160  $this->_richTextElements = $pElements;
161  } else {
162  throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
163  }
164  return $this;
165  }
166 
172  public function getHashCode()
173  {
174  $hashElements = '';
175  foreach ($this->_richTextElements as $element) {
176  $hashElements .= $element->getHashCode();
177  }
178 
179  return md5(
180  $hashElements
181  . __CLASS__
182  );
183  }
184 
188  public function __clone()
189  {
190  $vars = get_object_vars($this);
191  foreach ($vars as $key => $value) {
192  if (is_object($value)) {
193  $this->$key = clone $value;
194  } else {
195  $this->$key = $value;
196  }
197  }
198  }
199 }
setFont(PHPExcel_Style_Font $pFont=null)
Set font.
Definition: Run.php:71
__toString()
Convert to string.
Definition: RichText.php:135
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
Definition: RichText.php:188
createTextRun($pText='')
Create text run.
Definition: RichText.php:104
addText(PHPExcel_RichText_ITextElement $pText=null)
Add text.
Definition: RichText.php:77
createText($pText='')
Create text.
Definition: RichText.php:90
$text
Definition: errorreport.php:18
Create styles array
The data for the language used.
__construct(PHPExcel_Cell $pCell=null)
Create a new PHPExcel_RichText instance.
Definition: RichText.php:51
getHashCode()
Get hash code.
Definition: RichText.php:172
getRichTextElements()
Get Rich Text elements.
Definition: RichText.php:145
getPlainText()
Get plain text.
Definition: RichText.php:116
setRichTextElements($pElements=null)
Set Rich Text elements.
Definition: RichText.php:157
$key
Definition: croninfo.php:18