Object/Legend.pm untested

filter: Statementstmt 0.0% 0 / 102 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 21 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 138 CC 6 SCAR 15.3
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 4.6
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::Legend;
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::Area;
39 use AsposeCellsCloud::Object::ChartFrame;
40 use AsposeCellsCloud::Object::Font;
41 use AsposeCellsCloud::Object::Line;
42 use AsposeCellsCloud::Object::LinkElement;
43
44
45 use base ("Class::Accessor", "Class::Data::Inheritable");
46
47
48
49 __PACKAGE__->mk_classdata('attribute_map' => {});
50 __PACKAGE__->mk_classdata('swagger_types' => {});
51 __PACKAGE__->mk_classdata('method_documentation' => {});
52 __PACKAGE__->mk_classdata('class_documentation' => {});
53
54 # new object
55 sub new {
56 my ($class, %args) = @_;
57
58 my $self = bless {}, $class;
59
60 foreach my $attribute (keys %{$class->attribute_map}) {
61 my $args_key = $class->attribute_map->{$attribute};
62 $self->$attribute( $args{ $args_key } );
63 }
64
65 return $self;
66 }
67
68 # return perl hash
69 sub to_hash {
70 return decode_json(JSON->new->convert_blessed->encode( shift ));
71 }
72
73 # used by JSON for serialization
74 sub TO_JSON {
75 my $self = shift;
76 my $_data = {};
77 foreach my $_key (keys %{$self->attribute_map}) {
78 if (defined $self->{$_key}) {
79 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
80 }
81 }
82 return $_data;
83 }
84
85 # from Perl hashref
86 sub from_hash {
87 my ($self, $hash) = @_;
88
89 # loop through attributes and use swagger_types to deserialize the data
90 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
91 my $_json_attribute = $self->attribute_map->{$_key};
92 if ($_type =~ /^array\[/i) { # array
93 my $_subclass = substr($_type, 6, -1);
94 my @_array = ();
95 foreach my $_element (@{$hash->{$_json_attribute}}) {
96 push @_array, $self->_deserialize($_subclass, $_element);
97 }
98 $self->{$_key} = \@_array;
99 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
100 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
101 } else {
102 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
103 }
104 }
105
106 return $self;
107 }
108
109 # deserialize non-array data
110 sub _deserialize {
111 my ($self, $type, $data) = @_;
112 $log->debugf("deserializing %s with %s",Dumper($data), $type);
113
114 if ($type eq 'DateTime') {
115 return DateTime->from_epoch(epoch => str2time($data));
116 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
117 return $data;
118 } else { # hash(model)
119 my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
120 return $_instance->from_hash($data);
121 }
122 }
123
124
125 __PACKAGE__->class_documentation({description => 'Encapsulates the object that represents the chart legend.',
126 class => 'Legend',
127 required => [], # TODO
128 } );
129
130
131 __PACKAGE__->method_documentation({
132 'position' => {
133 datatype => 'string',
134 base_name => 'Position',
135 description => 'Gets or sets the legend position type.',
136 format => '',
137 read_only => '',
138 },
139 'legend_entries' => {
140 datatype => 'LinkElement',
141 base_name => 'LegendEntries',
142 description => 'Gets a collection of all the LegendEntry objects in the specified chart legend. Setting the legend entries of the surface chart is not supported. So it will return null if the chart type is surface chart type.',
143 format => '',
144 read_only => '',
145 },
146 'area' => {
147 datatype => 'Area',
148 base_name => 'Area',
149 description => '',
150 format => '',
151 read_only => '',
152 },
153 'auto_scale_font' => {
154 datatype => 'boolean',
155 base_name => 'AutoScaleFont',
156 description => '',
157 format => '',
158 read_only => '',
159 },
160 'background_mode' => {
161 datatype => 'string',
162 base_name => 'BackgroundMode',
163 description => '',
164 format => '',
165 read_only => '',
166 },
167 'border' => {
168 datatype => 'Line',
169 base_name => 'Border',
170 description => '',
171 format => '',
172 read_only => '',
173 },
174 'font' => {
175 datatype => 'Font',
176 base_name => 'Font',
177 description => '',
178 format => '',
179 read_only => '',
180 },
181 'is_automatic_size' => {
182 datatype => 'boolean',
183 base_name => 'IsAutomaticSize',
184 description => '',
185 format => '',
186 read_only => '',
187 },
188 'is_inner_mode' => {
189 datatype => 'boolean',
190 base_name => 'IsInnerMode',
191 description => '',
192 format => '',
193 read_only => '',
194 },
195 'shadow' => {
196 datatype => 'boolean',
197 base_name => 'Shadow',
198 description => '',
199 format => '',
200 read_only => '',
201 },
202 'width' => {
203 datatype => 'int',
204 base_name => 'Width',
205 description => '',
206 format => '',
207 read_only => '',
208 },
209 'height' => {
210 datatype => 'int',
211 base_name => 'Height',
212 description => '',
213 format => '',
214 read_only => '',
215 },
216 'x' => {
217 datatype => 'int',
218 base_name => 'X',
219 description => '',
220 format => '',
221 read_only => '',
222 },
223 'y' => {
224 datatype => 'int',
225 base_name => 'Y',
226 description => '',
227 format => '',
228 read_only => '',
229 },
230 });
231
232 __PACKAGE__->swagger_types( {
233 'position' => 'string',
234 'legend_entries' => 'LinkElement',
235 'area' => 'Area',
236 'auto_scale_font' => 'boolean',
237 'background_mode' => 'string',
238 'border' => 'Line',
239 'font' => 'Font',
240 'is_automatic_size' => 'boolean',
241 'is_inner_mode' => 'boolean',
242 'shadow' => 'boolean',
243 'width' => 'int',
244 'height' => 'int',
245 'x' => 'int',
246 'y' => 'int'
247 } );
248
249 __PACKAGE__->attribute_map( {
250 'position' => 'Position',
251 'legend_entries' => 'LegendEntries',
252 'area' => 'Area',
253 'auto_scale_font' => 'AutoScaleFont',
254 'background_mode' => 'BackgroundMode',
255 'border' => 'Border',
256 'font' => 'Font',
257 'is_automatic_size' => 'IsAutomaticSize',
258 'is_inner_mode' => 'IsInnerMode',
259 'shadow' => 'Shadow',
260 'width' => 'Width',
261 'height' => 'Height',
262 'x' => 'X',
263 'y' => 'Y'
264 } );
265
266 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
267
268
269 1;