@@ -140,11 +140,59 @@ feature {NONE} -- JSON To Eiffel
140140 if attached {JSON_OBJECT } json_value (a_json , " iterativeCalculationSettings" ) as iterativeCalculationSettings then
141141 -- Result.set_iterative_calculation_settings (a_iterative_calculation_settings: [like iterative_calculation_settings] detachable EG_ITERATIVE_CALCULATION_SETTINGS)
142142 end
143- if attached {JSON_OBJECT } json_value (a_json , " spreadsheetTheme" ) as spreadsheetTheme then
144- -- Result.set_spreadsheet_theme (a_theme: [like spreadsheet_theme] detachable EG_SPREADSHEET_THEME )
143+ if attached {JSON_OBJECT } json_value (a_json , " spreadsheetTheme" ) as l_spreadsheet then
144+ Result .set_spreadsheet_theme (spreadsheet_theme ( l_spreadsheet ) )
145145 end
146146 end
147147
148+ spreadsheet_theme (a_json : JSON_VALUE ): EG_SPREADSHEET_THEME
149+ -- Create an object `EG_SPREADSHEET_THEME` from a json representation `a_json`.
150+ do
151+ create Result
152+ if attached string_value_from_json (a_json , " primaryFontFamily" ) as l_primary_font then
153+ Result .set_primary_font_family (l_primary_font )
154+ end
155+ if attached {JSON_ARRAY } json_value (a_json , " themeColors" ) as l_theme_colors then
156+ across l_theme_colors as ic loop
157+ Result .force_theme_color (theme_color_pair (ic .item ))
158+ end
159+ end
160+ end
161+
162+ theme_color_pair (a_json : JSON_VALUE ): EG_THEME_COLOR_PAIR
163+ local
164+ l_tc : EG_THEME_COLOR
165+ do
166+ create Result
167+ if attached string_value_from_json (a_json , " colorType" ) as l_color_type then
168+ create l_tc
169+ if l_color_type .is_case_insensitive_equal (" TEXT" ) then
170+ l_tc .set_text
171+ elseif l_color_type .is_case_insensitive_equal (" BACKGROUND" ) then
172+ l_tc .set_background
173+ elseif l_color_type .is_case_insensitive_equal (" ACCENT1" ) then
174+ l_tc .set_accent 1
175+ elseif l_color_type .is_case_insensitive_equal (" ACCENT2" ) then
176+ l_tc .set_accent 2
177+ elseif l_color_type .is_case_insensitive_equal (" ACCENT3" ) then
178+ l_tc .set_accent 3
179+ elseif l_color_type .is_case_insensitive_equal (" ACCENT4" ) then
180+ l_tc .set_accent 4
181+ elseif l_color_type .is_case_insensitive_equal (" ACCENT5" ) then
182+ l_tc .set_accent 5
183+ elseif l_color_type .is_case_insensitive_equal (" ACCENT6" ) then
184+ l_tc .set_accent 6
185+ elseif l_color_type .is_case_insensitive_equal (" LINK" ) then
186+ l_tc .set_link
187+ end
188+ Result .set_color_type (l_tc )
189+ end
190+ if attached {JSON_OBJECT } json_value (a_json , " color" ) as l_color then
191+ Result .set_color (eg_color_style (l_color ))
192+ end
193+
194+ end
195+
148196 cell_format (a_json : JSON_OBJECT ): EG_CELL_FORMAT
149197 -- Create an object `EG_CELL_FORMAT` from a json representation `a_json`
150198 local
@@ -251,24 +299,16 @@ feature {NONE} -- JSON To Eiffel
251299 -- Create an object `EG_COLOR` from a json rerpesentation `a_json`.
252300 do
253301 create Result
254- if attached integer_value_from_json (a_json , " red" ) as l_val then
255- Result .set_red (l_val )
256- elseif attached real_value_from_json (a_json , " red" ) as l_val then
302+ if attached real_value_from_json (a_json , " red" ) as l_val then
257303 Result .set_red (l_val )
258304 end
259- if attached integer_value_from_json (a_json , " green" ) as l_val then
260- Result .set_green (l_val )
261- elseif attached real_value_from_json (a_json , " green" ) as l_val then
305+ if attached real_value_from_json (a_json , " green" ) as l_val then
262306 Result .set_green (l_val )
263307 end
264- if attached integer_value_from_json (a_json , " blue" ) as l_val then
265- Result .set_blue (l_val )
266- elseif attached real_value_from_json (a_json , " blue" ) as l_val then
308+ if attached real_value_from_json (a_json , " blue" ) as l_val then
267309 Result .set_blue (l_val )
268310 end
269- if attached integer_value_from_json (a_json , " alpha" ) as l_val then
270- Result .set_alpha (l_val )
271- elseif attached real_value_from_json (a_json , " alpha" ) as l_val then
311+ if attached real_value_from_json (a_json , " alpha" ) as l_val then
272312 Result .set_alpha (l_val )
273313 end
274314 end
0 commit comments