line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Writer::XLSX::Package::Relationships; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Relationships - A class for writing the Excel XLSX Rels file. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Used in conjunction with Excel::Writer::XLSX |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Copyright 2000-2020, John McNamara, jmcnamara@cpan.org |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Documentation after __END__ |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# perltidy with the following options: -mbl=2 -pt=0 -nola |
15
|
|
|
|
|
|
|
|
16
|
1081
|
|
|
1081
|
|
17201
|
use 5.008002; |
|
1081
|
|
|
|
|
5038
|
|
17
|
1081
|
|
|
1081
|
|
5520
|
use strict; |
|
1081
|
|
|
|
|
4670
|
|
|
1081
|
|
|
|
|
23274
|
|
18
|
1081
|
|
|
1081
|
|
8271
|
use warnings; |
|
1081
|
|
|
|
|
3786
|
|
|
1081
|
|
|
|
|
30731
|
|
19
|
1081
|
|
|
1081
|
|
8540
|
use Carp; |
|
1081
|
|
|
|
|
2408
|
|
|
1081
|
|
|
|
|
60118
|
|
20
|
1081
|
|
|
1081
|
|
8578
|
use Excel::Writer::XLSX::Package::XMLwriter; |
|
1081
|
|
|
|
|
4925
|
|
|
1081
|
|
|
|
|
622527
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @ISA = qw(Excel::Writer::XLSX::Package::XMLwriter); |
23
|
|
|
|
|
|
|
our $VERSION = '1.07'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $schema_root = 'http://schemas.openxmlformats.org'; |
26
|
|
|
|
|
|
|
our $package_schema = $schema_root . '/package/2006/relationships'; |
27
|
|
|
|
|
|
|
our $document_schema = $schema_root . '/officeDocument/2006/relationships'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
############################################################################### |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# Public and private API methods. |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
############################################################################### |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# new() |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
# Constructor. |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
sub new { |
43
|
|
|
|
|
|
|
|
44
|
2854
|
|
|
2854
|
0
|
8275
|
my $class = shift; |
45
|
2854
|
|
|
|
|
4523
|
my $fh = shift; |
46
|
2854
|
|
|
|
|
11706
|
my $self = Excel::Writer::XLSX::Package::XMLwriter->new( $fh ); |
47
|
|
|
|
|
|
|
|
48
|
2854
|
|
|
|
|
6775
|
$self->{_rels} = []; |
49
|
2854
|
|
|
|
|
5706
|
$self->{_id} = 1; |
50
|
|
|
|
|
|
|
|
51
|
2854
|
|
|
|
|
5180
|
bless $self, $class; |
52
|
|
|
|
|
|
|
|
53
|
2854
|
|
|
|
|
6715
|
return $self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
############################################################################### |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
# _assemble_xml_file() |
60
|
|
|
|
|
|
|
# |
61
|
|
|
|
|
|
|
# Assemble and write the XML file. |
62
|
|
|
|
|
|
|
# |
63
|
|
|
|
|
|
|
sub _assemble_xml_file { |
64
|
|
|
|
|
|
|
|
65
|
2853
|
|
|
2853
|
|
5800
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
2853
|
|
|
|
|
13851
|
$self->xml_declaration; |
68
|
2853
|
|
|
|
|
11149
|
$self->_write_relationships(); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
############################################################################### |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# _add_document_relationship() |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
# Add container relationship to XLSX .rels xml files. |
77
|
|
|
|
|
|
|
# |
78
|
|
|
|
|
|
|
sub _add_document_relationship { |
79
|
|
|
|
|
|
|
|
80
|
5223
|
|
|
5223
|
|
8540
|
my $self = shift; |
81
|
5223
|
|
|
|
|
7856
|
my $type = shift; |
82
|
5223
|
|
|
|
|
7421
|
my $target = shift; |
83
|
5223
|
|
|
|
|
7094
|
my $target_mode = shift; |
84
|
|
|
|
|
|
|
|
85
|
5223
|
|
|
|
|
12049
|
$type = $document_schema . $type; |
86
|
|
|
|
|
|
|
|
87
|
5223
|
|
|
|
|
8312
|
push @{ $self->{_rels} }, [ $type, $target, $target_mode ]; |
|
5223
|
|
|
|
|
21550
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
############################################################################### |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# _add_package_relationship() |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# Add container relationship to XLSX .rels xml files. |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
sub _add_package_relationship { |
98
|
|
|
|
|
|
|
|
99
|
849
|
|
|
849
|
|
1856
|
my $self = shift; |
100
|
849
|
|
|
|
|
1808
|
my $type = shift; |
101
|
849
|
|
|
|
|
1706
|
my $target = shift; |
102
|
|
|
|
|
|
|
|
103
|
849
|
|
|
|
|
2619
|
$type = $package_schema . $type; |
104
|
|
|
|
|
|
|
|
105
|
849
|
|
|
|
|
1888
|
push @{ $self->{_rels} }, [ $type, $target ]; |
|
849
|
|
|
|
|
3227
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
############################################################################### |
110
|
|
|
|
|
|
|
# |
111
|
|
|
|
|
|
|
# _add_ms_package_relationship() |
112
|
|
|
|
|
|
|
# |
113
|
|
|
|
|
|
|
# Add container relationship to XLSX .rels xml files. Uses MS schema. |
114
|
|
|
|
|
|
|
# |
115
|
|
|
|
|
|
|
sub _add_ms_package_relationship { |
116
|
|
|
|
|
|
|
|
117
|
6
|
|
|
6
|
|
13
|
my $self = shift; |
118
|
6
|
|
|
|
|
19
|
my $type = shift; |
119
|
6
|
|
|
|
|
12
|
my $target = shift; |
120
|
6
|
|
|
|
|
10
|
my $schema = 'http://schemas.microsoft.com/office/2006/relationships'; |
121
|
|
|
|
|
|
|
|
122
|
6
|
|
|
|
|
17
|
$type = $schema . $type; |
123
|
|
|
|
|
|
|
|
124
|
6
|
|
|
|
|
12
|
push @{ $self->{_rels} }, [ $type, $target ]; |
|
6
|
|
|
|
|
32
|
|
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
############################################################################### |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# _add_worksheet_relationship() |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
# Add worksheet relationship to sheet.rels xml files. |
133
|
|
|
|
|
|
|
# |
134
|
|
|
|
|
|
|
sub _add_worksheet_relationship { |
135
|
|
|
|
|
|
|
|
136
|
735
|
|
|
735
|
|
1598
|
my $self = shift; |
137
|
735
|
|
|
|
|
1657
|
my $type = shift; |
138
|
735
|
|
|
|
|
1485
|
my $target = shift; |
139
|
735
|
|
|
|
|
1423
|
my $target_mode = shift; |
140
|
|
|
|
|
|
|
|
141
|
735
|
|
|
|
|
2394
|
$type = $document_schema . $type; |
142
|
|
|
|
|
|
|
|
143
|
735
|
|
|
|
|
1629
|
push @{ $self->{_rels} }, [ $type, $target, $target_mode ]; |
|
735
|
|
|
|
|
3825
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
############################################################################### |
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
# Internal methods. |
150
|
|
|
|
|
|
|
# |
151
|
|
|
|
|
|
|
############################################################################### |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
############################################################################### |
155
|
|
|
|
|
|
|
# |
156
|
|
|
|
|
|
|
# XML writing methods. |
157
|
|
|
|
|
|
|
# |
158
|
|
|
|
|
|
|
############################################################################### |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
############################################################################## |
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
# _write_relationships() |
164
|
|
|
|
|
|
|
# |
165
|
|
|
|
|
|
|
# Write the element. |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
sub _write_relationships { |
168
|
|
|
|
|
|
|
|
169
|
2853
|
|
|
2853
|
|
5482
|
my $self = shift; |
170
|
|
|
|
|
|
|
|
171
|
2853
|
|
|
|
|
9238
|
my @attributes = ( 'xmlns' => $package_schema, ); |
172
|
|
|
|
|
|
|
|
173
|
2853
|
|
|
|
|
12234
|
$self->xml_start_tag( 'Relationships', @attributes ); |
174
|
|
|
|
|
|
|
|
175
|
2853
|
|
|
|
|
5264
|
for my $rel ( @{ $self->{_rels} } ) { |
|
2853
|
|
|
|
|
7529
|
|
176
|
6813
|
|
|
|
|
15428
|
$self->_write_relationship( @$rel ); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
2853
|
|
|
|
|
12264
|
$self->xml_end_tag( 'Relationships' ); |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# Close the XML writer filehandle. |
182
|
2853
|
|
|
|
|
8864
|
$self->xml_get_fh()->close(); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
############################################################################## |
187
|
|
|
|
|
|
|
# |
188
|
|
|
|
|
|
|
# _write_relationship() |
189
|
|
|
|
|
|
|
# |
190
|
|
|
|
|
|
|
# Write the element. |
191
|
|
|
|
|
|
|
# |
192
|
|
|
|
|
|
|
sub _write_relationship { |
193
|
|
|
|
|
|
|
|
194
|
6813
|
|
|
6813
|
|
10493
|
my $self = shift; |
195
|
6813
|
|
|
|
|
10063
|
my $type = shift; |
196
|
6813
|
|
|
|
|
9620
|
my $target = shift; |
197
|
6813
|
|
|
|
|
9431
|
my $target_mode = shift; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my @attributes = ( |
200
|
6813
|
|
|
|
|
20870
|
'Id' => 'rId' . $self->{_id}++, |
201
|
|
|
|
|
|
|
'Type' => $type, |
202
|
|
|
|
|
|
|
'Target' => $target, |
203
|
|
|
|
|
|
|
); |
204
|
|
|
|
|
|
|
|
205
|
6813
|
100
|
|
|
|
14353
|
push @attributes, ( 'TargetMode' => $target_mode ) if $target_mode; |
206
|
|
|
|
|
|
|
|
207
|
6813
|
|
|
|
|
18593
|
$self->xml_empty_tag( 'Relationship', @attributes ); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
1; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
__END__ |