line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# --*-Perl-*-- |
2
|
|
|
|
|
|
|
# $Id: Style.pm 10 2004-11-02 22:14:09Z tandler $ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package PBib::Style; |
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
8
|
|
|
|
|
|
|
#use English; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# for debug: |
11
|
|
|
|
|
|
|
#use Data::Dumper; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
1
|
|
|
1
|
|
5
|
use vars qw($Revision $VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
106
|
|
15
|
1
|
50
|
|
1
|
|
4
|
my $major = 1; q$Revision: 10 $ =~ /: (\d+)/; my ($minor) = ($1); $VERSION = "$major." . ($minor<10 ? '0' : '') . $minor;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
22
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# superclass |
19
|
|
|
|
|
|
|
#use YYYY; |
20
|
|
|
|
|
|
|
#use vars qw(@ISA); |
21
|
|
|
|
|
|
|
#@ISA = qw(YYYY); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# used modules |
24
|
1
|
|
|
1
|
|
13
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11554
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# module variables |
27
|
|
|
|
|
|
|
#use vars qw(mmmm); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# constructor |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
|
|
|
|
|
|
# 'class' => style class to use |
37
|
|
|
|
|
|
|
# 'style' => if no class is given, try to map the 'style' to a class name |
38
|
8
|
|
|
8
|
0
|
13
|
my $self = shift; |
39
|
8
|
|
|
|
|
40
|
my %args = @_; |
40
|
|
|
|
|
|
|
# foreach my $arg qw/XXX/ { |
41
|
|
|
|
|
|
|
# print STDERR "argument $arg missing in call to new $class\n" |
42
|
|
|
|
|
|
|
# unless exists $args{$arg}; |
43
|
|
|
|
|
|
|
# } |
44
|
8
|
|
33
|
|
|
39
|
my $class = ref($self) || $self; |
45
|
8
|
|
|
|
|
62
|
$class = $class->findStyleClass(%args); |
46
|
8
|
|
|
|
|
31
|
my $new = bless \%args, $class; |
47
|
8
|
|
|
|
|
32
|
return $new; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub findStyleClass { |
51
|
8
|
|
|
8
|
0
|
15
|
my $baseclass = shift; |
52
|
8
|
|
|
|
|
26
|
my %args = @_; |
53
|
8
|
|
|
|
|
34
|
my $class = $args{'class'}; |
54
|
8
|
|
|
|
|
14
|
my $style = $args{'style'}; |
55
|
|
|
|
|
|
|
#print "base=$baseclass, class=$class, style=$style\n"; |
56
|
8
|
50
|
66
|
|
|
35
|
if( ! defined $class && defined $style ) { |
57
|
0
|
|
|
|
|
0
|
$class = ucfirst($style); |
58
|
|
|
|
|
|
|
} |
59
|
8
|
100
|
|
|
|
19
|
if( defined $class ) { |
60
|
6
|
50
|
|
|
|
22
|
unless( $class =~ /::/ ) { |
61
|
6
|
|
|
|
|
16
|
$class = "${baseclass}::$class"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} else { |
64
|
2
|
|
|
|
|
5
|
$class = $baseclass; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
8
|
50
|
|
|
|
21
|
if( defined $class ) { |
68
|
|
|
|
|
|
|
#print ("use $class; \$${class}::VERSION\n"); |
69
|
1
|
|
|
1
|
|
3157
|
my $version = eval("use $class; \$${class}::VERSION"); |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
43
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
15
|
|
|
1
|
|
|
1
|
|
1152
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
1263
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
726
|
|
70
|
8
|
50
|
|
|
|
29
|
unless( defined $version ) { |
71
|
0
|
|
|
|
|
0
|
croak "Failed to open module $class\n"; |
72
|
|
|
|
|
|
|
} |
73
|
8
|
50
|
|
|
|
124
|
unless( $class->isa($baseclass) ) { |
74
|
0
|
|
|
|
|
0
|
croak "Module $class is no subclass of $baseclass\n"; |
75
|
|
|
|
|
|
|
} |
76
|
8
|
50
|
|
|
|
28
|
print STDERR "using $class version $version\n" if $args{'verbose'}; |
77
|
|
|
|
|
|
|
} |
78
|
8
|
|
|
|
|
34
|
return $class; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# |
84
|
|
|
|
|
|
|
# access methods |
85
|
|
|
|
|
|
|
# |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
|
88
|
8
|
|
|
8
|
0
|
14
|
sub setConverter { my ($self, $conv) = @_; $self->{'converter'} = $conv; } |
|
8
|
|
|
|
|
47
|
|
89
|
7913
|
|
|
7913
|
0
|
7669
|
sub converter { my $self = shift; return $self->{'converter'}; } |
|
7913
|
|
|
|
|
20519
|
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
0
|
0
|
sub refStyle { my $self = shift; |
92
|
0
|
|
|
|
|
0
|
my $refStyle = $self->converter()->refStyle(); |
93
|
0
|
|
|
|
|
0
|
$refStyle->setRefID($self->refID()); |
94
|
0
|
|
|
|
|
0
|
return $refStyle; |
95
|
|
|
|
|
|
|
} |
96
|
485
|
|
|
485
|
0
|
507
|
sub labelStyle { my $self = shift; |
97
|
485
|
|
|
|
|
739
|
my $labelStyle = $self->converter()->labelStyle(); |
98
|
485
|
|
|
|
|
949
|
$labelStyle->setRefID($self->refID()); |
99
|
485
|
|
|
|
|
1355
|
return $labelStyle; |
100
|
|
|
|
|
|
|
} |
101
|
2
|
|
|
2
|
0
|
5
|
sub bibStyle { my $self = shift; |
102
|
2
|
|
|
|
|
6
|
my $bibStyle = $self->converter()->bibStyle(); |
103
|
2
|
|
|
|
|
11
|
$bibStyle->setRefID($self->refID()); |
104
|
2
|
|
|
|
|
15
|
return $bibStyle; |
105
|
|
|
|
|
|
|
} |
106
|
110
|
|
|
110
|
0
|
116
|
sub itemStyle { my $self = shift; |
107
|
110
|
|
|
|
|
162
|
my $itemStyle = $self->converter()->itemStyle(); |
108
|
110
|
|
|
|
|
212
|
$itemStyle->setRefID($self->refID()); |
109
|
110
|
|
|
|
|
225
|
return $itemStyle; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# options should be overwritten by subclasses to return correct option hash |
113
|
0
|
|
|
0
|
0
|
0
|
sub options { my $self = shift; return $self->converter()->refOptions(); } |
|
0
|
|
|
|
|
0
|
|
114
|
2786
|
|
|
2786
|
0
|
3434
|
sub option { my ($self, $opt) = @_; return $self->options()->{$opt}; } |
|
2786
|
|
|
|
|
5894
|
|
115
|
|
|
|
|
|
|
|
116
|
1176
|
|
100
|
1176
|
0
|
1186
|
sub fieldOptions { my $self = shift; return $self->{'fieldOptions'} || {}; } |
|
1176
|
|
|
|
|
7839
|
|
117
|
1192
|
|
|
1192
|
0
|
1519
|
sub fieldOption { my ($self, $opt, $options) = @_; |
118
|
1192
|
|
100
|
|
|
4146
|
return ($options && $options->{$opt}) || |
119
|
|
|
|
|
|
|
$self->fieldOptions()->{$opt} || |
120
|
|
|
|
|
|
|
$self->option($opt); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
0
|
0
|
0
|
sub inDoc { my $self = shift; return $self->converter()->inDoc(); } |
|
0
|
|
|
|
|
0
|
|
124
|
730
|
|
|
730
|
0
|
776
|
sub outDoc { my $self = shift; return $self->converter()->outDoc(); } |
|
730
|
|
|
|
|
1128
|
|
125
|
|
|
|
|
|
|
|
126
|
4
|
|
|
4
|
0
|
6
|
sub logMessage { my $self = shift; return $self->converter()->logMessage(@_); } |
|
4
|
|
|
|
|
17
|
|
127
|
2
|
|
|
2
|
0
|
4
|
sub traceMessage { my $self = shift; return $self->converter()->traceMessage(@_); } |
|
2
|
|
|
|
|
7
|
|
128
|
0
|
|
|
0
|
0
|
0
|
sub warn { my $self = shift; return $self->converter()->warn(@_); } |
|
0
|
|
|
|
|
0
|
|
129
|
|
|
|
|
|
|
|
130
|
962
|
|
|
962
|
0
|
1173
|
sub setRefID { my ($self, $refID) = @_; $self->{'refID'} = $refID; } |
|
962
|
|
|
|
|
1755
|
|
131
|
3685
|
|
|
3685
|
0
|
3621
|
sub refID { my $self = shift; return $self->{'refID'}; } |
|
3685
|
|
|
|
|
10537
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
0
|
0
|
0
|
sub entries { my $self = shift; return $self->converter()->entries($self->refID()); } |
|
0
|
|
|
|
|
0
|
|
136
|
2498
|
|
|
2498
|
0
|
3206
|
sub entry { my ($self, $entry, $check) = @_; |
137
|
2498
|
|
|
|
|
4134
|
return $self->converter()->entry($self->refID(), $entry, $check); |
138
|
|
|
|
|
|
|
} |
139
|
0
|
|
|
0
|
0
|
0
|
sub entryExists { my ($self, $entry) = @_; |
140
|
0
|
|
|
|
|
0
|
return $self->converter()->entryExists($self->refID(), $entry); |
141
|
|
|
|
|
|
|
} |
142
|
476
|
|
|
476
|
0
|
572
|
sub entryNotEmpty { my ($self, $entry) = @_; |
143
|
476
|
|
|
|
|
813
|
return $self->converter()->entryNotEmpty($self->refID(), $entry); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
# |
150
|
|
|
|
|
|
|
# methods |
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
# |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub text { |
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
# return the replacement text |
157
|
|
|
|
|
|
|
# the refField is unquoted (i.e. the standard char set), |
158
|
|
|
|
|
|
|
# |
159
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
160
|
0
|
|
|
|
|
0
|
croak "abstract method PBib::Style::text called on class " . ref($self); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# |
165
|
|
|
|
|
|
|
# options |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub parseFieldOptions { |
169
|
8
|
|
|
8
|
0
|
17
|
my ($self, $optionString) = @_; |
170
|
8
|
|
|
|
|
32
|
my @optionArgs = split(/\s*:\s*/, $optionString); |
171
|
8
|
|
|
|
|
35
|
my %options = map( ($self->parseFieldOption($_)), @optionArgs); |
172
|
8
|
|
|
|
|
29
|
return \%options; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
sub parseFieldOption { |
175
|
8
|
|
|
8
|
0
|
13
|
my ($self, $optionString) = @_; |
176
|
|
|
|
|
|
|
# trim string |
177
|
8
|
|
|
|
|
16
|
$optionString =~ s/^\s+//; |
178
|
8
|
|
|
|
|
29
|
$optionString =~ s/\s+$//; |
179
|
|
|
|
|
|
|
#print "<$optionString>\n"; |
180
|
8
|
|
|
|
|
10
|
my $name = $optionString; |
181
|
8
|
|
|
|
|
9
|
my $value = 1; # option turned on |
182
|
8
|
50
|
|
|
|
24
|
if( $name =~ s/\s*=\s*(.*)$// ) { |
183
|
0
|
|
|
|
|
0
|
$value = $1; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
#print "(option <$name> => <$value>) "; |
186
|
8
|
|
|
|
|
37
|
return ($name => $value); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# |
194
|
|
|
|
|
|
|
# $Log: Style.pm,v $ |
195
|
|
|
|
|
|
|
# Revision 1.4 2003/06/12 22:02:20 tandler |
196
|
|
|
|
|
|
|
# support for logMessage() and warn() |
197
|
|
|
|
|
|
|
# |
198
|
|
|
|
|
|
|
# Revision 1.3 2003/01/14 11:07:38 ptandler |
199
|
|
|
|
|
|
|
# new config, allow to select style class |
200
|
|
|
|
|
|
|
# |
201
|
|
|
|
|
|
|
# Revision 1.2 2002/08/08 08:20:59 Diss |
202
|
|
|
|
|
|
|
# - parsing of options moved here |
203
|
|
|
|
|
|
|
# |
204
|
|
|
|
|
|
|
# Revision 1.1 2002/03/27 10:00:51 Diss |
205
|
|
|
|
|
|
|
# new module structure, not yet included in LitRefs/LitUI (R2) |
206
|
|
|
|
|
|
|
# |
207
|
|
|
|
|
|
|
# Revision 1.2 2002/03/22 17:31:01 Diss |
208
|
|
|
|
|
|
|
# small changes |
209
|
|
|
|
|
|
|
# |
210
|
|
|
|
|
|
|
# Revision 1.1 2002/03/18 11:15:50 Diss |
211
|
|
|
|
|
|
|
# major additions: replace [] refs, generate bibliography using [{}], ... |
212
|
|
|
|
|
|
|
# |