Object/PageSetup.pm untested

filter: Statementstmt 0.0% 0 / 90 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 122 CC 6 SCAR 16.3
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 5.1
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::PageSetup;
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::PageSection;
39
40
41 use base ("Class::Accessor", "Class::Data::Inheritable");
42
43
44
45 __PACKAGE__->mk_classdata('attribute_map' => {});
46 __PACKAGE__->mk_classdata('swagger_types' => {});
47 __PACKAGE__->mk_classdata('method_documentation' => {});
48 __PACKAGE__->mk_classdata('class_documentation' => {});
49
50 # new object
51 sub new {
52 my ($class, %args) = @_;
53
54 my $self = bless {}, $class;
55
56 foreach my $attribute (keys %{$class->attribute_map}) {
57 my $args_key = $class->attribute_map->{$attribute};
58 $self->$attribute( $args{ $args_key } );
59 }
60
61 return $self;
62 }
63
64 # return perl hash
65 sub to_hash {
66 return decode_json(JSON->new->convert_blessed->encode( shift ));
67 }
68
69 # used by JSON for serialization
70 sub TO_JSON {
71 my $self = shift;
72 my $_data = {};
73 foreach my $_key (keys %{$self->attribute_map}) {
74 if (defined $self->{$_key}) {
75 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
76 }
77 }
78 return $_data;
79 }
80
81 # from Perl hashref
82 sub from_hash {
83 my ($self, $hash) = @_;
84
85 # loop through attributes and use swagger_types to deserialize the data
86 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
87 my $_json_attribute = $self->attribute_map->{$_key};
88 if ($_type =~ /^array\[/i) { # array
89 my $_subclass = substr($_type, 6, -1);
90 my @_array = ();
91 foreach my $_element (@{$hash->{$_json_attribute}}) {
92 push @_array, $self->_deserialize($_subclass, $_element);
93 }
94 $self->{$_key} = \@_array;
95 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
96 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
97 } else {
98 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
99 }
100 }
101
102 return $self;
103 }
104
105 # deserialize non-array data
106 sub _deserialize {
107 my ($self, $type, $data) = @_;
108 $log->debugf("deserializing %s with %s",Dumper($data), $type);
109
110 if ($type eq 'DateTime') {
111 return DateTime->from_epoch(epoch => str2time($data));
112 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
113 return $data;
114 } else { # hash(model)
115 my $_instance = eval "AsposeCellsCloud::Object::$type->new()";
116 return $_instance->from_hash($data);
117 }
118 }
119
120
121 __PACKAGE__->class_documentation({description => 'excel print page setting',
122 class => 'PageSetup',
123 required => [], # TODO
124 } );
125
126
127 __PACKAGE__->method_documentation({
128 'black_and_white' => {
129 datatype => 'boolean',
130 base_name => 'BlackAndWhite',
131 description => 'Represents if elements of the document will be printed in black and white. ',
132 format => '',
133 read_only => '',
134 },
135 'bottom_margin' => {
136 datatype => 'double',
137 base_name => 'BottomMargin',
138 description => 'Represents the size of the bottom margin, in unit of centimeters. ',
139 format => '',
140 read_only => '',
141 },
142 'center_horizontally' => {
143 datatype => 'boolean',
144 base_name => 'CenterHorizontally',
145 description => 'Represent if the sheet is printed centered horizontally. ',
146 format => '',
147 read_only => '',
148 },
149 'center_vertically' => {
150 datatype => 'boolean',
151 base_name => 'CenterVertically',
152 description => 'Represent if the sheet is printed centered vertically. ',
153 format => '',
154 read_only => '',
155 },
156 'first_page_number' => {
157 datatype => 'int',
158 base_name => 'FirstPageNumber',
159 description => 'Represents the first page number that will be used when this sheet is printed. ',
160 format => '',
161 read_only => '',
162 },
163 'fit_to_pages_tall' => {
164 datatype => 'int',
165 base_name => 'FitToPagesTall',
166 description => 'Represents the number of pages tall the worksheet will be scaled to when it`s printed. The default value is 1. ',
167 format => '',
168 read_only => '',
169 },
170 'fit_to_pages_wide' => {
171 datatype => 'int',
172 base_name => 'FitToPagesWide',
173 description => 'Represents the number of pages wide the worksheet will be scaled to when it`s printed. The default value is 1. ',
174 format => '',
175 read_only => '',
176 },
177 'footer_margin' => {
178 datatype => 'double',
179 base_name => 'FooterMargin',
180 description => 'Represents the distance from the bottom of the page to the footer, in unit of centimeters. ',
181 format => '',
182 read_only => '',
183 },
184 'header_margin' => {
185 datatype => 'double',
186 base_name => 'HeaderMargin',
187 description => 'Represents the distance from the top of the page to the header, in unit of centimeters. ',
188 format => '',
189 read_only => '',
190 },
191 'is_auto_first_page_number' => {
192 datatype => 'boolean',
193 base_name => 'IsAutoFirstPageNumber',
194 description => 'Indicates whether the first the page number is automatically assigned. ',
195 format => '',
196 read_only => '',
197 },
198 'is_hf_align_margins' => {
199 datatype => 'boolean',
200 base_name => 'IsHFAlignMargins',
201 description => 'Indicates whether header and footer margins are aligned with the page margins. If this property is true, the left header and footer will be aligned with the left margin, and the right header and footer will be aligned with the right margin. This option is enabled by default. ',
202 format => '',
203 read_only => '',
204 },
205 'is_hf_diff_first' => {
206 datatype => 'boolean',
207 base_name => 'IsHFDiffFirst',
208 description => 'True means that the header/footer of the first page is different with other pages. ',
209 format => '',
210 read_only => '',
211 },
212 'is_hf_diff_odd_even' => {
213 datatype => 'boolean',
214 base_name => 'IsHFDiffOddEven',
215 description => 'True means that the header/footer of the odd pages is different with odd pages. ',
216 format => '',
217 read_only => '',
218 },
219 'is_hf_scale_with_doc' => {
220 datatype => 'boolean',
221 base_name => 'IsHFScaleWithDoc',
222 description => 'Indicates whether header and footer are scaled with document scaling. Only applies for Excel 2007. ',
223 format => '',
224 read_only => '',
225 },
226 'is_percent_scale' => {
227 datatype => 'boolean',
228 base_name => 'IsPercentScale',
229 description => 'If this property is False, the FitToPagesWide and FitToPagesTall properties control how the worksheet is scaled. ',
230 format => '',
231 read_only => '',
232 },
233 'left_margin' => {
234 datatype => 'double',
235 base_name => 'LeftMargin',
236 description => 'Represents the size of the left margin, in unit of centimeters. ',
237 format => '',
238 read_only => '',
239 },
240 'order' => {
241 datatype => 'string',
242 base_name => 'Order',
243 description => 'Represents the order that Microsoft Excel uses to number pages when printing a large worksheet. ',
244 format => '',
245 read_only => '',
246 },
247 'orientation' => {
248 datatype => 'string',
249 base_name => 'Orientation',
250 description => 'Represents page print orientation. ',
251 format => '',
252 read_only => '',
253 },
254 'paper_size' => {
255 datatype => 'string',
256 base_name => 'PaperSize',
257 description => 'Represents the size of the paper. ',
258 format => '',
259 read_only => '',
260 },
261 'print_area' => {
262 datatype => 'string',
263 base_name => 'PrintArea',
264 description => 'Represents the range to be printed. ',
265 format => '',
266 read_only => '',
267 },
268 'print_comments' => {
269 datatype => 'string',
270 base_name => 'PrintComments',
271 description => 'Represents the way comments are printed with the sheet. ',
272 format => '',
273 read_only => '',
274 },
275 'print_copies' => {
276 datatype => 'int',
277 base_name => 'PrintCopies',
278 description => 'Get and sets number of copies to print. ',
279 format => '',
280 read_only => '',
281 },
282 'print_draft' => {
283 datatype => 'boolean',
284 base_name => 'PrintDraft',
285 description => 'Represents if the sheet will be printed without graphics. ',
286 format => '',
287 read_only => '',
288 },
289 'print_errors' => {
290 datatype => 'string',
291 base_name => 'PrintErrors',
292 description => 'Specifies the type of print error displayed. ',
293 format => '',
294 read_only => '',
295 },
296 'print_gridlines' => {
297 datatype => 'boolean',
298 base_name => 'PrintGridlines',
299 description => 'Represents if cell gridlines are printed on the page. ',
300 format => '',
301 read_only => '',
302 },
303 'print_headings' => {
304 datatype => 'boolean',
305 base_name => 'PrintHeadings',
306 description => 'Represents if row and column headings are printed with this page. ',
307 format => '',
308 read_only => '',
309 },
310 'print_quality' => {
311 datatype => 'int',
312 base_name => 'PrintQuality',
313 description => 'Represents the print quality. ',
314 format => '',
315 read_only => '',
316 },
317 'print_title_columns' => {
318 datatype => 'string',
319 base_name => 'PrintTitleColumns',
320 description => 'Represents the columns that contain the cells to be repeated on the left side of each page. ',
321 format => '',
322 read_only => '',
323 },
324 'print_title_rows' => {
325 datatype => 'string',
326 base_name => 'PrintTitleRows',
327 description => 'Represents the rows that contain the cells to be repeated at the top of each page. ',
328 format => '',
329 read_only => '',
330 },
331 'right_margin' => {
332 datatype => 'double',
333 base_name => 'RightMargin',
334 description => 'Represents the size of the right margin, in unit of centimeters. ',
335 format => '',
336 read_only => '',
337 },
338 'top_margin' => {
339 datatype => 'double',
340 base_name => 'TopMargin',
341 description => 'Represents the size of the top margin, in unit of centimeters. ',
342 format => '',
343 read_only => '',
344 },
345 'zoom' => {
346 datatype => 'int',
347 base_name => 'Zoom',
348 description => 'Represents the scaling factor in percent. It should be between 10 and 400. ',
349 format => '',
350 read_only => '',
351 },
352 'header' => {
353 datatype => 'ARRAY[PageSection]',
354 base_name => 'Header',
355 description => 'Represents the page header.',
356 format => '',
357 read_only => '',
358 },
359 'footer' => {
360 datatype => 'ARRAY[PageSection]',
361 base_name => 'Footer',
362 description => 'Represents the page footor.',
363 format => '',
364 read_only => '',
365 },
366 });
367
368 __PACKAGE__->swagger_types( {
369 'black_and_white' => 'boolean',
370 'bottom_margin' => 'double',
371 'center_horizontally' => 'boolean',
372 'center_vertically' => 'boolean',
373 'first_page_number' => 'int',
374 'fit_to_pages_tall' => 'int',
375 'fit_to_pages_wide' => 'int',
376 'footer_margin' => 'double',
377 'header_margin' => 'double',
378 'is_auto_first_page_number' => 'boolean',
379 'is_hf_align_margins' => 'boolean',
380 'is_hf_diff_first' => 'boolean',
381 'is_hf_diff_odd_even' => 'boolean',
382 'is_hf_scale_with_doc' => 'boolean',
383 'is_percent_scale' => 'boolean',
384 'left_margin' => 'double',
385 'order' => 'string',
386 'orientation' => 'string',
387 'paper_size' => 'string',
388 'print_area' => 'string',
389 'print_comments' => 'string',
390 'print_copies' => 'int',
391 'print_draft' => 'boolean',
392 'print_errors' => 'string',
393 'print_gridlines' => 'boolean',
394 'print_headings' => 'boolean',
395 'print_quality' => 'int',
396 'print_title_columns' => 'string',
397 'print_title_rows' => 'string',
398 'right_margin' => 'double',
399 'top_margin' => 'double',
400 'zoom' => 'int',
401 'header' => 'ARRAY[PageSection]',
402 'footer' => 'ARRAY[PageSection]'
403 } );
404
405 __PACKAGE__->attribute_map( {
406 'black_and_white' => 'BlackAndWhite',
407 'bottom_margin' => 'BottomMargin',
408 'center_horizontally' => 'CenterHorizontally',
409 'center_vertically' => 'CenterVertically',
410 'first_page_number' => 'FirstPageNumber',
411 'fit_to_pages_tall' => 'FitToPagesTall',
412 'fit_to_pages_wide' => 'FitToPagesWide',
413 'footer_margin' => 'FooterMargin',
414 'header_margin' => 'HeaderMargin',
415 'is_auto_first_page_number' => 'IsAutoFirstPageNumber',
416 'is_hf_align_margins' => 'IsHFAlignMargins',
417 'is_hf_diff_first' => 'IsHFDiffFirst',
418 'is_hf_diff_odd_even' => 'IsHFDiffOddEven',
419 'is_hf_scale_with_doc' => 'IsHFScaleWithDoc',
420 'is_percent_scale' => 'IsPercentScale',
421 'left_margin' => 'LeftMargin',
422 'order' => 'Order',
423 'orientation' => 'Orientation',
424 'paper_size' => 'PaperSize',
425 'print_area' => 'PrintArea',
426 'print_comments' => 'PrintComments',
427 'print_copies' => 'PrintCopies',
428 'print_draft' => 'PrintDraft',
429 'print_errors' => 'PrintErrors',
430 'print_gridlines' => 'PrintGridlines',
431 'print_headings' => 'PrintHeadings',
432 'print_quality' => 'PrintQuality',
433 'print_title_columns' => 'PrintTitleColumns',
434 'print_title_rows' => 'PrintTitleRows',
435 'right_margin' => 'RightMargin',
436 'top_margin' => 'TopMargin',
437 'zoom' => 'Zoom',
438 'header' => 'Header',
439 'footer' => 'Footer'
440 } );
441
442 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
443
444
445 1;