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...
 
 getHashCode ()
 Get hash code. 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.

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

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

+ 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.

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

References $key.

◆ __toString()

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

Convert to string.

Returns
string

Definition at line 109 of file RichText.php.

110 {
111 return $this->getPlainText();
112 }

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

+ 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.

50 {
51 $this->richTextElements[] = $pText;
52
53 return $this;
54 }

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

+ 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.

64 {
65 $objText = new TextElement($pText);
66 $this->addText($objText);
67
68 return $objText;
69 }

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

+ 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.

79 {
80 $objText = new Run($pText);
81 $this->addText($objText);
82
83 return $objText;
84 }

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

+ 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.

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

References $text.

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

+ 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[]$textElementsArray 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: