ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
RichText.php
Go to the documentation of this file.
1
<?
php
2
3
namespace
PhpOffice\PhpSpreadsheet\RichText
;
4
5
use
PhpOffice\PhpSpreadsheet\Cell\Cell
;
6
use
PhpOffice\PhpSpreadsheet\Cell\DataType
;
7
use
PhpOffice\PhpSpreadsheet\IComparable
;
8
9
class
RichText
implements
IComparable
10
{
16
private
$richTextElements
;
17
23
public
function
__construct
(?
Cell
$pCell =
null
)
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
}
41
49
public
function
addText
(
ITextElement
$pText)
50
{
51
$this->richTextElements[] = $pText;
52
53
return
$this;
54
}
55
63
public
function
createText
($pText)
64
{
65
$objText =
new
TextElement
($pText);
66
$this->
addText
($objText);
67
68
return
$objText;
69
}
70
78
public
function
createTextRun
($pText)
79
{
80
$objText =
new
Run
($pText);
81
$this->
addText
($objText);
82
83
return
$objText;
84
}
85
91
public
function
getPlainText
()
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
}
103
109
public
function
__toString
()
110
{
111
return
$this->
getPlainText
();
112
}
113
119
public
function
getRichTextElements
()
120
{
121
return
$this->richTextElements
;
122
}
123
131
public
function
setRichTextElements
(array $textElements)
132
{
133
$this->richTextElements = $textElements;
134
135
return
$this;
136
}
137
143
public
function
getHashCode
()
144
{
145
$hashElements =
''
;
146
foreach
($this->richTextElements as $element) {
147
$hashElements .= $element->getHashCode();
148
}
149
150
return
md5(
151
$hashElements .
152
__CLASS__
153
);
154
}
155
159
public
function
__clone
()
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
}
170
}
php
An exception for terminatinating execution or to throw for unit testing.
PhpOffice\PhpSpreadsheet\Cell\Cell
Definition:
Cell.php:14
PhpOffice\PhpSpreadsheet\Cell\DataType
Definition:
DataType.php:9
PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING
const TYPE_STRING
Definition:
DataType.php:12
PhpOffice\PhpSpreadsheet\RichText\RichText
Definition:
RichText.php:10
PhpOffice\PhpSpreadsheet\RichText\RichText\setRichTextElements
setRichTextElements(array $textElements)
Set Rich Text elements.
Definition:
RichText.php:131
PhpOffice\PhpSpreadsheet\RichText\RichText\__construct
__construct(?Cell $pCell=null)
Create a new RichText instance.
Definition:
RichText.php:23
PhpOffice\PhpSpreadsheet\RichText\RichText\$richTextElements
$richTextElements
Definition:
RichText.php:16
PhpOffice\PhpSpreadsheet\RichText\RichText\getHashCode
getHashCode()
Get hash code.
Definition:
RichText.php:143
PhpOffice\PhpSpreadsheet\RichText\RichText\__clone
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
Definition:
RichText.php:159
PhpOffice\PhpSpreadsheet\RichText\RichText\getPlainText
getPlainText()
Get plain text.
Definition:
RichText.php:91
PhpOffice\PhpSpreadsheet\RichText\RichText\createTextRun
createTextRun($pText)
Create text run.
Definition:
RichText.php:78
PhpOffice\PhpSpreadsheet\RichText\RichText\getRichTextElements
getRichTextElements()
Get Rich Text elements.
Definition:
RichText.php:119
PhpOffice\PhpSpreadsheet\RichText\RichText\addText
addText(ITextElement $pText)
Add text.
Definition:
RichText.php:49
PhpOffice\PhpSpreadsheet\RichText\RichText\createText
createText($pText)
Create text.
Definition:
RichText.php:63
PhpOffice\PhpSpreadsheet\RichText\RichText\__toString
__toString()
Convert to string.
Definition:
RichText.php:109
PhpOffice\PhpSpreadsheet\RichText\Run
Definition:
Run.php:8
PhpOffice\PhpSpreadsheet\RichText\TextElement
Definition:
TextElement.php:6
$key
$key
Definition:
croninfo.php:18
PhpOffice\PhpSpreadsheet\IComparable
Definition:
IComparable.php:6
PhpOffice\PhpSpreadsheet\RichText\ITextElement
Definition:
ITextElement.php:6
PhpOffice\PhpSpreadsheet\RichText
Definition:
ITextElement.php:3
$text
$text
Definition:
errorreport.php:18
libs
composer
vendor
phpoffice
phpspreadsheet
src
PhpSpreadsheet
RichText
RichText.php
Generated on Thu Oct 2 2025 19:01:11 for ILIAS by
1.9.4 (using
Doxyfile
)