ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\RichText\RichText Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\RichText\RichText:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\RichText\RichText:

Public Member Functions

 __construct (?Cell $pCell=null)
 Create a new RichText instance. More...
 
 addText (ITextElement $pText)
 Add text. More...
 
 createText ($pText)
 Create text. More...
 
 createTextRun ($pText)
 Create text run. More...
 
 getPlainText ()
 Get plain text. More...
 
 __toString ()
 Convert to string. More...
 
 getRichTextElements ()
 Get Rich Text elements. More...
 
 setRichTextElements (array $textElements)
 Set Rich Text elements. More...
 
 getHashCode ()
 Get hash code. More...
 
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy. More...
 

Private Attributes

 $richTextElements
 

Detailed Description

Definition at line 9 of file RichText.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\RichText\RichText::__construct ( ?Cell  $pCell = null)

Create a new RichText instance.

Parameters
Cell$pCell

Definition at line 23 of file RichText.php.

References PhpOffice\PhpSpreadsheet\RichText\RichText\addText(), PhpOffice\PhpSpreadsheet\RichText\Run\setFont(), and PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING.

24  {
25  // Initialise variables
26  $this->richTextElements = [];
27 
28  // Rich-Text string attached to cell?
29  if ($pCell !== null) {
30  // Add cell text and style
31  if ($pCell->getValue() != '') {
32  $objRun = new Run($pCell->getValue());
33  $objRun->setFont(clone $pCell->getWorksheet()->getStyle($pCell->getCoordinate())->getFont());
34  $this->addText($objRun);
35  }
36 
37  // Set parent value
38  $pCell->setValueExplicit($this, DataType::TYPE_STRING);
39  }
40  }
addText(ITextElement $pText)
Add text.
Definition: RichText.php:49
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

PhpOffice\PhpSpreadsheet\RichText\RichText::__clone ( )

Implement PHP __clone to create a deep clone, not just a shallow copy.

Definition at line 159 of file RichText.php.

References $key.

160  {
161  $vars = get_object_vars($this);
162  foreach ($vars as $key => $value) {
163  if (is_object($value)) {
164  $this->$key = clone $value;
165  } else {
166  $this->$key = $value;
167  }
168  }
169  }
$key
Definition: croninfo.php:18

◆ __toString()

PhpOffice\PhpSpreadsheet\RichText\RichText::__toString ( )

Convert to string.

Returns
string

Definition at line 109 of file RichText.php.

References PhpOffice\PhpSpreadsheet\RichText\RichText\getPlainText().

110  {
111  return $this->getPlainText();
112  }
+ Here is the call graph for this function:

◆ addText()

PhpOffice\PhpSpreadsheet\RichText\RichText::addText ( ITextElement  $pText)

Add text.

Parameters
ITextElement$pTextRich text element
Returns
$this

Definition at line 49 of file RichText.php.

Referenced by PhpOffice\PhpSpreadsheet\RichText\RichText\__construct(), PhpOffice\PhpSpreadsheet\RichText\RichText\createText(), and PhpOffice\PhpSpreadsheet\RichText\RichText\createTextRun().

50  {
51  $this->richTextElements[] = $pText;
52 
53  return $this;
54  }
+ Here is the caller graph for this function:

◆ createText()

PhpOffice\PhpSpreadsheet\RichText\RichText::createText (   $pText)

Create text.

Parameters
string$pTextText
Returns
TextElement

Definition at line 63 of file RichText.php.

References PhpOffice\PhpSpreadsheet\RichText\RichText\addText().

64  {
65  $objText = new TextElement($pText);
66  $this->addText($objText);
67 
68  return $objText;
69  }
addText(ITextElement $pText)
Add text.
Definition: RichText.php:49
+ Here is the call graph for this function:

◆ createTextRun()

PhpOffice\PhpSpreadsheet\RichText\RichText::createTextRun (   $pText)

Create text run.

Parameters
string$pTextText
Returns
Run

Definition at line 78 of file RichText.php.

References PhpOffice\PhpSpreadsheet\RichText\RichText\addText().

79  {
80  $objText = new Run($pText);
81  $this->addText($objText);
82 
83  return $objText;
84  }
addText(ITextElement $pText)
Add text.
Definition: RichText.php:49
+ Here is the call graph for this function:

◆ getHashCode()

PhpOffice\PhpSpreadsheet\RichText\RichText::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PhpOffice\PhpSpreadsheet\IComparable.

Definition at line 143 of file RichText.php.

144  {
145  $hashElements = '';
146  foreach ($this->richTextElements as $element) {
147  $hashElements .= $element->getHashCode();
148  }
149 
150  return md5(
151  $hashElements .
152  __CLASS__
153  );
154  }

◆ getPlainText()

PhpOffice\PhpSpreadsheet\RichText\RichText::getPlainText ( )

Get plain text.

Returns
string

Definition at line 91 of file RichText.php.

References $text.

Referenced by PhpOffice\PhpSpreadsheet\RichText\RichText\__toString().

92  {
93  // Return value
94  $returnValue = '';
95 
96  // Loop through all ITextElements
97  foreach ($this->richTextElements as $text) {
98  $returnValue .= $text->getText();
99  }
100 
101  return $returnValue;
102  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

◆ getRichTextElements()

PhpOffice\PhpSpreadsheet\RichText\RichText::getRichTextElements ( )

Get Rich Text elements.

Returns
ITextElement[]

Definition at line 119 of file RichText.php.

References PhpOffice\PhpSpreadsheet\RichText\RichText\$richTextElements.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\StringTable\writeRichText().

+ Here is the caller graph for this function:

◆ setRichTextElements()

PhpOffice\PhpSpreadsheet\RichText\RichText::setRichTextElements ( array  $textElements)

Set Rich Text elements.

Parameters
ITextElement[]$textElements Array of elements
Returns
$this

Definition at line 131 of file RichText.php.

132  {
133  $this->richTextElements = $textElements;
134 
135  return $this;
136  }

Field Documentation

◆ $richTextElements

PhpOffice\PhpSpreadsheet\RichText\RichText::$richTextElements
private

The documentation for this class was generated from the following file: