| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (c) 2009, 2010 Oleksandr Tymoshenko <gonzo@bluezbox.com> |
|
2
|
|
|
|
|
|
|
# All rights reserved. |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
|
5
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions |
|
6
|
|
|
|
|
|
|
# are met: |
|
7
|
|
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright |
|
8
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer. |
|
9
|
|
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright |
|
10
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the |
|
11
|
|
|
|
|
|
|
# documentation and/or other materials provided with the distribution. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
14
|
|
|
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
15
|
|
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
16
|
|
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
17
|
|
|
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
18
|
|
|
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
19
|
|
|
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
20
|
|
|
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
21
|
|
|
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
22
|
|
|
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
23
|
|
|
|
|
|
|
# SUCH DAMAGE. |
|
24
|
|
|
|
|
|
|
package EBook::EPUB::NCX::NavPoint; |
|
25
|
1
|
|
|
1
|
|
1641
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has [qw/label id content class/] => ( isa => 'Str', is => 'rw' ); |
|
28
|
|
|
|
|
|
|
has play_order => ( isa => 'Int', is => 'rw' ); |
|
29
|
|
|
|
|
|
|
has navpoints => ( |
|
30
|
|
|
|
|
|
|
traits => ['Array'], |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
|
33
|
|
|
|
|
|
|
default => sub { [] }, |
|
34
|
|
|
|
|
|
|
handles => { |
|
35
|
|
|
|
|
|
|
all_navpoints => 'elements', |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub encode |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
|
|
|
|
|
|
my ($self, $writer) = @_; |
|
42
|
|
|
|
|
|
|
my @args = ( |
|
43
|
|
|
|
|
|
|
id => $self->id, |
|
44
|
|
|
|
|
|
|
playOrder => $self->play_order); |
|
45
|
|
|
|
|
|
|
if (defined($self->class)) { |
|
46
|
|
|
|
|
|
|
push @args, 'class', $self->class; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$writer->startTag('navPoint', @args); |
|
50
|
|
|
|
|
|
|
$writer->startTag('navLabel'); |
|
51
|
|
|
|
|
|
|
$writer->dataElement('text', $self->label); |
|
52
|
|
|
|
|
|
|
$writer->endTag('navLabel'); |
|
53
|
|
|
|
|
|
|
$writer->emptyTag('content', |
|
54
|
|
|
|
|
|
|
src => $self->content, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# subpoints |
|
58
|
|
|
|
|
|
|
foreach my $point (@{$self->navpoints}) { |
|
59
|
|
|
|
|
|
|
$point->encode($writer); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$writer->endTag('navPoint'); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub add_navpoint |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
my ($self, @args) = @_; |
|
68
|
|
|
|
|
|
|
my $subpoint = EBook::EPUB::NCX::NavPoint->new(@args); |
|
69
|
|
|
|
|
|
|
push @{$self->navpoints}, $subpoint; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return $subpoint; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
no Moose; |
|
75
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
EBook::EPUB::NCX::NavPoint |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Entry in Navigation Center that refers to part of a document (e.g. chapter) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item new(%opts) |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
%opts is an anonymous hash that might containe followig keys: |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
class |
|
98
|
|
|
|
|
|
|
content |
|
99
|
|
|
|
|
|
|
id |
|
100
|
|
|
|
|
|
|
play_order |
|
101
|
|
|
|
|
|
|
label |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item add_navpoint(%opts) |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Add refrence to an OPS Content Document that is a part of publication, |
|
106
|
|
|
|
|
|
|
subsection of the part current object references to. %opts is an anonymous |
|
107
|
|
|
|
|
|
|
hash, for possible key values see new() method description. Method returns |
|
108
|
|
|
|
|
|
|
created EBook::EPUB::NCX::NavPoint object that could be used later for adding |
|
109
|
|
|
|
|
|
|
subsections. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item all_navpoints() |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns array of EBook::EPUB::NCX::NavPoint objects, subsections of current one |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item encode($xmlwriter) |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Encode object to XML form using XML::Writer instance |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item class([$class]) |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Get/set class of navigation point |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item content([$content]) |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Get/set URI to the part navPoint references to |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item id([$id]) |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Get/set ID of navigation point |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item label([$label]) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Get/set human readable description of part navPoint references to |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item play_order([$play_order]) |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Get/set play order (number) of text part. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Oleksandr Tymoshenko, E<lt>gonzo@bluezbox.comE<gt> |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 BUGS |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Please report any bugs or feature requests to E<lt>gonzo@bluezbox.comE<gt> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright 2009, 2010 Oleksandr Tymoshenko. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L<http://bluezbox.com> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
156
|
|
|
|
|
|
|
modify it under the terms of the BSD license. See the F<LICENSE> file |
|
157
|
|
|
|
|
|
|
included with this distribution. |
|
158
|
|
|
|
|
|
|
|