14
14
use PhpOffice \PhpSpreadsheet \Chart \Properties as ChartProperties ;
15
15
use PhpOffice \PhpSpreadsheet \Chart \Title ;
16
16
use PhpOffice \PhpSpreadsheet \Chart \TrendLine ;
17
+ use PhpOffice \PhpSpreadsheet \Reader \Xlsx ;
17
18
use PhpOffice \PhpSpreadsheet \RichText \RichText ;
18
19
use PhpOffice \PhpSpreadsheet \Style \Font ;
19
20
use SimpleXMLElement ;
@@ -94,7 +95,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
94
95
break ;
95
96
case 'chart ' :
96
97
foreach ($ chartElement as $ chartDetailsKey => $ chartDetails ) {
97
- $ chartDetailsC = $ chartDetails -> children ( $ this -> cNamespace );
98
+ $ chartDetails = Xlsx:: testSimpleXml ( $ chartDetails );
98
99
switch ($ chartDetailsKey ) {
99
100
case 'autoTitleDeleted ' :
100
101
/** @var bool */
@@ -113,17 +114,17 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
113
114
$ plotSeries = $ plotAttributes = [];
114
115
$ catAxRead = false ;
115
116
$ plotNoFill = false ;
116
- /** @var SimpleXMLElement $chartDetail */
117
117
foreach ($ chartDetails as $ chartDetailKey => $ chartDetail ) {
118
+ $ chartDetail = Xlsx::testSimpleXml ($ chartDetail );
118
119
switch ($ chartDetailKey ) {
119
120
case 'spPr ' :
120
121
$ possibleNoFill = $ chartDetails ->spPr ->children ($ this ->aNamespace );
121
122
if (isset ($ possibleNoFill ->noFill )) {
122
123
$ plotNoFill = true ;
123
124
}
124
125
if (isset ($ possibleNoFill ->gradFill ->gsLst )) {
125
- /** @var SimpleXMLElement $gradient */
126
126
foreach ($ possibleNoFill ->gradFill ->gsLst ->gs as $ gradient ) {
127
+ $ gradient = Xlsx::testSimpleXml ($ gradient );
127
128
/** @var float */
128
129
$ pos = self ::getAttribute ($ gradient , 'pos ' , 'float ' );
129
130
$ gradientArray [] = [
@@ -348,6 +349,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
348
349
$ legendLayout = null ;
349
350
$ legendOverlay = false ;
350
351
foreach ($ chartDetails as $ chartDetailKey => $ chartDetail ) {
352
+ $ chartDetail = Xlsx::testSimpleXml ($ chartDetail );
351
353
switch ($ chartDetailKey ) {
352
354
case 'legendPos ' :
353
355
$ legendPos = self ::getAttribute ($ chartDetail , 'val ' , 'string ' );
@@ -399,11 +401,13 @@ private function chartTitle(SimpleXMLElement $titleDetails): Title
399
401
$ caption = [];
400
402
$ titleLayout = null ;
401
403
foreach ($ titleDetails as $ titleDetailKey => $ chartDetail ) {
404
+ $ chartDetail = Xlsx::testSimpleXml ($ chartDetail );
402
405
switch ($ titleDetailKey ) {
403
406
case 'tx ' :
404
407
if (isset ($ chartDetail ->rich )) {
405
408
$ titleDetails = $ chartDetail ->rich ->children ($ this ->aNamespace );
406
409
foreach ($ titleDetails as $ titleKey => $ titleDetail ) {
410
+ $ titleDetail = Xlsx::testSimpleXml ($ titleDetail );
407
411
switch ($ titleKey ) {
408
412
case 'p ' :
409
413
$ titleDetailPart = $ titleDetail ->children ($ this ->aNamespace );
@@ -440,6 +444,7 @@ private function chartLayoutDetails(SimpleXMLElement $chartDetail): ?Layout
440
444
}
441
445
$ layout = [];
442
446
foreach ($ details as $ detailKey => $ detail ) {
447
+ $ detail = Xlsx::testSimpleXml ($ detail );
443
448
$ layout [$ detailKey ] = self ::getAttribute ($ detail , 'val ' , 'string ' );
444
449
}
445
450
@@ -472,8 +477,8 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType
472
477
$ lineStyle = null ;
473
478
$ labelLayout = null ;
474
479
$ trendLines = [];
475
- /** @var SimpleXMLElement $seriesDetail */
476
480
foreach ($ seriesDetails as $ seriesKey => $ seriesDetail ) {
481
+ $ seriesDetail = Xlsx::testSimpleXml ($ seriesDetail );
477
482
switch ($ seriesKey ) {
478
483
case 'idx ' :
479
484
$ seriesIndex = self ::getAttribute ($ seriesDetail , 'val ' , 'integer ' );
@@ -786,6 +791,7 @@ private function chartDataSeriesValues(SimpleXMLElement $seriesValueSet, string
786
791
$ pointCount = 0 ;
787
792
788
793
foreach ($ seriesValueSet as $ seriesValueIdx => $ seriesValue ) {
794
+ $ seriesValue = Xlsx::testSimpleXml ($ seriesValue );
789
795
switch ($ seriesValueIdx ) {
790
796
case 'ptCount ' :
791
797
$ pointCount = self ::getAttribute ($ seriesValue , 'val ' , 'integer ' );
@@ -858,7 +864,6 @@ private function chartDataSeriesValuesMultiLevel(SimpleXMLElement $seriesValueSe
858
864
private function parseRichText (SimpleXMLElement $ titleDetailPart ): RichText
859
865
{
860
866
$ value = new RichText ();
861
- $ objText = null ;
862
867
$ defaultFontSize = null ;
863
868
$ defaultBold = null ;
864
869
$ defaultItalic = null ;
0 commit comments