Object/Style.pm untested

filter: Statementstmt 0.0% 0 / 99 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 20 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 134 CC 6 SCAR 15.5
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 4.7
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::Style;
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::Border;
39 use AsposeCellsCloud::Object::Color;
40 use AsposeCellsCloud::Object::Font;
41 use AsposeCellsCloud::Object::ThemeColor;
42
43
44 use base ("Class::Accessor", "Class::Data::Inheritable");
45
46
47
48 __PACKAGE__->mk_classdata('attribute_map' => {});
49 __PACKAGE__->mk_classdata('swagger_types' => {});
50 __PACKAGE__->mk_classdata('method_documentation' => {});
51 __PACKAGE__->mk_classdata('class_documentation' => {});
52
53 # new object
54 sub new {
55 my ($class, %args) = @_;
56
57 my $self = bless {}, $class;
58
59 foreach my $attribute (keys %{$class->attribute_map}) {
60 my $args_key = $class->attribute_map->{$attribute};
61 $self->$attribute( $args{ $args_key } );
62 }
63
64 return $self;
65 }
66
67 # return perl hash
68 sub to_hash {
69 return decode_json(JSON->new->convert_blessed->encode( shift ));
70 }
71
72 # used by JSON for serialization
73 sub TO_JSON {
74 my $self = shift;
75 my $_data = {};
76 foreach my $_key (keys %{$self->attribute_map}) {
77 if (defined $self->{$_key}) {
78 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
79 }
80 }
81 return $_data;
82 }
83
84 # from Perl hashref
85 sub from_hash {
86 my ($self, $hash) = @_;
87
88 # loop through attributes and use swagger_types to deserialize the data
89 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
90 my $_json_attribute = $self->attribute_map->{$_key};
91 if ($_type =~ /^array\[/i) { # array
92 my $_subclass = substr($_type, 6, -1);
93 my @_array = ();
94 foreach my $_element (@{$hash->{$_json_attribute}}) {
95 push @_array, $self->_deserialize($_subclass, $_element);
96 }
97 $self->{$_key} = \@_array;
98 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
99 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
100 } else {
101 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
102 }
103 }
104
105 return $self;
106 }
107
108 # deserialize non-array data
109 sub _deserialize {
110 my ($self, $type, $data) = @_;
111 $log->debugf("deserializing %s with %s",Dumper($data), $type);
112
113 if ($type eq 'DateTime') {
114 return DateTime->from_epoch(epoch => str2time($data));
115 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
116 return $data;
117 } else { # hash(model)
118 my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
119 return $_instance->from_hash($data);
120 }
121 }
122
123
124 __PACKAGE__->class_documentation({description => ' Represents display style of excel document,such as font,color,alignment,border,etc. The Style object contains all style attributes (font, number format, alignment, and so on) as properties. ',
125 class => 'Style',
126 required => [], # TODO
127 } );
128
129
130 __PACKAGE__->method_documentation({
131 'font' => {
132 datatype => 'Font',
133 base_name => 'Font',
134 description => 'Gets a object. ',
135 format => '',
136 read_only => '',
137 },
138 'name' => {
139 datatype => 'string',
140 base_name => 'Name',
141 description => 'Gets or sets the name of the style. ',
142 format => '',
143 read_only => '',
144 },
145 'culture_custom' => {
146 datatype => 'string',
147 base_name => 'CultureCustom',
148 description => 'Gets and sets the culture-dependent pattern string for number format. If no number format has been set for this object, null will be returned. If number format is builtin, the pattern string corresponding to the builtin number will be returned. ',
149 format => '',
150 read_only => '',
151 },
152 'custom' => {
153 datatype => 'string',
154 base_name => 'Custom',
155 description => 'Represents the custom number format string of this style object. If the custom number format is not set(For example, the number format is builtin), "" will be returned. ',
156 format => '',
157 read_only => '',
158 },
159 'background_color' => {
160 datatype => 'Color',
161 base_name => 'BackgroundColor',
162 description => 'Gets or sets a style`s background color. ',
163 format => '',
164 read_only => '',
165 },
166 'foreground_color' => {
167 datatype => 'Color',
168 base_name => 'ForegroundColor',
169 description => 'Gets or sets a style`s foreground color. ',
170 format => '',
171 read_only => '',
172 },
173 'is_formula_hidden' => {
174 datatype => 'boolean',
175 base_name => 'IsFormulaHidden',
176 description => 'Represents if the formula will be hidden when the worksheet is protected. ',
177 format => '',
178 read_only => '',
179 },
180 'is_date_time' => {
181 datatype => 'boolean',
182 base_name => 'IsDateTime',
183 description => 'Indicates whether the number format is a date format. ',
184 format => '',
185 read_only => '',
186 },
187 'is_text_wrapped' => {
188 datatype => 'boolean',
189 base_name => 'IsTextWrapped',
190 description => 'Gets or sets a value indicating whether the text within a cell is wrapped. ',
191 format => '',
192 read_only => '',
193 },
194 'is_gradient' => {
195 datatype => 'boolean',
196 base_name => 'IsGradient',
197 description => 'Indicates whether the cell shading is a gradient pattern. ',
198 format => '',
199 read_only => '',
200 },
201 'is_locked' => {
202 datatype => 'boolean',
203 base_name => 'IsLocked',
204 description => 'Gets or sets a value indicating whether a cell can be modified or not. ',
205 format => '',
206 read_only => '',
207 },
208 'is_percent' => {
209 datatype => 'boolean',
210 base_name => 'IsPercent',
211 description => 'Indicates whether the number format is a percent format. ',
212 format => '',
213 read_only => '',
214 },
215 'shrink_to_fit' => {
216 datatype => 'boolean',
217 base_name => 'ShrinkToFit',
218 description => 'Represents if text automatically shrinks to fit in the available column width. ',
219 format => '',
220 read_only => '',
221 },
222 'indent_level' => {
223 datatype => 'int',
224 base_name => 'IndentLevel',
225 description => 'Represents the indent level for the cell or range. Can only be an integer from 0 to 250. ',
226 format => '',
227 read_only => '',
228 },
229 'number' => {
230 datatype => 'int',
231 base_name => 'Number',
232 description => 'Gets or sets the display format of numbers and dates. The formatting patterns are different for different regions. ',
233 format => '',
234 read_only => '',
235 },
236 'rotation_angle' => {
237 datatype => 'int',
238 base_name => 'RotationAngle',
239 description => 'Represents text rotation angle. ',
240 format => '',
241 read_only => '',
242 },
243 'pattern' => {
244 datatype => 'string',
245 base_name => 'Pattern',
246 description => 'Gets or sets the cell background pattern type. ',
247 format => '',
248 read_only => '',
249 },
250 'text_direction' => {
251 datatype => 'string',
252 base_name => 'TextDirection',
253 description => 'Represents text reading order. ',
254 format => '',
255 read_only => '',
256 },
257 'vertical_alignment' => {
258 datatype => 'string',
259 base_name => 'VerticalAlignment',
260 description => 'Gets or sets the vertical alignment type of the text in a cell. ',
261 format => '',
262 read_only => '',
263 },
264 'horizontal_alignment' => {
265 datatype => 'string',
266 base_name => 'HorizontalAlignment',
267 description => 'Gets or sets the horizontal alignment type of the text in a cell. ',
268 format => '',
269 read_only => '',
270 },
271 'border_collection' => {
272 datatype => 'ARRAY[Border]',
273 base_name => 'BorderCollection',
274 description => 'A public property named `BorderCollection` that is a list of `Border` objects.',
275 format => '',
276 read_only => '',
277 },
278 'background_theme_color' => {
279 datatype => 'ThemeColor',
280 base_name => 'BackgroundThemeColor',
281 description => 'Gets and sets the background theme color. ',
282 format => '',
283 read_only => '',
284 },
285 'foreground_theme_color' => {
286 datatype => 'ThemeColor',
287 base_name => 'ForegroundThemeColor',
288 description => 'Gets and sets the foreground theme color. ',
289 format => '',
290 read_only => '',
291 },
292 });
293
294 __PACKAGE__->swagger_types( {
295 'font' => 'Font',
296 'name' => 'string',
297 'culture_custom' => 'string',
298 'custom' => 'string',
299 'background_color' => 'Color',
300 'foreground_color' => 'Color',
301 'is_formula_hidden' => 'boolean',
302 'is_date_time' => 'boolean',
303 'is_text_wrapped' => 'boolean',
304 'is_gradient' => 'boolean',
305 'is_locked' => 'boolean',
306 'is_percent' => 'boolean',
307 'shrink_to_fit' => 'boolean',
308 'indent_level' => 'int',
309 'number' => 'int',
310 'rotation_angle' => 'int',
311 'pattern' => 'string',
312 'text_direction' => 'string',
313 'vertical_alignment' => 'string',
314 'horizontal_alignment' => 'string',
315 'border_collection' => 'ARRAY[Border]',
316 'background_theme_color' => 'ThemeColor',
317 'foreground_theme_color' => 'ThemeColor'
318 } );
319
320 __PACKAGE__->attribute_map( {
321 'font' => 'Font',
322 'name' => 'Name',
323 'culture_custom' => 'CultureCustom',
324 'custom' => 'Custom',
325 'background_color' => 'BackgroundColor',
326 'foreground_color' => 'ForegroundColor',
327 'is_formula_hidden' => 'IsFormulaHidden',
328 'is_date_time' => 'IsDateTime',
329 'is_text_wrapped' => 'IsTextWrapped',
330 'is_gradient' => 'IsGradient',
331 'is_locked' => 'IsLocked',
332 'is_percent' => 'IsPercent',
333 'shrink_to_fit' => 'ShrinkToFit',
334 'indent_level' => 'IndentLevel',
335 'number' => 'Number',
336 'rotation_angle' => 'RotationAngle',
337 'pattern' => 'Pattern',
338 'text_direction' => 'TextDirection',
339 'vertical_alignment' => 'VerticalAlignment',
340 'horizontal_alignment' => 'HorizontalAlignment',
341 'border_collection' => 'BorderCollection',
342 'background_theme_color' => 'BackgroundThemeColor',
343 'foreground_theme_color' => 'ForegroundThemeColor'
344 } );
345
346 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
347
348
349 1;