line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Google::RestApi::SheetsApi4::Range::Cell; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.0.4'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
543
|
use Google::RestApi::Setup; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
13573
|
use Try::Tiny qw( try catch ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
53
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use aliased 'Google::RestApi::SheetsApi4::Range'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
204
|
use parent Range; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# make sure the translated range refers to a single cell (no ':'). |
14
|
|
|
|
|
|
|
sub new { |
15
|
135
|
|
|
135
|
1
|
318
|
my $class = shift; |
16
|
135
|
|
|
|
|
458
|
my %self = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# this is fucked up, but want to support creating this object directly and also |
19
|
|
|
|
|
|
|
# via the range::factory method, so have to handle both cases here. try to create |
20
|
|
|
|
|
|
|
# the cell directly first (which could also come via the factory method, which will |
21
|
|
|
|
|
|
|
# have already translated the address into a cell), and failing that, see if the |
22
|
|
|
|
|
|
|
# range factory can create a cell (which will resolve any named or header references). |
23
|
|
|
|
|
|
|
# this has the potential of looping between this and factory method. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# if factory has already been used, then this should resolve here. |
26
|
135
|
|
|
|
|
285
|
my $err; |
27
|
|
|
|
|
|
|
try { |
28
|
135
|
|
|
135
|
|
6278
|
state $check = compile(RangeCell); |
29
|
135
|
|
|
|
|
375926
|
($self{range}) = $check->($self{range}); |
30
|
|
|
|
|
|
|
} catch { |
31
|
2
|
|
|
2
|
|
237
|
$err = $_; |
32
|
135
|
|
|
|
|
1150
|
}; |
33
|
135
|
100
|
|
|
|
8636
|
return $class->SUPER::new(%self) if !$err; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# see if the range passed can be translated to what we want via the factory. |
36
|
2
|
|
|
|
|
16
|
my $factory_range; |
37
|
|
|
|
|
|
|
try { |
38
|
2
|
|
|
2
|
|
93
|
$factory_range = Google::RestApi::SheetsApi4::Range::factory(%self); |
39
|
2
|
|
|
0
|
|
17
|
} catch {}; |
40
|
2
|
50
|
33
|
|
|
52
|
return $factory_range if $factory_range && $factory_range->isa(__PACKAGE__); |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
LOGDIE sprintf("Unable to translate '%s' into a worksheet cell: $err", flatten_range($self{range})); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub values { |
46
|
101
|
|
|
101
|
1
|
190
|
my $self = shift; |
47
|
101
|
|
|
|
|
166
|
state $check = compile_named( |
48
|
|
|
|
|
|
|
values => Str, { optional => 1 }, |
49
|
|
|
|
|
|
|
_extra_ => slurpy Any, |
50
|
|
|
|
|
|
|
); |
51
|
101
|
|
|
|
|
4237
|
my $p = named_extra($check->(@_)); |
52
|
101
|
50
|
|
|
|
331
|
$p->{values} = [[ $p->{values} ]] if defined $p->{values}; |
53
|
101
|
|
|
|
|
367
|
my $values = $self->SUPER::values(%$p); |
54
|
101
|
100
|
|
|
|
813
|
return defined $values ? $values->[0]->[0] : undef; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub batch_values { |
58
|
36
|
|
|
36
|
1
|
72
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
36
|
|
|
|
|
65
|
state $check = compile_named( |
61
|
|
|
|
|
|
|
values => Str, { optional => 1 }, |
62
|
|
|
|
|
|
|
); |
63
|
36
|
|
|
|
|
2078
|
my $p = $check->(@_); |
64
|
|
|
|
|
|
|
|
65
|
36
|
100
|
|
|
|
763
|
$p->{values} = [[ $p->{values} ]] if $p->{values}; |
66
|
36
|
|
|
|
|
138
|
return $self->SUPER::batch_values(%$p); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# is this 0 or infinity? return self if offset is 0, undef otherwise. |
70
|
|
|
|
|
|
|
sub cell_at_offset { |
71
|
4
|
|
|
4
|
0
|
450
|
my $self = shift; |
72
|
4
|
|
|
|
|
12
|
state $check = compile(Int, DimColRow, { optional => 1 }); |
73
|
4
|
|
|
|
|
3956
|
my ($offset) = $check->(@_); # we're a cell, no dim required. |
74
|
4
|
100
|
|
|
|
134
|
return $self if !$offset; |
75
|
2
|
|
|
|
|
9
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub is_other_inside { |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
state $check = compile(HasRange); |
81
|
0
|
|
|
|
|
|
my ($inside_range) = $check->(@_); |
82
|
0
|
|
|
|
|
|
return $self->range() eq $inside_range->range(); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Google::RestApi::SheetsApi4::Range::Cell - Represents a cell within a Worksheet. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
A Range::Cell object modifies the behaviour of the parent Range object |
96
|
|
|
|
|
|
|
to treat the values used within the range as a plain string instead of |
97
|
|
|
|
|
|
|
arrays of arrays. This object will encapsulate the passed string value |
98
|
|
|
|
|
|
|
into a [[$value]] array of arrays when interacting with Goolge API. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
See the description and synopsis at Google::RestApi::SheetsApi4. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHORS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Robin Murray mvsjes@cpan.org |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Copyright (c) 2021, Robin Murray. All rights reserved. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. |