| 1 | package EPUB::Parser::Manager::Pages; | ||||||||||
| 2 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 14 | ▶ | use Smart::Args; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 7 | 1 | args( | |||||||||
| 8 | my $class => 'ClassName', | ||||||||||
| 9 | my $opf, | ||||||||||
| 10 | my $navi, | ||||||||||
| 11 | ); | ||||||||||
| 12 | |||||||||||
| 13 | 1 | my $self = bless { | |||||||||
| 14 | opf => $opf, | ||||||||||
| 15 | navi => $navi, | ||||||||||
| 16 | } => $class; | ||||||||||
| 17 | |||||||||||
| 18 | 1 | return $self; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | sub get_page_from_each_chapter { | ||||||||
|
Subroutine
get_page_from_each_chapter: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||
| 22 | 1 | args( | |||||||||
| 23 | my $self, | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 1 | my $tree = { | |||||||||
| 27 | chapter_group => [], | ||||||||||
| 28 | no_chapter_member => [], | ||||||||||
| 29 | }; | ||||||||||
| 30 | |||||||||||
| 31 | 1 | my $chapter_paths = $self->{navi}->chapter_list({ abs => 1 }); | |||||||||
| 32 | 1 | my $spine_paths = $self->{opf}->spine->items_path({ abs => 1 }); | |||||||||
| 33 | 1 | my %spine_paths; | |||||||||
| 34 | 1 | @spine_paths{@$spine_paths} = (0 .. @$spine_paths-1); | |||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 1 | my @chapter_index_on_spine; | |||||||||
| 38 | 1 | for my $chapter_path (@$chapter_paths) { | |||||||||
| 39 | 7 | ▶ | next if !defined $spine_paths{$chapter_path}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 7 | push @chapter_index_on_spine, $spine_paths{$chapter_path}; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | ▶ | if ( $chapter_index_on_spine[0] > 0 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 1 | for my $i ( 0 .. $chapter_index_on_spine[0] -1 ) { | |||||||||
| 45 | 2 | push @{$tree->{no_chapter_member}}, $spine_paths->[$i]; | |||||||||
| 46 | } | ||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 1 | for my $i ( reverse @chapter_index_on_spine ) { | |||||||||
| 50 | 7 | unshift @{$tree->{chapter_group}}, [splice(@$spine_paths,$i)]; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 1 | return $tree; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | 14 | 1; | |||||||||
| 58 | |||||||||||