@@ -80,6 +80,8 @@ feature {NONE} -- JSON To Eiffel
8080
8181 eg_spreadsheet_properties (a_json : JSON_VALUE ): EG_SPREADSHEET_PROPERTIES
8282 --
83+ local
84+ l_cell_format : EG_CELL_FORMAT
8385 do
8486 create Result
8587 if attached {JSON_OBJECT } json_value (a_json , " properties" ) as l_properties then
@@ -92,21 +94,167 @@ feature {NONE} -- JSON To Eiffel
9294 if attached string_value_from_json (l_properties , " autoRecalc" ) as l_auto_recalc then
9395 if l_auto_recalc .is_case_insensitive_equal (" ON_CHANGE" ) then
9496 Result .auto_recalc .set_on_change
95- end
96- if l_auto_recalc .is_case_insensitive_equal (" MINUTE" ) then
97+ elseif l_auto_recalc .is_case_insensitive_equal (" MINUTE" ) then
9798 Result .auto_recalc .set_minute
98- end
99- if l_auto_recalc .is_case_insensitive_equal (" HOUR" ) then
99+ elseif l_auto_recalc .is_case_insensitive_equal (" HOUR" ) then
100100 Result .auto_recalc .set_hour
101101 end
102102 end
103103 if attached string_value_from_json (l_properties , " timeZone" ) as l_time_zone then
104104 Result .set_time_zone (l_time_zone )
105105 end
106+ if attached {JSON_OBJECT } json_value (l_properties , " defaultFormat" ) as l_default_format then
107+ end
108+ end
109+ end
110+
111+
112+ default_format (a_json : JSON_OBJECT ): EG_CELL_FORMAT
113+ do
114+ create Result
115+
116+ if attached {JSON_OBJECT } json_value (a_json , " backgroundColor" ) as l_background_color then
117+ Result .set_background_color (eg_color (l_background_color ))
118+ end
119+ if attached {JSON_OBJECT } json_value (a_json , " padding" ) as l_padding then
120+ Result .set_padding (padding (l_padding ))
121+ end
122+ if attached string_value_from_json (a_json , " verticalAlignment" ) as l_alignment then
123+ if l_alignment .is_case_insensitive_equal (" BOTTOM" ) then
124+ Result .vertical_alignment .set_bottom
125+ elseif l_alignment .is_case_insensitive_equal (" MIDDLE" ) then
126+ Result .vertical_alignment .set_middle
127+ elseif l_alignment .is_case_insensitive_equal (" TOP" ) then
128+ Result .vertical_alignment .set_top
129+ end
130+ end
131+ if attached string_value_from_json (a_json , " wrapStrategy" ) as l_wrap_strategy then
132+ if l_wrap_strategy .is_case_insensitive_equal (" OVERFLOW_CELL" ) then
133+ Result .wrap_strategy .set_overflow_cell
134+ end
135+ if l_wrap_strategy .is_case_insensitive_equal (" LEGACY_WRAP" ) then
136+ Result .wrap_strategy .set_legacy_wrap
137+ elseif l_wrap_strategy .is_case_insensitive_equal (" CLIP" ) then
138+ Result .wrap_strategy .set_clip
139+ elseif l_wrap_strategy .is_case_insensitive_equal (" WRAP" ) then
140+ Result .wrap_strategy .set_wrap
141+ end
142+ end
143+ if attached {JSON_OBJECT } json_value (a_json , " textFormat" ) as l_text_format then
144+ Result .set_text_format (text_format (l_text_format ))
145+ end
146+ if attached {JSON_OBJECT } json_value (a_json , " backgroundColorStyle" ) as l_background_color_style then
147+ Result .set_background_color_style (eg_color_style (l_background_color_style ))
148+ end
149+ end
150+
151+ eg_color (a_json : JSON_OBJECT ): EG_COLOR
152+ do
153+ create Result
154+ if attached integer_value_from_json (a_json , " red" ) as l_val then
155+ Result .set_red (l_val )
156+ elseif attached real_value_from_json (a_json , " red" ) as l_val then
157+ Result .set_red (l_val )
158+ end
159+ if attached integer_value_from_json (a_json , " green" ) as l_val then
160+ Result .set_green (l_val )
161+ elseif attached real_value_from_json (a_json , " green" ) as l_val then
162+ Result .set_green (l_val )
163+ end
164+ if attached integer_value_from_json (a_json , " blue" ) as l_val then
165+ Result .set_blue (l_val )
166+ elseif attached real_value_from_json (a_json , " blue" ) as l_val then
167+ Result .set_blue (l_val )
168+ end
169+ if attached integer_value_from_json (a_json , " alpha" ) as l_val then
170+ Result .set_alpha (l_val )
171+ elseif attached real_value_from_json (a_json , " alpha" ) as l_val then
172+ Result .set_alpha (l_val )
173+ end
174+ end
175+
176+ padding (a_json : JSON_OBJECT ): EG_PADDING
177+ do
178+ create Result
179+ if attached integer_value_from_json (a_json , " top" ) as l_val then
180+ Result .set_top (l_val )
181+ end
182+ if attached integer_value_from_json (a_json , " right" ) as l_val then
183+ Result .set_right (l_val )
184+ end
185+ if attached integer_value_from_json (a_json , " bottom" ) as l_val then
186+ Result .set_bottom (l_val )
187+ end
188+ if attached integer_value_from_json (a_json , " left" ) as l_val then
189+ Result .set_left (l_val )
190+ end
191+ end
192+
193+ text_format (a_json : JSON_OBJECT ): EG_TEXT_FORMAT
194+ do
195+ create Result
196+ if attached {JSON_OBJECT } json_value (a_json , " foregroundColor" ) as l_foreground_color then
197+ Result .set_foreground_color (eg_color (l_foreground_color ))
198+ end
199+ if attached {JSON_OBJECT } json_value (a_json , " foregroundColorStyle" ) as l_foreground_color_style then
200+ Result .set_foreground_color_style (eg_color_style (l_foreground_color_style ))
201+ end
202+ if attached string_value_from_json (a_json , " fontFamily" ) as l_font_family then
203+ Result .set_font_family (l_font_family )
204+ end
205+ if attached integer_value_from_json (a_json , " fontSize" ) as l_font_size then
206+ Result .set_font_size (l_font_size )
207+ end
208+ if attached boolean_value_from_json (a_json , " bold" ) as l_bold then
209+ Result .set_bold (l_bold )
210+ end
211+ if attached boolean_value_from_json (a_json , " italic" ) as l_italic then
212+ Result .set_italic (l_italic )
213+ end
214+ if attached boolean_value_from_json (a_json , " strikethrough" ) as l_strikethrough then
215+ Result .set_strikethrough (l_strikethrough )
216+ end
217+ if attached boolean_value_from_json (a_json , " underline" ) as l_underline then
218+ Result .set_strikethrough (l_underline )
219+ end
220+ end
221+
222+ eg_color_style (a_json : JSON_OBJECT ): EG_COLOR_STYLE
223+ local
224+ l_tc : EG_THEME_COLOR
225+ do
226+ create Result
227+ if attached {JSON_OBJECT } json_value (a_json , " rgbColor" ) as l_rgbcolor then
228+ Result .set_rgb (eg_color (l_rgbcolor ))
229+ elseif
230+ attached string_value_from_json (a_json , " themeColor" ) as l_theme_color
231+ then
232+ create l_tc
233+ if l_theme_color .is_case_insensitive_equal (" TEXT" ) then
234+ l_tc .set_text
235+ elseif l_theme_color .is_case_insensitive_equal (" BACKGROUND" ) then
236+ l_tc .set_background
237+ elseif l_theme_color .is_case_insensitive_equal (" ACCENT1" ) then
238+ l_tc .set_accent 1
239+ elseif l_theme_color .is_case_insensitive_equal (" ACCENT2" ) then
240+ l_tc .set_accent 2
241+ elseif l_theme_color .is_case_insensitive_equal (" ACCENT3" ) then
242+ l_tc .set_accent 3
243+ elseif l_theme_color .is_case_insensitive_equal (" ACCENT4" ) then
244+ l_tc .set_accent 4
245+ elseif l_theme_color .is_case_insensitive_equal (" ACCENT5" ) then
246+ l_tc .set_accent 5
247+ elseif l_theme_color .is_case_insensitive_equal (" ACCENT6" ) then
248+ l_tc .set_accent 6
249+ elseif l_theme_color .is_case_insensitive_equal (" LINK" ) then
250+ l_tc .set_link
251+ end
252+ Result .set_theme_color (l_tc )
106253 end
107254 end
108255
109256
257+
110258feature {NONE } -- Implementation
111259
112260 eg_sheets_api : EG_SHEETS_API
0 commit comments