| 1 | =begin comment | ||
| 2 | |||
| 3 | Copyright (c) 2026 Aspose.Cells Cloud | ||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 5 | of this software and associated documentation files (the "Software"), to deal | ||
| 6 | in the Software without restriction, including without limitation the rights | ||
| 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 8 | copies of the Software, and to permit persons to whom the Software is | ||
| 9 | furnished to do so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in all | ||
| 12 | copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 20 | SOFTWARE. | ||
| 21 | |||
| 22 | =end comment | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | package AsposeCellsCloud::Object::ListObject; | ||
| 27 | |||
| 28 | require 5.6.0; | ||
| 29 | use strict; | ||
| 30 | use warnings; | ||
| 31 | use utf8; | ||
| 32 | use JSON qw(decode_json); | ||
| 33 | use Data::Dumper; | ||
| 34 | use Module::Runtime qw(use_module); | ||
| 35 | use Log::Any qw($log); | ||
| 36 | use Date::Parse; | ||
| 37 | use DateTime; | ||
| 38 | use AsposeCellsCloud::Object::AutoFilter; | ||
| 39 | use AsposeCellsCloud::Object::Link; | ||
| 40 | use AsposeCellsCloud::Object::LinkElement; | ||
| 41 | use AsposeCellsCloud::Object::ListColumn; | ||
| 42 | use AsposeCellsCloud::Object::Range; | ||
| 43 | use AsposeCellsCloud::Object::XmlMap; | ||
| 44 | |||
| 45 | |||
| 46 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 51 | __PACKAGE__->mk_classdata('swagger_types' => {}); | ||
| 52 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 53 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 54 | |||
| 55 | # new object | ||
| 56 | sub new { | ||
| 57 | my ($class, %args) = @_; | ||
| 58 | |||
| 59 | my $self = bless {}, $class; | ||
| 60 | |||
| 61 | foreach my $attribute (keys %{$class->attribute_map}) { | ||
| 62 | my $args_key = $class->attribute_map->{$attribute}; | ||
| 63 | $self->$attribute( $args{ $args_key } ); | ||
| 64 | } | ||
| 65 | |||
| 66 | return $self; | ||
| 67 | } | ||
| 68 | |||
| 69 | # return perl hash | ||
| 70 | sub to_hash { | ||
| 71 | return decode_json(JSON->new->convert_blessed->encode( shift )); | ||
| 72 | } | ||
| 73 | |||
| 74 | # used by JSON for serialization | ||
| 75 | sub TO_JSON { | ||
| 76 | my $self = shift; | ||
| 77 | my $_data = {}; | ||
| 78 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 79 | if (defined $self->{$_key}) { | ||
| 80 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | return $_data; | ||
| 84 | } | ||
| 85 | |||
| 86 | # from Perl hashref | ||
| 87 | sub from_hash { | ||
| 88 | my ($self, $hash) = @_; | ||
| 89 | |||
| 90 | # loop through attributes and use swagger_types to deserialize the data | ||
| 91 | while ( my ($_key, $_type) = each %{$self->swagger_types} ) { | ||
| 92 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 93 | if ($_type =~ /^array\[/i) { # array | ||
| 94 | my $_subclass = substr($_type, 6, -1); | ||
| 95 | my @_array = (); | ||
| 96 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 97 | push @_array, $self->_deserialize($_subclass, $_element); | ||
| 98 | } | ||
| 99 | $self->{$_key} = \@_array; | ||
| 100 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 101 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); | ||
| 102 | } else { | ||
| 103 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | return $self; | ||
| 108 | } | ||
| 109 | |||
| 110 | # deserialize non-array data | ||
| 111 | sub _deserialize { | ||
| 112 | my ($self, $type, $data) = @_; | ||
| 113 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 114 | |||
| 115 | if ($type eq 'DateTime') { | ||
| 116 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 117 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 118 | return $data; | ||
| 119 | } else { # hash(model) | ||
| 120 | my $_instance = eval "AsposeCellsCloud::Object::$type->new()"; | ||
| 121 | return $_instance->from_hash($data); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | |||
| 126 | __PACKAGE__->class_documentation({description => 'Represents a list object on a worksheet. The ListObject object is a member of the ListObjects collection. The ListObjects collection contains all the list objects on a worksheet.', | ||
| 127 | class => 'ListObject', | ||
| 128 | required => [], # TODO | ||
| 129 | } ); | ||
| 130 | |||
| 131 | |||
| 132 | __PACKAGE__->method_documentation({ | ||
| 133 | 'auto_filter' => { | ||
| 134 | datatype => 'AutoFilter', | ||
| 135 | base_name => 'AutoFilter', | ||
| 136 | description => 'Gets auto filter.', | ||
| 137 | format => '', | ||
| 138 | read_only => '', | ||
| 139 | }, | ||
| 140 | 'display_name' => { | ||
| 141 | datatype => 'string', | ||
| 142 | base_name => 'DisplayName', | ||
| 143 | description => 'Gets and sets the display name.', | ||
| 144 | format => '', | ||
| 145 | read_only => '', | ||
| 146 | }, | ||
| 147 | 'start_column' => { | ||
| 148 | datatype => 'int', | ||
| 149 | base_name => 'StartColumn', | ||
| 150 | description => 'Gets the start column of the range.', | ||
| 151 | format => '', | ||
| 152 | read_only => '', | ||
| 153 | }, | ||
| 154 | 'start_row' => { | ||
| 155 | datatype => 'int', | ||
| 156 | base_name => 'StartRow', | ||
| 157 | description => 'Gets the start row of the range.', | ||
| 158 | format => '', | ||
| 159 | read_only => '', | ||
| 160 | }, | ||
| 161 | 'end_column' => { | ||
| 162 | datatype => 'int', | ||
| 163 | base_name => 'EndColumn', | ||
| 164 | description => 'Gets the end column of the range.', | ||
| 165 | format => '', | ||
| 166 | read_only => '', | ||
| 167 | }, | ||
| 168 | 'end_row' => { | ||
| 169 | datatype => 'int', | ||
| 170 | base_name => 'EndRow', | ||
| 171 | description => 'Gets the end row of the range.', | ||
| 172 | format => '', | ||
| 173 | read_only => '', | ||
| 174 | }, | ||
| 175 | 'list_columns' => { | ||
| 176 | datatype => 'ARRAY[ListColumn]', | ||
| 177 | base_name => 'ListColumns', | ||
| 178 | description => 'Gets ListColumns of the ListObject.', | ||
| 179 | format => '', | ||
| 180 | read_only => '', | ||
| 181 | }, | ||
| 182 | 'show_header_row' => { | ||
| 183 | datatype => 'boolean', | ||
| 184 | base_name => 'ShowHeaderRow', | ||
| 185 | description => 'Gets and sets whether this ListObject show header row.', | ||
| 186 | format => '', | ||
| 187 | read_only => '', | ||
| 188 | }, | ||
| 189 | 'show_table_style_column_stripes' => { | ||
| 190 | datatype => 'boolean', | ||
| 191 | base_name => 'ShowTableStyleColumnStripes', | ||
| 192 | description => 'Indicates whether column stripe formatting is applied.', | ||
| 193 | format => '', | ||
| 194 | read_only => '', | ||
| 195 | }, | ||
| 196 | 'show_table_style_first_column' => { | ||
| 197 | datatype => 'boolean', | ||
| 198 | base_name => 'ShowTableStyleFirstColumn', | ||
| 199 | description => 'Indicates whether the first column in the table should have the style applied.', | ||
| 200 | format => '', | ||
| 201 | read_only => '', | ||
| 202 | }, | ||
| 203 | 'show_table_style_last_column' => { | ||
| 204 | datatype => 'boolean', | ||
| 205 | base_name => 'ShowTableStyleLastColumn', | ||
| 206 | description => 'Indicates whether the last column in the table should have the style applied.', | ||
| 207 | format => '', | ||
| 208 | read_only => '', | ||
| 209 | }, | ||
| 210 | 'show_table_style_row_stripes' => { | ||
| 211 | datatype => 'boolean', | ||
| 212 | base_name => 'ShowTableStyleRowStripes', | ||
| 213 | description => 'Indicates whether row stripe formatting is applied.', | ||
| 214 | format => '', | ||
| 215 | read_only => '', | ||
| 216 | }, | ||
| 217 | 'show_totals' => { | ||
| 218 | datatype => 'boolean', | ||
| 219 | base_name => 'ShowTotals', | ||
| 220 | description => 'Gets and sets whether this ListObject show total row.', | ||
| 221 | format => '', | ||
| 222 | read_only => '', | ||
| 223 | }, | ||
| 224 | 'table_style_name' => { | ||
| 225 | datatype => 'string', | ||
| 226 | base_name => 'TableStyleName', | ||
| 227 | description => 'Gets and sets the table style name.', | ||
| 228 | format => '', | ||
| 229 | read_only => '', | ||
| 230 | }, | ||
| 231 | 'table_style_type' => { | ||
| 232 | datatype => 'string', | ||
| 233 | base_name => 'TableStyleType', | ||
| 234 | description => 'Gets and the built-in table style.', | ||
| 235 | format => '', | ||
| 236 | read_only => '', | ||
| 237 | }, | ||
| 238 | 'data_range' => { | ||
| 239 | datatype => 'Range', | ||
| 240 | base_name => 'DataRange', | ||
| 241 | description => 'Gets the data range of the ListObject.', | ||
| 242 | format => '', | ||
| 243 | read_only => '', | ||
| 244 | }, | ||
| 245 | 'data_source_type' => { | ||
| 246 | datatype => 'string', | ||
| 247 | base_name => 'DataSourceType', | ||
| 248 | description => 'Gets the data source type of the table.', | ||
| 249 | format => '', | ||
| 250 | read_only => '', | ||
| 251 | }, | ||
| 252 | 'comment' => { | ||
| 253 | datatype => 'string', | ||
| 254 | base_name => 'Comment', | ||
| 255 | description => 'Gets and sets the comment of the table.', | ||
| 256 | format => '', | ||
| 257 | read_only => '', | ||
| 258 | }, | ||
| 259 | 'xml_map' => { | ||
| 260 | datatype => 'XmlMap', | ||
| 261 | base_name => 'XmlMap', | ||
| 262 | description => 'Gets an used for this list.', | ||
| 263 | format => '', | ||
| 264 | read_only => '', | ||
| 265 | }, | ||
| 266 | 'alternative_text' => { | ||
| 267 | datatype => 'string', | ||
| 268 | base_name => 'AlternativeText', | ||
| 269 | description => 'Gets and sets the alternative text.', | ||
| 270 | format => '', | ||
| 271 | read_only => '', | ||
| 272 | }, | ||
| 273 | 'alternative_description' => { | ||
| 274 | datatype => 'string', | ||
| 275 | base_name => 'AlternativeDescription', | ||
| 276 | description => 'Gets and sets the alternative description.', | ||
| 277 | format => '', | ||
| 278 | read_only => '', | ||
| 279 | }, | ||
| 280 | 'link' => { | ||
| 281 | datatype => 'Link', | ||
| 282 | base_name => 'link', | ||
| 283 | description => '', | ||
| 284 | format => '', | ||
| 285 | read_only => '', | ||
| 286 | }, | ||
| 287 | }); | ||
| 288 | |||
| 289 | __PACKAGE__->swagger_types( { | ||
| 290 | 'auto_filter' => 'AutoFilter', | ||
| 291 | 'display_name' => 'string', | ||
| 292 | 'start_column' => 'int', | ||
| 293 | 'start_row' => 'int', | ||
| 294 | 'end_column' => 'int', | ||
| 295 | 'end_row' => 'int', | ||
| 296 | 'list_columns' => 'ARRAY[ListColumn]', | ||
| 297 | 'show_header_row' => 'boolean', | ||
| 298 | 'show_table_style_column_stripes' => 'boolean', | ||
| 299 | 'show_table_style_first_column' => 'boolean', | ||
| 300 | 'show_table_style_last_column' => 'boolean', | ||
| 301 | 'show_table_style_row_stripes' => 'boolean', | ||
| 302 | 'show_totals' => 'boolean', | ||
| 303 | 'table_style_name' => 'string', | ||
| 304 | 'table_style_type' => 'string', | ||
| 305 | 'data_range' => 'Range', | ||
| 306 | 'data_source_type' => 'string', | ||
| 307 | 'comment' => 'string', | ||
| 308 | 'xml_map' => 'XmlMap', | ||
| 309 | 'alternative_text' => 'string', | ||
| 310 | 'alternative_description' => 'string', | ||
| 311 | 'link' => 'Link' | ||
| 312 | } ); | ||
| 313 | |||
| 314 | __PACKAGE__->attribute_map( { | ||
| 315 | 'auto_filter' => 'AutoFilter', | ||
| 316 | 'display_name' => 'DisplayName', | ||
| 317 | 'start_column' => 'StartColumn', | ||
| 318 | 'start_row' => 'StartRow', | ||
| 319 | 'end_column' => 'EndColumn', | ||
| 320 | 'end_row' => 'EndRow', | ||
| 321 | 'list_columns' => 'ListColumns', | ||
| 322 | 'show_header_row' => 'ShowHeaderRow', | ||
| 323 | 'show_table_style_column_stripes' => 'ShowTableStyleColumnStripes', | ||
| 324 | 'show_table_style_first_column' => 'ShowTableStyleFirstColumn', | ||
| 325 | 'show_table_style_last_column' => 'ShowTableStyleLastColumn', | ||
| 326 | 'show_table_style_row_stripes' => 'ShowTableStyleRowStripes', | ||
| 327 | 'show_totals' => 'ShowTotals', | ||
| 328 | 'table_style_name' => 'TableStyleName', | ||
| 329 | 'table_style_type' => 'TableStyleType', | ||
| 330 | 'data_range' => 'DataRange', | ||
| 331 | 'data_source_type' => 'DataSourceType', | ||
| 332 | 'comment' => 'Comment', | ||
| 333 | 'xml_map' => 'XmlMap', | ||
| 334 | 'alternative_text' => 'AlternativeText', | ||
| 335 | 'alternative_description' => 'AlternativeDescription', | ||
| 336 | 'link' => 'link' | ||
| 337 | } ); | ||
| 338 | |||
| 339 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 340 | |||
| 341 | |||
| 342 | 1; |