@@ -86,6 +86,8 @@ class Font extends Supervisor
8686 */
8787 protected Color $ color ;
8888
89+ protected bool $ autoColor = false ;
90+
8991 public ?int $ colorIndex = null ;
9092
9193 protected string $ scheme = '' ;
@@ -175,7 +177,7 @@ public function getStyleArray(array $array): array
175177 * );
176178 * </code>
177179 *
178- * @param array{name?: string, latin?: string, eastAsian?: string, complexScript?: string, bold?: bool, italic?: bool, superscript?: bool, subscript?: bool, underline?: bool|string, strikethrough?: bool, color?: string[], size?: ?int, chartColor?: ChartColor, scheme?: string, cap?: string} $styleArray Array containing style information
180+ * @param array{name?: string, latin?: string, eastAsian?: string, complexScript?: string, bold?: bool, italic?: bool, superscript?: bool, subscript?: bool, underline?: bool|string, strikethrough?: bool, color?: string[], size?: ?int, chartColor?: ChartColor, scheme?: string, cap?: string, autoColor?: bool } $styleArray Array containing style information
179181 *
180182 * @return $this
181183 */
@@ -194,7 +196,9 @@ public function applyFromArray(array $styleArray): static
194196 $ this ->setEastAsian ($ styleArray ['eastAsian ' ]);
195197 }
196198 if (isset ($ styleArray ['complexScript ' ])) {
197- $ this ->setComplexScript ($ styleArray ['complexScript ' ]);
199+ $ this ->setComplexScript (
200+ $ styleArray ['complexScript ' ]
201+ );
198202 }
199203 if (isset ($ styleArray ['bold ' ])) {
200204 $ this ->setBold ($ styleArray ['bold ' ]);
@@ -212,7 +216,9 @@ public function applyFromArray(array $styleArray): static
212216 $ this ->setUnderline ($ styleArray ['underline ' ]);
213217 }
214218 if (isset ($ styleArray ['strikethrough ' ])) {
215- $ this ->setStrikethrough ($ styleArray ['strikethrough ' ]);
219+ $ this ->setStrikethrough (
220+ $ styleArray ['strikethrough ' ]
221+ );
216222 }
217223 if (isset ($ styleArray ['color ' ])) {
218224 /** @var array{rgb?: string, argb?: string, theme?: int} */
@@ -232,6 +238,9 @@ public function applyFromArray(array $styleArray): static
232238 if (isset ($ styleArray ['cap ' ])) {
233239 $ this ->setCap ($ styleArray ['cap ' ]);
234240 }
241+ if (isset ($ styleArray ['autoColor ' ])) {
242+ $ this ->setAutoColor ($ styleArray ['autoColor ' ]);
243+ }
235244 }
236245
237246 return $ this ;
@@ -745,6 +754,7 @@ public function getHashCode(): string
745754 . ($ this ->subscript ? 't ' : 'f ' )
746755 . $ this ->underline
747756 . ($ this ->strikethrough ? 't ' : 'f ' )
757+ . ($ this ->autoColor ? 't ' : 'f ' )
748758 . $ this ->color ->getHashCode ()
749759 . $ this ->scheme
750760 . implode (
@@ -786,6 +796,7 @@ protected function exportArray1(): array
786796 $ this ->exportArray2 ($ exportedArray , 'superscript ' , $ this ->getSuperscript ());
787797 $ this ->exportArray2 ($ exportedArray , 'underline ' , $ this ->getUnderline ());
788798 $ this ->exportArray2 ($ exportedArray , 'underlineColor ' , $ this ->getUnderlineColor ());
799+ $ this ->exportArray2 ($ exportedArray , 'autoColor ' , $ this ->getAutoColor ());
789800
790801 return $ exportedArray ;
791802 }
@@ -840,6 +851,29 @@ public function setHyperlinkTheme(): self
840851 return $ this ;
841852 }
842853
854+ public function setAutoColor (bool $ autoColor ): self
855+ {
856+ if ($ this ->isSupervisor ) {
857+ $ styleArray = $ this ->getStyleArray (['autoColor ' => $ autoColor ]);
858+ $ this ->getActiveSheet ()
859+ ->getStyle ($ this ->getSelectedCells ())
860+ ->applyFromArray ($ styleArray );
861+ } else {
862+ $ this ->autoColor = $ autoColor ;
863+ }
864+
865+ return $ this ;
866+ }
867+
868+ public function getAutoColor (): bool
869+ {
870+ if ($ this ->isSupervisor ) {
871+ return $ this ->getSharedComponent ()->getAutoColor ();
872+ }
873+
874+ return $ this ->autoColor ;
875+ }
876+
843877 /**
844878 * Implement PHP __clone to create a deep clone, not just a shallow copy.
845879 */
0 commit comments