« lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookMeta.pm
↑ Summary
lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookProps.pm »
| 1 | package Spreadsheet::Reader::ExcelXML::ZipReader::WorkbookRels; | ||||||||||||||||||||||||||||
| 2 | 14 | our $AUTHORITY = 'cpan:JANDREW'; | |||||||||||||||||||||||||||
| 3 | 14 | ▶ | use version; our $VERSION = version->declare('v0.16.8'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | ###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::ZipReader::WorkbookRels-$VERSION"; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 14 | requires qw( | |||||||||||||||||||||||||||
| 8 | current_node_parsed advance_element_position parse_element | ||||||||||||||||||||||||||||
| 9 | squash_node get_rel_info get_sheet_info | ||||||||||||||||||||||||||||
| 10 | get_sheet_names good_load | ||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||
| 12 | ###LogSD requires 'get_log_space', 'get_all_space'; | ||||||||||||||||||||||||||||
| 13 | 14 | ▶ | use Types::Standard qw( Enum ArrayRef HashRef Bool ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 14 | ▶ | use lib '../../../../../lib',; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | ###LogSD use Log::Shiras::Telephone; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | #########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #########1 Public Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 17 | ▶ | sub load_unique_bits{ | ||||||||||||||||||||||||||
|
Subroutine
load_unique_bits: called CC=11 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 17 | my( $self, ) = @_; | |||||||||||||||||||||||||||
| 30 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||||||||||||
| 31 | ###LogSD $self->get_all_space . '::load_unique_bits', ); | ||||||||||||||||||||||||||||
| 32 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 33 | ###LogSD "Setting the WorkbookRelsInterface unique bits" ] ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Build the list | ||||||||||||||||||||||||||||
| 36 | 17 | $self->start_the_file_over; | |||||||||||||||||||||||||||
| 37 | 17 | my ( $found_member_names, $worksheet_list, $chartsheet_list ); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Handle a zip based file | ||||||||||||||||||||||||||||
| 40 | 17 | my( $result, $node_name, $node_level, $result_ref ) = $self->advance_element_position( 'Relationship' ); | |||||||||||||||||||||||||||
| 41 | 17 | ▶ | while( $result and $node_name eq 'Relationship' ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$result and $node_name eq "Relationship"
MC/DC50%1/2
$result and $node_name eq "Relationship"
$result
$node_name eq "Relationship"
Truth table66%2/3
A and B
A= $resultB= $node_name eq "Relationship"
| |||||||||||||||||||||||||||||
| 42 | 109 | my $relationship_ref = $self->squash_node( $self->parse_element );# Cleans up end nodes without other work | |||||||||||||||||||||||||||
| 43 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 44 | ###LogSD "parsed sheet ref is:", $relationship_ref ] ); | ||||||||||||||||||||||||||||
| 45 | 109 | my $rel_ref = $self->get_rel_info( $relationship_ref->{Id} ) ; | |||||||||||||||||||||||||||
| 46 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 47 | ###LogSD "Current rel ref:", $rel_ref ] ); | ||||||||||||||||||||||||||||
| 48 | 109 | ▶ | if( $rel_ref ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 41 | my $target = 'xl/' . $relationship_ref->{Target}; | |||||||||||||||||||||||||||
| 50 | 41 | my $sheet_ref = $self->get_sheet_info( $rel_ref ); | |||||||||||||||||||||||||||
| 51 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 52 | ###LogSD "Building relationship for: $relationship_ref->{Id}", | ||||||||||||||||||||||||||||
| 53 | ###LogSD "With target: $target", | ||||||||||||||||||||||||||||
| 54 | ###LogSD "For sheet -$rel_ref- with info:", $sheet_ref ] ); | ||||||||||||||||||||||||||||
| 55 | 41 | $target =~ s/\\/\//g; | |||||||||||||||||||||||||||
| 56 | 41 | ▶ | if( $target =~ /worksheets(\\|\/)/ ){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 57 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 58 | ###LogSD "Found a worksheet" ] ); | ||||||||||||||||||||||||||||
| 59 | 40 | $sheet_ref->{file} = $target; | |||||||||||||||||||||||||||
| 60 | 40 | $sheet_ref->{sheet_type} = 'worksheet'; | |||||||||||||||||||||||||||
| 61 | 40 | $self->_set_sheet_info( $rel_ref => $sheet_ref ); | |||||||||||||||||||||||||||
| 62 | 40 | $worksheet_list->[$sheet_ref->{sheet_position}] = $rel_ref; | |||||||||||||||||||||||||||
| 63 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 64 | ###LogSD "Updating sheet member key -$rel_ref- with:", $sheet_ref, | ||||||||||||||||||||||||||||
| 65 | ###LogSD "..and updated worksheet list:", $worksheet_list ] ); | ||||||||||||||||||||||||||||
| 66 | ###LogSD $phone->talk( level => 'trace', message => [ | ||||||||||||||||||||||||||||
| 67 | ###LogSD "..resulting new sheet lookup for sheet: $rel_ref", $self->get_sheet_info( $rel_ref ), ] ); | ||||||||||||||||||||||||||||
| 68 | 40 | $found_member_names = 1; | |||||||||||||||||||||||||||
| 69 | }elsif( $target =~ /chartsheets(\\|\/)/ ){ | ||||||||||||||||||||||||||||
| 70 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 71 | ###LogSD "Found a chartsheet" ] ); | ||||||||||||||||||||||||||||
| 72 | 1 | $sheet_ref->{file} = $target; | |||||||||||||||||||||||||||
| 73 | 1 | $sheet_ref->{sheet_type} = 'chartsheet'; | |||||||||||||||||||||||||||
| 74 | 1 | $self->_set_sheet_info( $rel_ref => $sheet_ref ); | |||||||||||||||||||||||||||
| 75 | 1 | $chartsheet_list->[$sheet_ref->{sheet_position}] = $rel_ref; | |||||||||||||||||||||||||||
| 76 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 77 | ###LogSD "Updating sheet member key -$rel_ref- with:", $sheet_ref, | ||||||||||||||||||||||||||||
| 78 | ###LogSD "..and updated chartsheet list:", $chartsheet_list ] ); | ||||||||||||||||||||||||||||
| 79 | 1 | $found_member_names = 1; | |||||||||||||||||||||||||||
| 80 | }else{# Add method for pivot table lookup later | ||||||||||||||||||||||||||||
| 81 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 82 | ###LogSD "Not a worksheet or a chartsheet - possible pivot table lookup" ] ); | ||||||||||||||||||||||||||||
| 83 | #~ $pivot_lookup->{$rel_ID} = $target; | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 109 | ( $result, $node_name, $node_level, $result_ref ) = $self->advance_element_position( 'Relationship' );# Advance to the next start | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 17 | ▶ | if( !$found_member_names ){# Handle and xml based file | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | confess "Couldn't find any zip member (file) names for the sheets - is the workbook empty?"; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 92 | ###LogSD "Loading the worksheet list with:", $worksheet_list ] ); | ||||||||||||||||||||||||||||
| 93 | 17 | ▶ | map{ $self->_add_worksheet( $_ ) if $_ } @$worksheet_list if $worksheet_list; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 94 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 95 | ###LogSD "Loading the chartsheet list with:", $chartsheet_list ] ); | ||||||||||||||||||||||||||||
| 96 | 17 | ▶ | map{ $self->_add_chartsheet( $_ ) if $_ } @$chartsheet_list if $chartsheet_list; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||||||||||||
| 99 | ###LogSD "Closing out the xml file" ] ); | ||||||||||||||||||||||||||||
| 100 | 17 | $self->close_the_file; | |||||||||||||||||||||||||||
| 101 | 17 | $self->good_load( 1 ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | has _sheet_lookup =>( | ||||||||||||||||||||||||||||
| 107 | isa => HashRef, | ||||||||||||||||||||||||||||
| 108 | traits => ['Hash'], | ||||||||||||||||||||||||||||
| 109 | reader => 'get_sheet_lookup', | ||||||||||||||||||||||||||||
| 110 | handles =>{ | ||||||||||||||||||||||||||||
| 111 | _set_sheet_info => 'set', | ||||||||||||||||||||||||||||
| 112 | }, | ||||||||||||||||||||||||||||
| 113 | 17 | ▶ | default => sub{ {} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 114 | 14 | ); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | has _worksheet_list =>( | ||||||||||||||||||||||||||||
| 117 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 118 | traits => ['Array'], | ||||||||||||||||||||||||||||
| 119 | reader => 'get_worksheet_list', | ||||||||||||||||||||||||||||
| 120 | handles =>{ | ||||||||||||||||||||||||||||
| 121 | _add_worksheet => 'push', | ||||||||||||||||||||||||||||
| 122 | }, | ||||||||||||||||||||||||||||
| 123 | 17 | ▶ | default => sub{ [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 124 | 14 | ); | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | has _chartsheet_list =>( | ||||||||||||||||||||||||||||
| 127 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 128 | traits => ['Array'], | ||||||||||||||||||||||||||||
| 129 | reader => 'get_chartsheet_list', | ||||||||||||||||||||||||||||
| 130 | handles =>{ | ||||||||||||||||||||||||||||
| 131 | _add_chartsheet => 'push', | ||||||||||||||||||||||||||||
| 132 | }, | ||||||||||||||||||||||||||||
| 133 | 17 | ▶ | default => sub{ [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 134 | 14 | ); | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | #########1 Private Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | #########1 Phinish 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 14 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 143 | 14 | 1; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | #########1 Documentation 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||
| 146 | __END__ | ||||||||||||||||||||||||||||