| @@ -98,8 +98,28 @@ | ||
| 98 | 98 | private ?Font $labelFont = null; |
| 99 | 99 | |
| 100 | 100 | private ?Properties $labelEffects = null; |
| 101 | 101 | |
| 102 | + /** @var array{ | |
| 103 | + * vertOverflow?: string, | |
| 104 | + * horzOverflow?: string, | |
| 105 | + * wrap?: string, | |
| 106 | + * lIns?: numeric-string, | |
| 107 | + * tIns?: numeric-string, | |
| 108 | + * rIns?: numeric-string, | |
| 109 | + * bIns?: numeric-string, | |
| 110 | + * anchor?: string, | |
| 111 | + * } | |
| 112 | + */ | |
| 113 | + private array $bodyPr = [ | |
| 114 | + 'wrap' => 'square', | |
| 115 | + 'lIns' => '38100', | |
| 116 | + 'tIns' => '19050', | |
| 117 | + 'rIns' => '38100', | |
| 118 | + 'bIns' => '19050', | |
| 119 | + 'anchor' => 'ctr', | |
| 120 | + ]; | |
| 121 | + | |
| 102 | 122 | /** |
| 103 | 123 | * Create a new Layout. |
| 104 | 124 | * |
| 105 | 125 | * @param array<mixed> $layout |
| @@ -105,9 +125,24 @@ | ||
| 105 | 125 | * @param array<mixed> $layout |
| 106 | 126 | */ |
| 107 | 127 | public function __construct(array $layout = []) |
| 108 | 128 | { |
| 109 | - /** @var array{layoutTarget?: string, xMode?: string, yMode?: string, x?: float, y?: float, w?:float, h?:float, dLblPos?: string, labelFont?: ?mixed, labelFontColor?: ?mixed, labelEffects?: ?mixed, numFmtCode?: string} $layout */ | |
| 129 | + /** @var array{ | |
| 130 | + * layoutTarget?: string, | |
| 131 | + * xMode?: string, | |
| 132 | + * yMode?: string, | |
| 133 | + * x?: float, | |
| 134 | + * y?: float, | |
| 135 | + * w?:float, | |
| 136 | + * h?:float, | |
| 137 | + * dLblPos?: string, | |
| 138 | + * labelFont?: ?mixed, | |
| 139 | + * labelFontColor?: ?mixed, | |
| 140 | + * labelEffects?: ?mixed, | |
| 141 | + * numFmtCode?: string, | |
| 142 | + * bodyPr?: mixed, | |
| 143 | + * } $layout | |
| 144 | + */ | |
| 110 | 145 | if (isset($layout['layoutTarget'])) { |
| 111 | 146 | $this->layoutTarget = $layout['layoutTarget']; |
| 112 | 147 | } |
| 113 | 148 | if (isset($layout['xMode'])) { |
| @@ -155,8 +190,12 @@ | ||
| 155 | 190 | $labelEffects = $layout['labelEffects'] ?? null; |
| 156 | 191 | if ($labelEffects instanceof Properties) { |
| 157 | 192 | $this->labelEffects = $labelEffects; |
| 158 | 193 | } |
| 194 | + $bodyPr = $layout['bodyPr'] ?? null; | |
| 195 | + if (is_array($bodyPr)) { | |
| 196 | + $this->setBodyPr($bodyPr); | |
| 197 | + } | |
| 159 | 198 | } |
| 160 | 199 | |
| 161 | 200 | /** @param mixed[] $layout */ |
| 162 | 201 | private function initBoolean(array $layout, string $name): void |
| @@ -235,9 +274,9 @@ | ||
| 235 | 274 | } |
| 236 | 275 | |
| 237 | 276 | /** |
| 238 | 277 | * Get X-Position. |
| 239 | - * @return float|int|null | |
| 278 | + * @return null|float|int | |
| 240 | 279 | */ |
| 241 | 280 | public function getXPosition() |
| 242 | 281 | { |
| 243 | 282 | return $this->xPos; |
| @@ -469,13 +508,9 @@ | ||
| 469 | 508 | } |
| 470 | 509 | |
| 471 | 510 | public function getLabelFontColor(): ?ChartColor |
| 472 | 511 | { |
| 473 | - if ($this->labelFont === null) { | |
| 474 | - return null; | |
| 475 | - } | |
| 476 | - | |
| 477 | - return $this->labelFont->getChartColor(); | |
| 512 | + return ($nullsafeVariable1 = $this->labelFont) ? $nullsafeVariable1->getChartColor() : null; | |
| 478 | 513 | } |
| 479 | 514 | |
| 480 | 515 | public function setLabelFontColor(?ChartColor $chartColor): self |
| 481 | 516 | { |
| @@ -519,8 +554,47 @@ | ||
| 519 | 554 | |
| 520 | 555 | public function setNumFmtLinked(bool $numFmtLinked): self |
| 521 | 556 | { |
| 522 | 557 | $this->numFmtLinked = $numFmtLinked; |
| 558 | + | |
| 559 | + return $this; | |
| 560 | + } | |
| 561 | + | |
| 562 | + /** @return array{ | |
| 563 | + * vertOverflow?: string, | |
| 564 | + * horzOverflow?: string, | |
| 565 | + * wrap?: string, | |
| 566 | + * lIns?: numeric-string, | |
| 567 | + * tIns?: numeric-string, | |
| 568 | + * rIns?: numeric-string, | |
| 569 | + * bIns?: numeric-string, | |
| 570 | + * anchor?: string, | |
| 571 | + * } | |
| 572 | + */ | |
| 573 | + public function getBodyPr(): array | |
| 574 | + { | |
| 575 | + return $this->bodyPr; | |
| 576 | + } | |
| 577 | + | |
| 578 | + /** | |
| 579 | + * @param mixed $bodyPr expect array matching $this->bodyPr | |
| 580 | + */ | |
| 581 | + public function setBodyPr($bodyPr): self | |
| 582 | + { | |
| 583 | + if (is_array($bodyPr)) { | |
| 584 | + foreach (['vertOverflow', 'horzOverflow', 'wrap', 'anchor'] as $key) { | |
| 585 | + $value = $bodyPr[$key] ?? null; | |
| 586 | + if (is_string($value)) { | |
| 587 | + $this->bodyPr[$key] = "$value"; | |
| 588 | + } | |
| 589 | + } | |
| 590 | + foreach (['lIns', 'tIns', 'rIns', 'bIns'] as $key) { | |
| 591 | + $value = $bodyPr[$key] ?? null; | |
| 592 | + if (is_string($value) && is_numeric($value)) { | |
| 593 | + $this->bodyPr[$key] = "$value"; | |
| 594 | + } | |
| 595 | + } | |
| 596 | + } | |
| 523 | 597 | |
| 524 | 598 | return $this; |
| 525 | 599 | } |
| 526 | 600 | |