123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- class PHPExcel_RichText implements PHPExcel_IComparable
- {
-
- private $richTextElements;
-
- public function __construct(PHPExcel_Cell $pCell = null)
- {
-
- $this->richTextElements = array();
-
- if ($pCell !== null) {
-
- if ($pCell->getValue() != "") {
- $objRun = new PHPExcel_RichText_Run($pCell->getValue());
- $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
- $this->addText($objRun);
- }
-
- $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
- }
- }
-
- public function addText(PHPExcel_RichText_ITextElement $pText = null)
- {
- $this->richTextElements[] = $pText;
- return $this;
- }
-
- public function createText($pText = '')
- {
- $objText = new PHPExcel_RichText_TextElement($pText);
- $this->addText($objText);
- return $objText;
- }
-
- public function createTextRun($pText = '')
- {
- $objText = new PHPExcel_RichText_Run($pText);
- $this->addText($objText);
- return $objText;
- }
-
- public function getPlainText()
- {
-
- $returnValue = '';
-
- foreach ($this->richTextElements as $text) {
- $returnValue .= $text->getText();
- }
-
- return $returnValue;
- }
-
- public function __toString()
- {
- return $this->getPlainText();
- }
-
- public function getRichTextElements()
- {
- return $this->richTextElements;
- }
-
- public function setRichTextElements($pElements = null)
- {
- if (is_array($pElements)) {
- $this->richTextElements = $pElements;
- } else {
- throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
- }
- return $this;
- }
-
- public function getHashCode()
- {
- $hashElements = '';
- foreach ($this->richTextElements as $element) {
- $hashElements .= $element->getHashCode();
- }
- return md5(
- $hashElements .
- __CLASS__
- );
- }
-
- public function __clone()
- {
- $vars = get_object_vars($this);
- foreach ($vars as $key => $value) {
- if (is_object($value)) {
- $this->$key = clone $value;
- } else {
- $this->$key = $value;
- }
- }
- }
- }
|