| 1 | package Google::RestApi::SheetsApi4::Range::Col; | ||||||||||||||||||||||||||||
| 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 Try::Tiny qw( try catch ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use aliased 'Google::RestApi::SheetsApi4::Range'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use aliased 'Google::RestApi::SheetsApi4::Range::Cell'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use parent Range; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 51 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 51 | my $class = shift; | |||||||||||||||||||||||||||
| 16 | 51 | my %self = @_; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 51 | $self{dim} = 'col'; | |||||||||||||||||||||||||||
| 19 | 51 | $self{range} = _col_i2a($self{range}); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # this is fucked up, but want to support creating this object directly and also | ||||||||||||||||||||||||||||
| 22 | # via the range::factory method, so have to handle both cases here. try to create | ||||||||||||||||||||||||||||
| 23 | # the col directly first (which could also come via the factory method, which will | ||||||||||||||||||||||||||||
| 24 | # have already translated the address into a col), and failing that, see if the | ||||||||||||||||||||||||||||
| 25 | # range factory can create a col (which will resolve any named or header references). | ||||||||||||||||||||||||||||
| 26 | # this has the potential of looping between this and factory method. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # if factory has already been used, then this should resolve here. | ||||||||||||||||||||||||||||
| 29 | 51 | my $err; | |||||||||||||||||||||||||||
| 30 | 51 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 51 | state $check = signature(positional => [RangeCol]); | |||||||||||||||||||||||||||
| 32 | 51 | ($self{range}) = $check->($self{range}); | |||||||||||||||||||||||||||
| 33 | 4 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 4 | $err = $_; | |||||||||||||||||||||||||||
| 35 | 51 | }; | |||||||||||||||||||||||||||
| 36 | 51 | ▶ | return $class->SUPER::new(%self) if !$err; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # see if the range passed can be translated to what we want via the factory. | ||||||||||||||||||||||||||||
| 39 | 4 | my $factory_range; | |||||||||||||||||||||||||||
| 40 | 4 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 4 | $factory_range = Google::RestApi::SheetsApi4::Range::factory(%self); | |||||||||||||||||||||||||||
| 42 | 4 | ▶ | } catch {}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 4 | ▶ | return $factory_range if $factory_range && $factory_range->isa(__PACKAGE__); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$factory_range and $factory_range->isa(__PACKAGE__)
MC/DC50%1/2
$factory_range and $factory_range->isa(__PACKAGE__)
$factory_range
$factory_range->isa(__PACKAGE__)
Truth table66%2/3
A and B
A= $factory_rangeB= $factory_range->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | LOGDIE sprintf("Unable to translate '%s' into a worksheet column: $err", flatten_range($self{range})); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 51 | ▶ | sub _col_i2a { | ||||||||||||||||||||||||||
|
Subroutine
_col_i2a: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 49 | 51 | my $col = shift; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 51 | ▶ | return $col if ref($col); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 34 | ▶ | return $col if $col =~ qr/\D/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 5 | ▶ | $col > 0 or die "Column number should greater than zero, got $col"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 5 | my $result = ""; | |||||||||||||||||||||||||||
| 56 | 5 | ▶ | while ($col > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | # The logic requires decrementing first to handle the missing zero symbol in the A-Z system | ||||||||||||||||||||||||||||
| 58 | 12 | my $remainder = ($col - 1) % 26; | |||||||||||||||||||||||||||
| 59 | # Get the ASCII character for the letter (A is 65) | ||||||||||||||||||||||||||||
| 60 | 12 | $result = chr($remainder + ord('A')) . $result; | |||||||||||||||||||||||||||
| 61 | # Update the column number for the next iteration | ||||||||||||||||||||||||||||
| 62 | 12 | $col = int(($col - 1) / 26); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 5 | return $result; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 18 | ▶ | sub values { | ||||||||||||||||||||||||||
|
Subroutine
values: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 18 | my $self = shift; | |||||||||||||||||||||||||||
| 69 | 18 | state $check = signature( | |||||||||||||||||||||||||||
| 70 | bless => !!0, | ||||||||||||||||||||||||||||
| 71 | named => [ | ||||||||||||||||||||||||||||
| 72 | values => ArrayRef[Str], { optional => 1 }, | ||||||||||||||||||||||||||||
| 73 | _extra_ => slurpy HashRef, | ||||||||||||||||||||||||||||
| 74 | ], | ||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | 18 | my $p = named_extra($check->(@_)); | |||||||||||||||||||||||||||
| 77 | 18 | ▶ | $p->{values} = [ $p->{values} ] if defined $p->{values}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 18 | my $values = $self->SUPER::values(%$p); | |||||||||||||||||||||||||||
| 79 | 18 | ▶ | return defined $values ? $values->[0] : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 12 | ▶ | sub batch_values { | ||||||||||||||||||||||||||
|
Subroutine
batch_values: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 84 | 12 | state $check = signature( | |||||||||||||||||||||||||||
| 85 | bless => !!0, | ||||||||||||||||||||||||||||
| 86 | named => [ | ||||||||||||||||||||||||||||
| 87 | values => ArrayRef[Str], { optional => 1 }, | ||||||||||||||||||||||||||||
| 88 | ], | ||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||
| 90 | 12 | my $p = $check->(@_); | |||||||||||||||||||||||||||
| 91 | 12 | ▶ | $p->{values} = [ $p->{values} ] if $p->{values}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 12 | return $self->SUPER::batch_values(%$p); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 12 | ▶ | sub cell_at_offset { | ||||||||||||||||||||||||||
|
Subroutine
cell_at_offset: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 12 | state $check = signature(positional => [Int, DimColRow, { optional => 1 }]); | |||||||||||||||||||||||||||
| 99 | 12 | my ($offset) = $check->(@_); # we're a column, no dim required. | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 12 | my $col_range = $self->range_to_array($Google::RestApi::SheetsApi4::Range::RANGE_EXPANDED); # can't use aliased. | |||||||||||||||||||||||||||
| 102 | 12 | my $cell_range = $col_range->[0]; | |||||||||||||||||||||||||||
| 103 | 12 | ▶ | $cell_range->[1] = ($cell_range->[1] || 1) + $offset; | ||||||||||||||||||||||||||
|
Condition50%1/2
$$cell_range[1] || 1
MC/DC0%0/1
$$cell_range[1] || 1
$$cell_range[1]
Truth table50%1/2
A
A= $$cell_range[1]
| |||||||||||||||||||||||||||||
| 104 | 12 | ▶ | return if $col_range->[1]->[1] && $cell_range->[1] > $col_range->[1]->[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$$col_range[1][1] and $$cell_range[1] > $$col_range[1][1]
MC/DC0%0/2
$$col_range[1][1] and $$cell_range[1] > $$col_range[1][1]
$$col_range[1][1]
$$cell_range[1] > $$col_range[1][1]
Truth table33%1/3
A and B
A= $$col_range[1][1]B= $$cell_range[1] > $$col_range[1][1]
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 12 | my $cell = Cell->new(worksheet => $self->worksheet(), range => $cell_range); | |||||||||||||||||||||||||||
| 107 | 12 | $cell->share_values($self); | |||||||||||||||||||||||||||
| 108 | 12 | return $cell; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 21 | ▶ | sub is_other_inside { | ||||||||||||||||||||||||||
|
Subroutine
is_other_inside: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 21 | state $check = signature(positional => [HasRange]); | |||||||||||||||||||||||||||
| 115 | 21 | my ($inside_range) = $check->(@_); | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 21 | my $range = $self->range_to_hash($Google::RestApi::SheetsApi4::Range::RANGE_EXPANDED); | |||||||||||||||||||||||||||
| 118 | 21 | $inside_range = $inside_range->range_to_hash($Google::RestApi::SheetsApi4::Range::RANGE_EXPANDED); # can't use aliased. | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 21 | ▶ | return if $range->[0]->{col} < $inside_range->[0]->{col}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 18 | ▶ | return if $range->[1]->{col} > $inside_range->[1]->{col}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 18 | ▶ | return if $range->[0]->{row} && $range->[0]->{row} > $inside_range->[0]->{row}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$$range[0]{"row"} and $$range[0]{"row"} > $$inside_range[0]{"row"}
MC/DC100%2/2
$$range[0]{"row"} and $$range[0]{"row"} > $$inside_range[0]{"row"}
$$range[0]{"row"}
$$range[0]{"row"} > $$inside_range[0]{"row"}
Truth table100%3/3
A and B
A= $$range[0]{"row"}B= $$range[0]{"row"} > $$inside_range[0]{"row"}
| |||||||||||||||||||||||||||||
| 123 | 16 | ▶ | return if $range->[1]->{row} && $range->[1]->{row} < $inside_range->[1]->{row}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$range[1]{"row"} and $$range[1]{"row"} < $$inside_range[1]{"row"}
MC/DC0%0/2
$$range[1]{"row"} and $$range[1]{"row"} < $$inside_range[1]{"row"}
$$range[1]{"row"}
$$range[1]{"row"} < $$inside_range[1]{"row"}
Truth table66%2/3
A and B
A= $$range[1]{"row"}B= $$range[1]{"row"} < $$inside_range[1]{"row"}
| |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 16 | return 1; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub freeze { | ||||||||||||||||||||||||||
|
Subroutine
freeze: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | 0 | my $range = $self->range_to_dimension('col'); | |||||||||||||||||||||||||||
| 131 | 0 | return $self->freeze_cols($range->{endIndex}); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub thaw { | ||||||||||||||||||||||||||
|
Subroutine
thaw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 136 | 0 | my $range = $self->range_to_dimension('col'); | |||||||||||||||||||||||||||
| 137 | 0 | return $self->freeze_cols($range->{startIndex}); | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub heading { shift->SUPER::heading(@_)->right()->freeze(); } | ||||||||||||||||||||||||||
|
Subroutine
heading: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub insert_d { shift->insert_dimension(inherit => shift); } | ||||||||||||||||||||||||||
|
Subroutine
insert_d: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub insert_dimension { shift->SUPER::insert_dimension(dimension => 'col', @_); } | ||||||||||||||||||||||||||
|
Subroutine
insert_dimension: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub move_dimension { shift->SUPER::move_dimension(dimension => 'col', @_); } | ||||||||||||||||||||||||||
|
Subroutine
move_dimension: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub delete_dimension { shift->SUPER::delete_dimension(dimension => 'col', @_); } | ||||||||||||||||||||||||||
|
Subroutine
delete_dimension: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 2 | 1; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | __END__ | ||||||||||||||||||||||||||||