RestApi/SheetsApi4/Request/Spreadsheet/Worksheet/Range.pm

filter: Statementstmt 64.5% 197 / 305 Branchbran 52.5% 21 / 40 Conditioncond 64.0% 16 / 25 MC/DCmcdc 42.8% 6 / 14 Subroutinesub 63.4% 78 / 123 Podpod 0.0% 0 / 114 totaltotal 51.2% 318 / 621 CC 34 SCAR 15.3
CC
34
Cov
63%
update_named
56.0
borders
9.0
number_format
6.0
CRAP 4.6
« RestApi/SheetsApi4/Worksheet.pm ↑ Summary RestApi/Utils.pm »
1 package Google::RestApi::SheetsApi4::Request::Spreadsheet::Worksheet::Range;
2  
3 2 our $VERSION = '2.2.5';
4  
5 2 ▶use Google::RestApi::Setup;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use aliased "Google::RestApi::SheetsApi4::Range";
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use parent "Google::RestApi::SheetsApi4::Request::Spreadsheet::Worksheet";
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub range { LOGDIE "Pure virtual function 'range' must be overridden"; }
Subroutine range: not called CC=1 SCAR=6.9
Pod undocumented
12  
13 0 ▶sub left { shift->horizontal_alignment('LEFT'); }
Subroutine left: not called CC=1 SCAR=6.9
Pod undocumented
14 1 ▶sub center { shift->horizontal_alignment('CENTER'); }
Subroutine center: called CC=1 SCAR=0.0
Pod undocumented
15 0 ▶sub right { shift->horizontal_alignment('RIGHT'); }
Subroutine right: not called CC=1 SCAR=6.9
Pod undocumented
16 1 ▶sub horizontal_alignment { shift->user_entered_format({ horizontalAlignment => shift }); }
Subroutine horizontal_alignment: called CC=1 SCAR=0.0
Pod undocumented
17  
18 0 ▶sub top { shift->vertical_alignment('TOP'); }
Subroutine top: not called CC=1 SCAR=6.9
Pod undocumented
19 0 ▶sub middle { shift->vertical_alignment('MIDDLE'); }
Subroutine middle: not called CC=1 SCAR=6.9
Pod undocumented
20 0 ▶sub bottom { shift->vertical_alignment('BOTTOM'); }
Subroutine bottom: not called CC=1 SCAR=6.9
Pod undocumented
21 0 ▶sub vertical_alignment { shift->user_entered_format({ verticalAlignment => shift }); }
Subroutine vertical_alignment: not called CC=1 SCAR=6.9
Pod undocumented
22  
23 2 ▶sub font_family { shift->text_format({ fontFamily => shift }); }
Subroutine font_family: called CC=1 SCAR=0.0
Pod undocumented
24 3 ▶sub font_size { shift->text_format({ fontSize => shift }); }
Subroutine font_size: called CC=1 SCAR=0.0
Pod undocumented
25 4 ▶sub bold { shift->text_format({ bold => bool(shift) }); }
Subroutine bold: called CC=1 SCAR=0.0
Pod undocumented
26 2 ▶sub italic { shift->text_format({ italic => bool(shift) }); }
Subroutine italic: called CC=1 SCAR=0.0
Pod undocumented
27 2 ▶sub strikethrough { shift->text_format({ strikethrough => bool(shift) }); }
Subroutine strikethrough: called CC=1 SCAR=0.0
Pod undocumented
28 2 ▶sub underline { shift->text_format({ underline => bool(shift) }); }
Subroutine underline: called CC=1 SCAR=0.0
Pod undocumented
29  
30 11 ▶sub _rgba { shift->color({ (shift) => (shift // 1) }); }
Subroutine _rgba: called CC=2 SCAR=6.9
Condition100%2/2
shift() // 1
l!l
74
MC/DC100%1/1
shift() // 1
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
31 6 ▶sub red { shift->_rgba('red' => shift); }
Subroutine red: called CC=1 SCAR=0.0
Pod undocumented
32 2 ▶sub blue { shift->_rgba('blue' => shift); }
Subroutine blue: called CC=1 SCAR=0.0
Pod undocumented
33 2 ▶sub green { shift->_rgba('green' => shift); }
Subroutine green: called CC=1 SCAR=0.0
Pod undocumented
34 1 ▶sub alpha { shift->_rgba('alpha' => shift); }
Subroutine alpha: called CC=1 SCAR=0.0
Pod undocumented
35 1 ▶sub black { shift->color(cl_black()); }
Subroutine black: called CC=1 SCAR=0.0
Pod undocumented
36 1 ▶sub white { shift->color(cl_white()); }
Subroutine white: called CC=1 SCAR=0.0
Pod undocumented
37 13 ▶sub color { shift->text_format({ foregroundColor => shift }); }
Subroutine color: called CC=1 SCAR=0.0
Pod undocumented
38  
39 4 ▶sub _bk_rgba { shift->bk_color({ (shift) => (shift // 1) }); }
Subroutine _bk_rgba: called CC=2 SCAR=7.6
Condition50%1/2
shift() // 1
l!l
40
MC/DC0%0/1
shift() // 1
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
40 1 ▶sub bk_red { shift->_bk_rgba('red' => shift); }
Subroutine bk_red: called CC=1 SCAR=0.0
Pod undocumented
41 1 ▶sub bk_blue { shift->_bk_rgba('blue' => shift); }
Subroutine bk_blue: called CC=1 SCAR=0.0
Pod undocumented
42 1 ▶sub bk_green { shift->_bk_rgba('green' => shift); }
Subroutine bk_green: called CC=1 SCAR=0.0
Pod undocumented
43 1 ▶sub bk_alpha { shift->_bk_rgba('alpha' => shift); }
Subroutine bk_alpha: called CC=1 SCAR=0.0
Pod undocumented
44 2 ▶sub bk_black { shift->bk_color(cl_black()); }
Subroutine bk_black: called CC=1 SCAR=0.0
Pod undocumented
45 2 ▶sub bk_white { shift->bk_color(cl_white()); }
Subroutine bk_white: called CC=1 SCAR=0.0
Pod undocumented
46 8 ▶sub bk_color { shift->user_entered_format({ backgroundColor => shift }); }
Subroutine bk_color: called CC=1 SCAR=0.0
Pod undocumented
47  
48 0 ▶sub text { shift->number_format('TEXT', @_); }
Subroutine text: not called CC=1 SCAR=6.9
Pod undocumented
49 0 ▶sub number { shift->number_format('NUMBER', @_); }
Subroutine number: not called CC=1 SCAR=6.9
Pod undocumented
50 0 ▶sub percent { shift->number_format('PERCENT', @_); }
Subroutine percent: not called CC=1 SCAR=6.9
Pod undocumented
51 0 ▶sub currency { shift->number_format('CURRENCY', @_); }
Subroutine currency: not called CC=1 SCAR=6.9
Pod undocumented
52 0 ▶sub date { shift->number_format('DATE', @_); }
Subroutine date: not called CC=1 SCAR=6.9
Pod undocumented
53 0 ▶sub time { shift->number_format('TIME', @_); }
Subroutine time: not called CC=1 SCAR=6.9
Pod undocumented
54 0 ▶sub date_time { shift->number_format('DATE_TIME', @_); }
Subroutine date_time: not called CC=1 SCAR=6.9
Pod undocumented
55 0 ▶sub scientific { shift->number_format('SCIENTIFIC', @_); }
Subroutine scientific: not called CC=1 SCAR=6.9
Pod undocumented
56 0 ▶sub number_format {
Subroutine number_format: not called CC=2 SCAR=17.9
Pod undocumented
57 shift->user_entered_format(
58 {
59 0 ▶ numberFormat => {
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 0 0 0
60 type => shift,
61 defined $_[0] ? (pattern => shift) : ()
62 }
63 },
64 );
65 }
66  
67 1 ▶sub padding { my $s = shift; my %p = @_; $s->user_entered_format({ padding => \%p }); }
Subroutine padding: called CC=1 SCAR=0.0
Pod undocumented
68  
69 0 ▶sub overflow { shift->wrap_strategy('OVERFLOW_CELL'); }
Subroutine overflow: not called CC=1 SCAR=6.9
Pod undocumented
70 1 ▶sub clip { shift->wrap_strategy('CLIP'); }
Subroutine clip: called CC=1 SCAR=0.0
Pod undocumented
71 0 ▶sub wrap { shift->wrap_strategy('WRAP'); }
Subroutine wrap: not called CC=1 SCAR=6.9
Pod undocumented
72 1 ▶sub wrap_strategy { shift->user_entered_format({ wrapStrategy => shift }); }
Subroutine wrap_strategy: called CC=1 SCAR=0.0
Pod undocumented
73  
74 0 ▶sub left_to_right { shift->text_direction('LEFT_TO_RIGHT'); }
Subroutine left_to_right: not called CC=1 SCAR=6.9
Pod undocumented
75 1 ▶sub right_to_left { shift->text_direction('RIGHT_TO_LEFT'); }
Subroutine right_to_left: called CC=1 SCAR=0.0
Pod undocumented
76 1 ▶sub text_direction { shift->user_entered_format({ textDirection => shift }); }
Subroutine text_direction: called CC=1 SCAR=0.0
Pod undocumented
77  
78 1 ▶sub rotate { shift->text_rotation({ angle => shift }); }
Subroutine rotate: called CC=1 SCAR=0.0
Pod undocumented
79 1 ▶sub vertical { shift->text_rotation({ vertical => bool(shift) }); }
Subroutine vertical: called CC=1 SCAR=0.0
Pod undocumented
80 2 ▶sub text_rotation { shift->user_entered_format({ textRotation => shift }); }
Subroutine text_rotation: called CC=1 SCAR=0.0
Pod undocumented
81  
82 1 ▶sub hyper_linked { shift->user_entered_format({ hyperlinkDisplayType => 'LINKED' }); }
Subroutine hyper_linked: called CC=1 SCAR=0.0
Pod undocumented
83 0 ▶sub hyper_plain { shift->user_entered_format({ hyperlinkDisplayType => 'PLAIN_TEXT' }); }
Subroutine hyper_plain: not called CC=1 SCAR=6.9
Pod undocumented
84  
85 28 ▶sub text_format {
Subroutine text_format: called CC=2 SCAR=7.0
Pod undocumented
86 28 my $self = shift;
87 28 my ($format, $fields) = @_;
88 28 ▶ ($fields) = each %$format if !defined $fields;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fields 28 0 28
89 28 $self->user_entered_format(
90 { textFormat => $format },
91 'textFormat.' . $fields,
92 );
93 }
94  
95 44 ▶sub user_entered_format {
Subroutine user_entered_format: called CC=2 SCAR=6.9
Pod undocumented
96 44 my $self = shift;
97 44 my ($format, $fields) = @_;
98 44 ▶ ($fields) = each %$format if !defined $fields;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fields 16 28 44
99 44 $self->repeat_cell(
100 cell => {
101 userEnteredFormat => $format,
102 },
103 fields => 'userEnteredFormat.' . $fields,
104 );
105 44 return $self;
106 }
107  
108 44 ▶sub repeat_cell {
Subroutine repeat_cell: called CC=2 SCAR=7.1
Pod undocumented
109 44 my $self = shift;
110  
111 44 state $check = signature(
112 bless => !!0,
113 named => [
114 cell => HashRef,
115 fields => Str, { optional => 1 },
116 ],
117 );
118 44 my $p = $check->(@_);
119  
120 44 my $cell = $p->{cell};
121 44 ▶ my $fields = $p->{fields} || join(',', sort keys %$cell);
Condition33%1/3
$$p{'fields'} || join(',', sort(keys %$cell))
l!l&&r!l&&!r
4400
MC/DC0%0/2
$$p{'fields'} || join(',', sort(keys %$cell))
$$p{'fields'} join(',', sort(keys %$cell))
Truth table33%1/3
A || B
A= $$p{'fields'}B= join(',', sort(keys %$cell))
ABresult
1X1
011
000
122  
123 44 $self->batch_requests(
124 repeatCell => {
125 range => $self->range_to_index(),
126 cell => $cell,
127 fields => $fields,
128 },
129 );
130  
131 44 return $self;
132 }
133  
134 0 ▶sub heading {
Subroutine heading: not called CC=1 SCAR=6.9
Pod undocumented
135 0 my $self = shift;
136 0 $self->center()->bold()->white()->bk_black()->font_size(12);
137 0 return $self;
138 }
139  
140 30 ▶sub _bd { shift->borders(properties => shift, border => (shift||'')); };
Subroutine _bd: called CC=2 SCAR=6.9
Condition100%2/2
shift() || ''
l!l
291
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
141 5 ▶sub bd_red { shift->_bd_rbga('red' => shift, @_); }
Subroutine bd_red: called CC=1 SCAR=0.0
Pod undocumented
142 1 ▶sub bd_blue { shift->_bd_rbga('blue' => shift, @_); }
Subroutine bd_blue: called CC=1 SCAR=0.0
Pod undocumented
143 1 ▶sub bd_green { shift->_bd_rbga('green' => shift, @_); }
Subroutine bd_green: called CC=1 SCAR=0.0
Pod undocumented
144 1 ▶sub bd_alpha { shift->_bd_rbga('alpha' => shift, @_); }
Subroutine bd_alpha: called CC=1 SCAR=0.0
Pod undocumented
145 2 ▶sub bd_black { shift->bd_color(cl_black(), @_); }
Subroutine bd_black: called CC=1 SCAR=0.0
Pod undocumented
146 2 ▶sub bd_white { shift->bd_color(cl_white(), @_); }
Subroutine bd_white: called CC=1 SCAR=0.0
Pod undocumented
147 12 ▶sub bd_color { shift->_bd({ color => shift }, @_); }
Subroutine bd_color: called CC=1 SCAR=0.0
Pod undocumented
148  
149 12 ▶sub bd_dotted { shift->bd_style('DOTTED', @_); }
Subroutine bd_dotted: called CC=1 SCAR=0.0
Pod undocumented
150 1 ▶sub bd_dashed { shift->bd_style('DASHED', @_); }
Subroutine bd_dashed: called CC=1 SCAR=0.0
Pod undocumented
151 1 ▶sub bd_solid { shift->bd_style('SOLID', @_); }
Subroutine bd_solid: called CC=1 SCAR=0.0
Pod undocumented
152 1 ▶sub bd_medium { shift->bd_style('SOLID_MEDIUM', @_); }
Subroutine bd_medium: called CC=1 SCAR=0.0
Pod undocumented
153 1 ▶sub bd_thick { shift->bd_style('SOLID_THICK', @_); }
Subroutine bd_thick: called CC=1 SCAR=0.0
Pod undocumented
154 1 ▶sub bd_double { shift->bd_style('DOUBLE', @_); }
Subroutine bd_double: called CC=1 SCAR=0.0
Pod undocumented
155 1 ▶sub bd_none { shift->bd_style('NONE', @_); }
Subroutine bd_none: called CC=1 SCAR=0.0
Pod undocumented
156 18 ▶sub bd_style { shift->_bd({ style => shift }, @_); }
Subroutine bd_style: called CC=1 SCAR=0.0
Pod undocumented
157  
158 # allows:
159 # bd_red() turns it all on
160 # bd_red(0) turns it all off
161 # bd_red(0.3, 'top')
162 # bd_red(0.3)
163 # bd_red('top')
164 8 ▶sub _bd_rbga {
Subroutine _bd_rbga: called CC=3 SCAR=11.0
165 8 my $self = shift;
166 8 my $color = shift;
167 8 my $value;
168 8 ▶ $value = shift if looks_like_number($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if &looks_like_number($_[0]) 4 4 8
169 8 ▶ $value //= 1;
Condition100%2/2
$value //= 1
l!l
44
MC/DC100%1/1
$value //= 1
$value
Truth table100%2/2
A
A= $value
Aresult
11
00
170 8 return $self->bd_color({ $color => $value }, @_);
171 }
172  
173 # borders can be set for a range or each individual cell
174 # in a range. bd_repeat_cell is turned on to redirect
175 # border calls to repeat_cell above.
176 1 ▶sub bd_repeat_cell {
Subroutine bd_repeat_cell: called CC=3 SCAR=11.3
Pod undocumented
177 1 my $self = shift;
178 1 $self->{bd_repeat_cell} = shift;
179 1 ▶ $self->{bd_repeat_cell} //= 1; # bd_repeat_cell() turns it on, bd_repeat_cell(0) turns it off.
Condition50%1/2
$$self{"bd_repeat_cell"} //= 1
l!l
01
MC/DC0%0/1
$$self{"bd_repeat_cell"} //= 1
$$self{"bd_repeat_cell"}
Truth table50%1/2
A
A= $$self{"bd_repeat_cell"}
Aresult
11
00
180 1 ▶ delete $self->{bd_repeat_cell} if !$self->{bd_repeat_cell};
Branch: 1 branch
BranchTrueFalseTotal
unless $$self{"bd_repeat_cell"} 0 1 1
181 1 return $self;
182 }
183  
184 57 ▶sub borders {
Subroutine borders: called CC=9 SCAR=22.0
Pod undocumented
185 57 my $self = shift;
186  
187 # allow an array of borders to be passed, recurse with each one.
188 57 my %p = @_;
189 57 ▶ if ($p{border} && ref($p{border}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($p{"border"} and ref $p{"border"} eq "ARRAY") 1 56 57
Condition100%3/3
$p{"border"} and ref $p{"border"} eq "ARRAY"
!ll&&!rl&&r
1551
MC/DC100%2/2
$p{"border"} and ref $p{"border"} eq "ARRAY"
$p{"border"} ref $p{"border"} eq "ARRAY"
Truth table100%3/3
A and B
A= $p{"border"}B= ref $p{"border"} eq "ARRAY"
ABresult
0X0
100
111
190 $self->borders(border => $_, properties => $p{properties})
191 1 foreach (@{ $p{border} });
192 1 return $self;
193 }
194  
195 56 state $check = signature(
196 bless => !!0,
197 named => [
198 border =>
199 StrMatch[qr/^(top|bottom|left|right|around|vertical|horizontal|inner|all|)$/],
200 { default => 'around' },
201 properties => HashRef,
202 ],
203 );
204 56 my $p = $check->(@_);
205 56 ▶ $p->{border} ||= 'around';
Condition100%2/2
$$p{"border"} ||= "around"
l!l
551
MC/DC100%1/1
$$p{"border"} ||= "around"
$$p{"border"}
Truth table100%2/2
A
A= $$p{"border"}
Aresult
11
00
206  
207 # recurse with border groups.
208 56 my %groups = (
209 around => [qw(top bottom left right)],
210 inner => [qw(vertical horizontal)],
211 all => [qw(around inner)],
212 );
213 56 my $group = $groups{ $p->{border} };
214 56 ▶ if ($group) {
Branch: 1 branch
BranchTrueFalseTotal
if ($group) 9 47 56
215 $self->borders(border => $_, properties => $p->{properties})
216 9 foreach (@$group);
217 8 return $self;
218 }
219  
220 # now we finally get to the guts of the borders.
221 # if these borders are to be part of repeatCell request, redirect
222 # the borders to it.
223 47 ▶ if ($self->{bd_repeat_cell}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$self{"bd_repeat_cell"}) 4 43 47
224 LOGDIE "Cannot use vertical|horizontal|inner when bd_repeat_cell is turned on"
225 4 ▶ if $p->{border} =~ /^(vertical|horizontal|inner)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"border"} =~ /^(vertical|horizontal|inner)$/ 3 1 4
226 return $self->user_entered_format(
227 {
228 borders => {
229 $p->{border} => $p->{properties},
230 }
231 },
232 1 );
233 }
234  
235 # change vertical to innerVertical. horizontal same same.
236 43 $p->{border} =~ s/^(vertical|horizontal)$/"'inner' . '" . ucfirst($1) . "'"/ee;
237  
238 $self->batch_requests(
239 updateBorders => {
240 range => $self->range_to_index(),
241 $p->{border} => $p->{properties},
242 }
243 43 );
244  
245 43 return $self;
246 }
247  
248 1 ▶sub merge_cols { shift->merge_cells(merge_type => 'col'); }
Subroutine merge_cols: called CC=1 SCAR=0.0
Pod undocumented
249 1 ▶sub merge_rows { shift->merge_cells(merge_type => 'row'); }
Subroutine merge_rows: called CC=1 SCAR=0.0
Pod undocumented
250 1 ▶sub merge_all { shift->merge_cells(merge_type => 'all'); }
Subroutine merge_all: called CC=1 SCAR=0.0
Pod undocumented
251 1 ▶sub merge_both { merge_all(@_); }
Subroutine merge_both: called CC=1 SCAR=0.0
Pod undocumented
252 3 ▶sub merge_cells {
Subroutine merge_cells: called CC=1 SCAR=0.0
Pod undocumented
253 3 my $self = shift;
254  
255 3 state $check = signature(
256 bless => !!0,
257 named => [
258 merge_type => DimColRow | DimAll,
259 ],
260 );
261 3 my $p = $check->(@_);
262 3 $p->{merge_type} = dims_all($p->{merge_type});
263  
264 3 $self->batch_requests(
265 mergeCells => {
266 range => $self->range_to_index(),
267 mergeType => "MERGE_$p->{merge_type}",
268 },
269 );
270  
271 3 return $self;
272 }
273  
274 0 ▶sub unmerge { unmerge_cells(@_); }
Subroutine unmerge: not called CC=1 SCAR=6.9
Pod undocumented
275 0 ▶sub unmerge_cells {
Subroutine unmerge_cells: not called CC=1 SCAR=6.9
Pod undocumented
276 0 my $self = shift;
277 0 $self->batch_requests(
278 unmergeCells => {
279 range => $self->range_to_index(),
280 },
281 );
282 0 return $self;
283 }
284  
285 0 ▶sub insert_d { shift->insert_dimension(dimension => shift, inherit => shift); }
Subroutine insert_d: not called CC=1 SCAR=6.9
Pod undocumented
286 0 ▶sub insert_dimension {
Subroutine insert_dimension: not called CC=1 SCAR=6.9
Pod undocumented
287 0 my $self = shift;
288  
289 0 state $check = signature(
290 bless => !!0,
291 named => [
292 dimension => Str,
293 inherit => Bool, { default => 0 }
294 ],
295 );
296 0 my $p = $check->(@_);
297  
298 $self->batch_requests(
299 insertDimension => {
300 range => $self->range_to_dimension($p->{dimension}),
301 inheritFromBefore => $p->{inherit},
302 },
303 0 );
304  
305 0 return $self;
306 }
307  
308 0 ▶sub insert_r { shift->insert_dimension(dimension => shift); }
Subroutine insert_r: not called CC=1 SCAR=6.9
Pod undocumented
309 0 ▶sub insert_range {
Subroutine insert_range: not called CC=1 SCAR=6.9
Pod undocumented
310 0 my $self = shift;
311  
312 0 state $check = signature(
313 bless => !!0,
314 named => [
315 dimension => Str,
316 ],
317 );
318 0 my $p = $check->(@_);
319  
320 $self->batch_requests(
321 insertRange => {
322 range => $self->range_to_dimension($p->{dimension}),
323 },
324 shiftDimension => $p->{dimension},
325 0 );
326  
327 0 return $self;
328 }
329  
330 0 ▶sub move { shift->move_dimension(dimension => shift, destination => shift); }
Subroutine move: not called CC=1 SCAR=6.9
Pod undocumented
331 0 ▶sub move_dimension {
Subroutine move_dimension: not called CC=1 SCAR=6.9
Pod undocumented
332 0 my $self = shift;
333  
334 0 state $check = signature(
335 bless => !!0,
336 named => [
337 dimension => Str,
338 destination => HasMethods['range_to_index'],
339 ],
340 );
341 0 my $p = $check->(@_);
342  
343 $self->batch_requests(
344 insertDimension => {
345 range => $self->range_to_dimension($p->{dimension}),
346 destinationIndex => $p->{destination},
347 },
348 0 );
349  
350 0 return $self;
351 }
352  
353 0 ▶sub copy_paste {
Subroutine copy_paste: not called CC=1 SCAR=6.9
Pod undocumented
354 0 my $self = shift;
355  
356 0 state $check = signature(
357 bless => !!0,
358 named => [
359 destination => HasMethods['range_to_index'],
360 type => Str, { default => 'normal' },
361 orientation => Str, { default => 'normal' },
362 ],
363 );
364 0 my $p = $check->(@_);
365 0 $p->{type} = "PASTE_" . uc($p->{type});
366 0 $p->{orientation} = uc($p->{orientation});
367  
368 $self->batch_requests(
369 copyPaste => {
370 source => $self->range_to_index(),
371 destination => $p->{destination}->range_to_index(),
372 type => $p->{type},
373 orientation => $p->{orientation},
374 },
375 0 );
376  
377 0 return $self;
378 }
379  
380 0 ▶sub cut_paste {
Subroutine cut_paste: not called CC=1 SCAR=6.9
Pod undocumented
381 0 my $self = shift;
382  
383 0 state $check = signature(
384 bless => !!0,
385 named => [
386 destination => HasMethods['range_to_index'],
387 type => Str, { default => 'normal' },
388 ],
389 );
390 0 my $p = $check->(@_);
391 0 $p->{type} = "PASTE_" . uc($p->{type});
392  
393 $self->batch_requests(
394 cutPaste => {
395 source => $self->range_to_index(),
396 destination => $p->{destination}->range_to_index(),
397 type => $p->{type},
398 },
399 0 );
400  
401 0 return $self;
402 }
403  
404 0 ▶sub delete_d { shift->delete_dimension(dimension => shift); }
Subroutine delete_d: not called CC=1 SCAR=6.9
Pod undocumented
405 0 ▶sub delete_dimension {
Subroutine delete_dimension: not called CC=1 SCAR=6.9
Pod undocumented
406 0 my $self = shift;
407  
408 0 state $check = signature(bless => !!0, named => [dimension => Str]);
409 0 my $p = $check->(@_);
410  
411 $self->batch_requests(
412 deleteDimension => {
413 0 range => $self->range_to_dimension($p->{dimension}),
414 },
415 );
416  
417 0 return $self;
418 }
419  
420 0 ▶sub delete_r { shift->delete_range(dimension => shift); }
Subroutine delete_r: not called CC=1 SCAR=6.9
Pod undocumented
421 0 ▶sub delete_range {
Subroutine delete_range: not called CC=1 SCAR=6.9
Pod undocumented
422 0 my $self = shift;
423  
424 0 state $check = signature(bless => !!0, named => [dimension => Str]);
425 0 my $p = $check->(@_);
426  
427 $self->batch_requests(
428 deleteRange => {
429 range => $self->range_to_dimension($p->{dimension}),
430 },
431 shiftDimension => $p->{dimension},
432 0 );
433  
434 0 return $self;
435 }
436  
437 0 ▶sub named_a { shift->add_named(name => shift); }
Subroutine named_a: not called CC=1 SCAR=6.9
Pod undocumented
438 0 ▶sub add_named {
Subroutine add_named: not called CC=1 SCAR=6.9
Pod undocumented
439 0 my $self = shift;
440  
441 0 state $check = signature(bless => !!0, named => [name => Str]);
442 0 my $p = $check->(@_);
443  
444 $self->batch_requests(
445 addNamedRange => {
446 namedRange => {
447 name => $p->{name},
448 0 range => $self->range_to_index(),
449 },
450 }
451 );
452  
453 0 return $self;
454 }
455  
456 0 ▶sub named_d { shift->delete_named(); }
Subroutine named_d: not called CC=1 SCAR=6.9
Pod undocumented
457 0 ▶sub delete_named {
Subroutine delete_named: not called CC=2 SCAR=17.9
Pod undocumented
458 0 my $self = shift;
459  
460 0 ▶ my $named = $self->named() or LOGDIE "Not a named range";
Branch: 1 branch
BranchTrueFalseTotal
my $named = $self->named or LOGDIE("Not a named range") 0 0 0
461 0 $self->batch_requests(
462 deleteNamedRange => {
463 namedRangeId => $named,
464 },
465 );
466  
467 0 return $self;
468 }
469  
470 0 ▶sub named_u { shift->update_named(@_); }
Subroutine named_u: not called CC=1 SCAR=6.9
Pod undocumented
471 0 ▶sub update_named {
Subroutine update_named: not called CC=7 SCAR=40.3
Pod undocumented
472 0 my $self = shift;
473  
474 0 state $check = signature(
475 bless => !!0,
476 named => [
477 name => Optional[Str],
478 range => Optional[HashRef],
479 fields => Str, { optional => 1 },
480 ],
481 );
482 0 my $p = $check->(@_);
483  
484 0 ▶ my $named = $self->named() or LOGDIE "Not a named range";
Branch: 1 branch
BranchTrueFalseTotal
my $named = $self->named or LOGDIE("Not a named range") 0 0 0
485 0 my %named_range = (namedRangeId => $named);
486 0 ▶ $named_range{name} = $p->{name} if defined $p->{name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"name"} 0 0 0
487 0 ▶ $named_range{range} = $p->{range} if $p->{range};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"range"} 0 0 0
488  
489 0 my @field_list;
490 0 ▶ push @field_list, 'name' if defined $p->{name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"name"} 0 0 0
491 0 ▶ push @field_list, 'range' if $p->{range};
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"range"} 0 0 0
492 0 ▶ my $fields = $p->{fields} || join(',', @field_list);
Condition0%0/3
$$p{'fields'} || join(',', @field_list)
l!l&&r!l&&!r
000
MC/DC0%0/2
$$p{'fields'} || join(',', @field_list)
$$p{'fields'} join(',', @field_list)
Truth table0%0/3
A || B
A= $$p{'fields'}B= join(',', @field_list)
ABresult
1X1
011
000
493  
494 0 $self->batch_requests(
495 updateNamedRange => {
496 namedRange => \%named_range,
497 fields => $fields,
498 },
499 );
500  
501 0 return $self;
502 }
503  
504 0 ▶sub auto_fill {
Subroutine auto_fill: not called CC=1 SCAR=6.9
Pod undocumented
505 0 my $self = shift;
506  
507 0 state $check = signature(
508 bless => !!0,
509 named => [
510 source => HasMethods['range_to_index'],
511 use_template => Bool, { default => 1 },
512 ],
513 );
514 0 my $p = $check->(@_);
515  
516 $self->batch_requests(
517 autoFill => {
518 range => $self->range_to_index(),
519 sourceAndDestination => {
520 source => $p->{source}->range_to_index(),
521 dimension => 'ROWS',
522 fillLength => 1,
523 },
524 0 useAlternateSeries => bool(!$p->{use_template}),
525 },
526 );
527  
528 0 return $self;
529 }
530  
531 1 ▶sub append_cells {
Subroutine append_cells: called CC=1 SCAR=0.0
Pod undocumented
532 1 my $self = shift;
533  
534 1 state $check = signature(
535 bless => !!0,
536 named => [
537 rows => ArrayRef,
538 fields => Str, { default => '*' },
539 ],
540 );
541 1 my $p = $check->(@_);
542  
543 $self->batch_requests(
544 appendCells => {
545 sheetId => $self->worksheet_id(),
546 rows => $p->{rows},
547 fields => $p->{fields},
548 },
549 1 );
550  
551 1 return $self;
552 }
553  
554 2 ▶sub paste_data {
Subroutine paste_data: called CC=2 SCAR=6.9
Pod undocumented
555 2 my $self = shift;
556  
557 2 state $check = signature(
558 bless => !!0,
559 named => [
560 data => Str,
561 delimiter => Str, { default => "\t" },
562 type => Str, { default => 'PASTE_NORMAL' },
563 html => Bool, { default => 0 },
564 ],
565 );
566 2 my $p = $check->(@_);
567  
568 # pasteData requires a GridCoordinate (single cell), not a GridRange
569 2 my $range_index = $self->range_to_index();
570 my %coordinate = (
571 sheetId => $range_index->{sheetId},
572 rowIndex => $range_index->{startRowIndex},
573 columnIndex => $range_index->{startColumnIndex},
574 2 );
575  
576 my %request = (
577 coordinate => \%coordinate,
578 data => $p->{data},
579 type => $p->{type},
580 2 );
581 2 ▶ if ($p->{html}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$p{'html'}) { } 1 1 2
582 1 $request{html} = bool(1);
583 } else {
584 1 $request{delimiter} = $p->{delimiter};
585 }
586  
587 2 $self->batch_requests(pasteData => \%request);
588  
589 2 return $self;
590 }
591  
592 2 ▶sub text_to_columns {
Subroutine text_to_columns: called CC=2 SCAR=6.9
Pod undocumented
593 2 my $self = shift;
594  
595 2 state $check = signature(
596 bless => !!0,
597 named => [
598 delimiter => Optional[Str],
599 delimiter_type => Str, { default => 'AUTODETECT' },
600 ],
601 );
602 2 my $p = $check->(@_);
603  
604 my %request = (
605 source => $self->range_to_index(),
606 delimiterType => $p->{delimiter_type},
607 2 );
608 2 ▶ $request{delimiter} = $p->{delimiter} if defined $p->{delimiter};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"delimiter"} 1 1 2
609  
610 2 $self->batch_requests(textToColumns => \%request);
611  
612 2 return $self;
613 }
614  
615 2 ▶sub find_replace {
Subroutine find_replace: called CC=1 SCAR=0.0
Pod undocumented
616 2 my $self = shift;
617  
618 2 state $check = signature(
619 bless => !!0,
620 named => [
621 find => Str,
622 replacement => Str, { default => '' },
623 match_case => Bool, { default => 0 },
624 match_entire_cell => Bool, { default => 0 },
625 search_by_regex => Bool, { default => 0 },
626 include_formulas => Bool, { default => 0 },
627 ],
628 );
629 2 my $p = $check->(@_);
630  
631 $self->batch_requests(
632 findReplace => {
633 range => $self->range_to_index(),
634 find => $p->{find},
635 replacement => $p->{replacement},
636 matchCase => bool($p->{match_case}),
637 matchEntireCell => bool($p->{match_entire_cell}),
638 searchByRegex => bool($p->{search_by_regex}),
639 2 includeFormulas => bool($p->{include_formulas}),
640 },
641 );
642  
643 2 return $self;
644 }
645  
646 2 ▶sub set_data_validation {
Subroutine set_data_validation: called CC=1 SCAR=0.0
Pod undocumented
647 2 my $self = shift;
648  
649 2 state $check = signature(
650 bless => !!0,
651 named => [
652 rule => HashRef,
653 ],
654 );
655 2 my $p = $check->(@_);
656  
657 $self->batch_requests(
658 setDataValidation => {
659 range => $self->range_to_index(),
660 rule => $p->{rule},
661 },
662 2 );
663  
664 2 return $self;
665 }
666  
667 1 ▶sub clear_data_validation {
Subroutine clear_data_validation: called CC=1 SCAR=0.0
Pod undocumented
668 1 my $self = shift;
669  
670 1 $self->batch_requests(
671 setDataValidation => {
672 range => $self->range_to_index(),
673 },
674 );
675  
676 1 return $self;
677 }
678  
679 1 ▶sub data_validation_list {
Subroutine data_validation_list: called CC=2 SCAR=6.9
Pod undocumented
680 1 my $self = shift;
681  
682 1 state $check = signature(
683 bless => !!0,
684 named => [
685 values => ArrayRef,
686 strict => Bool, { default => 1 },
687 show_custom => Bool, { default => 0 },
688 input_message => Optional[Str],
689 ],
690 );
691 1 my $p = $check->(@_);
692  
693 1 my @condition_values = map { { userEnteredValue => $_ } } @{ $p->{values} };
694 my %rule = (
695 condition => {
696 type => 'ONE_OF_LIST',
697 values => \@condition_values,
698 },
699 strict => bool($p->{strict}),
700 1 showCustomUi => bool($p->{show_custom}),
701 );
702 1 ▶ $rule{inputMessage} = $p->{input_message} if defined $p->{input_message};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"input_message"} 0 1 1
703  
704 1 $self->set_data_validation(rule => \%rule);
705 }
706  
707 0 ▶sub data_validation_range {
Subroutine data_validation_range: not called CC=2 SCAR=17.9
Pod undocumented
708 0 my $self = shift;
709  
710 0 state $check = signature(
711 bless => !!0,
712 named => [
713 source => HasMethods['range'],
714 strict => Bool, { default => 1 },
715 show_custom => Bool, { default => 0 },
716 input_message => Optional[Str],
717 ],
718 );
719 0 my $p = $check->(@_);
720  
721 my %rule = (
722 condition => {
723 type => 'ONE_OF_RANGE',
724 values => [{ userEnteredValue => '=' . $p->{source}->range() }],
725 },
726 strict => bool($p->{strict}),
727 0 showCustomUi => bool($p->{show_custom}),
728 );
729 0 ▶ $rule{inputMessage} = $p->{input_message} if defined $p->{input_message};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$p{"input_message"} 0 0 0
730  
731 0 $self->set_data_validation(rule => \%rule);
732 }
733  
734 1 ▶sub randomize_range {
Subroutine randomize_range: called CC=1 SCAR=0.0
Pod undocumented
735 1 my $self = shift;
736  
737 1 $self->batch_requests(
738 randomizeRange => {
739 range => $self->range_to_index(),
740 },
741 );
742  
743 1 return $self;
744 }
745  
746 1 ▶sub trim_whitespace {
Subroutine trim_whitespace: called CC=1 SCAR=0.0
Pod undocumented
747 1 my $self = shift;
748  
749 1 $self->batch_requests(
750 trimWhitespace => {
751 range => $self->range_to_index(),
752 },
753 );
754  
755 1 return $self;
756 }
757  
758 2 ▶sub delete_duplicates {
Subroutine delete_duplicates: called CC=2 SCAR=6.9
Pod undocumented
759 2 my $self = shift;
760  
761 2 state $check = signature(
762 bless => !!0,
763 named => [
764 comparison_columns => Optional[ArrayRef],
765 ],
766 );
767 2 my $p = $check->(@_);
768  
769 2 my %request = (range => $self->range_to_index());
770 2 ▶ if ($p->{comparison_columns}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$p{"comparison_columns"}) 1 1 2
771 $request{comparisonColumns} = [
772 2 map { { sheetId => $self->worksheet_id(), dimension => 'COLUMNS', startIndex => $_, endIndex => $_ + 1 } }
773 1 @{ $p->{comparison_columns} }
774 ];
775 }
776  
777 2 $self->batch_requests(deleteDuplicates => \%request);
778  
779 2 return $self;
780 }
781  
782 2 ▶sub sort_range {
Subroutine sort_range: called CC=1 SCAR=0.0
Pod undocumented
783 2 my $self = shift;
784  
785 2 state $check = signature(
786 bless => !!0,
787 named => [
788 sort_specs => ArrayRef,
789 ],
790 );
791 2 my $p = $check->(@_);
792  
793 $self->batch_requests(
794 sortRange => {
795 range => $self->range_to_index(),
796 sortSpecs => $p->{sort_specs},
797 },
798 2 );
799  
800 2 return $self;
801 }
802  
803 1 ▶sub sort_asc {
Subroutine sort_asc: called CC=2 SCAR=7.1
Pod undocumented
804 1 my $self = shift;
805 1 ▶ my $col = shift // 0;
Condition50%1/2
shift() // 0
l!l
10
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
806 1 $self->sort_range(sort_specs => [{ dimensionIndex => $col, sortOrder => 'ASCENDING' }]);
807 }
808  
809 1 ▶sub sort_desc {
Subroutine sort_desc: called CC=2 SCAR=7.1
Pod undocumented
810 1 my $self = shift;
811 1 ▶ my $col = shift // 0;
Condition50%1/2
shift() // 0
l!l
10
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
812 1 $self->sort_range(sort_specs => [{ dimensionIndex => $col, sortOrder => 'DESCENDING' }]);
813 }
814  
815 56 ▶sub _clear {
Subroutine _clear: called CC=1 SCAR=0.0
816 56 my $self = shift;
817 56 return $self->SUPER::_clear(@_, $self->range_to_index());
818 }
819  
820 0 ▶sub range_to_index { shift->range()->range_to_index(@_); }
Subroutine range_to_index: not called CC=1 SCAR=6.9
Pod undocumented
821 0 ▶sub range_to_dimension { shift->range()->range_to_dimension(@_); }
Subroutine range_to_dimension: not called CC=1 SCAR=6.9
Pod undocumented
822  
823 2 1;
824  
825 __END__
« RestApi/SheetsApi4/Worksheet.pm ↑ Summary RestApi/Utils.pm »