@@ -27,129 +27,119 @@ note
2727class
2828 EG_SPREADSHEET_PROPERTIES
2929
30- inherit
31- ANY
32- redefine
33- default_create
34- end
35- create
36- default_create
37-
38- feature {NONE } -- Initialization
39-
40- default_create
41- do
42- create title .make_empty
43- create locale .make_empty
44- create auto_recalc
45- create time_zone .make_empty
46- create default_format
47- create spreadsheet_theme
48- create iterative_calculation_settings
49- end
5030
5131feature -- Access
5232
53- title : STRING
33+ title : detachable STRING
5434 -- The title of the spreadsheet.
5535
56- locale : STRING
36+ locale : detachable STRING
5737 -- The locale of the spreadsheet in one of the following formats:
5838 -- an ISO 639-1 language code such as en
5939 -- an ISO 639-2 language code such as fil, if no 639-1 code exists
6040 -- a combination of the ISO language code and country code, such as en_US
6141 -- Note: when updating this field, not all locales/languages are supported.
6242
63- auto_recalc : EG_RECALCULATION_INTERVAL
43+ auto_recalc : detachable EG_RECALCULATION_INTERVAL
6444 -- The amount of time to wait before volatile functions are recalculated.
6545
66- time_zone : STRING
46+ time_zone : detachable STRING
6747 -- The time zone of the spreadsheet, in CLDR format such as America/New_York.
6848 -- If the time zone isn't recognized, this may be a custom time zone such as GMT-07:00.
6949
70- default_format : EG_CELL_FORMAT
50+ default_format : detachable EG_CELL_FORMAT
7151 -- The default format of all cells in the spreadsheet.
7252 -- CellData.effectiveFormat will not be set if the cell's format is equal to this default format. This field is read-only.
7353
7454 iterative_calculation_settings : detachable EG_ITERATIVE_CALCULATION_SETTINGS
7555 -- Determines whether and how circular references are resolved with iterative calculation.
7656 -- Absence of this field means that circular references result in calculation errors.
7757
78- spreadsheet_theme : EG_SPREADSHEET_THEME
58+ spreadsheet_theme : detachable EG_SPREADSHEET_THEME
7959 -- theme applied to the spreadsheet.
8060
8161feature -- Element Change
8262
83- set_title (a_title : STRING )
63+ set_title (a_title : like title )
8464 -- Set `title` with `a_title`.
8565 do
8666 title := a_title
8767 ensure
8868 title_set : title = a_title
8969 end
9070
91- set_locale (a_locale : STRING )
71+ set_locale (a_locale : like locale )
9272 -- Set `locale` with `a_locale`.
9373 do
9474 locale := a_locale
9575 ensure
9676 locale_set : locale = a_locale
9777 end
9878
99- set_time_zone (a_time_zone : STRING )
79+ set_time_zone (a_time_zone : like time_zone )
10080 -- Set `time_zone` with `a_time_zone`
10181 do
10282 time_zone := a_time_zone
83+ ensure
84+ time_zone_set : time_zone = a_time_zone
10385 end
10486
105- set_default_format (a_format : EG_CELL_FORMAT )
87+ set_default_format (a_format : like default_format )
10688 -- Set `default_format` with `format`.
10789 do
10890 default_format := a_format
91+ ensure
92+ default_format_set : default_format = a_format
10993 end
11094
11195 set_iterative_calculation_settings (a_iterative_calculation_settings : like iterative_calculation_settings )
11296 -- Set `iterative_calculation_settings` with `a_iterative_calculation_settings`.
11397 do
11498 iterative_calculation_settings := a_iterative_calculation_settings
99+ ensure
100+ iterative_calculation_settings_set : iterative_calculation_settings = a_iterative_calculation_settings
115101 end
116102
117- set_spreadsheet_theme (a_theme : EG_SPREADSHEET_THEME )
103+ set_spreadsheet_theme (a_theme : like spreadsheet_theme )
118104 do
119105 spreadsheet_theme := a_theme
106+ ensure
107+ spreadsheet_theme_set : spreadsheet_theme = a_theme
108+ end
109+
110+ set_auto_recalc (a_auto_recalc : like auto_recalc )
111+ -- Set auto_recalc with `a_auto_recalc`.
112+ do
113+ auto_recalc := a_auto_recalc
114+ ensure
115+ auto_recalc_set : auto_recalc = a_auto_recalc
120116 end
121117
118+
122119feature -- Eiffel to JSON
123120
124121 to_json : JSON_OBJECT
125122 -- Json representation of the current object
126- -- {
127- -- "title": string,
128- -- "locale": string,
129- -- "autoRecalc": enum (RecalculationInterval),
130- -- "timeZone": string,
131- -- "defaultFormat": {
132- -- object (CellFormat)
133- -- },
134- -- "iterativeCalculationSettings": {
135- -- object (IterativeCalculationSettings)
136- -- },
137- -- "spreadsheetTheme": {
138- -- object (SpreadsheetTheme)
139- -- }
140- -- }
141123 do
142- create Result .make_with_capacity (5 )
143- Result .put (create {JSON_STRING }.make_from_string (title ), " title" )
144- Result .put (create {JSON_STRING }.make_from_string (locale ), " locale" )
145- Result .put (auto_recalc .to_json , " autoRecalc" )
146- Result .put (create {JSON_STRING }.make_from_string (time_zone ), " timeZone" )
147- Result .put (default_format .to_json , " defaultFormat" )
124+ create Result .make_empty
125+ if attached title as l_title then
126+ Result .put (create {JSON_STRING }.make_from_string (l_title ), " title" )
127+ end
128+ if attached locale as l_locale then
129+ Result .put (create {JSON_STRING }.make_from_string (l_locale ), " locale" )
130+ end
131+ if attached auto_recalc as l_auto_recalc then
132+ Result .put (l_auto_recalc .to_json , " autoRecalc" )
133+ end
134+ if attached time_zone as l_time_zone then
135+ Result .put (create {JSON_STRING }.make_from_string (l_time_zone ), " timeZone" )
136+ end
148137 if attached iterative_calculation_settings as l_ics then
149- Result .put (default_format .to_json , " iterativeCalculationSettings" )
138+ Result .put (l_ics .to_json , " iterativeCalculationSettings" )
139+ end
140+ if attached spreadsheet_theme as l_sp then
141+ Result .put (l_sp .to_json , " spreadsheetTheme" )
150142 end
151- Result .put (spreadsheet_theme .to_json , " spreadsheetTheme" )
152-
153143 end
154144
155145end
0 commit comments