| 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::TrimContentOptions; | ||
| 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::DataSource; | ||
| 39 | use AsposeCellsCloud::Object::FileInfo; | ||
| 40 | use AsposeCellsCloud::Object::ScopeOptions; | ||
| 41 | |||
| 42 | |||
| 43 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 48 | __PACKAGE__->mk_classdata('swagger_types' => {}); | ||
| 49 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 50 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 51 | |||
| 52 | # new object | ||
| 53 | sub new { | ||
| 54 | my ($class, %args) = @_; | ||
| 55 | |||
| 56 | my $self = bless {}, $class; | ||
| 57 | |||
| 58 | foreach my $attribute (keys %{$class->attribute_map}) { | ||
| 59 | my $args_key = $class->attribute_map->{$attribute}; | ||
| 60 | $self->$attribute( $args{ $args_key } ); | ||
| 61 | } | ||
| 62 | |||
| 63 | return $self; | ||
| 64 | } | ||
| 65 | |||
| 66 | # return perl hash | ||
| 67 | sub to_hash { | ||
| 68 | return decode_json(JSON->new->convert_blessed->encode( shift )); | ||
| 69 | } | ||
| 70 | |||
| 71 | # used by JSON for serialization | ||
| 72 | sub TO_JSON { | ||
| 73 | my $self = shift; | ||
| 74 | my $_data = {}; | ||
| 75 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 76 | if (defined $self->{$_key}) { | ||
| 77 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | return $_data; | ||
| 81 | } | ||
| 82 | |||
| 83 | # from Perl hashref | ||
| 84 | sub from_hash { | ||
| 85 | my ($self, $hash) = @_; | ||
| 86 | |||
| 87 | # loop through attributes and use swagger_types to deserialize the data | ||
| 88 | while ( my ($_key, $_type) = each %{$self->swagger_types} ) { | ||
| 89 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 90 | if ($_type =~ /^array\[/i) { # array | ||
| 91 | my $_subclass = substr($_type, 6, -1); | ||
| 92 | my @_array = (); | ||
| 93 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 94 | push @_array, $self->_deserialize($_subclass, $_element); | ||
| 95 | } | ||
| 96 | $self->{$_key} = \@_array; | ||
| 97 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 98 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); | ||
| 99 | } else { | ||
| 100 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | return $self; | ||
| 105 | } | ||
| 106 | |||
| 107 | # deserialize non-array data | ||
| 108 | sub _deserialize { | ||
| 109 | my ($self, $type, $data) = @_; | ||
| 110 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 111 | |||
| 112 | if ($type eq 'DateTime') { | ||
| 113 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 114 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 115 | return $data; | ||
| 116 | } else { # hash(model) | ||
| 117 | my $_instance = eval "AsposeCellsCloud::Object::$type->new()"; | ||
| 118 | return $_instance->from_hash($data); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | |||
| 123 | __PACKAGE__->class_documentation({description => '', | ||
| 124 | class => 'TrimContentOptions', | ||
| 125 | required => [], # TODO | ||
| 126 | } ); | ||
| 127 | |||
| 128 | |||
| 129 | __PACKAGE__->method_documentation({ | ||
| 130 | 'data_source' => { | ||
| 131 | datatype => 'DataSource', | ||
| 132 | base_name => 'DataSource', | ||
| 133 | description => 'Represents data source. There are three types of data, they are CloudFileSystem, RequestFiles, HttpUri.', | ||
| 134 | format => '', | ||
| 135 | read_only => '', | ||
| 136 | }, | ||
| 137 | 'file_info' => { | ||
| 138 | datatype => 'FileInfo', | ||
| 139 | base_name => 'FileInfo', | ||
| 140 | description => 'Represents file information. Include of filename, filesize, and file content(base64String).', | ||
| 141 | format => '', | ||
| 142 | read_only => '', | ||
| 143 | }, | ||
| 144 | 'trim_content' => { | ||
| 145 | datatype => 'string', | ||
| 146 | base_name => 'TrimContent', | ||
| 147 | description => 'Trim Content', | ||
| 148 | format => '', | ||
| 149 | read_only => '', | ||
| 150 | }, | ||
| 151 | 'trim_leading' => { | ||
| 152 | datatype => 'boolean', | ||
| 153 | base_name => 'TrimLeading', | ||
| 154 | description => 'If the trim leading value is true, the trim content before and after cell values will be deleted.', | ||
| 155 | format => '', | ||
| 156 | read_only => '', | ||
| 157 | }, | ||
| 158 | 'trim_trailing' => { | ||
| 159 | datatype => 'boolean', | ||
| 160 | base_name => 'TrimTrailing', | ||
| 161 | description => 'If the trim trailing value is true, the trim content before and after cell values will be deleted.', | ||
| 162 | format => '', | ||
| 163 | read_only => '', | ||
| 164 | }, | ||
| 165 | 'trim_space_between_word_to1' => { | ||
| 166 | datatype => 'boolean', | ||
| 167 | base_name => 'TrimSpaceBetweenWordTo1', | ||
| 168 | description => 'When the trim space between word to 1 parameter is true, it enables the removal of extra spaces between words within a cell, ensuring that only a single space is maintained between words.', | ||
| 169 | format => '', | ||
| 170 | read_only => '', | ||
| 171 | }, | ||
| 172 | 'trim_non_breaking_spaces' => { | ||
| 173 | datatype => 'boolean', | ||
| 174 | base_name => 'TrimNonBreakingSpaces', | ||
| 175 | description => '', | ||
| 176 | format => '', | ||
| 177 | read_only => '', | ||
| 178 | }, | ||
| 179 | 'remove_extra_line_breaks' => { | ||
| 180 | datatype => 'boolean', | ||
| 181 | base_name => 'RemoveExtraLineBreaks', | ||
| 182 | description => 'When this parameter is enabled (set to True), it deletes extra line breaks within the selected range, ensuring that only necessary line breaks are retained.', | ||
| 183 | format => '', | ||
| 184 | read_only => '', | ||
| 185 | }, | ||
| 186 | 'remove_all_line_breaks' => { | ||
| 187 | datatype => 'boolean', | ||
| 188 | base_name => 'RemoveAllLineBreaks', | ||
| 189 | description => 'When this parameter is enabled (set to True), it removes all line breaks within the selected range, resulting in a continuous block of text without any line breaks.', | ||
| 190 | format => '', | ||
| 191 | read_only => '', | ||
| 192 | }, | ||
| 193 | 'scope_options' => { | ||
| 194 | datatype => 'ScopeOptions', | ||
| 195 | base_name => 'ScopeOptions', | ||
| 196 | description => 'Specifies the range of cells within the worksheet where the spreadsheet operations will be performed. This parameter allows users to define the exact area to be processed, ensuring that operations are applied only to the designated cells.', | ||
| 197 | format => '', | ||
| 198 | read_only => '', | ||
| 199 | }, | ||
| 200 | }); | ||
| 201 | |||
| 202 | __PACKAGE__->swagger_types( { | ||
| 203 | 'data_source' => 'DataSource', | ||
| 204 | 'file_info' => 'FileInfo', | ||
| 205 | 'trim_content' => 'string', | ||
| 206 | 'trim_leading' => 'boolean', | ||
| 207 | 'trim_trailing' => 'boolean', | ||
| 208 | 'trim_space_between_word_to1' => 'boolean', | ||
| 209 | 'trim_non_breaking_spaces' => 'boolean', | ||
| 210 | 'remove_extra_line_breaks' => 'boolean', | ||
| 211 | 'remove_all_line_breaks' => 'boolean', | ||
| 212 | 'scope_options' => 'ScopeOptions' | ||
| 213 | } ); | ||
| 214 | |||
| 215 | __PACKAGE__->attribute_map( { | ||
| 216 | 'data_source' => 'DataSource', | ||
| 217 | 'file_info' => 'FileInfo', | ||
| 218 | 'trim_content' => 'TrimContent', | ||
| 219 | 'trim_leading' => 'TrimLeading', | ||
| 220 | 'trim_trailing' => 'TrimTrailing', | ||
| 221 | 'trim_space_between_word_to1' => 'TrimSpaceBetweenWordTo1', | ||
| 222 | 'trim_non_breaking_spaces' => 'TrimNonBreakingSpaces', | ||
| 223 | 'remove_extra_line_breaks' => 'RemoveExtraLineBreaks', | ||
| 224 | 'remove_all_line_breaks' => 'RemoveAllLineBreaks', | ||
| 225 | 'scope_options' => 'ScopeOptions' | ||
| 226 | } ); | ||
| 227 | |||
| 228 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 229 | |||
| 230 | |||
| 231 | 1; |