xlsxrb 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -0
  3. data/README.md +34 -11
  4. data/lib/ruby_lsp/xlsxrb/completion_listener.rb +410 -80
  5. data/lib/xlsxrb/chart_builder.rb +251 -386
  6. data/lib/xlsxrb/dsl_helpers.rb +120 -67
  7. data/lib/xlsxrb/elements/cell.rb +37 -157
  8. data/lib/xlsxrb/elements/column.rb +11 -19
  9. data/lib/xlsxrb/elements/coordinate_access.rb +15 -86
  10. data/lib/xlsxrb/elements/image.rb +5 -72
  11. data/lib/xlsxrb/elements/metadata.rb +463 -817
  12. data/lib/xlsxrb/elements/row.rb +27 -145
  13. data/lib/xlsxrb/elements/styles.rb +30 -88
  14. data/lib/xlsxrb/elements/types.rb +6 -99
  15. data/lib/xlsxrb/elements/workbook.rb +19 -126
  16. data/lib/xlsxrb/elements/worksheet.rb +43 -314
  17. data/lib/xlsxrb/ooxml/reader/listeners/core_listeners.rb +4 -1
  18. data/lib/xlsxrb/ooxml/reader/listeners/drawing_listeners.rb +7 -7
  19. data/lib/xlsxrb/ooxml/reader/listeners/feature_listeners.rb +32 -17
  20. data/lib/xlsxrb/ooxml/reader.rb +49 -51
  21. data/lib/xlsxrb/ooxml/styles_parser.rb +26 -2
  22. data/lib/xlsxrb/ooxml/utils.rb +2 -2
  23. data/lib/xlsxrb/ooxml/workbook_parser.rb +0 -1
  24. data/lib/xlsxrb/ooxml/workbook_writer.rb +172 -93
  25. data/lib/xlsxrb/ooxml/worksheet_parser.rb +61 -29
  26. data/lib/xlsxrb/ooxml/worksheet_writer.rb +65 -47
  27. data/lib/xlsxrb/ooxml/writer/drawing_xml.rb +28 -11
  28. data/lib/xlsxrb/ooxml/writer/features_xml.rb +53 -14
  29. data/lib/xlsxrb/ooxml/writer/styles_xml.rb +1 -1
  30. data/lib/xlsxrb/ooxml/writer.rb +105 -41
  31. data/lib/xlsxrb/ooxml/xml_parser.rb +78 -5
  32. data/lib/xlsxrb/ooxml/zip_reader.rb +65 -15
  33. data/lib/xlsxrb/ooxml/zip_writer.rb +119 -30
  34. data/lib/xlsxrb/stream_row.rb +12 -116
  35. data/lib/xlsxrb/stream_sheet.rb +14 -261
  36. data/lib/xlsxrb/stream_writer.rb +623 -1476
  37. data/lib/xlsxrb/style_builder.rb +376 -593
  38. data/lib/xlsxrb/version.rb +1 -1
  39. data/lib/xlsxrb/workbook_builder.rb +192 -226
  40. data/lib/xlsxrb/worksheet_builder.rb +456 -1324
  41. data/lib/xlsxrb.rb +266 -1083
  42. data/sig/generated/xlsxrb/chart_builder.rbs +202 -205
  43. data/sig/generated/xlsxrb/dsl_helpers.rbs +64 -16
  44. data/sig/generated/xlsxrb/elements/cell.rbs +12 -76
  45. data/sig/generated/xlsxrb/elements/column.rbs +0 -7
  46. data/sig/generated/xlsxrb/elements/coordinate_access.rbs +5 -41
  47. data/sig/generated/xlsxrb/elements/image.rbs +3 -29
  48. data/sig/generated/xlsxrb/elements/metadata.rbs +138 -151
  49. data/sig/generated/xlsxrb/elements/row.rbs +10 -53
  50. data/sig/generated/xlsxrb/elements/styles.rbs +1 -39
  51. data/sig/generated/xlsxrb/elements/workbook.rbs +14 -78
  52. data/sig/generated/xlsxrb/elements/worksheet.rbs +5 -121
  53. data/sig/generated/xlsxrb/ooxml/reader/listeners/feature_listeners.rbs +0 -4
  54. data/sig/generated/xlsxrb/ooxml/reader.rbs +0 -3
  55. data/sig/generated/xlsxrb/ooxml/styles_parser.rbs +1 -1
  56. data/sig/generated/xlsxrb/ooxml/utils.rbs +3 -3
  57. data/sig/generated/xlsxrb/ooxml/workbook_writer.rbs +12 -0
  58. data/sig/generated/xlsxrb/ooxml/worksheet_parser.rbs +16 -0
  59. data/sig/generated/xlsxrb/ooxml/worksheet_writer.rbs +5 -3
  60. data/sig/generated/xlsxrb/ooxml/writer/features_xml.rbs +7 -0
  61. data/sig/generated/xlsxrb/ooxml/writer.rbs +20 -14
  62. data/sig/generated/xlsxrb/ooxml/xml_parser.rbs +70 -0
  63. data/sig/generated/xlsxrb/ooxml/zip_reader.rbs +22 -7
  64. data/sig/generated/xlsxrb/ooxml/zip_writer.rbs +26 -1
  65. data/sig/generated/xlsxrb/stream_row.rbs +7 -42
  66. data/sig/generated/xlsxrb/stream_sheet.rbs +1 -158
  67. data/sig/generated/xlsxrb/stream_writer.rbs +457 -976
  68. data/sig/generated/xlsxrb/style_builder.rbs +206 -242
  69. data/sig/generated/xlsxrb/workbook_builder.rbs +84 -132
  70. data/sig/generated/xlsxrb/worksheet_builder.rbs +309 -685
  71. data/sig/generated/xlsxrb.rbs +43 -190
  72. data/sig/rexml.rbs +8 -0
  73. metadata +3 -5
  74. data/lib/xlsxrb/utils.rb +0 -251
  75. data/sig/generated/xlsxrb/utils.rbs +0 -200
@@ -3,21 +3,74 @@
3
3
  # rbs_inline: enabled
4
4
 
5
5
  module Xlsxrb
6
+ # Immutable value objects that describe workbook content and metadata.
6
7
  module Elements
7
- # Shared mixin for metadata Data value objects providing Hash compatibility.
8
+ # Rejects keyword arguments that a value object does not have.
9
+ #
10
+ # Prepended to the singleton class of each value object, so Klass.new(**opts) raises
11
+ # ArgumentError for an unknown key instead of dropping it. A class can declare
12
+ # KEY_ALIASES, mapping old key names to the member they were renamed to: an alias is
13
+ # dropped when its member is also given (readers emit both), and otherwise raises with
14
+ # the new name.
15
+ #
16
+ # @api private
17
+ module StrictKeywords
18
+ #: (*untyped args, **untyped kwargs) -> untyped
19
+ def new(*args, **kwargs)
20
+ return super if kwargs.empty?
21
+
22
+ allowed = members
23
+ return super if kwargs.each_key.all? { |key| allowed.include?(key) }
24
+
25
+ super(*args, **StrictKeywords.normalize(self, kwargs))
26
+ end
27
+
28
+ # Removes alias keys whose member is also given; raises for any other unknown key.
29
+ #
30
+ # @param klass [Class] The value object class.
31
+ # @param kwargs [Hash{Symbol => Object}] Keyword arguments given to new.
32
+ # @return [Hash{Symbol => Object}]
33
+ # @raise [ArgumentError] for an unknown key or an alias given without its member.
34
+ #: (Class klass, Hash[Symbol, untyped] kwargs) -> Hash[Symbol, untyped]
35
+ def self.normalize(klass, kwargs)
36
+ params = klass.instance_method(:initialize).parameters
37
+ # Value objects with an options member collect other keys there through **extra.
38
+ return kwargs if params.any? { |type, _| type == :keyrest }
39
+
40
+ allowed = klass.members | params.filter_map { |type, name| name if %i[key keyreq].include?(type) }
41
+ aliases = klass.const_defined?(:KEY_ALIASES, false) ? klass.const_get(:KEY_ALIASES, false) : {}
42
+ result = kwargs.dup
43
+ kwargs.each_key do |key|
44
+ next if allowed.include?(key)
45
+
46
+ member = aliases[key]
47
+ if member && !kwargs[member].nil?
48
+ result.delete(key)
49
+ next
50
+ end
51
+
52
+ message = "unknown keyword: #{key.inspect} for #{klass.name}"
53
+ if member
54
+ message << "; use #{member.inspect}"
55
+ elsif defined?(DidYouMean::SpellChecker) && (suggestion = DidYouMean::SpellChecker.new(dictionary: allowed.map(&:to_s)).correct(key.to_s).first)
56
+ message << "; did you mean #{suggestion.to_sym.inspect}?"
57
+ end
58
+ raise ArgumentError, message
59
+ end
60
+ result
61
+ end
62
+ end
63
+
64
+ # Hyperlink is defined in types.rb, before this file, and does not include MetadataRecord.
65
+ Hyperlink.singleton_class.prepend(StrictKeywords)
66
+
67
+ # Shared mixin for metadata Data value objects.
8
68
  #
9
69
  # @api public
10
70
  module MetadataRecord
11
- # Accesses an attribute by Symbol or String key, supporting key aliases.
12
- #
13
- # @deprecated Hash-like access via {#[]} is deprecated and will be removed in 0.2.0; use method calls instead.
14
- # @param key [Symbol, String]
15
- # @return [Object, nil]
16
- # @api public
17
- #: (Symbol | String key) -> untyped
18
- def [](key)
19
- warn "[DEPRECATION] Hash access on #{self.class} (`#[]`) is deprecated and will be removed in 0.2.0; use method calls instead.", uplevel: 1
20
- _lookup_key(key)
71
+ #: (Module base) -> void
72
+ def self.included(base)
73
+ base.singleton_class.prepend(StrictKeywords)
21
74
  end
22
75
 
23
76
  # Returns whether all attributes are nil or empty.
@@ -37,8 +90,12 @@ module Xlsxrb
37
90
  def to_h
38
91
  res = super.compact.transform_values do |val|
39
92
  if val.is_a?(Array)
40
- val.map { |v| v.respond_to?(:to_h) && !v.is_a?(String) ? v.to_h : v }
41
- elsif val.respond_to?(:to_h) && !val.is_a?(String) && !val.is_a?(Hash)
93
+ # Nested Arrays, such as the [name, count] pairs of AppProperties#heading_pairs,
94
+ # respond to to_h but are not key-value pairs, so they stay as they are.
95
+ val.map { |v| v.respond_to?(:to_h) && !v.is_a?(String) && !v.is_a?(Array) ? v.to_h : v }
96
+ elsif val.respond_to?(:to_h) && !val.is_a?(String) && !val.is_a?(Hash) && !val.is_a?(RichText)
97
+ # RichText is Enumerable over its runs, so Enumerable#to_h would treat each run as a
98
+ # key-value pair. It stays a value object, which the writers accept as cell and comment text.
42
99
  val.to_h
43
100
  else
44
101
  val
@@ -51,158 +108,25 @@ module Xlsxrb
51
108
  res
52
109
  end
53
110
 
54
- # Checks whether a key is present with a non-nil value.
55
- #
56
- # @deprecated {#key?} is deprecated and will be removed in 0.2.0; check attribute presence directly.
57
- # @param key [Symbol, String]
58
- # @return [Boolean]
59
- # @api public
60
- #: (Symbol | String key) -> bool
61
- def key?(key)
62
- warn "[DEPRECATION] `#{self.class}#key?` is deprecated and will be removed in 0.2.0; check attribute presence directly.", uplevel: 1
63
- _has_key?(key)
64
- end
65
- alias has_key? key?
66
-
67
- # Digs into nested metadata by key path.
68
- #
69
- # @deprecated {#dig} is deprecated and will be removed in 0.2.0; use method chaining instead.
70
- # @param head [Symbol, String]
71
- # @param rest [Array<Symbol, String>]
72
- # @return [Object, nil]
73
- # @api public
74
- #: (Symbol | String head, *(Symbol | String) rest) -> untyped
75
- def dig(head, *rest)
76
- warn "[DEPRECATION] `#{self.class}#dig` is deprecated and will be removed in 0.2.0; use method chaining instead.", uplevel: 1
77
- val = _lookup_key(head)
78
- return nil if val.nil?
79
- return val if rest.empty?
80
-
81
- val.respond_to?(:dig) ? val.dig(*rest) : nil
82
- end
83
-
84
- # Fetches a key with an optional default.
85
- #
86
- # @deprecated {#fetch} is deprecated and will be removed in 0.2.0; use method calls instead.
87
- # @param key [Symbol, String]
88
- # @param args [Array<Object>]
89
- # @return [Object, nil]
90
- # @api public
91
- #: (Symbol | String key, *untyped args) ?{ (Symbol | String) -> untyped } -> untyped
92
- def fetch(key, *args)
93
- warn "[DEPRECATION] `#{self.class}#fetch` is deprecated and will be removed in 0.2.0; use method calls instead.", uplevel: 1
94
- val = _lookup_key(key)
95
- if !val.nil? || (_has_key?(key) && members.include?(key.to_sym))
96
- val
97
- elsif block_given?
98
- yield(key)
99
- elsif !args.empty?
100
- args.first
101
- else
102
- raise KeyError, "key not found: #{key.inspect}"
103
- end
104
- end
105
-
106
- # Merges non-nil attributes with another Hash or MetadataRecord.
107
- #
108
- # @deprecated {#merge} is deprecated and will be removed in 0.2.0; use {#with} or {#to_h} instead.
109
- # @param other [Hash, MetadataRecord]
110
- # @return [Hash{Symbol => Object}]
111
- # @api public
112
- #: (untyped other) -> Hash[Symbol, untyped]
113
- def merge(other)
114
- warn "[DEPRECATION] `#{self.class}#merge` is deprecated and will be removed in 0.2.0; use `#with` or `#to_h.merge` instead.", uplevel: 1
115
- h = to_h
116
- other_h = other.respond_to?(:to_h) ? other.to_h : other
117
- h.merge(other_h)
118
- end
119
-
120
111
  alias to_hash to_h
121
-
122
- # Checks equality against another instance, a Hash, or a scalar.
123
- #
124
- # @param other [Object]
125
- # @return [Boolean]
126
- # @api public
127
- #: (untyped other) -> bool
128
- def ==(other)
129
- if other.is_a?(Hash)
130
- warn "[DEPRECATION] Comparing `#{self.class}` with a Hash is deprecated and will be removed in 0.2.0; compare attributes directly or use `#to_h`.", uplevel: 1
131
- to_h == other.transform_keys(&:to_sym).compact
132
- else
133
- super
134
- end
135
- end
136
-
137
- private
138
-
139
- def _lookup_key(key)
140
- k = _normalize_key(key)
141
- return public_send(k) if members.include?(k)
142
-
143
- if members.include?(:options)
144
- opts = options
145
- return opts[k] || opts[key] if opts.is_a?(Hash)
146
- end
147
- nil
148
- end
149
-
150
- def _has_key?(key)
151
- k = _normalize_key(key)
152
- return true if members.include?(k) && !public_send(k).nil?
153
-
154
- if members.include?(:options)
155
- opts = options
156
- return true if opts.is_a?(Hash) && (opts.key?(k) || opts.key?(key))
157
- end
158
- false
159
- end
160
-
161
- def _normalize_key(key)
162
- k = key.is_a?(Symbol) ? key : key.to_s.to_sym
163
- k = :size if k == :sz
164
- k = :number_format if k == :num_fmt
165
- k = :page_setup_properties if k == :page_setup_pr
166
- k = :pattern_type if k == :pattern
167
- k = :column if k == :col
168
- k = :columns if k == :cols
169
- k = :ref if k == :cell
170
- k = :sheet_calc_properties if %i[sheet_calc_pr calc_pr].include?(k)
171
- k = :sqref if %i[location_ref location].include?(k)
172
- k = :formula if %i[formulas data_ref f].include?(k)
173
- k = :dxf_id if k == :format_id
174
- k = :default_column_width if k == :default_col_width
175
- k = :outline_level_column if k == :outline_level_col
176
- k = :base_column_width if k == :base_col_width
177
- k = :from_column if k == :from_col
178
- k = :to_column if k == :to_col
179
- k = :column_id if k == :col_id
180
- k = :active_sheet if k == :active_tab
181
- k = :first_sheet if k == :first_tab
182
- k = :background_image if %i[background_picture picture].include?(k)
183
- k = :local_sheet_name if k == :sheet
184
- k = :local_sheet_id if k == :sheet_id
185
- k = :value if k == :range
186
- k = :app_name if k == :application
187
- k
188
- end
189
112
  end
190
113
 
191
114
  # Core document properties (docProps/core.xml).
192
115
  # @api public
193
116
  CoreProperties = Data.define(
194
117
  :title, :subject, :creator, :keywords, :description, :last_modified_by,
195
- :revision, :created, :modified, :category, :content_status
118
+ :revision, :created, :modified, :category, :content_status,
119
+ :language
196
120
  ) do
197
121
  include MetadataRecord
198
122
 
199
- #: (?title: String?, ?subject: String?, ?creator: String?, ?keywords: String?, ?description: String?, ?last_modified_by: String?, ?revision: String?, ?created: untyped, ?modified: untyped, ?category: String?, ?content_status: String?, **untyped) -> void
200
- def initialize(title: nil, subject: nil, creator: nil, keywords: nil, description: nil, last_modified_by: nil, revision: nil, created: nil, modified: nil, category: nil, content_status: nil, **_extra)
201
- super(
123
+ #: (?title: String?, ?subject: String?, ?creator: String?, ?keywords: String?, ?description: String?, ?last_modified_by: String?, ?revision: String?, ?created: untyped, ?modified: untyped, ?category: String?, ?content_status: String?, ?language: String?) -> void
124
+ def initialize(title: nil, subject: nil, creator: nil, keywords: nil, description: nil, last_modified_by: nil, revision: nil, created: nil, modified: nil, category: nil, content_status: nil, language: nil)
125
+ super(**{
202
126
  title: title, subject: subject, creator: creator, keywords: keywords, description: description,
203
127
  last_modified_by: last_modified_by, revision: revision, created: created, modified: modified,
204
- category: category, content_status: content_status
205
- )
128
+ category: category, content_status: content_status, language: language
129
+ })
206
130
  end
207
131
  end
208
132
 
@@ -215,15 +139,16 @@ module Xlsxrb
215
139
  ) do
216
140
  include MetadataRecord
217
141
 
218
- #: (?app_name: String?, ?app_version: String?, ?doc_security: Integer?, ?scale_crop: bool?, ?heading_pairs: Array[untyped]?, ?titles_of_parts: Array[untyped]?, ?manager: String?, ?company: String?, ?links_up_to_date: bool?, ?shared_doc: bool?, ?hyperlink_base: String?, ?hyperlinks_changed: bool?, **untyped) -> void
219
- def initialize(app_name: nil, app_version: nil, doc_security: nil, scale_crop: nil, heading_pairs: nil, titles_of_parts: nil, manager: nil, company: nil, links_up_to_date: nil, shared_doc: nil, hyperlink_base: nil, hyperlinks_changed: nil, **extra)
220
- app_name ||= extra[:application]
221
- super(
142
+ private :scale_crop, :links_up_to_date, :shared_doc, :hyperlinks_changed
143
+
144
+ #: (?app_name: String?, ?app_version: String?, ?doc_security: Integer?, ?scale_crop: bool?, ?heading_pairs: Array[untyped]?, ?titles_of_parts: Array[untyped]?, ?manager: String?, ?company: String?, ?links_up_to_date: bool?, ?shared_doc: bool?, ?hyperlink_base: String?, ?hyperlinks_changed: bool?) -> void
145
+ def initialize(app_name: nil, app_version: nil, doc_security: nil, scale_crop: nil, heading_pairs: nil, titles_of_parts: nil, manager: nil, company: nil, links_up_to_date: nil, shared_doc: nil, hyperlink_base: nil, hyperlinks_changed: nil)
146
+ super(**{
222
147
  app_name: app_name, app_version: app_version, doc_security: doc_security, scale_crop: scale_crop,
223
148
  heading_pairs: heading_pairs, titles_of_parts: titles_of_parts, manager: manager, company: company,
224
149
  links_up_to_date: links_up_to_date, shared_doc: shared_doc, hyperlink_base: hyperlink_base,
225
150
  hyperlinks_changed: hyperlinks_changed
226
- )
151
+ })
227
152
  end
228
153
 
229
154
  # Returns whether scale and crop are enabled.
@@ -262,44 +187,22 @@ module Xlsxrb
262
187
  # Workbook-level properties (<workbookPr> and <workbookView>).
263
188
  # @api public
264
189
  WorkbookProperties = Data.define(
265
- :date1904, :code_name, :active_sheet, :first_sheet, :first_tab,
190
+ :date1904, :code_name, :active_sheet, :first_sheet,
266
191
  :show_sheet_tabs, :tab_ratio, :full_calc_on_load, :filter_privacy,
267
- :default_theme_version, :refresh_all
192
+ :default_theme_version, :refresh_all,
193
+ :update_links
268
194
  ) do
269
195
  include MetadataRecord
270
196
 
271
- #: (?date1904: bool?, ?code_name: String?, ?active_sheet: Integer?, ?active_tab: Integer?, ?first_sheet: Integer?, ?first_tab: Integer?, ?show_sheet_tabs: bool?, ?tab_ratio: Integer?, ?full_calc_on_load: bool?, ?filter_privacy: bool?, ?default_theme_version: String?, ?refresh_all: bool?, **untyped) -> void
272
- def initialize(date1904: nil, code_name: nil, active_sheet: nil, active_tab: nil, first_sheet: nil, first_tab: nil, show_sheet_tabs: nil, tab_ratio: nil, full_calc_on_load: nil, filter_privacy: nil, default_theme_version: nil, refresh_all: nil, **extra)
273
- if (!active_tab.nil? || extra.key?(:active_tab)) && active_sheet.nil?
274
- warn "[Xlsxrb DEPRECATION] WorkbookProperties.new(active_tab:) is deprecated and will be removed in v0.2.0. Use active_sheet: instead.", uplevel: 1
275
- active_sheet = active_tab || extra[:active_tab]
276
- end
277
- ft = first_tab || first_sheet
278
- super(
279
- date1904: date1904, code_name: code_name, active_sheet: active_sheet, first_sheet: ft, first_tab: ft,
280
- show_sheet_tabs: show_sheet_tabs, tab_ratio: tab_ratio, full_calc_on_load: full_calc_on_load,
281
- filter_privacy: filter_privacy, default_theme_version: default_theme_version, refresh_all: refresh_all
282
- )
283
- end
284
-
285
- undef_method :first_tab
286
-
287
- # @deprecated Use {#first_sheet} instead.
288
- # @return [Integer, nil]
289
- # @api public
290
- #: () -> Integer?
291
- def first_tab
292
- warn "[Xlsxrb DEPRECATION] WorkbookProperties#first_tab is deprecated; use #first_sheet instead.", uplevel: 1
293
- first_sheet
294
- end
197
+ private :date1904, :show_sheet_tabs, :full_calc_on_load, :filter_privacy, :refresh_all
295
198
 
296
- # @deprecated Use {#active_sheet} instead.
297
- # @return [Integer, nil]
298
- # @api public
299
- #: () -> Integer?
300
- def active_tab
301
- warn "[Xlsxrb DEPRECATION] WorkbookProperties#active_tab is deprecated and will be removed in v0.2.0. Use #active_sheet instead.", uplevel: 1
302
- active_sheet
199
+ #: (?date1904: bool?, ?code_name: String?, ?active_sheet: Integer?, ?first_sheet: Integer?, ?show_sheet_tabs: bool?, ?tab_ratio: Integer?, ?full_calc_on_load: bool?, ?filter_privacy: bool?, ?default_theme_version: String?, ?refresh_all: bool?, ?update_links: String?) -> void
200
+ def initialize(date1904: nil, code_name: nil, active_sheet: nil, first_sheet: nil, show_sheet_tabs: nil, tab_ratio: nil, full_calc_on_load: nil, filter_privacy: nil, default_theme_version: nil, refresh_all: nil, update_links: nil)
201
+ super(**{
202
+ date1904: date1904, code_name: code_name, active_sheet: active_sheet, first_sheet: first_sheet,
203
+ show_sheet_tabs: show_sheet_tabs, tab_ratio: tab_ratio, full_calc_on_load: full_calc_on_load,
204
+ filter_privacy: filter_privacy, default_theme_version: default_theme_version, refresh_all: refresh_all, update_links: update_links
205
+ })
303
206
  end
304
207
 
305
208
  # Returns whether the 1904 date system is used.
@@ -310,7 +213,15 @@ module Xlsxrb
310
213
  date1904 ? true : false
311
214
  end
312
215
 
313
- # Returns whether sheet tabs are shown in the workbook window.
216
+ # Returns whether filter privacy is enabled.
217
+ # @return [Boolean]
218
+ # @api public
219
+ #: () -> bool
220
+ def filter_privacy?
221
+ filter_privacy ? true : false
222
+ end
223
+
224
+ # Returns whether sheet tabs are visible.
314
225
  # @return [Boolean]
315
226
  # @api public
316
227
  #: () -> bool
@@ -318,7 +229,7 @@ module Xlsxrb
318
229
  show_sheet_tabs != false
319
230
  end
320
231
 
321
- # Returns whether full calculation is performed when loading the workbook.
232
+ # Returns whether full calculation is performed on load.
322
233
  # @return [Boolean]
323
234
  # @api public
324
235
  #: () -> bool
@@ -326,38 +237,33 @@ module Xlsxrb
326
237
  full_calc_on_load ? true : false
327
238
  end
328
239
 
329
- # Returns whether external data connections are refreshed when opening.
240
+ # Returns whether all external data ranges and PivotTables are refreshed on open.
330
241
  # @return [Boolean]
331
242
  # @api public
332
243
  #: () -> bool
333
244
  def refresh_all?
334
245
  refresh_all ? true : false
335
246
  end
336
-
337
- # Returns whether filter privacy is enabled.
338
- # @return [Boolean]
339
- # @api public
340
- #: () -> bool
341
- def filter_privacy?
342
- filter_privacy ? true : false
343
- end
344
247
  end
345
248
 
346
249
  # Workbook protection settings (<workbookProtection>).
347
250
  # @api public
348
251
  WorkbookProtection = Data.define(
349
252
  :workbook_password, :lock_structure, :lock_windows, :revisions_password,
350
- :lock_revision, :algorithm_name, :hash_value, :salt_value, :spin_count
253
+ :lock_revision, :algorithm_name, :hash_value, :salt_value, :spin_count,
254
+ :revisions_algorithm_name, :revisions_hash_value, :revisions_salt_value, :revisions_spin_count
351
255
  ) do
352
256
  include MetadataRecord
353
257
 
354
- #: (?workbook_password: String?, ?lock_structure: bool?, ?lock_windows: bool?, ?revisions_password: String?, ?lock_revision: bool?, ?algorithm_name: String?, ?hash_value: String?, ?salt_value: String?, ?spin_count: Integer?, **untyped) -> void
355
- def initialize(workbook_password: nil, lock_structure: nil, lock_windows: nil, revisions_password: nil, lock_revision: nil, algorithm_name: nil, hash_value: nil, salt_value: nil, spin_count: nil, **_extra)
356
- super(
258
+ private :lock_structure, :lock_windows, :lock_revision
259
+
260
+ #: (?workbook_password: String?, ?lock_structure: bool?, ?lock_windows: bool?, ?revisions_password: String?, ?lock_revision: bool?, ?algorithm_name: String?, ?hash_value: String?, ?salt_value: String?, ?spin_count: Integer?, ?revisions_algorithm_name: String?, ?revisions_hash_value: String?, ?revisions_salt_value: String?, ?revisions_spin_count: Integer?) -> void
261
+ def initialize(workbook_password: nil, lock_structure: nil, lock_windows: nil, revisions_password: nil, lock_revision: nil, algorithm_name: nil, hash_value: nil, salt_value: nil, spin_count: nil, revisions_algorithm_name: nil, revisions_hash_value: nil, revisions_salt_value: nil, revisions_spin_count: nil)
262
+ super(**{
357
263
  workbook_password: workbook_password, lock_structure: lock_structure, lock_windows: lock_windows,
358
264
  revisions_password: revisions_password, lock_revision: lock_revision, algorithm_name: algorithm_name,
359
- hash_value: hash_value, salt_value: salt_value, spin_count: spin_count
360
- )
265
+ hash_value: hash_value, salt_value: salt_value, spin_count: spin_count, revisions_algorithm_name: revisions_algorithm_name, revisions_hash_value: revisions_hash_value, revisions_salt_value: revisions_salt_value, revisions_spin_count: revisions_spin_count
266
+ })
361
267
  end
362
268
 
363
269
  # Returns whether the workbook structure is locked.
@@ -391,19 +297,22 @@ module Xlsxrb
391
297
  :paper_size, :orientation, :scale, :fit_to_width, :fit_to_height,
392
298
  :first_page_number, :use_first_page_number, :black_and_white, :draft,
393
299
  :cell_comments, :use_printer_defaults, :copies, :horizontal_centered,
394
- :vertical_centered, :id
300
+ :vertical_centered, :id,
301
+ :page_order, :horizontal_dpi, :vertical_dpi
395
302
  ) do
396
303
  include MetadataRecord
397
304
 
398
- #: (?paper_size: (Integer | String)?, ?orientation: (Symbol | String)?, ?scale: Integer?, ?fit_to_width: Integer?, ?fit_to_height: Integer?, ?first_page_number: Integer?, ?use_first_page_number: bool?, ?black_and_white: bool?, ?draft: bool?, ?cell_comments: String?, ?use_printer_defaults: bool?, ?copies: Integer?, ?horizontal_centered: bool?, ?vertical_centered: bool?, ?id: String?, **untyped) -> void
399
- def initialize(paper_size: nil, orientation: nil, scale: nil, fit_to_width: nil, fit_to_height: nil, first_page_number: nil, use_first_page_number: nil, black_and_white: nil, draft: nil, cell_comments: nil, use_printer_defaults: nil, copies: nil, horizontal_centered: nil, vertical_centered: nil, id: nil, **_extra)
400
- super(
305
+ private :use_first_page_number, :black_and_white, :draft, :use_printer_defaults, :horizontal_centered, :vertical_centered
306
+
307
+ #: (?paper_size: (Integer | String)?, ?orientation: (Symbol | String)?, ?scale: Integer?, ?fit_to_width: Integer?, ?fit_to_height: Integer?, ?first_page_number: Integer?, ?use_first_page_number: bool?, ?black_and_white: bool?, ?draft: bool?, ?cell_comments: String?, ?use_printer_defaults: bool?, ?copies: Integer?, ?horizontal_centered: bool?, ?vertical_centered: bool?, ?id: String?, ?page_order: String?, ?horizontal_dpi: Integer?, ?vertical_dpi: Integer?) -> void
308
+ def initialize(paper_size: nil, orientation: nil, scale: nil, fit_to_width: nil, fit_to_height: nil, first_page_number: nil, use_first_page_number: nil, black_and_white: nil, draft: nil, cell_comments: nil, use_printer_defaults: nil, copies: nil, horizontal_centered: nil, vertical_centered: nil, id: nil, page_order: nil, horizontal_dpi: nil, vertical_dpi: nil)
309
+ super(**{
401
310
  paper_size: paper_size, orientation: orientation, scale: scale, fit_to_width: fit_to_width,
402
311
  fit_to_height: fit_to_height, first_page_number: first_page_number, use_first_page_number: use_first_page_number,
403
312
  black_and_white: black_and_white, draft: draft, cell_comments: cell_comments,
404
313
  use_printer_defaults: use_printer_defaults, copies: copies, horizontal_centered: horizontal_centered,
405
- vertical_centered: vertical_centered, id: id
406
- )
314
+ vertical_centered: vertical_centered, id: id, page_order: page_order, horizontal_dpi: horizontal_dpi, vertical_dpi: vertical_dpi
315
+ })
407
316
  end
408
317
 
409
318
  # Returns whether black and white print mode is enabled.
@@ -460,9 +369,9 @@ module Xlsxrb
460
369
  PageMargins = Data.define(:left, :right, :top, :bottom, :header, :footer) do
461
370
  include MetadataRecord
462
371
 
463
- #: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?, **untyped) -> void
464
- def initialize(left: nil, right: nil, top: nil, bottom: nil, header: nil, footer: nil, **_extra)
465
- super(left: left, right: right, top: top, bottom: bottom, header: header, footer: footer)
372
+ #: (?left: Float?, ?right: Float?, ?top: Float?, ?bottom: Float?, ?header: Float?, ?footer: Float?) -> void
373
+ def initialize(left: nil, right: nil, top: nil, bottom: nil, header: nil, footer: nil)
374
+ super(**{ left: left, right: right, top: top, bottom: bottom, header: header, footer: footer })
466
375
  end
467
376
  end
468
377
 
@@ -475,14 +384,16 @@ module Xlsxrb
475
384
  ) do
476
385
  include MetadataRecord
477
386
 
478
- #: (?odd_header: String?, ?odd_footer: String?, ?even_header: String?, ?even_footer: String?, ?first_header: String?, ?first_footer: String?, ?different_odd_even: bool?, ?different_first: bool?, ?scale_with_doc: bool?, ?align_with_margins: bool?, **untyped) -> void
479
- def initialize(odd_header: nil, odd_footer: nil, even_header: nil, even_footer: nil, first_header: nil, first_footer: nil, different_odd_even: nil, different_first: nil, scale_with_doc: nil, align_with_margins: nil, **_extra)
480
- super(
387
+ private :different_odd_even, :different_first, :scale_with_doc, :align_with_margins
388
+
389
+ #: (?odd_header: String?, ?odd_footer: String?, ?even_header: String?, ?even_footer: String?, ?first_header: String?, ?first_footer: String?, ?different_odd_even: bool?, ?different_first: bool?, ?scale_with_doc: bool?, ?align_with_margins: bool?) -> void
390
+ def initialize(odd_header: nil, odd_footer: nil, even_header: nil, even_footer: nil, first_header: nil, first_footer: nil, different_odd_even: nil, different_first: nil, scale_with_doc: nil, align_with_margins: nil)
391
+ super(**{
481
392
  odd_header: odd_header, odd_footer: odd_footer, even_header: even_header,
482
393
  even_footer: even_footer, first_header: first_header, first_footer: first_footer,
483
394
  different_odd_even: different_odd_even, different_first: different_first,
484
395
  scale_with_doc: scale_with_doc, align_with_margins: align_with_margins
485
- )
396
+ })
486
397
  end
487
398
 
488
399
  # Returns whether different first page header/footer is enabled.
@@ -523,12 +434,14 @@ module Xlsxrb
523
434
  PrintOptions = Data.define(:grid_lines, :grid_lines_set, :headings, :horizontal_centered, :vertical_centered) do
524
435
  include MetadataRecord
525
436
 
526
- #: (?grid_lines: bool?, ?grid_lines_set: bool?, ?headings: bool?, ?horizontal_centered: bool?, ?vertical_centered: bool?, **untyped) -> void
527
- def initialize(grid_lines: nil, grid_lines_set: nil, headings: nil, horizontal_centered: nil, vertical_centered: nil, **_extra)
528
- super(
437
+ private :grid_lines, :grid_lines_set, :headings, :horizontal_centered, :vertical_centered
438
+
439
+ #: (?grid_lines: bool?, ?grid_lines_set: bool?, ?headings: bool?, ?horizontal_centered: bool?, ?vertical_centered: bool?) -> void
440
+ def initialize(grid_lines: nil, grid_lines_set: nil, headings: nil, horizontal_centered: nil, vertical_centered: nil)
441
+ super(**{
529
442
  grid_lines: grid_lines, grid_lines_set: grid_lines_set, headings: headings,
530
443
  horizontal_centered: horizontal_centered, vertical_centered: vertical_centered
531
- )
444
+ })
532
445
  end
533
446
 
534
447
  # Returns whether grid lines are printed.
@@ -574,58 +487,39 @@ module Xlsxrb
574
487
 
575
488
  # Worksheet repeating print titles.
576
489
  # @api public
577
- PrintTitles = Data.define(:rows, :columns, :cols) do
490
+ PrintTitles = Data.define(:rows, :columns) do
578
491
  include MetadataRecord
579
492
 
580
- #: (?rows: String?, ?columns: String?, ?cols: String?, **untyped) -> void
581
- def initialize(rows: nil, columns: nil, cols: nil, **_extra)
582
- c = columns || cols
583
- super(rows: rows, columns: c, cols: c)
584
- end
585
-
586
- undef_method :cols
587
-
588
- # @deprecated Use {#columns} instead.
589
- # @return [String, nil]
590
- # @api public
591
- #: () -> String?
592
- def cols
593
- warn "[Xlsxrb DEPRECATION] PrintTitles#cols is deprecated; use #columns instead.", uplevel: 1
594
- columns
493
+ #: (?rows: String?, ?columns: String?) -> void
494
+ def initialize(rows: nil, columns: nil)
495
+ super(**{ rows: rows, columns: columns })
595
496
  end
596
497
  end
597
498
 
598
499
  # Worksheet freeze pane settings (<pane>).
599
500
  # @api public
600
- FreezePane = Data.define(:row, :column, :col, :top_row, :left_column, :active_pane, :state) do
501
+ #
502
+ # +top_left_cell+ is the first visible cell of the bottom-right pane (the topLeftCell
503
+ # attribute). When nil, the writer uses the cell just past the frozen rows and columns.
504
+ FreezePane = Data.define(:row, :column, :top_left_cell, :active_pane, :state) do
601
505
  include MetadataRecord
602
506
 
603
- #: (?row: Integer?, ?column: (Integer | String | Symbol)?, ?col: (Integer | String | Symbol)?, ?top_row: Integer?, ?left_column: (Integer | String | Symbol)?, ?active_pane: String?, ?state: Symbol?, **untyped) -> void
604
- def initialize(row: nil, column: nil, col: nil, top_row: nil, left_column: nil, active_pane: nil, state: :frozen, **_extra)
605
- c = column || col
606
- super(row: row, column: c, col: c, top_row: top_row, left_column: left_column, active_pane: active_pane, state: state || :frozen)
607
- end
608
-
609
- undef_method :col
610
-
611
- # @deprecated Use {#column} instead.
612
- # @return [Integer, String, Symbol, nil]
613
- # @api public
614
- #: () -> (Integer | String | Symbol)?
615
- def col
616
- warn "[Xlsxrb DEPRECATION] FreezePane#col is deprecated; use #column instead.", uplevel: 1
617
- column
507
+ #: (?row: Integer?, ?column: (Integer | String | Symbol)?, ?top_left_cell: String?, ?active_pane: String?, ?state: Symbol?) -> void
508
+ def initialize(row: nil, column: nil, top_left_cell: nil, active_pane: nil, state: :frozen)
509
+ super(**{ row: row, column: column, top_left_cell: top_left_cell, active_pane: active_pane, state: state || :frozen })
618
510
  end
619
511
  end
620
512
 
621
513
  # Worksheet split pane settings (<pane>).
622
514
  # @api public
623
- SplitPane = Data.define(:x_split, :y_split, :top_row, :left_column, :active_pane, :state) do
515
+ #
516
+ # +top_left_cell+ is the first visible cell of the bottom-right pane (the topLeftCell attribute).
517
+ SplitPane = Data.define(:x_split, :y_split, :top_left_cell, :active_pane, :state) do
624
518
  include MetadataRecord
625
519
 
626
- #: (?x_split: (Integer | Float)?, ?y_split: (Integer | Float)?, ?top_row: Integer?, ?left_column: Integer?, ?active_pane: String?, ?state: String?, **untyped) -> void
627
- def initialize(x_split: nil, y_split: nil, top_row: nil, left_column: nil, active_pane: nil, state: nil, **_extra)
628
- super(x_split: x_split, y_split: y_split, top_row: top_row, left_column: left_column, active_pane: active_pane, state: state)
520
+ #: (?x_split: (Integer | Float)?, ?y_split: (Integer | Float)?, ?top_left_cell: String?, ?active_pane: String?, ?state: String?) -> void
521
+ def initialize(x_split: nil, y_split: nil, top_left_cell: nil, active_pane: nil, state: nil)
522
+ super(**{ x_split: x_split, y_split: y_split, top_left_cell: top_left_cell, active_pane: active_pane, state: state })
629
523
  end
630
524
  end
631
525
 
@@ -634,9 +528,9 @@ module Xlsxrb
634
528
  Selection = Data.define(:pane, :active_cell, :active_cell_id, :sqref) do
635
529
  include MetadataRecord
636
530
 
637
- #: (?pane: String?, ?active_cell: String?, ?active_cell_id: Integer?, ?sqref: String?, **untyped) -> void
638
- def initialize(pane: nil, active_cell: nil, active_cell_id: nil, sqref: nil, **_extra)
639
- super(pane: pane, active_cell: active_cell, active_cell_id: active_cell_id, sqref: sqref)
531
+ #: (?pane: String?, ?active_cell: String?, ?active_cell_id: Integer?, ?sqref: String?) -> void
532
+ def initialize(pane: nil, active_cell: nil, active_cell_id: nil, sqref: nil)
533
+ super(**{ pane: pane, active_cell: active_cell, active_cell_id: active_cell_id, sqref: sqref })
640
534
  end
641
535
  end
642
536
 
@@ -650,9 +544,11 @@ module Xlsxrb
650
544
  ) do
651
545
  include MetadataRecord
652
546
 
653
- #: (?password: String?, ?sheet: bool?, ?objects: bool?, ?scenarios: bool?, ?format_cells: bool?, ?format_columns: bool?, ?format_rows: bool?, ?insert_columns: bool?, ?insert_rows: bool?, ?insert_hyperlinks: bool?, ?delete_columns: bool?, ?delete_rows: bool?, ?select_locked_cells: bool?, ?select_unlocked_cells: bool?, ?sort: bool?, ?auto_filter: bool?, ?pivot_tables: bool?, ?algorithm_name: String?, ?hash_value: String?, ?salt_value: String?, ?spin_count: Integer?, **untyped) -> void
654
- def initialize(password: nil, sheet: nil, objects: nil, scenarios: nil, format_cells: nil, format_columns: nil, format_rows: nil, insert_columns: nil, insert_rows: nil, insert_hyperlinks: nil, delete_columns: nil, delete_rows: nil, select_locked_cells: nil, select_unlocked_cells: nil, sort: nil, auto_filter: nil, pivot_tables: nil, algorithm_name: nil, hash_value: nil, salt_value: nil, spin_count: nil, **_extra)
655
- super(
547
+ private :sheet, :objects, :scenarios, :format_cells, :format_columns, :format_rows, :insert_columns, :insert_rows, :insert_hyperlinks, :delete_columns, :delete_rows, :select_locked_cells, :select_unlocked_cells, :sort, :auto_filter, :pivot_tables
548
+
549
+ #: (?password: String?, ?sheet: bool?, ?objects: bool?, ?scenarios: bool?, ?format_cells: bool?, ?format_columns: bool?, ?format_rows: bool?, ?insert_columns: bool?, ?insert_rows: bool?, ?insert_hyperlinks: bool?, ?delete_columns: bool?, ?delete_rows: bool?, ?select_locked_cells: bool?, ?select_unlocked_cells: bool?, ?sort: bool?, ?auto_filter: bool?, ?pivot_tables: bool?, ?algorithm_name: String?, ?hash_value: String?, ?salt_value: String?, ?spin_count: Integer?) -> void
550
+ def initialize(password: nil, sheet: nil, objects: nil, scenarios: nil, format_cells: nil, format_columns: nil, format_rows: nil, insert_columns: nil, insert_rows: nil, insert_hyperlinks: nil, delete_columns: nil, delete_rows: nil, select_locked_cells: nil, select_unlocked_cells: nil, sort: nil, auto_filter: nil, pivot_tables: nil, algorithm_name: nil, hash_value: nil, salt_value: nil, spin_count: nil)
551
+ super(**{
656
552
  password: password, sheet: sheet, objects: objects, scenarios: scenarios,
657
553
  format_cells: format_cells, format_columns: format_columns, format_rows: format_rows,
658
554
  insert_columns: insert_columns, insert_rows: insert_rows, insert_hyperlinks: insert_hyperlinks,
@@ -660,7 +556,7 @@ module Xlsxrb
660
556
  select_unlocked_cells: select_unlocked_cells, sort: sort, auto_filter: auto_filter,
661
557
  pivot_tables: pivot_tables, algorithm_name: algorithm_name, hash_value: hash_value,
662
558
  salt_value: salt_value, spin_count: spin_count
663
- )
559
+ })
664
560
  end
665
561
 
666
562
  # Returns whether worksheet protection is enabled.
@@ -795,7 +691,7 @@ module Xlsxrb
795
691
  # Worksheet properties (<sheetPr>).
796
692
  # @api public
797
693
  SheetProperties = Data.define(
798
- :tab_color, :filter_mode, :enable_format_conditions_calculation, :outline_pr, :page_setup_properties,
694
+ :tab_color, :filter_mode, :enable_format_conditions_calculation, :page_setup_properties,
799
695
  :code_name, :fit_to_page, :full_calc_on_load, :tab_color_theme, :tab_color_tint, :tab_color_indexed,
800
696
  :tab_color_auto, :outline_properties, :auto_page_breaks, :sync_horizontal, :sync_vertical, :sync_ref,
801
697
  :transition_evaluation, :transition_entry, :published,
@@ -803,46 +699,37 @@ module Xlsxrb
803
699
  ) do
804
700
  include MetadataRecord
805
701
 
806
- #: (?tab_color: String?, ?filter_mode: bool?, ?enable_format_conditions_calculation: bool?, ?outline_pr: Hash[Symbol, untyped]?, ?page_setup_properties: Hash[Symbol, untyped]?, ?code_name: String?, ?fit_to_page: bool?, ?full_calc_on_load: bool?, ?tab_color_theme: Integer?, ?tab_color_tint: Float?, ?tab_color_indexed: Integer?, ?tab_color_auto: bool?, ?outline_properties: Hash[Symbol, untyped]?, ?auto_page_breaks: bool?, ?sync_horizontal: bool?, ?sync_vertical: bool?, ?sync_ref: String?, ?transition_evaluation: bool?, ?transition_entry: bool?, ?published: bool?, ?apply_styles: bool?, ?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?, **untyped) -> void
807
- def initialize(tab_color: nil, filter_mode: nil, enable_format_conditions_calculation: nil, outline_pr: nil, page_setup_properties: nil, page_setup_pr: nil, code_name: nil, fit_to_page: nil, full_calc_on_load: nil, tab_color_theme: nil, tab_color_tint: nil, tab_color_indexed: nil, tab_color_auto: nil, outline_properties: nil, auto_page_breaks: nil, sync_horizontal: nil, sync_vertical: nil, sync_ref: nil, transition_evaluation: nil, transition_entry: nil, published: nil, apply_styles: nil, summary_below: nil, summary_right: nil, show_outline_symbols: nil, **extra)
702
+ private :filter_mode, :enable_format_conditions_calculation, :fit_to_page, :full_calc_on_load, :tab_color_auto, :auto_page_breaks, :sync_horizontal, :sync_vertical, :transition_evaluation, :transition_entry, :published, :apply_styles, :summary_below, :summary_right, :show_outline_symbols
703
+
704
+ #: (?tab_color: String?, ?filter_mode: bool?, ?enable_format_conditions_calculation: bool?, ?page_setup_properties: Hash[Symbol, untyped]?, ?code_name: String?, ?fit_to_page: bool?, ?full_calc_on_load: bool?, ?tab_color_theme: Integer?, ?tab_color_tint: Float?, ?tab_color_indexed: Integer?, ?tab_color_auto: bool?, ?outline_properties: Hash[Symbol, untyped]?, ?auto_page_breaks: bool?, ?sync_horizontal: bool?, ?sync_vertical: bool?, ?sync_ref: String?, ?transition_evaluation: bool?, ?transition_entry: bool?, ?published: bool?, ?apply_styles: bool?, ?summary_below: bool?, ?summary_right: bool?, ?show_outline_symbols: bool?) -> void
705
+ def initialize(tab_color: nil, filter_mode: nil, enable_format_conditions_calculation: nil, page_setup_properties: nil, code_name: nil, fit_to_page: nil, full_calc_on_load: nil, tab_color_theme: nil, tab_color_tint: nil, tab_color_indexed: nil, tab_color_auto: nil, outline_properties: nil, auto_page_breaks: nil, sync_horizontal: nil, sync_vertical: nil, sync_ref: nil, transition_evaluation: nil, transition_entry: nil, published: nil, apply_styles: nil, summary_below: nil, summary_right: nil, show_outline_symbols: nil)
808
706
  psp = page_setup_properties
809
- if (page_setup_pr || extra.key?(:page_setup_pr) || extra.key?("page_setup_pr")) && psp.nil?
810
- Xlsxrb::Deprecation.warn("SheetProperties keyword :page_setup_pr is deprecated; use :page_setup_properties instead.", uplevel: 1)
811
- psp = page_setup_pr || extra[:page_setup_pr] || extra["page_setup_pr"]
812
- end
813
- out_pr = outline_properties || outline_pr || {}
814
- app_st = apply_styles.nil? ? (out_pr[:apply_styles] || extra[:apply_styles]) : apply_styles
815
- sum_b = summary_below.nil? ? (out_pr[:summary_below] || extra[:summary_below]) : summary_below
816
- sum_r = summary_right.nil? ? (out_pr[:summary_right] || extra[:summary_right]) : summary_right
817
- show_sym = show_outline_symbols.nil? ? (out_pr[:show_outline_symbols] || out_pr[:show_symbols] || extra[:show_outline_symbols] || extra[:show_symbols]) : show_outline_symbols
818
- super(
707
+ ftp = if fit_to_page.nil?
708
+ psp.is_a?(Hash) ? psp[:fit_to_page] : nil
709
+ else
710
+ fit_to_page
711
+ end
712
+ apb = if auto_page_breaks.nil?
713
+ psp.is_a?(Hash) ? psp[:auto_page_breaks] : nil
714
+ else
715
+ auto_page_breaks
716
+ end
717
+ out_pr = outline_properties || {}
718
+ app_st = apply_styles.nil? ? out_pr[:apply_styles] : apply_styles
719
+ sum_b = summary_below.nil? ? out_pr[:summary_below] : summary_below
720
+ sum_r = summary_right.nil? ? out_pr[:summary_right] : summary_right
721
+ show_sym = show_outline_symbols.nil? ? out_pr[:show_outline_symbols] : show_outline_symbols
722
+ super(**{
819
723
  tab_color: tab_color, filter_mode: filter_mode,
820
724
  enable_format_conditions_calculation: enable_format_conditions_calculation,
821
- outline_pr: outline_pr, page_setup_properties: psp,
822
- code_name: code_name, fit_to_page: fit_to_page, full_calc_on_load: full_calc_on_load,
725
+ page_setup_properties: psp,
726
+ code_name: code_name, fit_to_page: ftp, full_calc_on_load: full_calc_on_load,
823
727
  tab_color_theme: tab_color_theme, tab_color_tint: tab_color_tint, tab_color_indexed: tab_color_indexed,
824
- tab_color_auto: tab_color_auto, outline_properties: outline_properties, auto_page_breaks: auto_page_breaks,
728
+ tab_color_auto: tab_color_auto, outline_properties: outline_properties, auto_page_breaks: apb,
825
729
  sync_horizontal: sync_horizontal, sync_vertical: sync_vertical, sync_ref: sync_ref,
826
730
  transition_evaluation: transition_evaluation, transition_entry: transition_entry, published: published,
827
731
  apply_styles: app_st, summary_below: sum_b, summary_right: sum_r, show_outline_symbols: show_sym
828
- )
829
- end
830
-
831
- # @deprecated Use {#page_setup_properties} instead. Will be removed in 0.2.0.
832
- def page_setup_pr
833
- Xlsxrb::Deprecation.warn("SheetProperties#page_setup_pr is deprecated; use SheetProperties#page_setup_properties instead.", uplevel: 1)
834
- page_setup_properties
835
- end
836
-
837
- undef_method :outline_pr
838
-
839
- # @deprecated Use {#outline_properties} instead.
840
- # @return [Hash{Symbol => untyped}, nil]
841
- # @api public
842
- #: () -> Hash[Symbol, untyped]?
843
- def outline_pr
844
- warn "[Xlsxrb DEPRECATION] SheetProperties#outline_pr is deprecated; use #outline_properties instead.", uplevel: 1
845
- outline_properties
732
+ })
846
733
  end
847
734
 
848
735
  # Returns whether filter mode is enabled.
@@ -974,44 +861,16 @@ module Xlsxrb
974
861
  ) do
975
862
  include MetadataRecord
976
863
 
977
- #: (?default_row_height: (Float | Integer)?, ?default_column_width: (Float | Integer)?, ?custom_height: bool?, ?zero_height: bool?, ?thick_top: bool?, ?thick_bottom: bool?, ?outline_level_row: Integer?, ?outline_level_column: Integer?, ?base_column_width: (Float | Integer)?, **untyped) -> void
978
- def initialize(default_row_height: nil, default_column_width: nil, custom_height: nil, zero_height: nil, thick_top: nil, thick_bottom: nil, outline_level_row: nil, outline_level_column: nil, base_column_width: nil, **extra)
979
- default_column_width ||= extra[:default_col_width]
980
- outline_level_column ||= extra[:outline_level_col]
981
- base_column_width ||= extra[:base_col_width]
982
- super(
864
+ private :custom_height, :zero_height, :thick_top, :thick_bottom
865
+
866
+ #: (?default_row_height: (Float | Integer)?, ?default_column_width: (Float | Integer)?, ?custom_height: bool?, ?zero_height: bool?, ?thick_top: bool?, ?thick_bottom: bool?, ?outline_level_row: Integer?, ?outline_level_column: Integer?, ?base_column_width: (Float | Integer)?) -> void
867
+ def initialize(default_row_height: nil, default_column_width: nil, custom_height: nil, zero_height: nil, thick_top: nil, thick_bottom: nil, outline_level_row: nil, outline_level_column: nil, base_column_width: nil)
868
+ super(**{
983
869
  default_row_height: default_row_height, default_column_width: default_column_width,
984
870
  custom_height: custom_height, zero_height: zero_height, thick_top: thick_top,
985
871
  thick_bottom: thick_bottom, outline_level_row: outline_level_row,
986
872
  outline_level_column: outline_level_column, base_column_width: base_column_width
987
- )
988
- end
989
-
990
- # @deprecated Use {#default_column_width} instead.
991
- # @return [Float, Integer, nil]
992
- # @api public
993
- #: () -> (Float | Integer)?
994
- def default_col_width
995
- warn "[Xlsxrb DEPRECATION] SheetFormat#default_col_width is deprecated; use #default_column_width instead.", uplevel: 1
996
- default_column_width
997
- end
998
-
999
- # @deprecated Use {#outline_level_column} instead.
1000
- # @return [Integer, nil]
1001
- # @api public
1002
- #: () -> Integer?
1003
- def outline_level_col
1004
- warn "[Xlsxrb DEPRECATION] SheetFormat#outline_level_col is deprecated; use #outline_level_column instead.", uplevel: 1
1005
- outline_level_column
1006
- end
1007
-
1008
- # @deprecated Use {#base_column_width} instead.
1009
- # @return [Float, Integer, nil]
1010
- # @api public
1011
- #: () -> (Float | Integer)?
1012
- def base_col_width
1013
- warn "[Xlsxrb DEPRECATION] SheetFormat#base_col_width is deprecated; use #base_column_width instead.", uplevel: 1
1014
- base_column_width
873
+ })
1015
874
  end
1016
875
 
1017
876
  # Returns whether custom row height is set.
@@ -1058,15 +917,17 @@ module Xlsxrb
1058
917
  ) do
1059
918
  include MetadataRecord
1060
919
 
1061
- #: (?workbook_view_id: Integer?, ?show_grid_lines: bool?, ?show_row_col_headers: bool?, ?show_ruler: bool?, ?show_zeros: bool?, ?right_to_left: bool?, ?tab_selected: bool?, ?zoom_scale: Integer?, ?zoom_scale_normal: Integer?, ?zoom_scale_page_layout_view: Integer?, ?zoom_scale_sheet_layout_view: Integer?, ?view: String?, ?window_protection: bool?, ?show_formulas: bool?, ?show_outline_symbols: bool?, ?default_grid_color: bool?, ?show_white_space: bool?, ?top_left_cell: String?, ?color_id: Integer?, **untyped) -> void
920
+ private :show_grid_lines, :show_row_col_headers, :show_ruler, :show_zeros, :right_to_left, :tab_selected, :window_protection, :show_formulas, :show_outline_symbols, :default_grid_color, :show_white_space
921
+
922
+ #: (?workbook_view_id: Integer?, ?show_grid_lines: bool?, ?show_row_col_headers: bool?, ?show_ruler: bool?, ?show_zeros: bool?, ?right_to_left: bool?, ?tab_selected: bool?, ?zoom_scale: Integer?, ?zoom_scale_normal: Integer?, ?zoom_scale_page_layout_view: Integer?, ?zoom_scale_sheet_layout_view: Integer?, ?view: String?, ?window_protection: bool?, ?show_formulas: bool?, ?show_outline_symbols: bool?, ?default_grid_color: bool?, ?show_white_space: bool?, ?top_left_cell: String?, ?color_id: Integer?) -> void
1062
923
  def initialize(
1063
924
  workbook_view_id: nil, show_grid_lines: nil, show_row_col_headers: nil, show_ruler: nil,
1064
925
  show_zeros: nil, right_to_left: nil, tab_selected: nil, zoom_scale: nil, zoom_scale_normal: nil,
1065
926
  zoom_scale_page_layout_view: nil, zoom_scale_sheet_layout_view: nil, view: nil,
1066
927
  window_protection: nil, show_formulas: nil, show_outline_symbols: nil, default_grid_color: nil, show_white_space: nil,
1067
- top_left_cell: nil, color_id: nil, **_extra
928
+ top_left_cell: nil, color_id: nil
1068
929
  )
1069
- super(
930
+ super(**{
1070
931
  workbook_view_id: workbook_view_id, show_grid_lines: show_grid_lines,
1071
932
  show_row_col_headers: show_row_col_headers, show_ruler: show_ruler,
1072
933
  show_zeros: show_zeros, right_to_left: right_to_left, tab_selected: tab_selected,
@@ -1076,7 +937,7 @@ module Xlsxrb
1076
937
  window_protection: window_protection, show_formulas: show_formulas,
1077
938
  show_outline_symbols: show_outline_symbols, default_grid_color: default_grid_color,
1078
939
  show_white_space: show_white_space, top_left_cell: top_left_cell, color_id: color_id
1079
- )
940
+ })
1080
941
  end
1081
942
 
1082
943
  # Returns whether window protection is enabled.
@@ -1173,9 +1034,9 @@ module Xlsxrb
1173
1034
  PhoneticProperties = Data.define(:font_id, :type, :alignment) do
1174
1035
  include MetadataRecord
1175
1036
 
1176
- #: (?font_id: Integer?, ?type: String?, ?alignment: String?, **untyped) -> void
1177
- def initialize(font_id: nil, type: nil, alignment: nil, **_extra)
1178
- super(font_id: font_id, type: type, alignment: alignment)
1037
+ #: (?font_id: Integer?, ?type: String?, ?alignment: String?) -> void
1038
+ def initialize(font_id: nil, type: nil, alignment: nil)
1039
+ super(**{ font_id: font_id, type: type, alignment: alignment })
1179
1040
  end
1180
1041
  end
1181
1042
 
@@ -1184,9 +1045,11 @@ module Xlsxrb
1184
1045
  SheetCalcProperties = Data.define(:full_calc_on_load) do
1185
1046
  include MetadataRecord
1186
1047
 
1187
- #: (?full_calc_on_load: bool?, **untyped) -> void
1188
- def initialize(full_calc_on_load: nil, **_extra)
1189
- super(full_calc_on_load: full_calc_on_load)
1048
+ private :full_calc_on_load
1049
+
1050
+ #: (?full_calc_on_load: bool?) -> void
1051
+ def initialize(full_calc_on_load: nil)
1052
+ super(**{ full_calc_on_load: full_calc_on_load })
1190
1053
  end
1191
1054
 
1192
1055
  # Returns whether full calculation is performed on load.
@@ -1203,9 +1066,12 @@ module Xlsxrb
1203
1066
  SortState = Data.define(:ref, :case_sensitive, :sort_method, :conditions) do
1204
1067
  include MetadataRecord
1205
1068
 
1069
+ private :case_sensitive
1070
+
1206
1071
  #: (?ref: String?, ?case_sensitive: bool?, ?sort_method: String?, ?conditions: Array[Hash[Symbol, untyped]]?, **untyped) -> void
1207
- def initialize(ref: nil, case_sensitive: nil, sort_method: nil, conditions: nil, **_extra)
1208
- super(ref: ref, case_sensitive: case_sensitive, sort_method: sort_method, conditions: conditions)
1072
+ def initialize(ref: nil, case_sensitive: nil, sort_method: nil, conditions: nil, **extra)
1073
+ conds = conditions || extra[:sort_conditions]
1074
+ super(**{ ref: ref, case_sensitive: case_sensitive, sort_method: sort_method, conditions: conds })
1209
1075
  end
1210
1076
 
1211
1077
  # Returns whether sorting is case sensitive.
@@ -1219,47 +1085,12 @@ module Xlsxrb
1219
1085
 
1220
1086
  # Worksheet background image (<picture>).
1221
1087
  # @api public
1222
- BackgroundImage = Data.define(:r_id, :rel_id, :path, :extension, :data, :ext, :filename, :content_type) do
1088
+ BackgroundImage = Data.define(:r_id, :path, :extension, :data, :content_type) do
1223
1089
  include MetadataRecord
1224
1090
 
1225
- #: (?r_id: String?, ?rel_id: String?, ?path: String?, ?extension: String?, ?data: String?, ?ext: String?, ?filename: String?, ?content_type: String?, **untyped) -> void
1226
- def initialize(r_id: nil, rel_id: nil, path: nil, extension: nil, data: nil, ext: nil, filename: nil, content_type: nil, **extra)
1227
- rid = r_id || rel_id
1228
- e = extension || ext || extra[:ext]
1229
- d = data || extra[:file_data]
1230
- p = path || filename
1231
- super(r_id: rid, rel_id: rid, path: p, extension: e, data: d, ext: e, filename: p, content_type: content_type)
1232
- end
1233
-
1234
- undef_method :rel_id
1235
- undef_method :ext
1236
- undef_method :filename
1237
-
1238
- # @deprecated Use {#r_id} instead.
1239
- # @return [String, nil]
1240
- # @api public
1241
- #: () -> String?
1242
- def rel_id
1243
- warn "[Xlsxrb DEPRECATION] BackgroundImage#rel_id is deprecated; use #r_id instead.", uplevel: 1
1244
- r_id
1245
- end
1246
-
1247
- # @deprecated Use {#extension} instead.
1248
- # @return [String, nil]
1249
- # @api public
1250
- #: () -> String?
1251
- def ext
1252
- warn "[Xlsxrb DEPRECATION] BackgroundImage#ext is deprecated; use #extension instead.", uplevel: 1
1253
- extension
1254
- end
1255
-
1256
- # @deprecated Use {#path} instead.
1257
- # @return [String, nil]
1258
- # @api public
1259
- #: () -> String?
1260
- def filename
1261
- warn "[Xlsxrb DEPRECATION] BackgroundImage#filename is deprecated; use #path instead.", uplevel: 1
1262
- path
1091
+ #: (?r_id: String?, ?path: String?, ?extension: String?, ?data: String?, ?content_type: String?) -> void
1092
+ def initialize(r_id: nil, path: nil, extension: nil, data: nil, content_type: nil)
1093
+ super(**{ r_id: r_id, path: path, extension: extension, data: data, content_type: content_type })
1263
1094
  end
1264
1095
  end
1265
1096
 
@@ -1268,9 +1099,9 @@ module Xlsxrb
1268
1099
  TableStyles = Data.define(:default_table_style, :default_pivot_style, :styles) do
1269
1100
  include MetadataRecord
1270
1101
 
1271
- #: (?default_table_style: String?, ?default_pivot_style: String?, ?styles: Array[Hash[Symbol, untyped]]?, **untyped) -> void
1272
- def initialize(default_table_style: nil, default_pivot_style: nil, styles: nil, **_extra)
1273
- super(default_table_style: default_table_style, default_pivot_style: default_pivot_style, styles: styles)
1102
+ #: (?default_table_style: String?, ?default_pivot_style: String?, ?styles: Array[Hash[Symbol, untyped]]?) -> void
1103
+ def initialize(default_table_style: nil, default_pivot_style: nil, styles: nil)
1104
+ super(**{ default_table_style: default_table_style, default_pivot_style: default_pivot_style, styles: styles })
1274
1105
  end
1275
1106
  end
1276
1107
 
@@ -1279,9 +1110,9 @@ module Xlsxrb
1279
1110
  Colors = Data.define(:indexed, :mru) do
1280
1111
  include MetadataRecord
1281
1112
 
1282
- #: (?indexed: Array[String]?, ?mru: Array[Hash[Symbol, untyped]]?, **untyped) -> void
1283
- def initialize(indexed: nil, mru: nil, **_extra)
1284
- super(indexed: indexed, mru: mru)
1113
+ #: (?indexed: Array[String]?, ?mru: Array[Hash[Symbol, untyped]]?) -> void
1114
+ def initialize(indexed: nil, mru: nil)
1115
+ super(**{ indexed: indexed, mru: mru })
1285
1116
  end
1286
1117
  end
1287
1118
 
@@ -1290,9 +1121,9 @@ module Xlsxrb
1290
1121
  CustomProperty = Data.define(:name, :value, :type) do
1291
1122
  include MetadataRecord
1292
1123
 
1293
- #: (?name: String?, ?value: untyped, ?type: Symbol?, **untyped) -> void
1294
- def initialize(name: nil, value: nil, type: nil, **_extra)
1295
- super(name: name, value: value, type: type)
1124
+ #: (?name: String?, ?value: untyped, ?type: Symbol?) -> void
1125
+ def initialize(name: nil, value: nil, type: nil)
1126
+ super(**{ name: name, value: value, type: type })
1296
1127
  end
1297
1128
 
1298
1129
  # @return [String]
@@ -1302,14 +1133,11 @@ module Xlsxrb
1302
1133
  value.to_s
1303
1134
  end
1304
1135
 
1305
- # Matches against scalar values or hashes.
1136
+ # Matches against another CustomProperty or scalar value.
1306
1137
  #: (untyped other) -> bool
1307
1138
  def ==(other)
1308
1139
  if other.is_a?(CustomProperty)
1309
1140
  super
1310
- elsif other.is_a?(Hash)
1311
- warn "[Xlsxrb DEPRECATION] Comparing CustomProperty with Hash is deprecated; compare with CustomProperty instead.", uplevel: 1
1312
- to_h == other.transform_keys(&:to_sym).compact
1313
1141
  else
1314
1142
  value == other
1315
1143
  end
@@ -1318,26 +1146,14 @@ module Xlsxrb
1318
1146
 
1319
1147
  # AutoFilter column configuration (<filterColumn>).
1320
1148
  # @api public
1321
- FilterColumn = Data.define(:column_id, :filters, :custom_filters, :dynamic_filter, :top10, :color_filter, :icon_filter, :hidden, :show_button) do
1149
+ FilterColumn = Data.define(:column_id, :filters, :custom_filters, :dynamic_filter, :top10, :color_filter, :icon_filter, :hidden, :show_button, :blank, :custom_filters_and) do
1322
1150
  include MetadataRecord
1323
1151
 
1324
- #: (?column_id: Integer?, ?col_id: Integer?, ?filters: Array[untyped]?, ?custom_filters: Array[untyped]?, ?dynamic_filter: Hash[Symbol, untyped]?, ?top10: Hash[Symbol, untyped]?, ?color_filter: Hash[Symbol, untyped]?, ?icon_filter: Hash[Symbol, untyped]?, ?hidden: bool?, ?show_button: bool?, ?hidden_button: bool?, **untyped) -> void
1325
- def initialize(column_id: nil, col_id: nil, filters: nil, custom_filters: nil, dynamic_filter: nil, top10: nil, color_filter: nil, icon_filter: nil, hidden: false, show_button: true, hidden_button: nil, **extra)
1326
- if (!col_id.nil? || extra.key?(:col_id)) && column_id.nil?
1327
- warn "[Xlsxrb DEPRECATION] FilterColumn.new(col_id:) is deprecated and will be removed in v0.2.0. Use column_id: instead.", uplevel: 1
1328
- column_id = col_id || extra[:col_id]
1329
- end
1330
- h = hidden || hidden_button || false
1331
- super(column_id: column_id, filters: filters, custom_filters: custom_filters, dynamic_filter: dynamic_filter, top10: top10, color_filter: color_filter, icon_filter: icon_filter, hidden: h, show_button: show_button)
1332
- end
1152
+ private :hidden, :show_button
1333
1153
 
1334
- # @deprecated Use {#column_id} instead.
1335
- # @return [Integer, nil]
1336
- # @api public
1337
- #: () -> Integer?
1338
- def col_id
1339
- warn "[Xlsxrb DEPRECATION] FilterColumn#col_id is deprecated and will be removed in v0.2.0. Use #column_id instead.", uplevel: 1
1340
- column_id
1154
+ #: (?column_id: Integer?, ?filters: Array[untyped]?, ?custom_filters: Array[untyped]?, ?dynamic_filter: Hash[Symbol, untyped]?, ?top10: Hash[Symbol, untyped]?, ?color_filter: Hash[Symbol, untyped]?, ?icon_filter: Hash[Symbol, untyped]?, ?hidden: bool?, ?show_button: bool?, ?blank: bool?, ?custom_filters_and: bool?) -> void
1155
+ def initialize(column_id: nil, filters: nil, custom_filters: nil, dynamic_filter: nil, top10: nil, color_filter: nil, icon_filter: nil, hidden: false, show_button: true, blank: nil, custom_filters_and: nil)
1156
+ super(**{ column_id: column_id, filters: filters, custom_filters: custom_filters, dynamic_filter: dynamic_filter, top10: top10, color_filter: color_filter, icon_filter: icon_filter, hidden: hidden || false, show_button: show_button != false, blank: blank, custom_filters_and: custom_filters_and })
1341
1157
  end
1342
1158
 
1343
1159
  # Returns whether the filter column is hidden.
@@ -1355,6 +1171,54 @@ module Xlsxrb
1355
1171
  def show_button?
1356
1172
  show_button ? true : false
1357
1173
  end
1174
+
1175
+ # Builds a FilterColumn from the filter Hash that the reader and Worksheet#filter_column
1176
+ # use: { type: :filters, values: [...] }, { type: :custom, operator:, val: } or
1177
+ # { type: :custom, filters: [...] }, { type: :dynamic, ... }, { type: :top10, ... },
1178
+ # { type: :color_filter, ... }, or { type: :icon_filter, ... }. A Hash with member
1179
+ # keys and no :type is passed to new as is.
1180
+ #
1181
+ # @param column_id [Integer] 0-based column within the filter range.
1182
+ # @param spec [Hash]
1183
+ # @return [FilterColumn]
1184
+ # @raise [ArgumentError] for an unknown :type.
1185
+ # @api private
1186
+ #: (Integer column_id, Hash[Symbol, untyped] spec) -> FilterColumn
1187
+ def self.from_spec(column_id, spec)
1188
+ return new(column_id: column_id, **spec.except(:column_id)) unless spec.key?(:type)
1189
+
1190
+ base = { column_id: column_id, hidden: spec[:hidden] || spec[:hidden_button] || false, show_button: spec[:show_button] != false }
1191
+ detail = spec.except(:type, :hidden, :hidden_button, :show_button)
1192
+ case spec[:type].to_sym
1193
+ when :filters then new(**base, filters: Array(detail[:values]), blank: detail[:blank])
1194
+ when :custom then new(**base, custom_filters: detail[:filters] || [{ operator: detail[:operator], val: detail[:val] }], custom_filters_and: detail[:and])
1195
+ when :dynamic then new(**base, dynamic_filter: detail)
1196
+ when :top10 then new(**base, top10: detail)
1197
+ when :color_filter then new(**base, color_filter: detail)
1198
+ when :icon_filter then new(**base, icon_filter: detail)
1199
+ else raise ArgumentError, "unknown filter type: #{spec[:type].inspect}"
1200
+ end
1201
+ end
1202
+
1203
+ # Returns the filter Hash that the worksheet writer emits (see .from_spec).
1204
+ #
1205
+ # @return [Hash{Symbol => Object}]
1206
+ # @api private
1207
+ #: () -> Hash[Symbol, untyped]
1208
+ def to_spec
1209
+ spec = if (filters && !filters.empty?) || blank then { type: :filters, values: filters || [], blank: blank }.compact
1210
+ elsif custom_filters && custom_filters.size == 1 then { type: :custom, operator: custom_filters.first[:operator], val: custom_filters.first[:val] }
1211
+ elsif custom_filters && !custom_filters.empty? then { type: :custom, filters: custom_filters, and: custom_filters_and }.compact
1212
+ elsif dynamic_filter then { type: :dynamic, **dynamic_filter }
1213
+ elsif top10 then { type: :top10, **top10 }
1214
+ elsif color_filter then { type: :color_filter, **color_filter }
1215
+ elsif icon_filter then { type: :icon_filter, **icon_filter }
1216
+ else {}
1217
+ end
1218
+ spec[:hidden] = true if hidden?
1219
+ spec[:show_button] = false unless show_button?
1220
+ spec
1221
+ end
1358
1222
  end
1359
1223
 
1360
1224
  # Workbook defined name (<definedName>).
@@ -1362,14 +1226,11 @@ module Xlsxrb
1362
1226
  DefinedName = Data.define(:name, :value, :local_sheet_id, :local_sheet_name, :hidden, :comment) do
1363
1227
  include MetadataRecord
1364
1228
 
1365
- #: (?name: String?, ?value: String?, ?local_sheet_id: Integer?, ?local_sheet_name: String?, ?hidden: bool?, ?comment: String?, **untyped) -> void
1366
- def initialize(name: nil, value: nil, local_sheet_id: nil, local_sheet_name: nil, hidden: nil, comment: nil, **extra)
1367
- local_sheet_name ||= extra[:sheet]
1368
- value ||= extra[:formula]
1369
- if (value.nil? || (value.respond_to?(:empty?) && value.empty?)) && extra[:range]
1370
- value = local_sheet_name ? "'#{local_sheet_name}'!#{extra[:range]}" : extra[:range].to_s
1371
- end
1372
- super(name: name, value: value || "", local_sheet_id: local_sheet_id, local_sheet_name: local_sheet_name, hidden: hidden, comment: comment)
1229
+ private :hidden
1230
+
1231
+ #: (?name: String?, ?value: String?, ?local_sheet_id: Integer?, ?local_sheet_name: String?, ?hidden: bool?, ?comment: String?) -> void
1232
+ def initialize(name: nil, value: nil, local_sheet_id: nil, local_sheet_name: nil, hidden: nil, comment: nil)
1233
+ super(**{ name: name, value: value || "", local_sheet_id: local_sheet_id, local_sheet_name: local_sheet_name, hidden: hidden, comment: comment })
1373
1234
  end
1374
1235
 
1375
1236
  # Returns whether the defined name is hidden.
@@ -1393,15 +1254,10 @@ module Xlsxrb
1393
1254
  PageBreak = Data.define(:id, :max, :min, :man, :pt) do
1394
1255
  include MetadataRecord
1395
1256
 
1396
- #: (?id: Integer?, ?max: Integer?, ?min: Integer?, ?man: (Integer | bool)?, ?pt: bool?, ?manual: bool?, **untyped) -> void
1257
+ #: (?id: Integer?, ?max: Integer?, ?min: Integer?, ?man: (Integer | bool)?, ?pt: bool?) -> void
1397
1258
  # rubocop:disable Naming/MethodParameterName
1398
- def initialize(id: nil, max: nil, min: nil, man: nil, pt: nil, manual: nil, **_extra)
1399
- m = if manual.nil?
1400
- man
1401
- else
1402
- manual ? 1 : 0
1403
- end
1404
- super(id: id, max: max, min: min, man: m, pt: pt)
1259
+ def initialize(id: nil, max: nil, min: nil, man: nil, pt: nil)
1260
+ super(**{ id: id, max: max, min: min, man: man, pt: pt })
1405
1261
  end
1406
1262
  # rubocop:enable Naming/MethodParameterName
1407
1263
 
@@ -1415,23 +1271,22 @@ module Xlsxrb
1415
1271
  end
1416
1272
 
1417
1273
  # Cell comment or note (<comment>).
1274
+ #
1275
+ # +anchor+ places the comment box: the eight integers of the VML note's <x:Anchor>, that is
1276
+ # the left column, x offset, top row, y offset, right column, x offset, bottom row, and
1277
+ # y offset (0-based columns and rows, offsets in pixels). Without it, the box is placed
1278
+ # next to the cell.
1418
1279
  # @api public
1419
- Comment = Data.define(:ref, :text, :author, :r_id, :shape_id, :author_id, :visible) do
1280
+ Comment = Data.define(:ref, :text, :author, :r_id, :shape_id, :author_id, :visible, :anchor) do
1420
1281
  include MetadataRecord
1421
1282
 
1422
- #: (?ref: String?, ?cell: String?, ?text: String?, ?author: String?, ?r_id: String?, ?shape_id: Integer?, ?author_id: Integer?, ?visible: bool?, **untyped) -> void
1423
- def initialize(ref: nil, cell: nil, text: nil, author: nil, r_id: nil, shape_id: nil, author_id: nil, visible: false, **_extra)
1424
- r = ref || cell
1425
- super(ref: r, text: text, author: author, r_id: r_id, shape_id: shape_id, author_id: author_id, visible: visible)
1426
- end
1283
+ private :visible
1427
1284
 
1428
- # @deprecated Use {#ref} instead.
1429
- # @return [String, nil]
1430
- # @api public
1431
- #: () -> String?
1432
- def cell
1433
- warn "[Xlsxrb DEPRECATION] Comment#cell is deprecated; use #ref instead.", uplevel: 1
1434
- ref
1285
+ #: (?ref: String?, ?text: String?, ?author: String?, ?r_id: String?, ?shape_id: Integer?, ?author_id: Integer?, ?visible: bool?, ?anchor: Array[Integer]?) -> void
1286
+ def initialize(ref: nil, text: nil, author: nil, r_id: nil, shape_id: nil, author_id: nil, visible: false, anchor: nil)
1287
+ raise ArgumentError, "comment anchor must be an Array of 8 Integers, got #{anchor.inspect}" unless anchor.nil? || (anchor.is_a?(Array) && anchor.size == 8 && anchor.all?(Integer))
1288
+
1289
+ super(**{ ref: ref, text: text, author: author, r_id: r_id, shape_id: shape_id, author_id: author_id, visible: visible, anchor: anchor&.dup&.freeze })
1435
1290
  end
1436
1291
 
1437
1292
  # Returns whether the comment is visible by default.
@@ -1442,6 +1297,18 @@ module Xlsxrb
1442
1297
  visible ? true : false
1443
1298
  end
1444
1299
 
1300
+ # The anchor of a comment box without an explicit anchor: next to the cell at the
1301
+ # 0-based +column+ and +row+, two columns wide and four rows high.
1302
+ #
1303
+ # @param column [Integer]
1304
+ # @param row [Integer]
1305
+ # @return [Array<Integer>]
1306
+ # @api private
1307
+ #: (Integer column, Integer row) -> Array[Integer]
1308
+ def self.default_anchor(column, row)
1309
+ [column + 1, 15, row, 10, column + 3, 15, row + 4, 4]
1310
+ end
1311
+
1445
1312
  # Returns whether the comment has no text.
1446
1313
  #
1447
1314
  # @return [Boolean]
@@ -1461,40 +1328,18 @@ module Xlsxrb
1461
1328
 
1462
1329
  # Threaded comment (<threadedComment>).
1463
1330
  # @api public
1464
- ThreadedComment = Data.define(:id, :ref, :text, :author, :author_id, :created_at, :parent_id, :resolved) do
1331
+ ThreadedComment = Data.define(:id, :ref, :text, :author, :author_id, :created_at, :parent_id, :resolved, :provider_id) do
1465
1332
  include MetadataRecord
1466
1333
 
1467
- #: (?id: String?, ?ref: String?, ?cell: String?, ?text: String?, ?author: String?, ?author_id: String?, ?person_id: String?, ?created_at: untyped, ?timestamp: untyped, ?dt: untyped, ?parent_id: String?, ?resolved: bool?, ?done: bool?, **untyped) -> void
1468
- # rubocop:disable Naming/MethodParameterName
1334
+ private :resolved
1335
+
1336
+ #: (?id: String?, ?ref: String?, ?text: String?, ?author: String?, ?author_id: String?, ?created_at: untyped, ?parent_id: String?, ?resolved: bool?, ?provider_id: String?) -> void
1469
1337
  def initialize(
1470
- id: nil, ref: nil, cell: nil, text: nil, author: nil,
1471
- author_id: nil, person_id: nil, created_at: nil, timestamp: nil, dt: nil,
1472
- parent_id: nil, resolved: nil, done: nil, **_extra
1338
+ id: nil, ref: nil, text: nil, author: nil,
1339
+ author_id: nil, created_at: nil,
1340
+ parent_id: nil, resolved: nil, provider_id: nil
1473
1341
  )
1474
- r = ref || cell
1475
- res = resolved.nil? ? done : resolved
1476
- aid = author_id || person_id
1477
- cat = created_at || timestamp || dt
1478
- super(id: id, ref: r, text: text, author: author, author_id: aid, created_at: cat, parent_id: parent_id, resolved: res)
1479
- end
1480
- # rubocop:enable Naming/MethodParameterName
1481
-
1482
- # @deprecated Use {#ref} instead.
1483
- # @return [String, nil]
1484
- # @api public
1485
- #: () -> String?
1486
- def cell
1487
- warn "[Xlsxrb DEPRECATION] ThreadedComment#cell is deprecated; use #ref instead.", uplevel: 1
1488
- ref
1489
- end
1490
-
1491
- # @deprecated Use {#resolved} instead.
1492
- # @return [Boolean, nil]
1493
- # @api public
1494
- #: () -> bool?
1495
- def done
1496
- warn "[Xlsxrb DEPRECATION] ThreadedComment#done is deprecated; use #resolved instead.", uplevel: 1
1497
- resolved
1342
+ super(**{ id: id, ref: ref, text: text, author: author, author_id: author_id, created_at: created_at, parent_id: parent_id, resolved: resolved, provider_id: provider_id })
1498
1343
  end
1499
1344
 
1500
1345
  # Returns whether the threaded comment is resolved.
@@ -1505,15 +1350,6 @@ module Xlsxrb
1505
1350
  resolved ? true : false
1506
1351
  end
1507
1352
 
1508
- # @deprecated Use {#resolved?} instead.
1509
- # @return [Boolean]
1510
- # @api public
1511
- #: () -> bool
1512
- def done?
1513
- warn "[Xlsxrb DEPRECATION] ThreadedComment#done? is deprecated; use #resolved? instead.", uplevel: 1
1514
- resolved?
1515
- end
1516
-
1517
1353
  # @return [String]
1518
1354
  # @api public
1519
1355
  #: () -> String
@@ -1531,25 +1367,17 @@ module Xlsxrb
1531
1367
  ) do
1532
1368
  include MetadataRecord
1533
1369
 
1534
- #: (?sqref: String?, ?type: String?, ?error_style: String?, ?operator: String?, ?allow_blank: bool?, ?show_input_message: bool?, ?show_error_message: bool?, ?prompt_title: String?, ?prompt: String?, ?error_title: String?, ?error: String?, ?formula1: String?, ?formula2: String?, ?ime_mode: String?, ?show_drop_down: bool?, **untyped) -> void
1535
- def initialize(sqref: nil, type: nil, error_style: nil, operator: nil, allow_blank: nil, show_input_message: nil, show_error_message: nil, prompt_title: nil, prompt: nil, error_title: nil, error: nil, formula1: nil, formula2: nil, ime_mode: nil, show_drop_down: nil, **extra)
1536
- sdd = show_drop_down.nil? ? extra[:show_dropdown] : show_drop_down
1537
- super(
1370
+ private :allow_blank, :show_input_message, :show_error_message, :show_drop_down
1371
+
1372
+ #: (?sqref: String?, ?type: String?, ?error_style: String?, ?operator: String?, ?allow_blank: bool?, ?show_input_message: bool?, ?show_error_message: bool?, ?prompt_title: String?, ?prompt: String?, ?error_title: String?, ?error: String?, ?formula1: String?, ?formula2: String?, ?ime_mode: String?, ?show_drop_down: bool?) -> void
1373
+ def initialize(sqref: nil, type: nil, error_style: nil, operator: nil, allow_blank: nil, show_input_message: nil, show_error_message: nil, prompt_title: nil, prompt: nil, error_title: nil, error: nil, formula1: nil, formula2: nil, ime_mode: nil, show_drop_down: nil)
1374
+ super(**{
1538
1375
  sqref: sqref, type: type, error_style: error_style, operator: operator,
1539
1376
  allow_blank: allow_blank, show_input_message: show_input_message,
1540
1377
  show_error_message: show_error_message, prompt_title: prompt_title, prompt: prompt,
1541
1378
  error_title: error_title, error: error, formula1: formula1, formula2: formula2,
1542
- ime_mode: ime_mode, show_drop_down: sdd
1543
- )
1544
- end
1545
-
1546
- # @deprecated Use {#show_drop_down} instead.
1547
- # @return [Boolean, nil]
1548
- # @api public
1549
- #: () -> bool?
1550
- def show_dropdown
1551
- warn "[Xlsxrb DEPRECATION] DataValidation#show_dropdown is deprecated; use #show_drop_down instead.", uplevel: 1
1552
- show_drop_down
1379
+ ime_mode: ime_mode, show_drop_down: show_drop_down
1380
+ })
1553
1381
  end
1554
1382
 
1555
1383
  # Returns whether blank cells are allowed in validation.
@@ -1583,15 +1411,6 @@ module Xlsxrb
1583
1411
  def show_drop_down?
1584
1412
  show_drop_down ? true : false
1585
1413
  end
1586
-
1587
- # @deprecated Use {#show_drop_down?} instead.
1588
- # @return [Boolean]
1589
- # @api public
1590
- #: () -> bool
1591
- def show_dropdown?
1592
- warn "[Xlsxrb DEPRECATION] DataValidation#show_dropdown? is deprecated; use #show_drop_down? instead.", uplevel: 1
1593
- show_drop_down?
1594
- end
1595
1414
  end
1596
1415
 
1597
1416
  # Conditional formatting rule (<cfRule>).
@@ -1603,27 +1422,18 @@ module Xlsxrb
1603
1422
  ) do
1604
1423
  include MetadataRecord
1605
1424
 
1425
+ private :above_average, :equal_average, :bottom, :percent, :stop_if_true
1426
+
1606
1427
  #: (?type: (Symbol | String)?, ?dxf_id: Integer?, ?priority: Integer?, ?operator: (Symbol | String)?, ?formula: untyped, ?text: String?, ?time_period: (Symbol | String)?, ?rank: Integer?, ?std_dev: Integer?, ?above_average: bool?, ?equal_average: bool?, ?bottom: bool?, ?percent: bool?, ?stop_if_true: bool?, ?color_scale: Hash[Symbol, untyped]?, ?data_bar: Hash[Symbol, untyped]?, ?icon_set: Hash[Symbol, untyped]?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
1607
1428
  def initialize(type: nil, dxf_id: nil, priority: nil, operator: nil, formula: nil, text: nil, time_period: nil, rank: nil, std_dev: nil, above_average: nil, equal_average: nil, bottom: nil, percent: nil, stop_if_true: nil, color_scale: nil, data_bar: nil, icon_set: nil, options: nil, **extra)
1608
- dxf_id ||= extra.delete(:format_id)
1609
- f = formula || extra.delete(:formulas)
1610
1429
  opts = (options || {}).merge(extra)
1611
- super(
1612
- type: type, dxf_id: dxf_id, priority: priority, operator: operator, formula: f,
1430
+ super(**{
1431
+ type: type, dxf_id: dxf_id, priority: priority, operator: operator, formula: formula,
1613
1432
  text: text, time_period: time_period, rank: rank, std_dev: std_dev,
1614
1433
  above_average: above_average, equal_average: equal_average, bottom: bottom,
1615
1434
  percent: percent, stop_if_true: stop_if_true, color_scale: color_scale,
1616
1435
  data_bar: data_bar, icon_set: icon_set, options: opts.empty? ? nil : opts
1617
- )
1618
- end
1619
-
1620
- # @deprecated Use {#formula} instead.
1621
- # @return [Object]
1622
- # @api public
1623
- #: () -> untyped
1624
- def formulas
1625
- warn "[Xlsxrb DEPRECATION] ConditionalFormatRule#formulas is deprecated; use #formula instead.", uplevel: 1
1626
- formula
1436
+ })
1627
1437
  end
1628
1438
 
1629
1439
  # Returns whether rule matches above average values.
@@ -1677,31 +1487,22 @@ module Xlsxrb
1677
1487
  ) do
1678
1488
  include MetadataRecord
1679
1489
 
1490
+ private :above_average, :equal_average, :bottom, :percent, :stop_if_true, :pivot
1491
+
1680
1492
  #: (?sqref: String?, ?type: (Symbol | String)?, ?dxf_id: Integer?, ?priority: Integer?, ?operator: (Symbol | String)?, ?formula: untyped, ?text: String?, ?time_period: (Symbol | String)?, ?rank: Integer?, ?std_dev: Integer?, ?above_average: bool?, ?equal_average: bool?, ?bottom: bool?, ?percent: bool?, ?stop_if_true: bool?, ?color_scale: Hash[Symbol, untyped]?, ?data_bar: Hash[Symbol, untyped]?, ?icon_set: Hash[Symbol, untyped]?, ?pivot: bool?, ?rules: Array[untyped]?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
1681
1493
  def initialize(sqref: nil, type: nil, dxf_id: nil, priority: nil, operator: nil, formula: nil, text: nil, time_period: nil, rank: nil, std_dev: nil, above_average: nil, equal_average: nil, bottom: nil, percent: nil, stop_if_true: nil, color_scale: nil, data_bar: nil, icon_set: nil, pivot: nil, rules: nil, options: nil, **extra)
1682
- dxf_id ||= extra.delete(:format_id)
1683
- f = formula || extra.delete(:formulas)
1684
1494
  wrapped_rules = if rules && !rules.empty?
1685
1495
  rules.map { |r| r.is_a?(ConditionalFormatRule) ? r : ConditionalFormatRule.new(**r) }
1686
1496
  end
1687
1497
  opts = (options || {}).merge(extra)
1688
- super(
1689
- sqref: sqref, type: type, dxf_id: dxf_id, priority: priority, operator: operator, formula: f,
1498
+ super(**{
1499
+ sqref: sqref, type: type, dxf_id: dxf_id, priority: priority, operator: operator, formula: formula,
1690
1500
  text: text, time_period: time_period, rank: rank, std_dev: std_dev,
1691
1501
  above_average: above_average, equal_average: equal_average, bottom: bottom,
1692
1502
  percent: percent, stop_if_true: stop_if_true, color_scale: color_scale,
1693
1503
  data_bar: data_bar, icon_set: icon_set, pivot: pivot, rules: wrapped_rules,
1694
1504
  options: opts.empty? ? nil : opts
1695
- )
1696
- end
1697
-
1698
- # @deprecated Use {#formula} instead.
1699
- # @return [Object]
1700
- # @api public
1701
- #: () -> untyped
1702
- def formulas
1703
- warn "[Xlsxrb DEPRECATION] ConditionalFormat#formulas is deprecated; use #formula instead.", uplevel: 1
1704
- formula
1505
+ })
1705
1506
  end
1706
1507
 
1707
1508
  # Returns whether rule matches above average values.
@@ -1755,26 +1556,17 @@ module Xlsxrb
1755
1556
 
1756
1557
  # Column definition in an OpenXML table (<tableColumn>).
1757
1558
  # @api public
1758
- TableColumn = Data.define(:id, :name, :totals_row_function, :totals_row_label, :totals_row_formula, :data_dxf_id, :calculated_column_formula) do
1559
+ TableColumn = Data.define(:id, :name, :totals_row_function, :totals_row_label, :totals_row_formula, :data_dxf_id, :calculated_column_formula, :data_cell_style) do
1759
1560
  include MetadataRecord
1760
1561
 
1761
- #: (?id: Integer?, ?name: String?, ?totals_row_function: String?, ?totals_row_label: String?, ?totals_row_formula: String?, ?data_dxf_id: Integer?, ?calculated_column_formula: String?, ?data_formula: String?, **untyped) -> void
1762
- def initialize(id: nil, name: nil, totals_row_function: nil, totals_row_label: nil, totals_row_formula: nil, data_dxf_id: nil, calculated_column_formula: nil, data_formula: nil, **_extra)
1763
- super(
1562
+ #: (?id: Integer?, ?name: String?, ?totals_row_function: String?, ?totals_row_label: String?, ?totals_row_formula: String?, ?data_dxf_id: Integer?, ?calculated_column_formula: String?, ?data_cell_style: String?) -> void
1563
+ def initialize(id: nil, name: nil, totals_row_function: nil, totals_row_label: nil, totals_row_formula: nil, data_dxf_id: nil, calculated_column_formula: nil, data_cell_style: nil)
1564
+ super(**{
1764
1565
  id: id, name: name, totals_row_function: totals_row_function,
1765
1566
  totals_row_label: totals_row_label, totals_row_formula: totals_row_formula,
1766
1567
  data_dxf_id: data_dxf_id,
1767
- calculated_column_formula: calculated_column_formula || data_formula
1768
- )
1769
- end
1770
-
1771
- # @deprecated Use {#calculated_column_formula} instead.
1772
- # @return [String, nil]
1773
- # @api public
1774
- #: () -> String?
1775
- def data_formula
1776
- warn "[Xlsxrb DEPRECATION] TableColumn#data_formula is deprecated; use #calculated_column_formula instead.", uplevel: 1
1777
- calculated_column_formula
1568
+ calculated_column_formula: calculated_column_formula, data_cell_style: data_cell_style
1569
+ })
1778
1570
  end
1779
1571
  end
1780
1572
 
@@ -1783,12 +1575,14 @@ module Xlsxrb
1783
1575
  TableStyleInfo = Data.define(:name, :show_first_column, :show_last_column, :show_row_stripes, :show_column_stripes) do
1784
1576
  include MetadataRecord
1785
1577
 
1786
- #: (?name: String?, ?show_first_column: bool?, ?show_last_column: bool?, ?show_row_stripes: bool?, ?show_column_stripes: bool?, **untyped) -> void
1787
- def initialize(name: nil, show_first_column: nil, show_last_column: nil, show_row_stripes: nil, show_column_stripes: nil, **_extra)
1788
- super(
1578
+ private :show_first_column, :show_last_column, :show_row_stripes, :show_column_stripes
1579
+
1580
+ #: (?name: String?, ?show_first_column: bool?, ?show_last_column: bool?, ?show_row_stripes: bool?, ?show_column_stripes: bool?) -> void
1581
+ def initialize(name: nil, show_first_column: nil, show_last_column: nil, show_row_stripes: nil, show_column_stripes: nil)
1582
+ super(**{
1789
1583
  name: name, show_first_column: show_first_column, show_last_column: show_last_column,
1790
1584
  show_row_stripes: show_row_stripes, show_column_stripes: show_column_stripes
1791
- )
1585
+ })
1792
1586
  end
1793
1587
 
1794
1588
  # Returns whether first column is formatted distinctly.
@@ -1843,31 +1637,25 @@ module Xlsxrb
1843
1637
  end
1844
1638
  wrapped_cols = (columns || []).map { |c| c.is_a?(TableColumn) ? c : TableColumn.new(**c) }
1845
1639
  wrapped_si = style_info.is_a?(Hash) ? TableStyleInfo.new(**style_info) : style_info
1846
- super(
1640
+ super(**{
1847
1641
  id: id, name: name, display_name: display_name, ref: ref,
1848
1642
  totals_row_count: trc, header_row_count: hrc,
1849
1643
  columns: wrapped_cols, style_info: wrapped_si, auto_filter: auto_filter
1850
- )
1851
- end
1852
-
1853
- #: (Symbol | String key) -> untyped
1854
- def [](key)
1855
- warn "[DEPRECATION] Hash access on Elements::Table (`#[]`) is deprecated and will be removed in 0.2.0; use method calls instead.", uplevel: 1
1856
- k = key.is_a?(Symbol) ? key : key.to_s.to_sym
1857
- case k
1858
- when :style
1859
- style_info&.name
1860
- when :show_row_stripes
1861
- style_info&.show_row_stripes
1862
- when :show_first_column
1863
- style_info&.show_first_column
1864
- when :show_last_column
1865
- style_info&.show_last_column
1866
- when :show_column_stripes
1867
- style_info&.show_column_stripes
1868
- else
1869
- super
1870
- end
1644
+ })
1645
+ end
1646
+
1647
+ # Builds the style_info of a table hash whose style is given as :style: a style name with
1648
+ # the show_* flags at the root of the hash, or a Hash or TableStyleInfo as the reader returns.
1649
+ #
1650
+ # @param table [Hash{Symbol => Object}]
1651
+ # @return [Hash, Elements::TableStyleInfo, nil]
1652
+ # @api private
1653
+ #: (Hash[Symbol, untyped] table) -> (Hash[Symbol, untyped] | Elements::TableStyleInfo)?
1654
+ def self.style_info_from(table)
1655
+ style = table[:style]
1656
+ return style if style.nil? || style.is_a?(Hash) || style.is_a?(TableStyleInfo)
1657
+
1658
+ { name: style.to_s }.merge(table.slice(:show_first_column, :show_last_column, :show_row_stripes, :show_column_stripes))
1871
1659
  end
1872
1660
 
1873
1661
  # Returns whether the table totals row is shown.
@@ -1917,7 +1705,6 @@ module Xlsxrb
1917
1705
  def show_row_stripes?
1918
1706
  style_info ? style_info.show_row_stripes? : false
1919
1707
  end
1920
- alias_method :show_row_stripes, :show_row_stripes?
1921
1708
 
1922
1709
  # Returns whether column stripes are shown.
1923
1710
  # @return [Boolean]
@@ -1933,11 +1720,9 @@ module Xlsxrb
1933
1720
  Sparkline = Data.define(:sqref, :formula) do
1934
1721
  include MetadataRecord
1935
1722
 
1936
- #: (?sqref: String?, ?formula: String?, **untyped) -> void
1937
- def initialize(sqref: nil, formula: nil, **extra)
1938
- sqref ||= extra[:location_ref] || extra[:location]
1939
- formula ||= extra[:data_ref] || extra[:f] || extra[:data]
1940
- super(sqref: sqref, formula: formula)
1723
+ #: (?sqref: String?, ?formula: String?) -> void
1724
+ def initialize(sqref: nil, formula: nil)
1725
+ super(**{ sqref: sqref, formula: formula })
1941
1726
  end
1942
1727
  end
1943
1728
 
@@ -1951,48 +1736,20 @@ module Xlsxrb
1951
1736
  ) do
1952
1737
  include MetadataRecord
1953
1738
 
1739
+ private :markers, :high, :low, :first, :last, :negative
1740
+
1954
1741
  #: (?type: String?, ?color_series: String?, ?color_negative: String?, ?color_axis: String?, ?color_markers: String?, ?color_first: String?, ?color_last: String?, ?color_high: String?, ?color_low: String?, ?sparklines: Array[Elements::Sparkline | Hash[Symbol, untyped]]?, ?display_empty_cells_as: String?, ?markers: bool?, ?high: bool?, ?low: bool?, ?first: bool?, ?last: bool?, ?negative: bool?, ?manual_max: (Integer | Float)?, ?manual_min: (Integer | Float)?, ?line_weight: (Integer | Float)?, **untyped) -> void
1955
1742
  def initialize(type: nil, color_series: nil, color_negative: nil, color_axis: nil, color_markers: nil, color_first: nil, color_last: nil, color_high: nil, color_low: nil, sparklines: nil, display_empty_cells_as: nil, markers: nil, high: nil, low: nil, first: nil, last: nil, negative: nil, manual_max: nil, manual_min: nil, line_weight: nil, **extra)
1956
1743
  wrapped_sps = (sparklines || []).map { |s| s.is_a?(Sparkline) ? s : Sparkline.new(**s) }
1957
- disp = display_empty_cells_as || extra[:display_empty]
1958
- m_max = manual_max || extra[:max]
1959
- m_min = manual_min || extra[:min]
1960
1744
  lw = line_weight || extra[:line_weight]
1961
- super(
1745
+ super(**{
1962
1746
  type: type, color_series: color_series, color_negative: color_negative,
1963
1747
  color_axis: color_axis, color_markers: color_markers, color_first: color_first,
1964
1748
  color_last: color_last, color_high: color_high, color_low: color_low,
1965
- sparklines: wrapped_sps, display_empty_cells_as: disp,
1749
+ sparklines: wrapped_sps, display_empty_cells_as: display_empty_cells_as,
1966
1750
  markers: markers, high: high, low: low, first: first, last: last, negative: negative,
1967
- manual_max: m_max, manual_min: m_min, line_weight: lw
1968
- )
1969
- end
1970
-
1971
- # @deprecated Use {#display_empty_cells_as} instead.
1972
- # @return [String, nil]
1973
- # @api public
1974
- #: () -> String?
1975
- def display_empty
1976
- warn "[Xlsxrb DEPRECATION] SparklineGroup#display_empty is deprecated; use #display_empty_cells_as instead.", uplevel: 1
1977
- display_empty_cells_as
1978
- end
1979
-
1980
- # @deprecated Use {#manual_max} instead.
1981
- # @return [Integer, Float, nil]
1982
- # @api public
1983
- #: () -> (Integer | Float)?
1984
- def max
1985
- warn "[Xlsxrb DEPRECATION] SparklineGroup#max is deprecated; use #manual_max instead.", uplevel: 1
1986
- manual_max
1987
- end
1988
-
1989
- # @deprecated Use {#manual_min} instead.
1990
- # @return [Integer, Float, nil]
1991
- # @api public
1992
- #: () -> (Integer | Float)?
1993
- def min
1994
- warn "[Xlsxrb DEPRECATION] SparklineGroup#min is deprecated; use #manual_min instead.", uplevel: 1
1995
- manual_min
1751
+ manual_max: manual_max, manual_min: manual_min, line_weight: lw
1752
+ })
1996
1753
  end
1997
1754
 
1998
1755
  # Returns whether data markers are displayed.
@@ -2049,12 +1806,12 @@ module Xlsxrb
2049
1806
  ProtectedRange = Data.define(:name, :sqref, :security_descriptor, :password, :algorithm_name, :hash_value, :salt_value, :spin_count) do
2050
1807
  include MetadataRecord
2051
1808
 
2052
- #: (?name: String?, ?sqref: String?, ?security_descriptor: String?, ?password: String?, ?algorithm_name: String?, ?hash_value: String?, ?salt_value: String?, ?spin_count: Integer?, **untyped) -> void
2053
- def initialize(name: nil, sqref: nil, security_descriptor: nil, password: nil, algorithm_name: nil, hash_value: nil, salt_value: nil, spin_count: nil, **_extra)
2054
- super(
1809
+ #: (?name: String?, ?sqref: String?, ?security_descriptor: String?, ?password: String?, ?algorithm_name: String?, ?hash_value: String?, ?salt_value: String?, ?spin_count: Integer?) -> void
1810
+ def initialize(name: nil, sqref: nil, security_descriptor: nil, password: nil, algorithm_name: nil, hash_value: nil, salt_value: nil, spin_count: nil)
1811
+ super(**{
2055
1812
  name: name, sqref: sqref, security_descriptor: security_descriptor, password: password,
2056
1813
  algorithm_name: algorithm_name, hash_value: hash_value, salt_value: salt_value, spin_count: spin_count
2057
- )
1814
+ })
2058
1815
  end
2059
1816
  end
2060
1817
 
@@ -2067,14 +1824,16 @@ module Xlsxrb
2067
1824
  ) do
2068
1825
  include MetadataRecord
2069
1826
 
2070
- #: (?sqref: String?, ?eval_error: bool?, ?two_digit_text_year: bool?, ?number_stored_as_text: bool?, ?formula: bool?, ?formula_range: bool?, ?unlocked_formula: bool?, ?empty_cell_reference: bool?, ?list_data_validation: bool?, ?calculated_column: bool?, **untyped) -> void
2071
- def initialize(sqref: nil, eval_error: nil, two_digit_text_year: nil, number_stored_as_text: nil, formula: nil, formula_range: nil, unlocked_formula: nil, empty_cell_reference: nil, list_data_validation: nil, calculated_column: nil, **_extra)
2072
- super(
1827
+ private :eval_error, :two_digit_text_year, :number_stored_as_text, :formula, :formula_range, :unlocked_formula, :empty_cell_reference, :list_data_validation, :calculated_column
1828
+
1829
+ #: (?sqref: String?, ?eval_error: bool?, ?two_digit_text_year: bool?, ?number_stored_as_text: bool?, ?formula: bool?, ?formula_range: bool?, ?unlocked_formula: bool?, ?empty_cell_reference: bool?, ?list_data_validation: bool?, ?calculated_column: bool?) -> void
1830
+ def initialize(sqref: nil, eval_error: nil, two_digit_text_year: nil, number_stored_as_text: nil, formula: nil, formula_range: nil, unlocked_formula: nil, empty_cell_reference: nil, list_data_validation: nil, calculated_column: nil)
1831
+ super(**{
2073
1832
  sqref: sqref, eval_error: eval_error, two_digit_text_year: two_digit_text_year,
2074
1833
  number_stored_as_text: number_stored_as_text, formula: formula, formula_range: formula_range,
2075
1834
  unlocked_formula: unlocked_formula, empty_cell_reference: empty_cell_reference,
2076
1835
  list_data_validation: list_data_validation, calculated_column: calculated_column
2077
- )
1836
+ })
2078
1837
  end
2079
1838
 
2080
1839
  # Returns whether evaluation error check is ignored.
@@ -2160,79 +1919,17 @@ module Xlsxrb
2160
1919
  ) do
2161
1920
  include MetadataRecord
2162
1921
 
2163
- #: (?r_id: String?, ?name: String?, ?title: String?, ?type: String?, ?anchor: String?, ?from: untyped, ?to: untyped, ?series: Array[untyped]?, ?legend: untyped, ?category_axis: untyped, ?value_axis: untyped, ?secondary_value_axis: untyped, ?grouping: untyped, ?gap_width: untyped, ?overlap: untyped, ?target: untyped, ?from_column: untyped, ?from_row: untyped, ?to_column: untyped, ?to_row: untyped, ?data_labels: untyped?, ?cat_axis_title: String?, ?val_axis_title: String?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
2164
- def initialize(r_id: nil, name: nil, title: nil, type: nil, anchor: nil, from: nil, to: nil, series: nil, legend: nil, category_axis: nil, value_axis: nil, secondary_value_axis: nil, grouping: nil, gap_width: nil, overlap: nil, target: nil, from_column: nil, from_row: nil, to_column: nil, to_row: nil, data_labels: nil, cat_axis_title: nil, val_axis_title: nil, options: nil, **extra)
2165
- from_column ||= extra.delete(:from_col)
2166
- to_column ||= extra.delete(:to_col)
2167
- r_id ||= extra.delete(:rid)
2168
- type ||= extra.delete(:chart_type)
2169
- cat_title = cat_axis_title || extra.delete(:cat_axis_title)
2170
- val_title = val_axis_title || extra.delete(:val_axis_title)
2171
- category_axis ||= { title: cat_title } if cat_title
2172
- value_axis ||= { title: val_title } if val_title
1922
+ #: (?r_id: String?, ?name: String?, ?title: String?, ?type: String?, ?anchor: String?, ?from: untyped, ?to: untyped, ?series: Array[untyped]?, ?legend: untyped, ?category_axis: untyped, ?value_axis: untyped, ?secondary_value_axis: untyped, ?grouping: untyped, ?gap_width: untyped, ?overlap: untyped, ?target: untyped, ?from_column: untyped, ?from_row: untyped, ?to_column: untyped, ?to_row: untyped, ?data_labels: untyped?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
1923
+ def initialize(r_id: nil, name: nil, title: nil, type: nil, anchor: nil, from: nil, to: nil, series: nil, legend: nil, category_axis: nil, value_axis: nil, secondary_value_axis: nil, grouping: nil, gap_width: nil, overlap: nil, target: nil, from_column: nil, from_row: nil, to_column: nil, to_row: nil, data_labels: nil, options: nil, **extra)
2173
1924
  opts = (options || {}).merge(extra)
2174
- super(
1925
+ super(**{
2175
1926
  r_id: r_id, name: name, title: title, type: type, anchor: anchor, from: from, to: to,
2176
1927
  series: series, legend: legend, category_axis: category_axis, value_axis: value_axis,
2177
1928
  secondary_value_axis: secondary_value_axis, grouping: grouping, gap_width: gap_width,
2178
1929
  overlap: overlap, target: target, from_column: from_column, from_row: from_row,
2179
1930
  to_column: to_column, to_row: to_row, data_labels: data_labels,
2180
1931
  options: opts.empty? ? nil : opts
2181
- )
2182
- end
2183
-
2184
- # @deprecated Use {#category_axis}[:title] instead.
2185
- # @return [String, nil]
2186
- # @api public
2187
- #: () -> String?
2188
- def cat_axis_title
2189
- warn "[Xlsxrb DEPRECATION] Chart#cat_axis_title is deprecated and will be removed in v0.2.0. Use #category_axis[:title] instead.", uplevel: 1
2190
- category_axis&.[](:title) || options&.[](:cat_axis_title)
2191
- end
2192
-
2193
- # @deprecated Use {#value_axis}[:title] instead.
2194
- # @return [String, nil]
2195
- # @api public
2196
- #: () -> String?
2197
- def val_axis_title
2198
- warn "[Xlsxrb DEPRECATION] Chart#val_axis_title is deprecated and will be removed in v0.2.0. Use #value_axis[:title] instead.", uplevel: 1
2199
- value_axis&.[](:title) || options&.[](:val_axis_title)
2200
- end
2201
-
2202
- # @deprecated Use {#r_id} instead.
2203
- # @return [String, nil]
2204
- # @api public
2205
- #: () -> String?
2206
- def rid
2207
- warn "[Xlsxrb DEPRECATION] Chart#rid is deprecated; use #r_id instead.", uplevel: 1
2208
- r_id
2209
- end
2210
-
2211
- # @deprecated Use {#type} instead.
2212
- # @return [String, nil]
2213
- # @api public
2214
- #: () -> String?
2215
- def chart_type
2216
- warn "[Xlsxrb DEPRECATION] Chart#chart_type is deprecated; use #type instead.", uplevel: 1
2217
- type
2218
- end
2219
-
2220
- # @deprecated Use {#from_column} instead.
2221
- # @return [Object]
2222
- # @api public
2223
- #: () -> untyped
2224
- def from_col
2225
- warn "[Xlsxrb DEPRECATION] Chart#from_col is deprecated; use #from_column instead.", uplevel: 1
2226
- from_column
2227
- end
2228
-
2229
- # @deprecated Use {#to_column} instead.
2230
- # @return [Object]
2231
- # @api public
2232
- #: () -> untyped
2233
- def to_col
2234
- warn "[Xlsxrb DEPRECATION] Chart#to_col is deprecated; use #to_column instead.", uplevel: 1
2235
- to_column
1932
+ })
2236
1933
  end
2237
1934
  end
2238
1935
 
@@ -2244,18 +1941,18 @@ module Xlsxrb
2244
1941
  #: (?id: Integer?, ?name: String?, ?type: String?, ?anchor: String?, ?from: untyped, ?to: untyped, ?text: String?, ?preset: String?, ?width: (Float | Integer)?, ?height: (Float | Integer)?, ?left: (Float | Integer)?, ?top: (Float | Integer)?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
2245
1942
  def initialize(id: nil, name: nil, type: nil, anchor: nil, from: nil, to: nil, text: nil, preset: nil, width: nil, height: nil, left: nil, top: nil, options: nil, **extra)
2246
1943
  opts = (options || {}).merge(extra)
2247
- super(
1944
+ super(**{
2248
1945
  id: id, name: name, type: type, anchor: anchor, from: from, to: to,
2249
1946
  text: text, preset: preset, width: width, height: height, left: left, top: top,
2250
1947
  options: opts.empty? ? nil : opts
2251
- )
1948
+ })
2252
1949
  end
2253
1950
  end
2254
1951
 
2255
1952
  # Pivot table entry (<pivotTableDefinition>).
2256
1953
  # @api public
2257
1954
  PivotTable = Data.define(
2258
- :name, :ref, :location, :source_ref, :row_fields, :column_fields,
1955
+ :name, :ref, :source_ref, :row_fields, :column_fields,
2259
1956
  :data_fields, :page_fields, :data_caption, :page_wrap,
2260
1957
  :column_grand_totals, :row_grand_totals, :show_row_headers,
2261
1958
  :show_column_headers, :show_row_stripes, :show_column_stripes,
@@ -2263,37 +1960,27 @@ module Xlsxrb
2263
1960
  ) do
2264
1961
  include MetadataRecord
2265
1962
 
2266
- #: (?name: String?, ?ref: String?, ?location: String?, ?source_ref: String?, ?row_fields: Array[untyped]?, ?column_fields: Array[untyped]?, ?col_fields: Array[untyped]?, ?data_fields: Array[untyped]?, ?page_fields: Array[untyped]?, ?data_caption: String?, ?page_wrap: Integer?, ?column_grand_totals: bool?, ?row_grand_totals: bool?, ?show_row_headers: bool?, ?show_column_headers: bool?, ?show_row_stripes: bool?, ?show_column_stripes: bool?, ?cache: Hash[Symbol, untyped]?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
1963
+ private :column_grand_totals, :row_grand_totals, :show_row_headers, :show_column_headers, :show_row_stripes, :show_column_stripes
1964
+
1965
+ #: (?name: String?, ?ref: String?, ?source_ref: String?, ?row_fields: Array[untyped]?, ?column_fields: Array[untyped]?, ?data_fields: Array[untyped]?, ?page_fields: Array[untyped]?, ?data_caption: String?, ?page_wrap: Integer?, ?column_grand_totals: bool?, ?row_grand_totals: bool?, ?show_row_headers: bool?, ?show_column_headers: bool?, ?show_row_stripes: bool?, ?show_column_stripes: bool?, ?cache: Hash[Symbol, untyped]?, ?options: Hash[Symbol, untyped]?, **untyped) -> void
2267
1966
  def initialize(
2268
- name: nil, ref: nil, location: nil, source_ref: nil,
2269
- row_fields: nil, column_fields: nil, col_fields: nil, data_fields: nil, page_fields: nil,
1967
+ name: nil, ref: nil, source_ref: nil,
1968
+ row_fields: nil, column_fields: nil, data_fields: nil, page_fields: nil,
2270
1969
  data_caption: nil, page_wrap: nil, column_grand_totals: nil, row_grand_totals: nil,
2271
1970
  show_row_headers: nil, show_column_headers: nil, show_row_stripes: nil, show_column_stripes: nil,
2272
1971
  cache: nil, options: nil, **extra
2273
1972
  )
2274
- r = ref || location
2275
- cols = column_fields || col_fields || []
1973
+ cols = column_fields || []
2276
1974
  merged_opts = (options || {}).merge(extra).freeze
2277
- super(
2278
- name: name, ref: r, location: r, source_ref: source_ref,
1975
+ super(**{
1976
+ name: name, ref: ref, source_ref: source_ref,
2279
1977
  row_fields: row_fields, column_fields: cols, data_fields: data_fields, page_fields: page_fields,
2280
1978
  data_caption: data_caption, page_wrap: page_wrap,
2281
1979
  column_grand_totals: column_grand_totals, row_grand_totals: row_grand_totals,
2282
1980
  show_row_headers: show_row_headers, show_column_headers: show_column_headers,
2283
1981
  show_row_stripes: show_row_stripes, show_column_stripes: show_column_stripes,
2284
1982
  cache: cache, options: merged_opts.empty? ? nil : merged_opts
2285
- )
2286
- end
2287
-
2288
- undef_method :location
2289
-
2290
- # @deprecated Use {#ref} instead.
2291
- # @return [String, nil]
2292
- # @api public
2293
- #: () -> String?
2294
- def location
2295
- warn "[Xlsxrb DEPRECATION] PivotTable#location is deprecated; use #ref instead.", uplevel: 1
2296
- ref
1983
+ })
2297
1984
  end
2298
1985
 
2299
1986
  # Returns whether column grand totals are displayed.
@@ -2350,63 +2037,24 @@ module Xlsxrb
2350
2037
  HeaderFooterImage = Data.define(:position, :r_id, :path, :extension, :data, :content_type) do
2351
2038
  include MetadataRecord
2352
2039
 
2353
- #: (?position: String?, ?r_id: String?, ?path: String?, ?extension: String?, ?data: String?, ?content_type: String?, **untyped) -> void
2354
- def initialize(position: nil, r_id: nil, path: nil, extension: nil, data: nil, content_type: nil, **extra)
2355
- rid = r_id || extra[:rid]
2356
- ext = extension || extra[:ext]
2357
- p = path || extra[:filename]
2358
- ct = content_type || extra[:content_type]
2359
- super(position: position, r_id: rid, path: p, extension: ext, data: data, content_type: ct)
2360
- end
2361
-
2362
- # @deprecated Use {#extension} instead.
2363
- # @return [String, nil]
2364
- # @api public
2365
- #: () -> String?
2366
- def ext
2367
- warn "[Xlsxrb DEPRECATION] HeaderFooterImage#ext is deprecated; use #extension instead.", uplevel: 1
2368
- extension
2369
- end
2370
-
2371
- # @deprecated Use {#path} instead.
2372
- # @return [String, nil]
2373
- # @api public
2374
- #: () -> String?
2375
- def filename
2376
- warn "[Xlsxrb DEPRECATION] HeaderFooterImage#filename is deprecated; use #path instead.", uplevel: 1
2377
- path
2378
- end
2379
-
2380
- # @deprecated Use {#r_id} instead.
2381
- # @return [String, nil]
2382
- # @api public
2383
- #: () -> String?
2384
- def rid
2385
- warn "[Xlsxrb DEPRECATION] HeaderFooterImage#rid is deprecated; use #r_id instead.", uplevel: 1
2386
- r_id
2040
+ #: (?position: String?, ?r_id: String?, ?path: String?, ?extension: String?, ?data: String?, ?content_type: String?) -> void
2041
+ def initialize(position: nil, r_id: nil, path: nil, extension: nil, data: nil, content_type: nil)
2042
+ super(**{ position: position, r_id: r_id, path: path, extension: extension, data: data, content_type: content_type })
2387
2043
  end
2388
2044
  end
2389
2045
 
2390
2046
  # Font style definition in stylesheet (<font>).
2391
2047
  # @api public
2392
2048
  # rubocop:disable Lint/DataDefineOverride
2393
- Font = Data.define(:name, :size, :bold, :italic, :underline, :strike, :color, :family, :scheme, :outline, :shadow, :condense, :extend) do
2049
+ Font = Data.define(:name, :size, :bold, :italic, :underline, :strike, :color, :family, :scheme, :outline, :shadow, :condense, :extend, :vert_align) do
2394
2050
  # rubocop:enable Lint/DataDefineOverride
2395
2051
  include MetadataRecord
2396
2052
 
2397
- #: (?name: String?, ?size: (Integer | Float)?, ?bold: bool?, ?italic: bool?, ?underline: (String | bool)?, ?strike: bool?, ?color: Hash[Symbol, untyped]?, ?family: Integer?, ?scheme: String?, ?outline: bool?, ?shadow: bool?, ?condense: bool?, ?extend: bool?, **untyped) -> void
2398
- def initialize(name: nil, size: nil, bold: nil, italic: nil, underline: nil, strike: nil, color: nil, family: nil, scheme: nil, outline: nil, shadow: nil, condense: nil, extend: nil, **extra)
2399
- sz = size || extra[:sz]
2400
- super(name: name, size: sz, bold: bold, italic: italic, underline: underline, strike: strike, color: color, family: family, scheme: scheme, outline: outline, shadow: shadow, condense: condense, extend: extend)
2401
- end
2053
+ private :bold, :italic, :strike, :outline, :shadow, :condense, :extend
2402
2054
 
2403
- # @deprecated Use {#size} instead.
2404
- # @return [Integer, Float, nil]
2405
- # @api public
2406
- #: () -> (Integer | Float)?
2407
- def sz
2408
- warn "[Xlsxrb DEPRECATION] Font#sz is deprecated; use #size instead.", uplevel: 1
2409
- size
2055
+ #: (?name: String?, ?size: (Integer | Float)?, ?bold: bool?, ?italic: bool?, ?underline: (String | bool)?, ?strike: bool?, ?color: Hash[Symbol, untyped]?, ?family: Integer?, ?scheme: String?, ?outline: bool?, ?shadow: bool?, ?condense: bool?, ?extend: bool?, ?vert_align: String?) -> void
2056
+ def initialize(name: nil, size: nil, bold: nil, italic: nil, underline: nil, strike: nil, color: nil, family: nil, scheme: nil, outline: nil, shadow: nil, condense: nil, extend: nil, vert_align: nil)
2057
+ super(**{ name: name, size: size, bold: bold, italic: italic, underline: underline, strike: strike, color: color, family: family, scheme: scheme, outline: outline, shadow: shadow, condense: condense, extend: extend, vert_align: vert_align })
2410
2058
  end
2411
2059
 
2412
2060
  # Returns whether the font is bold.
@@ -2467,23 +2115,16 @@ module Xlsxrb
2467
2115
  end
2468
2116
 
2469
2117
  # Fill style definition in stylesheet (<fill>).
2118
+ #
2119
+ # +gradient+ describes a <gradientFill> in place of a pattern: { type:, degree:, left:, right:,
2120
+ # top:, bottom:, stops: [{ position:, color: { rgb: | theme:, tint: } }] }.
2470
2121
  # @api public
2471
- Fill = Data.define(:pattern_type, :fg_color, :bg_color) do
2122
+ Fill = Data.define(:pattern_type, :fg_color, :bg_color, :gradient) do
2472
2123
  include MetadataRecord
2473
2124
 
2474
- #: (?pattern_type: String?, ?fg_color: Hash[Symbol, untyped]?, ?bg_color: Hash[Symbol, untyped]?, **untyped) -> void
2475
- def initialize(pattern_type: nil, fg_color: nil, bg_color: nil, **extra)
2476
- pt = pattern_type || extra[:pattern]
2477
- super(pattern_type: pt, fg_color: fg_color, bg_color: bg_color)
2478
- end
2479
-
2480
- # @deprecated Use {#pattern_type} instead.
2481
- # @return [String, nil]
2482
- # @api public
2483
- #: () -> String?
2484
- def pattern
2485
- warn "[Xlsxrb DEPRECATION] Fill#pattern is deprecated; use #pattern_type instead.", uplevel: 1
2486
- pattern_type
2125
+ #: (?pattern_type: String?, ?fg_color: Hash[Symbol, untyped]?, ?bg_color: Hash[Symbol, untyped]?, ?gradient: Hash[Symbol, untyped]?) -> void
2126
+ def initialize(pattern_type: nil, fg_color: nil, bg_color: nil, gradient: nil)
2127
+ super(**{ pattern_type: pattern_type, fg_color: fg_color, bg_color: bg_color, gradient: gradient })
2487
2128
  end
2488
2129
  end
2489
2130
 
@@ -2492,9 +2133,11 @@ module Xlsxrb
2492
2133
  Border = Data.define(:left, :right, :top, :bottom, :diagonal, :diagonal_up, :diagonal_down) do
2493
2134
  include MetadataRecord
2494
2135
 
2495
- #: (?left: Hash[Symbol, untyped]?, ?right: Hash[Symbol, untyped]?, ?top: Hash[Symbol, untyped]?, ?bottom: Hash[Symbol, untyped]?, ?diagonal: Hash[Symbol, untyped]?, ?diagonal_up: bool?, ?diagonal_down: bool?, **untyped) -> void
2496
- def initialize(left: nil, right: nil, top: nil, bottom: nil, diagonal: nil, diagonal_up: nil, diagonal_down: nil, **_extra)
2497
- super(left: left, right: right, top: top, bottom: bottom, diagonal: diagonal, diagonal_up: diagonal_up, diagonal_down: diagonal_down)
2136
+ private :diagonal_up, :diagonal_down
2137
+
2138
+ #: (?left: Hash[Symbol, untyped]?, ?right: Hash[Symbol, untyped]?, ?top: Hash[Symbol, untyped]?, ?bottom: Hash[Symbol, untyped]?, ?diagonal: Hash[Symbol, untyped]?, ?diagonal_up: bool?, ?diagonal_down: bool?) -> void
2139
+ def initialize(left: nil, right: nil, top: nil, bottom: nil, diagonal: nil, diagonal_up: nil, diagonal_down: nil)
2140
+ super(**{ left: left, right: right, top: top, bottom: bottom, diagonal: diagonal, diagonal_up: diagonal_up, diagonal_down: diagonal_down })
2498
2141
  end
2499
2142
 
2500
2143
  # Returns whether diagonal up border is enabled.
@@ -2522,9 +2165,11 @@ module Xlsxrb
2522
2165
  ) do
2523
2166
  include MetadataRecord
2524
2167
 
2525
- #: (?horizontal: (String | Symbol)?, ?vertical: (String | Symbol)?, ?wrap_text: bool?, ?text_rotation: Numeric?, ?indent: Integer?, ?relative_indent: Integer?, ?shrink_to_fit: bool?, ?reading_order: Integer?, ?justify_last_line: bool?, **untyped) -> void
2526
- def initialize(horizontal: nil, vertical: nil, wrap_text: nil, text_rotation: nil, indent: nil, relative_indent: nil, shrink_to_fit: nil, reading_order: nil, justify_last_line: nil, **_extra)
2527
- super(horizontal: horizontal, vertical: vertical, wrap_text: wrap_text, text_rotation: text_rotation, indent: indent, relative_indent: relative_indent, shrink_to_fit: shrink_to_fit, reading_order: reading_order, justify_last_line: justify_last_line)
2168
+ private :wrap_text, :shrink_to_fit, :justify_last_line
2169
+
2170
+ #: (?horizontal: (String | Symbol)?, ?vertical: (String | Symbol)?, ?wrap_text: bool?, ?text_rotation: Numeric?, ?indent: Integer?, ?relative_indent: Integer?, ?shrink_to_fit: bool?, ?reading_order: Integer?, ?justify_last_line: bool?) -> void
2171
+ def initialize(horizontal: nil, vertical: nil, wrap_text: nil, text_rotation: nil, indent: nil, relative_indent: nil, shrink_to_fit: nil, reading_order: nil, justify_last_line: nil)
2172
+ super(**{ horizontal: horizontal, vertical: vertical, wrap_text: wrap_text, text_rotation: text_rotation, indent: indent, relative_indent: relative_indent, shrink_to_fit: shrink_to_fit, reading_order: reading_order, justify_last_line: justify_last_line })
2528
2173
  end
2529
2174
 
2530
2175
  # Returns whether text wrapping is enabled.
@@ -2557,9 +2202,11 @@ module Xlsxrb
2557
2202
  Protection = Data.define(:locked, :hidden) do
2558
2203
  include MetadataRecord
2559
2204
 
2560
- #: (?locked: bool?, ?hidden: bool?, **untyped) -> void
2561
- def initialize(locked: nil, hidden: nil, **_extra)
2562
- super(locked: locked, hidden: hidden)
2205
+ private :locked, :hidden
2206
+
2207
+ #: (?locked: bool?, ?hidden: bool?) -> void
2208
+ def initialize(locked: nil, hidden: nil)
2209
+ super(**{ locked: locked, hidden: hidden })
2563
2210
  end
2564
2211
 
2565
2212
  # Returns whether the cell is locked.
@@ -2589,31 +2236,24 @@ module Xlsxrb
2589
2236
  ) do
2590
2237
  include MetadataRecord
2591
2238
 
2592
- #: (?num_fmt_id: Integer?, ?font_id: Integer?, ?fill_id: Integer?, ?border_id: Integer?, ?xf_id: Integer?, ?apply_number_format: bool?, ?apply_font: bool?, ?apply_fill: bool?, ?apply_border: bool?, ?apply_alignment: bool?, ?apply_protection: bool?, ?alignment: (Elements::Alignment | Hash[Symbol, untyped])?, ?protection: (Elements::Protection | Hash[Symbol, untyped])?, ?quote_prefix: bool?, ?pivot_button: bool?, **untyped) -> void
2239
+ private :apply_number_format, :apply_font, :apply_fill, :apply_border, :apply_alignment, :apply_protection, :quote_prefix, :pivot_button
2240
+
2241
+ #: (?num_fmt_id: Integer?, ?font_id: Integer?, ?fill_id: Integer?, ?border_id: Integer?, ?xf_id: Integer?, ?apply_number_format: bool?, ?apply_font: bool?, ?apply_fill: bool?, ?apply_border: bool?, ?apply_alignment: bool?, ?apply_protection: bool?, ?alignment: (Elements::Alignment | Hash[Symbol, untyped])?, ?protection: (Elements::Protection | Hash[Symbol, untyped])?, ?quote_prefix: bool?, ?pivot_button: bool?) -> void
2593
2242
  def initialize(
2594
2243
  num_fmt_id: nil, font_id: nil, fill_id: nil, border_id: nil, xf_id: nil,
2595
2244
  apply_number_format: nil, apply_font: nil, apply_fill: nil, apply_border: nil,
2596
2245
  apply_alignment: nil, apply_protection: nil, alignment: nil, protection: nil,
2597
- quote_prefix: nil, pivot_button: nil, **_extra
2246
+ quote_prefix: nil, pivot_button: nil
2598
2247
  )
2599
2248
  align_obj = alignment.is_a?(Hash) ? Alignment.new(**alignment) : alignment
2600
2249
  prot_obj = protection.is_a?(Hash) ? Protection.new(**protection) : protection
2601
- super(
2250
+ super(**{
2602
2251
  num_fmt_id: num_fmt_id, font_id: font_id, fill_id: fill_id, border_id: border_id,
2603
2252
  xf_id: xf_id, apply_number_format: apply_number_format, apply_font: apply_font,
2604
2253
  apply_fill: apply_fill, apply_border: apply_border, apply_alignment: apply_alignment,
2605
2254
  apply_protection: apply_protection, alignment: align_obj, protection: prot_obj,
2606
2255
  quote_prefix: quote_prefix, pivot_button: pivot_button
2607
- )
2608
- end
2609
-
2610
- # @deprecated Use {#num_fmt_id} instead.
2611
- # @return [Integer, nil]
2612
- # @api public
2613
- #: () -> Integer?
2614
- def number_format_id
2615
- warn "[Xlsxrb DEPRECATION] CellXf#number_format_id is deprecated; use #num_fmt_id instead.", uplevel: 1
2616
- num_fmt_id
2256
+ })
2617
2257
  end
2618
2258
 
2619
2259
  # Returns whether quote prefix is enabled.
@@ -2686,25 +2326,16 @@ module Xlsxrb
2686
2326
  Dxf = Data.define(:font, :fill, :border, :number_format, :alignment, :protection) do
2687
2327
  include MetadataRecord
2688
2328
 
2689
- #: (?font: (Elements::Font | Hash[Symbol, untyped])?, ?fill: (Elements::Fill | Hash[Symbol, untyped])?, ?border: (Elements::Border | Hash[Symbol, untyped])?, ?number_format: Hash[Symbol, untyped]?, ?alignment: (Elements::Alignment | Hash[Symbol, untyped])?, ?protection: (Elements::Protection | Hash[Symbol, untyped])?, **untyped) -> void
2690
- def initialize(font: nil, fill: nil, border: nil, number_format: nil, alignment: nil, protection: nil, **extra)
2691
- nf = number_format
2692
- if (extra.key?(:num_fmt) || extra.key?("num_fmt")) && nf.nil?
2693
- Xlsxrb::Deprecation.warn("Dxf keyword :num_fmt is deprecated; use :number_format instead.", uplevel: 1)
2694
- nf = extra[:num_fmt] || extra["num_fmt"]
2695
- end
2329
+ #: (?font: (Elements::Font | Hash[Symbol, untyped])?, ?fill: (Elements::Fill | Hash[Symbol, untyped])?, ?border: (Elements::Border | Hash[Symbol, untyped])?, ?number_format: Hash[Symbol, untyped]?, ?alignment: (Elements::Alignment | Hash[Symbol, untyped])?, ?protection: (Elements::Protection | Hash[Symbol, untyped])?) -> void
2330
+ def initialize(font: nil, fill: nil, border: nil, number_format: nil, alignment: nil, protection: nil)
2696
2331
  f = font.is_a?(Hash) ? Font.new(**font) : font
2332
+ # Differential fills from the styles reader name the pattern :pattern only.
2333
+ fill = fill.merge(pattern_type: fill[:pattern]).except(:pattern) if fill.is_a?(Hash) && fill.key?(:pattern) && !fill.key?(:pattern_type)
2697
2334
  fi = fill.is_a?(Hash) ? Fill.new(**fill) : fill
2698
2335
  b = border.is_a?(Hash) ? Border.new(**border) : border
2699
2336
  align = alignment.is_a?(Hash) ? Alignment.new(**alignment) : alignment
2700
2337
  prot = protection.is_a?(Hash) ? Protection.new(**protection) : protection
2701
- super(font: f, fill: fi, border: b, number_format: nf, alignment: align, protection: prot)
2702
- end
2703
-
2704
- # @deprecated Use {#number_format} instead. Will be removed in 0.2.0.
2705
- def num_fmt
2706
- Xlsxrb::Deprecation.warn("Dxf#num_fmt is deprecated; use Dxf#number_format instead.", uplevel: 1)
2707
- number_format
2338
+ super(**{ font: f, fill: fi, border: b, number_format: number_format, alignment: align, protection: prot })
2708
2339
  end
2709
2340
  end
2710
2341
 
@@ -2713,9 +2344,9 @@ module Xlsxrb
2713
2344
  CellStyle = Data.define(:name, :xf_id, :builtin_id) do
2714
2345
  include MetadataRecord
2715
2346
 
2716
- #: (?name: String?, ?xf_id: Integer?, ?builtin_id: Integer?, **untyped) -> void
2717
- def initialize(name: nil, xf_id: nil, builtin_id: nil, **_extra)
2718
- super(name: name, xf_id: xf_id, builtin_id: builtin_id)
2347
+ #: (?name: String?, ?xf_id: Integer?, ?builtin_id: Integer?) -> void
2348
+ def initialize(name: nil, xf_id: nil, builtin_id: nil)
2349
+ super(**{ name: name, xf_id: xf_id, builtin_id: builtin_id })
2719
2350
  end
2720
2351
  end
2721
2352
 
@@ -2724,10 +2355,25 @@ module Xlsxrb
2724
2355
  Color = Data.define(:rgb, :indexed, :theme, :tint) do
2725
2356
  include MetadataRecord
2726
2357
 
2727
- #: (?rgb: String?, ?indexed: Integer?, ?theme: Integer?, ?tint: Float?, **untyped) -> void
2728
- def initialize(rgb: nil, indexed: nil, theme: nil, tint: nil, **_extra)
2729
- super(rgb: rgb, indexed: indexed, theme: theme, tint: tint)
2358
+ #: (?rgb: String?, ?indexed: Integer?, ?theme: Integer?, ?tint: Float?) -> void
2359
+ def initialize(rgb: nil, indexed: nil, theme: nil, tint: nil)
2360
+ super(**{ rgb: rgb, indexed: indexed, theme: theme, tint: tint })
2730
2361
  end
2731
2362
  end
2363
+
2364
+ # Old key names that readers and builders still emit next to the member they were renamed to
2365
+ # (see StrictKeywords).
2366
+ FreezePane::KEY_ALIASES = { col: :column }.freeze
2367
+ SplitPane::KEY_ALIASES = { row: :y_split, column: :x_split, col: :x_split }.freeze
2368
+ SheetFormat::KEY_ALIASES = { default_col_width: :default_column_width, base_col_width: :base_column_width, outline_level_col: :outline_level_column }.freeze
2369
+ Sparkline::KEY_ALIASES = { data_ref: :formula, location_ref: :sqref }.freeze
2370
+ AppProperties::KEY_ALIASES = { application: :app_name }.freeze
2371
+ WorkbookProperties::KEY_ALIASES = { active_sheet_index: :active_sheet }.freeze
2372
+ TableColumn::KEY_ALIASES = { data_formula: :calculated_column_formula }.freeze
2373
+ Font::KEY_ALIASES = { sz: :size }.freeze
2374
+ Fill::KEY_ALIASES = { pattern: :pattern_type }.freeze
2375
+ BackgroundImage::KEY_ALIASES = { ext: :extension, filename: :path, file_data: :data }.freeze
2376
+ WorkbookProtection::KEY_ALIASES = { password: :workbook_password }.freeze
2377
+ ThreadedComment::KEY_ALIASES = { dt: :created_at, timestamp: :created_at, done: :resolved, person_id: :author_id, user_id: :author_id }.freeze
2732
2378
  end
2733
2379
  end