@@ -86,6 +86,8 @@ class Font extends Supervisor
86
86
*/
87
87
protected Color $ color ;
88
88
89
+ protected bool $ autoColor = false ;
90
+
89
91
public ?int $ colorIndex = null ;
90
92
91
93
protected string $ scheme = '' ;
@@ -175,7 +177,7 @@ public function getStyleArray(array $array): array
175
177
* );
176
178
* </code>
177
179
*
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
179
181
*
180
182
* @return $this
181
183
*/
@@ -194,7 +196,9 @@ public function applyFromArray(array $styleArray): static
194
196
$ this ->setEastAsian ($ styleArray ['eastAsian ' ]);
195
197
}
196
198
if (isset ($ styleArray ['complexScript ' ])) {
197
- $ this ->setComplexScript ($ styleArray ['complexScript ' ]);
199
+ $ this ->setComplexScript (
200
+ $ styleArray ['complexScript ' ]
201
+ );
198
202
}
199
203
if (isset ($ styleArray ['bold ' ])) {
200
204
$ this ->setBold ($ styleArray ['bold ' ]);
@@ -212,7 +216,9 @@ public function applyFromArray(array $styleArray): static
212
216
$ this ->setUnderline ($ styleArray ['underline ' ]);
213
217
}
214
218
if (isset ($ styleArray ['strikethrough ' ])) {
215
- $ this ->setStrikethrough ($ styleArray ['strikethrough ' ]);
219
+ $ this ->setStrikethrough (
220
+ $ styleArray ['strikethrough ' ]
221
+ );
216
222
}
217
223
if (isset ($ styleArray ['color ' ])) {
218
224
/** @var array{rgb?: string, argb?: string, theme?: int} */
@@ -232,6 +238,9 @@ public function applyFromArray(array $styleArray): static
232
238
if (isset ($ styleArray ['cap ' ])) {
233
239
$ this ->setCap ($ styleArray ['cap ' ]);
234
240
}
241
+ if (isset ($ styleArray ['autoColor ' ])) {
242
+ $ this ->setAutoColor ($ styleArray ['autoColor ' ]);
243
+ }
235
244
}
236
245
237
246
return $ this ;
@@ -745,6 +754,7 @@ public function getHashCode(): string
745
754
. ($ this ->subscript ? 't ' : 'f ' )
746
755
. $ this ->underline
747
756
. ($ this ->strikethrough ? 't ' : 'f ' )
757
+ . ($ this ->autoColor ? 't ' : 'f ' )
748
758
. $ this ->color ->getHashCode ()
749
759
. $ this ->scheme
750
760
. implode (
@@ -786,6 +796,7 @@ protected function exportArray1(): array
786
796
$ this ->exportArray2 ($ exportedArray , 'superscript ' , $ this ->getSuperscript ());
787
797
$ this ->exportArray2 ($ exportedArray , 'underline ' , $ this ->getUnderline ());
788
798
$ this ->exportArray2 ($ exportedArray , 'underlineColor ' , $ this ->getUnderlineColor ());
799
+ $ this ->exportArray2 ($ exportedArray , 'autoColor ' , $ this ->getAutoColor ());
789
800
790
801
return $ exportedArray ;
791
802
}
@@ -840,6 +851,29 @@ public function setHyperlinkTheme(): self
840
851
return $ this ;
841
852
}
842
853
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
+
843
877
/**
844
878
* Implement PHP __clone to create a deep clone, not just a shallow copy.
845
879
*/
0 commit comments