| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Excel::Writer::XLSX::Package::Packager; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | ############################################################################### | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # Packager - A class for creating the Excel XLSX package. | 
| 6 |  |  |  |  |  |  | # | 
| 7 |  |  |  |  |  |  | # Used in conjunction with Excel::Writer::XLSX | 
| 8 |  |  |  |  |  |  | # | 
| 9 |  |  |  |  |  |  | # Copyright 2000-2019, 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 | 1040 |  |  | 1040 |  | 22518 | use 5.008002; | 
|  | 1040 |  |  |  |  | 5534 |  | 
| 17 | 1040 |  |  | 1040 |  | 6219 | use strict; | 
|  | 1040 |  |  |  |  | 3698 |  | 
|  | 1040 |  |  |  |  | 27057 |  | 
| 18 | 1040 |  |  | 1040 |  | 6508 | use warnings; | 
|  | 1040 |  |  |  |  | 3671 |  | 
|  | 1040 |  |  |  |  | 28902 |  | 
| 19 | 1040 |  |  | 1040 |  | 8328 | use Exporter; | 
|  | 1040 |  |  |  |  | 3523 |  | 
|  | 1040 |  |  |  |  | 35664 |  | 
| 20 | 1040 |  |  | 1040 |  | 5832 | use Carp; | 
|  | 1040 |  |  |  |  | 3653 |  | 
|  | 1040 |  |  |  |  | 55966 |  | 
| 21 | 1040 |  |  | 1040 |  | 9243 | use File::Copy; | 
|  | 1040 |  |  |  |  | 3557 |  | 
|  | 1040 |  |  |  |  | 58366 |  | 
| 22 | 1040 |  |  | 1040 |  | 500384 | use Excel::Writer::XLSX::Package::App; | 
|  | 1040 |  |  |  |  | 4247 |  | 
|  | 1040 |  |  |  |  | 54528 |  | 
| 23 | 1040 |  |  | 1040 |  | 486000 | use Excel::Writer::XLSX::Package::Comments; | 
|  | 1040 |  |  |  |  | 3161 |  | 
|  | 1040 |  |  |  |  | 61079 |  | 
| 24 | 1040 |  |  | 1040 |  | 492995 | use Excel::Writer::XLSX::Package::ContentTypes; | 
|  | 1040 |  |  |  |  | 4383 |  | 
|  | 1040 |  |  |  |  | 55653 |  | 
| 25 | 1040 |  |  | 1040 |  | 478632 | use Excel::Writer::XLSX::Package::Core; | 
|  | 1040 |  |  |  |  | 4366 |  | 
|  | 1040 |  |  |  |  | 62705 |  | 
| 26 | 1040 |  |  | 1040 |  | 473385 | use Excel::Writer::XLSX::Package::Custom; | 
|  | 1040 |  |  |  |  | 4375 |  | 
|  | 1040 |  |  |  |  | 57204 |  | 
| 27 | 1040 |  |  | 1040 |  | 467270 | use Excel::Writer::XLSX::Package::Relationships; | 
|  | 1040 |  |  |  |  | 5614 |  | 
|  | 1040 |  |  |  |  | 54922 |  | 
| 28 | 1040 |  |  | 1040 |  | 475779 | use Excel::Writer::XLSX::Package::SharedStrings; | 
|  | 1040 |  |  |  |  | 3080 |  | 
|  | 1040 |  |  |  |  | 57338 |  | 
| 29 | 1040 |  |  | 1040 |  | 545623 | use Excel::Writer::XLSX::Package::Styles; | 
|  | 1040 |  |  |  |  | 5536 |  | 
|  | 1040 |  |  |  |  | 57761 |  | 
| 30 | 1040 |  |  | 1040 |  | 484602 | use Excel::Writer::XLSX::Package::Table; | 
|  | 1040 |  |  |  |  | 2872 |  | 
|  | 1040 |  |  |  |  | 59710 |  | 
| 31 | 1040 |  |  | 1040 |  | 544753 | use Excel::Writer::XLSX::Package::Theme; | 
|  | 1040 |  |  |  |  | 5883 |  | 
|  | 1040 |  |  |  |  | 65522 |  | 
| 32 | 1040 |  |  | 1040 |  | 542024 | use Excel::Writer::XLSX::Package::VML; | 
|  | 1040 |  |  |  |  | 4315 |  | 
|  | 1040 |  |  |  |  | 3689491 |  | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | our @ISA     = qw(Exporter); | 
| 35 |  |  |  |  |  |  | our $VERSION = '1.03'; | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | ############################################################################### | 
| 39 |  |  |  |  |  |  | # | 
| 40 |  |  |  |  |  |  | # Public and private API methods. | 
| 41 |  |  |  |  |  |  | # | 
| 42 |  |  |  |  |  |  | ############################################################################### | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | ############################################################################### | 
| 46 |  |  |  |  |  |  | # | 
| 47 |  |  |  |  |  |  | # new() | 
| 48 |  |  |  |  |  |  | # | 
| 49 |  |  |  |  |  |  | # Constructor. | 
| 50 |  |  |  |  |  |  | # | 
| 51 |  |  |  |  |  |  | sub new { | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 809 |  |  | 809 | 0 | 2818 | my $class = shift; | 
| 54 | 809 |  |  |  |  | 2330 | my $fh    = shift; | 
| 55 | 809 |  |  |  |  | 3948 | my $self  = Excel::Writer::XLSX::Package::XMLwriter->new( $fh ); | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 809 |  |  |  |  | 3973 | $self->{_package_dir}      = ''; | 
| 58 | 809 |  |  |  |  | 2697 | $self->{_workbook}         = undef; | 
| 59 | 809 |  |  |  |  | 3036 | $self->{_worksheet_count}  = 0; | 
| 60 | 809 |  |  |  |  | 2895 | $self->{_chartsheet_count} = 0; | 
| 61 | 809 |  |  |  |  | 2570 | $self->{_chart_count}      = 0; | 
| 62 | 809 |  |  |  |  | 2506 | $self->{_drawing_count}    = 0; | 
| 63 | 809 |  |  |  |  | 3416 | $self->{_table_count}      = 0; | 
| 64 | 809 |  |  |  |  | 2992 | $self->{_named_ranges}     = []; | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  |  | 
| 67 | 809 |  |  |  |  | 2604 | bless $self, $class; | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 809 |  |  |  |  | 3387 | return $self; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | ############################################################################### | 
| 74 |  |  |  |  |  |  | # | 
| 75 |  |  |  |  |  |  | # _set_package_dir() | 
| 76 |  |  |  |  |  |  | # | 
| 77 |  |  |  |  |  |  | # Set the XLSX OPC package directory. | 
| 78 |  |  |  |  |  |  | # | 
| 79 |  |  |  |  |  |  | sub _set_package_dir { | 
| 80 |  |  |  |  |  |  |  | 
| 81 | 809 |  |  | 809 |  | 2284 | my $self = shift; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 809 |  |  |  |  | 2770 | $self->{_package_dir} = shift; | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | ############################################################################### | 
| 88 |  |  |  |  |  |  | # | 
| 89 |  |  |  |  |  |  | # _add_workbook() | 
| 90 |  |  |  |  |  |  | # | 
| 91 |  |  |  |  |  |  | # Add the Excel::Writer::XLSX::Workbook object to the package. | 
| 92 |  |  |  |  |  |  | # | 
| 93 |  |  |  |  |  |  | sub _add_workbook { | 
| 94 |  |  |  |  |  |  |  | 
| 95 | 809 |  |  | 809 |  | 2341 | my $self        = shift; | 
| 96 | 809 |  |  |  |  | 1992 | my $workbook    = shift; | 
| 97 |  |  |  |  |  |  |  | 
| 98 | 809 |  |  |  |  | 5665 | $self->{_workbook}          = $workbook; | 
| 99 | 809 |  |  |  |  | 2055 | $self->{_chart_count}       = scalar @{ $workbook->{_charts} }; | 
|  | 809 |  |  |  |  | 2819 |  | 
| 100 | 809 |  |  |  |  | 1972 | $self->{_drawing_count}     = scalar @{ $workbook->{_drawings} }; | 
|  | 809 |  |  |  |  | 2654 |  | 
| 101 | 809 |  |  |  |  | 2473 | $self->{_num_vml_files}     = $workbook->{_num_vml_files}; | 
| 102 | 809 |  |  |  |  | 2351 | $self->{_num_comment_files} = $workbook->{_num_comment_files}; | 
| 103 | 809 |  |  |  |  | 2548 | $self->{_named_ranges}      = $workbook->{_named_ranges}; | 
| 104 |  |  |  |  |  |  |  | 
| 105 | 809 |  |  |  |  | 2005 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3284 |  | 
| 106 | 956 | 100 |  |  |  | 4237 | if ( $worksheet->{_is_chartsheet} ) { | 
| 107 | 20 |  |  |  |  | 75 | $self->{_chartsheet_count}++; | 
| 108 |  |  |  |  |  |  | } | 
| 109 |  |  |  |  |  |  | else { | 
| 110 | 936 |  |  |  |  | 3394 | $self->{_worksheet_count}++; | 
| 111 |  |  |  |  |  |  | } | 
| 112 |  |  |  |  |  |  | } | 
| 113 |  |  |  |  |  |  | } | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | ############################################################################### | 
| 117 |  |  |  |  |  |  | # | 
| 118 |  |  |  |  |  |  | # _create_package() | 
| 119 |  |  |  |  |  |  | # | 
| 120 |  |  |  |  |  |  | # Write the xml files that make up the XLXS OPC package. | 
| 121 |  |  |  |  |  |  | # | 
| 122 |  |  |  |  |  |  | sub _create_package { | 
| 123 |  |  |  |  |  |  |  | 
| 124 | 809 |  |  | 809 |  | 2129 | my $self = shift; | 
| 125 |  |  |  |  |  |  |  | 
| 126 | 809 |  |  |  |  | 4308 | $self->_write_worksheet_files(); | 
| 127 | 809 |  |  |  |  | 49582 | $self->_write_chartsheet_files(); | 
| 128 | 809 |  |  |  |  | 5039 | $self->_write_workbook_file(); | 
| 129 | 809 |  |  |  |  | 35103 | $self->_write_chart_files(); | 
| 130 | 809 |  |  |  |  | 19747 | $self->_write_drawing_files(); | 
| 131 | 809 |  |  |  |  | 21640 | $self->_write_vml_files(); | 
| 132 | 809 |  |  |  |  | 3992 | $self->_write_comment_files(); | 
| 133 | 809 |  |  |  |  | 5640 | $self->_write_table_files(); | 
| 134 | 809 |  |  |  |  | 3901 | $self->_write_shared_strings_file(); | 
| 135 | 809 |  |  |  |  | 15182 | $self->_write_app_file(); | 
| 136 | 809 |  |  |  |  | 42907 | $self->_write_core_file(); | 
| 137 | 809 |  |  |  |  | 41261 | $self->_write_custom_file(); | 
| 138 | 809 |  |  |  |  | 4685 | $self->_write_content_types_file(); | 
| 139 | 809 |  |  |  |  | 42239 | $self->_write_styles_file(); | 
| 140 | 809 |  |  |  |  | 43110 | $self->_write_theme_file(); | 
| 141 | 809 |  |  |  |  | 34504 | $self->_write_root_rels_file(); | 
| 142 | 809 |  |  |  |  | 42635 | $self->_write_workbook_rels_file(); | 
| 143 | 809 |  |  |  |  | 37839 | $self->_write_worksheet_rels_files(); | 
| 144 | 809 |  |  |  |  | 25511 | $self->_write_chartsheet_rels_files(); | 
| 145 | 809 |  |  |  |  | 4553 | $self->_write_drawing_rels_files(); | 
| 146 | 809 |  |  |  |  | 20878 | $self->_add_image_files(); | 
| 147 | 809 |  |  |  |  | 33632 | $self->_add_vba_project(); | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | ############################################################################### | 
| 152 |  |  |  |  |  |  | # | 
| 153 |  |  |  |  |  |  | # _write_workbook_file() | 
| 154 |  |  |  |  |  |  | # | 
| 155 |  |  |  |  |  |  | # Write the workbook.xml file. | 
| 156 |  |  |  |  |  |  | # | 
| 157 |  |  |  |  |  |  | sub _write_workbook_file { | 
| 158 |  |  |  |  |  |  |  | 
| 159 | 809 |  |  | 809 |  | 2114 | my $self     = shift; | 
| 160 | 809 |  |  |  |  | 2995 | my $dir      = $self->{_package_dir}; | 
| 161 | 809 |  |  |  |  | 2320 | my $workbook = $self->{_workbook}; | 
| 162 |  |  |  |  |  |  |  | 
| 163 | 809 |  |  |  |  | 5620 | _mkdir( $dir . '/xl' ); | 
| 164 |  |  |  |  |  |  |  | 
| 165 | 809 |  |  |  |  | 6232 | $workbook->_set_xml_writer( $dir . '/xl/workbook.xml' ); | 
| 166 | 809 |  |  |  |  | 10975 | $workbook->_assemble_xml_file(); | 
| 167 |  |  |  |  |  |  | } | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | ############################################################################### | 
| 171 |  |  |  |  |  |  | # | 
| 172 |  |  |  |  |  |  | # _write_worksheet_files() | 
| 173 |  |  |  |  |  |  | # | 
| 174 |  |  |  |  |  |  | # Write the worksheet files. | 
| 175 |  |  |  |  |  |  | # | 
| 176 |  |  |  |  |  |  | sub _write_worksheet_files { | 
| 177 |  |  |  |  |  |  |  | 
| 178 | 809 |  |  | 809 |  | 2051 | my $self = shift; | 
| 179 | 809 |  |  |  |  | 2442 | my $dir  = $self->{_package_dir}; | 
| 180 |  |  |  |  |  |  |  | 
| 181 | 809 |  |  |  |  | 26291 | _mkdir( $dir . '/xl' ); | 
| 182 | 809 |  |  |  |  | 5330 | _mkdir( $dir . '/xl/worksheets' ); | 
| 183 |  |  |  |  |  |  |  | 
| 184 | 809 |  |  |  |  | 3381 | my $index = 1; | 
| 185 | 809 |  |  |  |  | 2093 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 4081 |  | 
| 186 | 956 | 100 |  |  |  | 11039 | next if $worksheet->{_is_chartsheet}; | 
| 187 |  |  |  |  |  |  |  | 
| 188 | 936 |  |  |  |  | 4988 | $worksheet->_set_xml_writer( | 
| 189 |  |  |  |  |  |  | $dir . '/xl/worksheets/sheet' . $index++ . '.xml' ); | 
| 190 | 936 |  |  |  |  | 5243 | $worksheet->_assemble_xml_file(); | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | } | 
| 193 |  |  |  |  |  |  | } | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  |  | 
| 196 |  |  |  |  |  |  | ############################################################################### | 
| 197 |  |  |  |  |  |  | # | 
| 198 |  |  |  |  |  |  | # _write_chartsheet_files() | 
| 199 |  |  |  |  |  |  | # | 
| 200 |  |  |  |  |  |  | # Write the chartsheet files. | 
| 201 |  |  |  |  |  |  | # | 
| 202 |  |  |  |  |  |  | sub _write_chartsheet_files { | 
| 203 |  |  |  |  |  |  |  | 
| 204 | 809 |  |  | 809 |  | 3238 | my $self = shift; | 
| 205 | 809 |  |  |  |  | 2714 | my $dir  = $self->{_package_dir}; | 
| 206 |  |  |  |  |  |  |  | 
| 207 | 809 |  |  |  |  | 2317 | my $index = 1; | 
| 208 | 809 |  |  |  |  | 2142 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3938 |  | 
| 209 | 956 | 100 |  |  |  | 4564 | next unless $worksheet->{_is_chartsheet}; | 
| 210 |  |  |  |  |  |  |  | 
| 211 | 20 |  |  |  |  | 98 | _mkdir( $dir . '/xl' ); | 
| 212 | 20 |  |  |  |  | 116 | _mkdir( $dir . '/xl/chartsheets' ); | 
| 213 |  |  |  |  |  |  |  | 
| 214 | 20 |  |  |  |  | 149 | $worksheet->_set_xml_writer( | 
| 215 |  |  |  |  |  |  | $dir . '/xl/chartsheets/sheet' . $index++ . '.xml' ); | 
| 216 | 20 |  |  |  |  | 136 | $worksheet->_assemble_xml_file(); | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  | } | 
| 219 |  |  |  |  |  |  | } | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | ############################################################################### | 
| 223 |  |  |  |  |  |  | # | 
| 224 |  |  |  |  |  |  | # _write_chart_files() | 
| 225 |  |  |  |  |  |  | # | 
| 226 |  |  |  |  |  |  | # Write the chart files. | 
| 227 |  |  |  |  |  |  | # | 
| 228 |  |  |  |  |  |  | sub _write_chart_files { | 
| 229 |  |  |  |  |  |  |  | 
| 230 | 809 |  |  | 809 |  | 2423 | my $self = shift; | 
| 231 | 809 |  |  |  |  | 2463 | my $dir  = $self->{_package_dir}; | 
| 232 |  |  |  |  |  |  |  | 
| 233 | 809 | 100 |  |  |  | 1824 | return unless @{ $self->{_workbook}->{_charts} }; | 
|  | 809 |  |  |  |  | 4293 |  | 
| 234 |  |  |  |  |  |  |  | 
| 235 | 353 |  |  |  |  | 1818 | _mkdir( $dir . '/xl' ); | 
| 236 | 353 |  |  |  |  | 2223 | _mkdir( $dir . '/xl/charts' ); | 
| 237 |  |  |  |  |  |  |  | 
| 238 | 353 |  |  |  |  | 1456 | my $index = 1; | 
| 239 | 353 |  |  |  |  | 871 | for my $chart ( @{ $self->{_workbook}->{_charts} } ) { | 
|  | 353 |  |  |  |  | 1660 |  | 
| 240 | 394 |  |  |  |  | 3431 | $chart->_set_xml_writer( | 
| 241 |  |  |  |  |  |  | $dir . '/xl/charts/chart' . $index++ . '.xml' ); | 
| 242 | 394 |  |  |  |  | 4349 | $chart->_assemble_xml_file(); | 
| 243 |  |  |  |  |  |  |  | 
| 244 |  |  |  |  |  |  | } | 
| 245 |  |  |  |  |  |  | } | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  |  | 
| 248 |  |  |  |  |  |  | ############################################################################### | 
| 249 |  |  |  |  |  |  | # | 
| 250 |  |  |  |  |  |  | # _write_drawing_files() | 
| 251 |  |  |  |  |  |  | # | 
| 252 |  |  |  |  |  |  | # Write the drawing files. | 
| 253 |  |  |  |  |  |  | # | 
| 254 |  |  |  |  |  |  | sub _write_drawing_files { | 
| 255 |  |  |  |  |  |  |  | 
| 256 | 809 |  |  | 809 |  | 2081 | my $self = shift; | 
| 257 | 809 |  |  |  |  | 2243 | my $dir  = $self->{_package_dir}; | 
| 258 |  |  |  |  |  |  |  | 
| 259 | 809 | 100 |  |  |  | 3211 | return unless $self->{_drawing_count}; | 
| 260 |  |  |  |  |  |  |  | 
| 261 | 431 |  |  |  |  | 2412 | _mkdir( $dir . '/xl' ); | 
| 262 | 431 |  |  |  |  | 2809 | _mkdir( $dir . '/xl/drawings' ); | 
| 263 |  |  |  |  |  |  |  | 
| 264 | 431 |  |  |  |  | 1902 | my $index = 1; | 
| 265 | 431 |  |  |  |  | 1112 | for my $drawing ( @{ $self->{_workbook}->{_drawings} } ) { | 
|  | 431 |  |  |  |  | 2248 |  | 
| 266 | 469 |  |  |  |  | 3498 | $drawing->_set_xml_writer( | 
| 267 |  |  |  |  |  |  | $dir . '/xl/drawings/drawing' . $index++ . '.xml' ); | 
| 268 | 469 |  |  |  |  | 3120 | $drawing->_assemble_xml_file(); | 
| 269 |  |  |  |  |  |  | } | 
| 270 |  |  |  |  |  |  | } | 
| 271 |  |  |  |  |  |  |  | 
| 272 |  |  |  |  |  |  |  | 
| 273 |  |  |  |  |  |  | ############################################################################### | 
| 274 |  |  |  |  |  |  | # | 
| 275 |  |  |  |  |  |  | # _write_vml_files() | 
| 276 |  |  |  |  |  |  | # | 
| 277 |  |  |  |  |  |  | # Write the comment VML files. | 
| 278 |  |  |  |  |  |  | # | 
| 279 |  |  |  |  |  |  | sub _write_vml_files { | 
| 280 |  |  |  |  |  |  |  | 
| 281 | 809 |  |  | 809 |  | 2178 | my $self = shift; | 
| 282 | 809 |  |  |  |  | 2715 | my $dir  = $self->{_package_dir}; | 
| 283 |  |  |  |  |  |  |  | 
| 284 | 809 |  |  |  |  | 1891 | my $index = 1; | 
| 285 | 809 |  |  |  |  | 1961 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3676 |  | 
| 286 |  |  |  |  |  |  |  | 
| 287 | 956 | 100 | 100 |  |  | 8056 | next if !$worksheet->{_has_vml} and !$worksheet->{_has_header_vml}; | 
| 288 |  |  |  |  |  |  |  | 
| 289 | 74 |  |  |  |  | 367 | _mkdir( $dir . '/xl' ); | 
| 290 | 74 |  |  |  |  | 753 | _mkdir( $dir . '/xl/drawings' ); | 
| 291 |  |  |  |  |  |  |  | 
| 292 | 74 | 100 |  |  |  | 430 | if ( $worksheet->{_has_vml} ) { | 
| 293 | 53 |  |  |  |  | 597 | my $vml = Excel::Writer::XLSX::Package::VML->new(); | 
| 294 |  |  |  |  |  |  |  | 
| 295 | 53 |  |  |  |  | 224 | $vml->_set_xml_writer( | 
| 296 |  |  |  |  |  |  | $dir . '/xl/drawings/vmlDrawing' . $index . '.vml' ); | 
| 297 |  |  |  |  |  |  | $vml->_assemble_xml_file( | 
| 298 |  |  |  |  |  |  | $worksheet->{_vml_data_id},    $worksheet->{_vml_shape_id}, | 
| 299 |  |  |  |  |  |  | $worksheet->{_comments_array}, $worksheet->{_buttons_array}, | 
| 300 |  |  |  |  |  |  | undef | 
| 301 | 53 |  |  |  |  | 434 | ); | 
| 302 |  |  |  |  |  |  |  | 
| 303 | 53 |  |  |  |  | 2784 | $index++; | 
| 304 |  |  |  |  |  |  | } | 
| 305 |  |  |  |  |  |  |  | 
| 306 | 74 | 100 |  |  |  | 423 | if ( $worksheet->{_has_header_vml} ) { | 
| 307 | 22 |  |  |  |  | 214 | my $vml = Excel::Writer::XLSX::Package::VML->new(); | 
| 308 |  |  |  |  |  |  |  | 
| 309 | 22 |  |  |  |  | 109 | $vml->_set_xml_writer( | 
| 310 |  |  |  |  |  |  | $dir . '/xl/drawings/vmlDrawing' . $index . '.vml' ); | 
| 311 |  |  |  |  |  |  | $vml->_assemble_xml_file( | 
| 312 |  |  |  |  |  |  | $worksheet->{_vml_header_id}, | 
| 313 |  |  |  |  |  |  | $worksheet->{_vml_header_id} * 1024, | 
| 314 |  |  |  |  |  |  | undef, undef, $worksheet->{_header_images_array} | 
| 315 | 22 |  |  |  |  | 195 | ); | 
| 316 |  |  |  |  |  |  |  | 
| 317 | 22 |  |  |  |  | 989 | $self->_write_vml_drawing_rels_file($worksheet, $index); | 
| 318 |  |  |  |  |  |  |  | 
| 319 | 22 |  |  |  |  | 1156 | $index++; | 
| 320 |  |  |  |  |  |  | } | 
| 321 |  |  |  |  |  |  | } | 
| 322 |  |  |  |  |  |  | } | 
| 323 |  |  |  |  |  |  |  | 
| 324 |  |  |  |  |  |  |  | 
| 325 |  |  |  |  |  |  | ############################################################################### | 
| 326 |  |  |  |  |  |  | # | 
| 327 |  |  |  |  |  |  | # _write_comment_files() | 
| 328 |  |  |  |  |  |  | # | 
| 329 |  |  |  |  |  |  | # Write the comment files. | 
| 330 |  |  |  |  |  |  | # | 
| 331 |  |  |  |  |  |  | sub _write_comment_files { | 
| 332 |  |  |  |  |  |  |  | 
| 333 | 809 |  |  | 809 |  | 1930 | my $self = shift; | 
| 334 | 809 |  |  |  |  | 2159 | my $dir  = $self->{_package_dir}; | 
| 335 |  |  |  |  |  |  |  | 
| 336 | 809 |  |  |  |  | 1887 | my $index = 1; | 
| 337 | 809 |  |  |  |  | 1808 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3083 |  | 
| 338 | 956 | 100 |  |  |  | 4057 | next unless $worksheet->{_has_comments}; | 
| 339 |  |  |  |  |  |  |  | 
| 340 | 39 |  |  |  |  | 412 | my $comment = Excel::Writer::XLSX::Package::Comments->new(); | 
| 341 |  |  |  |  |  |  |  | 
| 342 | 39 |  |  |  |  | 190 | _mkdir( $dir . '/xl' ); | 
| 343 | 39 |  |  |  |  | 238 | _mkdir( $dir . '/xl/drawings' ); | 
| 344 |  |  |  |  |  |  |  | 
| 345 | 39 |  |  |  |  | 227 | $comment->_set_xml_writer( $dir . '/xl/comments' . $index++ . '.xml' ); | 
| 346 | 39 |  |  |  |  | 230 | $comment->_assemble_xml_file( $worksheet->{_comments_array} ); | 
| 347 |  |  |  |  |  |  | } | 
| 348 |  |  |  |  |  |  | } | 
| 349 |  |  |  |  |  |  |  | 
| 350 |  |  |  |  |  |  |  | 
| 351 |  |  |  |  |  |  | ############################################################################### | 
| 352 |  |  |  |  |  |  | # | 
| 353 |  |  |  |  |  |  | # _write_shared_strings_file() | 
| 354 |  |  |  |  |  |  | # | 
| 355 |  |  |  |  |  |  | # Write the sharedStrings.xml file. | 
| 356 |  |  |  |  |  |  | # | 
| 357 |  |  |  |  |  |  | sub _write_shared_strings_file { | 
| 358 |  |  |  |  |  |  |  | 
| 359 | 809 |  |  | 809 |  | 1957 | my $self = shift; | 
| 360 | 809 |  |  |  |  | 2186 | my $dir  = $self->{_package_dir}; | 
| 361 | 809 |  |  |  |  | 8888 | my $sst  = Excel::Writer::XLSX::Package::SharedStrings->new(); | 
| 362 |  |  |  |  |  |  |  | 
| 363 | 809 |  |  |  |  | 2552 | my $total    = $self->{_workbook}->{_str_total}; | 
| 364 | 809 |  |  |  |  | 2409 | my $unique   = $self->{_workbook}->{_str_unique}; | 
| 365 | 809 |  |  |  |  | 2444 | my $sst_data = $self->{_workbook}->{_str_array}; | 
| 366 |  |  |  |  |  |  |  | 
| 367 | 809 | 100 |  |  |  | 9613 | return unless $total > 0; | 
| 368 |  |  |  |  |  |  |  | 
| 369 | 234 |  |  |  |  | 1280 | _mkdir( $dir . '/xl' ); | 
| 370 |  |  |  |  |  |  |  | 
| 371 | 234 |  |  |  |  | 2036 | $sst->_set_string_count( $total ); | 
| 372 | 234 |  |  |  |  | 1156 | $sst->_set_unique_count( $unique ); | 
| 373 | 234 |  |  |  |  | 1031 | $sst->_add_strings( $sst_data ); | 
| 374 |  |  |  |  |  |  |  | 
| 375 | 234 |  |  |  |  | 1044 | $sst->_set_xml_writer( $dir . '/xl/sharedStrings.xml' ); | 
| 376 | 234 |  |  |  |  | 1461 | $sst->_assemble_xml_file(); | 
| 377 |  |  |  |  |  |  | } | 
| 378 |  |  |  |  |  |  |  | 
| 379 |  |  |  |  |  |  |  | 
| 380 |  |  |  |  |  |  | ############################################################################### | 
| 381 |  |  |  |  |  |  | # | 
| 382 |  |  |  |  |  |  | # _write_app_file() | 
| 383 |  |  |  |  |  |  | # | 
| 384 |  |  |  |  |  |  | # Write the app.xml file. | 
| 385 |  |  |  |  |  |  | # | 
| 386 |  |  |  |  |  |  | sub _write_app_file { | 
| 387 |  |  |  |  |  |  |  | 
| 388 | 809 |  |  | 809 |  | 2182 | my $self       = shift; | 
| 389 | 809 |  |  |  |  | 2331 | my $dir        = $self->{_package_dir}; | 
| 390 | 809 |  |  |  |  | 2372 | my $properties = $self->{_workbook}->{_doc_properties}; | 
| 391 | 809 |  |  |  |  | 7615 | my $app        = Excel::Writer::XLSX::Package::App->new(); | 
| 392 |  |  |  |  |  |  |  | 
| 393 | 809 |  |  |  |  | 3981 | _mkdir( $dir . '/docProps' ); | 
| 394 |  |  |  |  |  |  |  | 
| 395 |  |  |  |  |  |  | # Add the Worksheet heading pairs. | 
| 396 | 809 |  |  |  |  | 9248 | $app->_add_heading_pair( [ 'Worksheets', $self->{_worksheet_count} ] ); | 
| 397 |  |  |  |  |  |  |  | 
| 398 |  |  |  |  |  |  | # Add the Chartsheet heading pairs. | 
| 399 | 809 |  |  |  |  | 5451 | $app->_add_heading_pair( [ 'Charts', $self->{_chartsheet_count} ] ); | 
| 400 |  |  |  |  |  |  |  | 
| 401 |  |  |  |  |  |  | # Add the Worksheet parts. | 
| 402 | 809 |  |  |  |  | 2431 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3786 |  | 
| 403 | 956 | 100 |  |  |  | 4321 | next if $worksheet->{_is_chartsheet}; | 
| 404 | 936 |  |  |  |  | 5049 | $app->_add_part_name( $worksheet->get_name() ); | 
| 405 |  |  |  |  |  |  | } | 
| 406 |  |  |  |  |  |  |  | 
| 407 |  |  |  |  |  |  | # Add the Chartsheet parts. | 
| 408 | 809 |  |  |  |  | 2619 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3484 |  | 
| 409 | 956 | 100 |  |  |  | 4529 | next unless $worksheet->{_is_chartsheet}; | 
| 410 | 20 |  |  |  |  | 192 | $app->_add_part_name( $worksheet->get_name() ); | 
| 411 |  |  |  |  |  |  | } | 
| 412 |  |  |  |  |  |  |  | 
| 413 |  |  |  |  |  |  | # Add the Named Range heading pairs. | 
| 414 | 809 | 100 |  |  |  | 2425 | if ( my $range_count = scalar @{ $self->{_named_ranges} } ) { | 
|  | 809 |  |  |  |  | 4531 |  | 
| 415 | 18 |  |  |  |  | 105 | $app->_add_heading_pair( [ 'Named Ranges', $range_count ] ); | 
| 416 |  |  |  |  |  |  | } | 
| 417 |  |  |  |  |  |  |  | 
| 418 |  |  |  |  |  |  | # Add the Named Ranges parts. | 
| 419 | 809 |  |  |  |  | 2166 | for my $named_range ( @{ $self->{_named_ranges} } ) { | 
|  | 809 |  |  |  |  | 2934 |  | 
| 420 | 38 |  |  |  |  | 113 | $app->_add_part_name( $named_range ); | 
| 421 |  |  |  |  |  |  | } | 
| 422 |  |  |  |  |  |  |  | 
| 423 | 809 |  |  |  |  | 4644 | $app->_set_properties( $properties ); | 
| 424 |  |  |  |  |  |  |  | 
| 425 | 809 |  |  |  |  | 3929 | $app->_set_xml_writer( $dir . '/docProps/app.xml' ); | 
| 426 | 809 |  |  |  |  | 5094 | $app->_assemble_xml_file(); | 
| 427 |  |  |  |  |  |  | } | 
| 428 |  |  |  |  |  |  |  | 
| 429 |  |  |  |  |  |  |  | 
| 430 |  |  |  |  |  |  | ############################################################################### | 
| 431 |  |  |  |  |  |  | # | 
| 432 |  |  |  |  |  |  | # _write_core_file() | 
| 433 |  |  |  |  |  |  | # | 
| 434 |  |  |  |  |  |  | # Write the core.xml file. | 
| 435 |  |  |  |  |  |  | # | 
| 436 |  |  |  |  |  |  | sub _write_core_file { | 
| 437 |  |  |  |  |  |  |  | 
| 438 | 809 |  |  | 809 |  | 2510 | my $self       = shift; | 
| 439 | 809 |  |  |  |  | 2791 | my $dir        = $self->{_package_dir}; | 
| 440 | 809 |  |  |  |  | 2358 | my $properties = $self->{_workbook}->{_doc_properties}; | 
| 441 | 809 |  |  |  |  | 7626 | my $core       = Excel::Writer::XLSX::Package::Core->new(); | 
| 442 |  |  |  |  |  |  |  | 
| 443 | 809 |  |  |  |  | 3879 | _mkdir( $dir . '/docProps' ); | 
| 444 |  |  |  |  |  |  |  | 
| 445 | 809 |  |  |  |  | 7109 | $core->_set_properties( $properties ); | 
| 446 | 809 |  |  |  |  | 3315 | $core->_set_xml_writer( $dir . '/docProps/core.xml' ); | 
| 447 | 809 |  |  |  |  | 5001 | $core->_assemble_xml_file(); | 
| 448 |  |  |  |  |  |  | } | 
| 449 |  |  |  |  |  |  |  | 
| 450 |  |  |  |  |  |  |  | 
| 451 |  |  |  |  |  |  | ############################################################################### | 
| 452 |  |  |  |  |  |  | # | 
| 453 |  |  |  |  |  |  | # _write_custom_file() | 
| 454 |  |  |  |  |  |  | # | 
| 455 |  |  |  |  |  |  | # Write the custom.xml file. | 
| 456 |  |  |  |  |  |  | # | 
| 457 |  |  |  |  |  |  | sub _write_custom_file { | 
| 458 |  |  |  |  |  |  |  | 
| 459 | 809 |  |  | 809 |  | 3154 | my $self       = shift; | 
| 460 | 809 |  |  |  |  | 2906 | my $dir        = $self->{_package_dir}; | 
| 461 | 809 |  |  |  |  | 3066 | my $properties = $self->{_workbook}->{_custom_properties}; | 
| 462 | 809 |  |  |  |  | 8045 | my $custom     = Excel::Writer::XLSX::Package::Custom->new(); | 
| 463 |  |  |  |  |  |  |  | 
| 464 | 809 | 100 |  |  |  | 7777 | return if !@$properties; | 
| 465 |  |  |  |  |  |  |  | 
| 466 | 4 |  |  |  |  | 19 | _mkdir( $dir . '/docProps' ); | 
| 467 |  |  |  |  |  |  |  | 
| 468 | 4 |  |  |  |  | 33 | $custom->_set_properties( $properties ); | 
| 469 | 4 |  |  |  |  | 17 | $custom->_set_xml_writer( $dir . '/docProps/custom.xml' ); | 
| 470 | 4 |  |  |  |  | 23 | $custom->_assemble_xml_file(); | 
| 471 |  |  |  |  |  |  | } | 
| 472 |  |  |  |  |  |  |  | 
| 473 |  |  |  |  |  |  |  | 
| 474 |  |  |  |  |  |  | ############################################################################### | 
| 475 |  |  |  |  |  |  | # | 
| 476 |  |  |  |  |  |  | # _write_content_types_file() | 
| 477 |  |  |  |  |  |  | # | 
| 478 |  |  |  |  |  |  | # Write the ContentTypes.xml file. | 
| 479 |  |  |  |  |  |  | # | 
| 480 |  |  |  |  |  |  | sub _write_content_types_file { | 
| 481 |  |  |  |  |  |  |  | 
| 482 | 809 |  |  | 809 |  | 2828 | my $self    = shift; | 
| 483 | 809 |  |  |  |  | 2629 | my $dir     = $self->{_package_dir}; | 
| 484 | 809 |  |  |  |  | 7161 | my $content = Excel::Writer::XLSX::Package::ContentTypes->new(); | 
| 485 |  |  |  |  |  |  |  | 
| 486 | 809 |  |  |  |  | 2214 | $content->_add_image_types( %{ $self->{_workbook}->{_image_types} } ); | 
|  | 809 |  |  |  |  | 6317 |  | 
| 487 |  |  |  |  |  |  |  | 
| 488 | 809 |  |  |  |  | 2712 | my $worksheet_index  = 1; | 
| 489 | 809 |  |  |  |  | 2036 | my $chartsheet_index = 1; | 
| 490 | 809 |  |  |  |  | 2889 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3717 |  | 
| 491 | 956 | 100 |  |  |  | 4912 | if ( $worksheet->{_is_chartsheet} ) { | 
| 492 | 20 |  |  |  |  | 101 | $content->_add_chartsheet_name( 'sheet' . $chartsheet_index++ ); | 
| 493 |  |  |  |  |  |  | } | 
| 494 |  |  |  |  |  |  | else { | 
| 495 | 936 |  |  |  |  | 6464 | $content->_add_worksheet_name( 'sheet' . $worksheet_index++ ); | 
| 496 |  |  |  |  |  |  | } | 
| 497 |  |  |  |  |  |  | } | 
| 498 |  |  |  |  |  |  |  | 
| 499 | 809 |  |  |  |  | 4408 | for my $i ( 1 .. $self->{_chart_count} ) { | 
| 500 | 394 |  |  |  |  | 2315 | $content->_add_chart_name( 'chart' . $i ); | 
| 501 |  |  |  |  |  |  | } | 
| 502 |  |  |  |  |  |  |  | 
| 503 | 809 |  |  |  |  | 3594 | for my $i ( 1 .. $self->{_drawing_count} ) { | 
| 504 | 469 |  |  |  |  | 2835 | $content->_add_drawing_name( 'drawing' . $i ); | 
| 505 |  |  |  |  |  |  | } | 
| 506 |  |  |  |  |  |  |  | 
| 507 | 809 | 100 |  |  |  | 3976 | if ( $self->{_num_vml_files} ) { | 
| 508 | 57 |  |  |  |  | 281 | $content->_add_vml_name(); | 
| 509 |  |  |  |  |  |  | } | 
| 510 |  |  |  |  |  |  |  | 
| 511 | 809 |  |  |  |  | 4195 | for my $i ( 1 .. $self->{_table_count} ) { | 
| 512 | 35 |  |  |  |  | 177 | $content->_add_table_name( 'table' . $i ); | 
| 513 |  |  |  |  |  |  | } | 
| 514 |  |  |  |  |  |  |  | 
| 515 | 809 |  |  |  |  | 3553 | for my $i ( 1 .. $self->{_num_comment_files} ) { | 
| 516 | 39 |  |  |  |  | 220 | $content->_add_comment_name( 'comments' . $i ); | 
| 517 |  |  |  |  |  |  | } | 
| 518 |  |  |  |  |  |  |  | 
| 519 |  |  |  |  |  |  | # Add the sharedString rel if there is string data in the workbook. | 
| 520 | 809 | 100 |  |  |  | 3823 | if ( $self->{_workbook}->{_str_total} ) { | 
| 521 | 234 |  |  |  |  | 1351 | $content->_add_shared_strings(); | 
| 522 |  |  |  |  |  |  | } | 
| 523 |  |  |  |  |  |  |  | 
| 524 |  |  |  |  |  |  | # Add vbaProject if present. | 
| 525 | 809 | 100 |  |  |  | 3848 | if ( $self->{_workbook}->{_vba_project} ) { | 
| 526 | 5 |  |  |  |  | 25 | $content->_add_vba_project(); | 
| 527 |  |  |  |  |  |  | } | 
| 528 |  |  |  |  |  |  |  | 
| 529 |  |  |  |  |  |  | # Add the custom properties if present. | 
| 530 | 809 | 100 |  |  |  | 2286 | if ( @{ $self->{_workbook}->{_custom_properties} } ) { | 
|  | 809 |  |  |  |  | 4065 |  | 
| 531 | 4 |  |  |  |  | 18 | $content->_add_custom_properties(); | 
| 532 |  |  |  |  |  |  | } | 
| 533 |  |  |  |  |  |  |  | 
| 534 | 809 |  |  |  |  | 4277 | $content->_set_xml_writer( $dir . '/[Content_Types].xml' ); | 
| 535 | 809 |  |  |  |  | 5406 | $content->_assemble_xml_file(); | 
| 536 |  |  |  |  |  |  | } | 
| 537 |  |  |  |  |  |  |  | 
| 538 |  |  |  |  |  |  |  | 
| 539 |  |  |  |  |  |  | ############################################################################### | 
| 540 |  |  |  |  |  |  | # | 
| 541 |  |  |  |  |  |  | # _write_styles_file() | 
| 542 |  |  |  |  |  |  | # | 
| 543 |  |  |  |  |  |  | # Write the style xml file. | 
| 544 |  |  |  |  |  |  | # | 
| 545 |  |  |  |  |  |  | sub _write_styles_file { | 
| 546 |  |  |  |  |  |  |  | 
| 547 | 809 |  |  | 809 |  | 2378 | my $self               = shift; | 
| 548 | 809 |  |  |  |  | 2700 | my $dir                = $self->{_package_dir}; | 
| 549 | 809 |  |  |  |  | 2649 | my $xf_formats         = $self->{_workbook}->{_xf_formats}; | 
| 550 | 809 |  |  |  |  | 2354 | my $palette            = $self->{_workbook}->{_palette}; | 
| 551 | 809 |  |  |  |  | 2161 | my $font_count         = $self->{_workbook}->{_font_count}; | 
| 552 | 809 |  |  |  |  | 2173 | my $num_format_count   = $self->{_workbook}->{_num_format_count}; | 
| 553 | 809 |  |  |  |  | 2091 | my $border_count       = $self->{_workbook}->{_border_count}; | 
| 554 | 809 |  |  |  |  | 2176 | my $fill_count         = $self->{_workbook}->{_fill_count}; | 
| 555 | 809 |  |  |  |  | 2129 | my $custom_colors      = $self->{_workbook}->{_custom_colors}; | 
| 556 | 809 |  |  |  |  | 1971 | my $dxf_formats        = $self->{_workbook}->{_dxf_formats}; | 
| 557 |  |  |  |  |  |  |  | 
| 558 | 809 |  |  |  |  | 7482 | my $rels = Excel::Writer::XLSX::Package::Styles->new(); | 
| 559 |  |  |  |  |  |  |  | 
| 560 | 809 |  |  |  |  | 3766 | _mkdir( $dir . '/xl' ); | 
| 561 |  |  |  |  |  |  |  | 
| 562 | 809 |  |  |  |  | 7916 | $rels->_set_style_properties( | 
| 563 |  |  |  |  |  |  | $xf_formats, | 
| 564 |  |  |  |  |  |  | $palette, | 
| 565 |  |  |  |  |  |  | $font_count, | 
| 566 |  |  |  |  |  |  | $num_format_count, | 
| 567 |  |  |  |  |  |  | $border_count, | 
| 568 |  |  |  |  |  |  | $fill_count, | 
| 569 |  |  |  |  |  |  | $custom_colors, | 
| 570 |  |  |  |  |  |  | $dxf_formats, | 
| 571 |  |  |  |  |  |  | ); | 
| 572 |  |  |  |  |  |  |  | 
| 573 | 809 |  |  |  |  | 3336 | $rels->_set_xml_writer( $dir . '/xl/styles.xml' ); | 
| 574 | 809 |  |  |  |  | 5054 | $rels->_assemble_xml_file(); | 
| 575 |  |  |  |  |  |  | } | 
| 576 |  |  |  |  |  |  |  | 
| 577 |  |  |  |  |  |  |  | 
| 578 |  |  |  |  |  |  | ############################################################################### | 
| 579 |  |  |  |  |  |  | # | 
| 580 |  |  |  |  |  |  | # _write_theme_file() | 
| 581 |  |  |  |  |  |  | # | 
| 582 |  |  |  |  |  |  | # Write the style xml file. | 
| 583 |  |  |  |  |  |  | # | 
| 584 |  |  |  |  |  |  | sub _write_theme_file { | 
| 585 |  |  |  |  |  |  |  | 
| 586 | 809 |  |  | 809 |  | 2503 | my $self = shift; | 
| 587 | 809 |  |  |  |  | 2341 | my $dir  = $self->{_package_dir}; | 
| 588 | 809 |  |  |  |  | 8180 | my $rels = Excel::Writer::XLSX::Package::Theme->new(); | 
| 589 |  |  |  |  |  |  |  | 
| 590 | 809 |  |  |  |  | 3917 | _mkdir( $dir . '/xl' ); | 
| 591 | 809 |  |  |  |  | 5314 | _mkdir( $dir . '/xl/theme' ); | 
| 592 |  |  |  |  |  |  |  | 
| 593 | 809 |  |  |  |  | 5492 | $rels->_set_xml_writer( $dir . '/xl/theme/theme1.xml' ); | 
| 594 | 809 |  |  |  |  | 4484 | $rels->_assemble_xml_file(); | 
| 595 |  |  |  |  |  |  | } | 
| 596 |  |  |  |  |  |  |  | 
| 597 |  |  |  |  |  |  |  | 
| 598 |  |  |  |  |  |  | ############################################################################### | 
| 599 |  |  |  |  |  |  | # | 
| 600 |  |  |  |  |  |  | # _write_table_files() | 
| 601 |  |  |  |  |  |  | # | 
| 602 |  |  |  |  |  |  | # Write the table files. | 
| 603 |  |  |  |  |  |  | # | 
| 604 |  |  |  |  |  |  | sub _write_table_files { | 
| 605 |  |  |  |  |  |  |  | 
| 606 | 809 |  |  | 809 |  | 1964 | my $self = shift; | 
| 607 | 809 |  |  |  |  | 2158 | my $dir  = $self->{_package_dir}; | 
| 608 |  |  |  |  |  |  |  | 
| 609 | 809 |  |  |  |  | 1773 | my $index = 1; | 
| 610 | 809 |  |  |  |  | 1850 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3212 |  | 
| 611 | 956 |  |  |  |  | 2045 | my @table_props = @{ $worksheet->{_tables} }; | 
|  | 956 |  |  |  |  | 2846 |  | 
| 612 |  |  |  |  |  |  |  | 
| 613 | 956 | 100 |  |  |  | 3817 | next unless @table_props; | 
| 614 |  |  |  |  |  |  |  | 
| 615 | 27 |  |  |  |  | 144 | _mkdir( $dir . '/xl' ); | 
| 616 | 27 |  |  |  |  | 164 | _mkdir( $dir . '/xl/tables' ); | 
| 617 |  |  |  |  |  |  |  | 
| 618 | 27 |  |  |  |  | 153 | for my $table_props ( @table_props ) { | 
| 619 |  |  |  |  |  |  |  | 
| 620 | 35 |  |  |  |  | 375 | my $table = Excel::Writer::XLSX::Package::Table->new(); | 
| 621 |  |  |  |  |  |  |  | 
| 622 | 35 |  |  |  |  | 162 | $table->_set_xml_writer( | 
| 623 |  |  |  |  |  |  | $dir . '/xl/tables/table' . $index++ . '.xml' ); | 
| 624 |  |  |  |  |  |  |  | 
| 625 | 35 |  |  |  |  | 554 | $table->_set_properties( $table_props ); | 
| 626 |  |  |  |  |  |  |  | 
| 627 | 35 |  |  |  |  | 140 | $table->_assemble_xml_file(); | 
| 628 |  |  |  |  |  |  |  | 
| 629 | 35 |  |  |  |  | 1681 | $self->{_table_count}++; | 
| 630 |  |  |  |  |  |  | } | 
| 631 |  |  |  |  |  |  | } | 
| 632 |  |  |  |  |  |  | } | 
| 633 |  |  |  |  |  |  |  | 
| 634 |  |  |  |  |  |  |  | 
| 635 |  |  |  |  |  |  | ############################################################################### | 
| 636 |  |  |  |  |  |  | # | 
| 637 |  |  |  |  |  |  | # _write_root_rels_file() | 
| 638 |  |  |  |  |  |  | # | 
| 639 |  |  |  |  |  |  | # Write the _rels/.rels xml file. | 
| 640 |  |  |  |  |  |  | # | 
| 641 |  |  |  |  |  |  | sub _write_root_rels_file { | 
| 642 |  |  |  |  |  |  |  | 
| 643 | 809 |  |  | 809 |  | 2600 | my $self = shift; | 
| 644 | 809 |  |  |  |  | 2445 | my $dir  = $self->{_package_dir}; | 
| 645 | 809 |  |  |  |  | 8681 | my $rels = Excel::Writer::XLSX::Package::Relationships->new(); | 
| 646 |  |  |  |  |  |  |  | 
| 647 | 809 |  |  |  |  | 3756 | _mkdir( $dir . '/_rels' ); | 
| 648 |  |  |  |  |  |  |  | 
| 649 | 809 |  |  |  |  | 7316 | $rels->_add_document_relationship( '/officeDocument', 'xl/workbook.xml' ); | 
| 650 |  |  |  |  |  |  |  | 
| 651 | 809 |  |  |  |  | 4559 | $rels->_add_package_relationship( '/metadata/core-properties', | 
| 652 |  |  |  |  |  |  | 'docProps/core.xml' ); | 
| 653 |  |  |  |  |  |  |  | 
| 654 | 809 |  |  |  |  | 3357 | $rels->_add_document_relationship( '/extended-properties', | 
| 655 |  |  |  |  |  |  | 'docProps/app.xml' ); | 
| 656 |  |  |  |  |  |  |  | 
| 657 | 809 | 100 |  |  |  | 1810 | if ( @{ $self->{_workbook}->{_custom_properties} } ) { | 
|  | 809 |  |  |  |  | 4214 |  | 
| 658 | 4 |  |  |  |  | 28 | $rels->_add_document_relationship( '/custom-properties', | 
| 659 |  |  |  |  |  |  | 'docProps/custom.xml' ); | 
| 660 |  |  |  |  |  |  | } | 
| 661 |  |  |  |  |  |  |  | 
| 662 | 809 |  |  |  |  | 3670 | $rels->_set_xml_writer( $dir . '/_rels/.rels' ); | 
| 663 | 809 |  |  |  |  | 4931 | $rels->_assemble_xml_file(); | 
| 664 |  |  |  |  |  |  | } | 
| 665 |  |  |  |  |  |  |  | 
| 666 |  |  |  |  |  |  |  | 
| 667 |  |  |  |  |  |  | ############################################################################### | 
| 668 |  |  |  |  |  |  | # | 
| 669 |  |  |  |  |  |  | # _write_workbook_rels_file() | 
| 670 |  |  |  |  |  |  | # | 
| 671 |  |  |  |  |  |  | # Write the _rels/.rels xml file. | 
| 672 |  |  |  |  |  |  | # | 
| 673 |  |  |  |  |  |  | sub _write_workbook_rels_file { | 
| 674 |  |  |  |  |  |  |  | 
| 675 | 809 |  |  | 809 |  | 2385 | my $self = shift; | 
| 676 | 809 |  |  |  |  | 2403 | my $dir  = $self->{_package_dir}; | 
| 677 | 809 |  |  |  |  | 5845 | my $rels = Excel::Writer::XLSX::Package::Relationships->new(); | 
| 678 |  |  |  |  |  |  |  | 
| 679 | 809 |  |  |  |  | 3931 | _mkdir( $dir . '/xl' ); | 
| 680 | 809 |  |  |  |  | 5033 | _mkdir( $dir . '/xl/_rels' ); | 
| 681 |  |  |  |  |  |  |  | 
| 682 | 809 |  |  |  |  | 3413 | my $worksheet_index  = 1; | 
| 683 | 809 |  |  |  |  | 2077 | my $chartsheet_index = 1; | 
| 684 |  |  |  |  |  |  |  | 
| 685 | 809 |  |  |  |  | 2025 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3928 |  | 
| 686 | 956 | 100 |  |  |  | 4383 | if ( $worksheet->{_is_chartsheet} ) { | 
| 687 | 20 |  |  |  |  | 97 | $rels->_add_document_relationship( '/chartsheet', | 
| 688 |  |  |  |  |  |  | 'chartsheets/sheet' . $chartsheet_index++ . '.xml' ); | 
| 689 |  |  |  |  |  |  | } | 
| 690 |  |  |  |  |  |  | else { | 
| 691 | 936 |  |  |  |  | 7070 | $rels->_add_document_relationship( '/worksheet', | 
| 692 |  |  |  |  |  |  | 'worksheets/sheet' . $worksheet_index++ . '.xml' ); | 
| 693 |  |  |  |  |  |  | } | 
| 694 |  |  |  |  |  |  | } | 
| 695 |  |  |  |  |  |  |  | 
| 696 | 809 |  |  |  |  | 4150 | $rels->_add_document_relationship( '/theme',  'theme/theme1.xml' ); | 
| 697 | 809 |  |  |  |  | 3807 | $rels->_add_document_relationship( '/styles', 'styles.xml' ); | 
| 698 |  |  |  |  |  |  |  | 
| 699 |  |  |  |  |  |  | # Add the sharedString rel if there is string data in the workbook. | 
| 700 | 809 | 100 |  |  |  | 3888 | if ( $self->{_workbook}->{_str_total} ) { | 
| 701 | 234 |  |  |  |  | 925 | $rels->_add_document_relationship( '/sharedStrings', | 
| 702 |  |  |  |  |  |  | 'sharedStrings.xml' ); | 
| 703 |  |  |  |  |  |  | } | 
| 704 |  |  |  |  |  |  |  | 
| 705 |  |  |  |  |  |  | # Add vbaProject if present. | 
| 706 | 809 | 100 |  |  |  | 3859 | if ( $self->{_workbook}->{_vba_project} ) { | 
| 707 | 5 |  |  |  |  | 22 | $rels->_add_ms_package_relationship( '/vbaProject', 'vbaProject.bin' ); | 
| 708 |  |  |  |  |  |  | } | 
| 709 |  |  |  |  |  |  |  | 
| 710 | 809 |  |  |  |  | 3743 | $rels->_set_xml_writer( $dir . '/xl/_rels/workbook.xml.rels' ); | 
| 711 | 809 |  |  |  |  | 4639 | $rels->_assemble_xml_file(); | 
| 712 |  |  |  |  |  |  | } | 
| 713 |  |  |  |  |  |  |  | 
| 714 |  |  |  |  |  |  |  | 
| 715 |  |  |  |  |  |  | ############################################################################### | 
| 716 |  |  |  |  |  |  | # | 
| 717 |  |  |  |  |  |  | # _write_worksheet_rels_files() | 
| 718 |  |  |  |  |  |  | # | 
| 719 |  |  |  |  |  |  | # Write the worksheet .rels files for worksheets that contain links to external | 
| 720 |  |  |  |  |  |  | # data such as hyperlinks or drawings. | 
| 721 |  |  |  |  |  |  | # | 
| 722 |  |  |  |  |  |  | sub _write_worksheet_rels_files { | 
| 723 |  |  |  |  |  |  |  | 
| 724 | 809 |  |  | 809 |  | 2330 | my $self = shift; | 
| 725 | 809 |  |  |  |  | 2534 | my $dir  = $self->{_package_dir}; | 
| 726 |  |  |  |  |  |  |  | 
| 727 | 809 |  |  |  |  | 2031 | my $index = 0; | 
| 728 | 809 |  |  |  |  | 1956 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3821 |  | 
| 729 |  |  |  |  |  |  |  | 
| 730 | 956 | 100 |  |  |  | 5929 | next if $worksheet->{_is_chartsheet}; | 
| 731 |  |  |  |  |  |  |  | 
| 732 | 936 |  |  |  |  | 2251 | $index++; | 
| 733 |  |  |  |  |  |  |  | 
| 734 |  |  |  |  |  |  | my @external_links = ( | 
| 735 | 936 |  |  |  |  | 2689 | @{ $worksheet->{_external_hyper_links} }, | 
| 736 | 936 |  |  |  |  | 2361 | @{ $worksheet->{_external_drawing_links} }, | 
| 737 | 936 |  |  |  |  | 2415 | @{ $worksheet->{_external_vml_links} }, | 
| 738 | 936 |  |  |  |  | 2344 | @{ $worksheet->{_external_table_links} }, | 
| 739 | 936 |  |  |  |  | 2044 | @{ $worksheet->{_external_comment_links} }, | 
|  | 936 |  |  |  |  | 2878 |  | 
| 740 |  |  |  |  |  |  | ); | 
| 741 |  |  |  |  |  |  |  | 
| 742 | 936 | 100 |  |  |  | 3647 | next unless @external_links; | 
| 743 |  |  |  |  |  |  |  | 
| 744 |  |  |  |  |  |  | # Create the worksheet .rels dirs. | 
| 745 | 580 |  |  |  |  | 2639 | _mkdir( $dir . '/xl' ); | 
| 746 | 580 |  |  |  |  | 3820 | _mkdir( $dir . '/xl/worksheets' ); | 
| 747 | 580 |  |  |  |  | 3304 | _mkdir( $dir . '/xl/worksheets/_rels' ); | 
| 748 |  |  |  |  |  |  |  | 
| 749 | 580 |  |  |  |  | 5769 | my $rels = Excel::Writer::XLSX::Package::Relationships->new(); | 
| 750 |  |  |  |  |  |  |  | 
| 751 | 580 |  |  |  |  | 2154 | for my $link_data ( @external_links ) { | 
| 752 | 671 |  |  |  |  | 3002 | $rels->_add_worksheet_relationship( @$link_data ); | 
| 753 |  |  |  |  |  |  | } | 
| 754 |  |  |  |  |  |  |  | 
| 755 |  |  |  |  |  |  | # Create the .rels file such as /xl/worksheets/_rels/sheet1.xml.rels. | 
| 756 |  |  |  |  |  |  | $rels->_set_xml_writer( | 
| 757 | 580 |  |  |  |  | 2578 | $dir . '/xl/worksheets/_rels/sheet' . $index . '.xml.rels' ); | 
| 758 | 580 |  |  |  |  | 2913 | $rels->_assemble_xml_file(); | 
| 759 |  |  |  |  |  |  | } | 
| 760 |  |  |  |  |  |  | } | 
| 761 |  |  |  |  |  |  |  | 
| 762 |  |  |  |  |  |  |  | 
| 763 |  |  |  |  |  |  | ############################################################################### | 
| 764 |  |  |  |  |  |  | # | 
| 765 |  |  |  |  |  |  | # _write_chartsheet_rels_files() | 
| 766 |  |  |  |  |  |  | # | 
| 767 |  |  |  |  |  |  | # Write the chartsheet .rels files for links to drawing files. | 
| 768 |  |  |  |  |  |  | # | 
| 769 |  |  |  |  |  |  | sub _write_chartsheet_rels_files { | 
| 770 |  |  |  |  |  |  |  | 
| 771 | 809 |  |  | 809 |  | 2262 | my $self = shift; | 
| 772 | 809 |  |  |  |  | 2298 | my $dir  = $self->{_package_dir}; | 
| 773 |  |  |  |  |  |  |  | 
| 774 |  |  |  |  |  |  |  | 
| 775 | 809 |  |  |  |  | 1882 | my $index = 0; | 
| 776 | 809 |  |  |  |  | 1851 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3466 |  | 
| 777 |  |  |  |  |  |  |  | 
| 778 | 956 | 100 |  |  |  | 4710 | next unless $worksheet->{_is_chartsheet}; | 
| 779 |  |  |  |  |  |  |  | 
| 780 | 20 |  |  |  |  | 47 | $index++; | 
| 781 |  |  |  |  |  |  |  | 
| 782 | 20 |  |  |  |  | 34 | my @external_links = @{ $worksheet->{_external_drawing_links} }; | 
|  | 20 |  |  |  |  | 69 |  | 
| 783 |  |  |  |  |  |  |  | 
| 784 | 20 | 50 |  |  |  | 69 | next unless @external_links; | 
| 785 |  |  |  |  |  |  |  | 
| 786 |  |  |  |  |  |  | # Create the chartsheet .rels dir. | 
| 787 | 20 |  |  |  |  | 91 | _mkdir( $dir . '/xl' ); | 
| 788 | 20 |  |  |  |  | 121 | _mkdir( $dir . '/xl/chartsheets' ); | 
| 789 | 20 |  |  |  |  | 106 | _mkdir( $dir . '/xl/chartsheets/_rels' ); | 
| 790 |  |  |  |  |  |  |  | 
| 791 | 20 |  |  |  |  | 195 | my $rels = Excel::Writer::XLSX::Package::Relationships->new(); | 
| 792 |  |  |  |  |  |  |  | 
| 793 | 20 |  |  |  |  | 79 | for my $link_data ( @external_links ) { | 
| 794 | 20 |  |  |  |  | 96 | $rels->_add_worksheet_relationship( @$link_data ); | 
| 795 |  |  |  |  |  |  | } | 
| 796 |  |  |  |  |  |  |  | 
| 797 |  |  |  |  |  |  | # Create the .rels file such as /xl/chartsheets/_rels/sheet1.xml.rels. | 
| 798 |  |  |  |  |  |  | $rels->_set_xml_writer( | 
| 799 | 20 |  |  |  |  | 94 | $dir . '/xl/chartsheets/_rels/sheet' . $index . '.xml.rels' ); | 
| 800 | 20 |  |  |  |  | 103 | $rels->_assemble_xml_file(); | 
| 801 |  |  |  |  |  |  | } | 
| 802 |  |  |  |  |  |  | } | 
| 803 |  |  |  |  |  |  |  | 
| 804 |  |  |  |  |  |  |  | 
| 805 |  |  |  |  |  |  | ############################################################################### | 
| 806 |  |  |  |  |  |  | # | 
| 807 |  |  |  |  |  |  | # _write_drawing_rels_files() | 
| 808 |  |  |  |  |  |  | # | 
| 809 |  |  |  |  |  |  | # Write the drawing .rels files for worksheets that contain charts or drawings. | 
| 810 |  |  |  |  |  |  | # | 
| 811 |  |  |  |  |  |  | sub _write_drawing_rels_files { | 
| 812 |  |  |  |  |  |  |  | 
| 813 | 809 |  |  | 809 |  | 1759 | my $self = shift; | 
| 814 | 809 |  |  |  |  | 2263 | my $dir  = $self->{_package_dir}; | 
| 815 |  |  |  |  |  |  |  | 
| 816 |  |  |  |  |  |  |  | 
| 817 | 809 |  |  |  |  | 1781 | my $index = 0; | 
| 818 | 809 |  |  |  |  | 1774 | for my $worksheet ( @{ $self->{_workbook}->{_worksheets} } ) { | 
|  | 809 |  |  |  |  | 3081 |  | 
| 819 |  |  |  |  |  |  |  | 
| 820 | 956 | 100 | 100 |  |  | 3157 | if ( @{ $worksheet->{_drawing_links} } || $worksheet->{_has_shapes} ) { | 
|  | 956 |  |  |  |  | 6186 |  | 
| 821 | 469 |  |  |  |  | 1024 | $index++; | 
| 822 |  |  |  |  |  |  | } | 
| 823 |  |  |  |  |  |  |  | 
| 824 | 956 | 100 |  |  |  | 1956 | next unless @{ $worksheet->{_drawing_links} }; | 
|  | 956 |  |  |  |  | 3682 |  | 
| 825 |  |  |  |  |  |  |  | 
| 826 |  |  |  |  |  |  | # Create the drawing .rels dir. | 
| 827 | 459 |  |  |  |  | 2037 | _mkdir( $dir . '/xl' ); | 
| 828 | 459 |  |  |  |  | 2822 | _mkdir( $dir . '/xl/drawings' ); | 
| 829 | 459 |  |  |  |  | 2639 | _mkdir( $dir . '/xl/drawings/_rels' ); | 
| 830 |  |  |  |  |  |  |  | 
| 831 | 459 |  |  |  |  | 4531 | my $rels = Excel::Writer::XLSX::Package::Relationships->new(); | 
| 832 |  |  |  |  |  |  |  | 
| 833 | 459 |  |  |  |  | 1288 | for my $drawing_data ( @{ $worksheet->{_drawing_links} } ) { | 
|  | 459 |  |  |  |  | 1949 |  | 
| 834 | 515 |  |  |  |  | 1953 | $rels->_add_document_relationship( @$drawing_data ); | 
| 835 |  |  |  |  |  |  | } | 
| 836 |  |  |  |  |  |  |  | 
| 837 |  |  |  |  |  |  | # Create the .rels file such as /xl/drawings/_rels/sheet1.xml.rels. | 
| 838 |  |  |  |  |  |  | $rels->_set_xml_writer( | 
| 839 | 459 |  |  |  |  | 2220 | $dir . '/xl/drawings/_rels/drawing' . $index . '.xml.rels' ); | 
| 840 | 459 |  |  |  |  | 2304 | $rels->_assemble_xml_file(); | 
| 841 |  |  |  |  |  |  | } | 
| 842 |  |  |  |  |  |  | } | 
| 843 |  |  |  |  |  |  |  | 
| 844 |  |  |  |  |  |  |  | 
| 845 |  |  |  |  |  |  | ############################################################################### | 
| 846 |  |  |  |  |  |  | # | 
| 847 |  |  |  |  |  |  | # _write_vml_drawing_rels_files() | 
| 848 |  |  |  |  |  |  | # | 
| 849 |  |  |  |  |  |  | # Write the vmlDdrawing .rels files for worksheets with images in header or | 
| 850 |  |  |  |  |  |  | # footers. | 
| 851 |  |  |  |  |  |  | # | 
| 852 |  |  |  |  |  |  | sub _write_vml_drawing_rels_file { | 
| 853 |  |  |  |  |  |  |  | 
| 854 | 22 |  |  | 22 |  | 58 | my $self      = shift; | 
| 855 | 22 |  |  |  |  | 51 | my $worksheet = shift; | 
| 856 | 22 |  |  |  |  | 54 | my $index     = shift; | 
| 857 | 22 |  |  |  |  | 63 | my $dir       = $self->{_package_dir}; | 
| 858 |  |  |  |  |  |  |  | 
| 859 |  |  |  |  |  |  |  | 
| 860 |  |  |  |  |  |  | # Create the drawing .rels dir. | 
| 861 | 22 |  |  |  |  | 109 | _mkdir( $dir . '/xl' ); | 
| 862 | 22 |  |  |  |  | 157 | _mkdir( $dir . '/xl/drawings' ); | 
| 863 | 22 |  |  |  |  | 127 | _mkdir( $dir . '/xl/drawings/_rels' ); | 
| 864 |  |  |  |  |  |  |  | 
| 865 | 22 |  |  |  |  | 274 | my $rels = Excel::Writer::XLSX::Package::Relationships->new(); | 
| 866 |  |  |  |  |  |  |  | 
| 867 | 22 |  |  |  |  | 55 | for my $drawing_data ( @{ $worksheet->{_vml_drawing_links} } ) { | 
|  | 22 |  |  |  |  | 87 |  | 
| 868 | 34 |  |  |  |  | 137 | $rels->_add_document_relationship( @$drawing_data ); | 
| 869 |  |  |  |  |  |  | } | 
| 870 |  |  |  |  |  |  |  | 
| 871 |  |  |  |  |  |  | # Create the .rels file such as /xl/drawings/_rels/vmlDrawing1.vml.rels. | 
| 872 |  |  |  |  |  |  | $rels->_set_xml_writer( | 
| 873 | 22 |  |  |  |  | 100 | $dir . '/xl/drawings/_rels/vmlDrawing' . $index . '.vml.rels' ); | 
| 874 | 22 |  |  |  |  | 133 | $rels->_assemble_xml_file(); | 
| 875 |  |  |  |  |  |  |  | 
| 876 |  |  |  |  |  |  | } | 
| 877 |  |  |  |  |  |  |  | 
| 878 |  |  |  |  |  |  |  | 
| 879 |  |  |  |  |  |  | ############################################################################### | 
| 880 |  |  |  |  |  |  | # | 
| 881 |  |  |  |  |  |  | # _add_image_files() | 
| 882 |  |  |  |  |  |  | # | 
| 883 |  |  |  |  |  |  | # Write the /xl/media/image?.xml files. | 
| 884 |  |  |  |  |  |  | # | 
| 885 |  |  |  |  |  |  | sub _add_image_files { | 
| 886 |  |  |  |  |  |  |  | 
| 887 | 809 |  |  | 809 |  | 2143 | my $self     = shift; | 
| 888 | 809 |  |  |  |  | 2266 | my $dir      = $self->{_package_dir}; | 
| 889 | 809 |  |  |  |  | 2056 | my $workbook = $self->{_workbook}; | 
| 890 | 809 |  |  |  |  | 1945 | my $index    = 1; | 
| 891 |  |  |  |  |  |  |  | 
| 892 | 809 |  |  |  |  | 1753 | for my $image ( @{ $workbook->{_images} } ) { | 
|  | 809 |  |  |  |  | 3443 |  | 
| 893 | 124 |  |  |  |  | 11241 | my $filename  = $image->[0]; | 
| 894 | 124 |  |  |  |  | 409 | my $extension = '.' . $image->[1]; | 
| 895 |  |  |  |  |  |  |  | 
| 896 | 124 |  |  |  |  | 534 | _mkdir( $dir . '/xl' ); | 
| 897 | 124 |  |  |  |  | 710 | _mkdir( $dir . '/xl/media' ); | 
| 898 |  |  |  |  |  |  |  | 
| 899 | 124 |  |  |  |  | 769 | copy( $filename, $dir . '/xl/media/image' . $index++ . $extension ); | 
| 900 |  |  |  |  |  |  | } | 
| 901 |  |  |  |  |  |  | } | 
| 902 |  |  |  |  |  |  |  | 
| 903 |  |  |  |  |  |  |  | 
| 904 |  |  |  |  |  |  | ############################################################################### | 
| 905 |  |  |  |  |  |  | # | 
| 906 |  |  |  |  |  |  | # _add_vba_project() | 
| 907 |  |  |  |  |  |  | # | 
| 908 |  |  |  |  |  |  | # Write the vbaProject.bin file. | 
| 909 |  |  |  |  |  |  | # | 
| 910 |  |  |  |  |  |  | sub _add_vba_project { | 
| 911 |  |  |  |  |  |  |  | 
| 912 | 809 |  |  | 809 |  | 1883 | my $self        = shift; | 
| 913 | 809 |  |  |  |  | 2140 | my $dir         = $self->{_package_dir}; | 
| 914 | 809 |  |  |  |  | 2132 | my $vba_project = $self->{_workbook}->{_vba_project}; | 
| 915 |  |  |  |  |  |  |  | 
| 916 | 809 | 100 |  |  |  | 4971 | return unless $vba_project; | 
| 917 |  |  |  |  |  |  |  | 
| 918 | 5 |  |  |  |  | 22 | _mkdir( $dir . '/xl' ); | 
| 919 |  |  |  |  |  |  |  | 
| 920 | 5 |  |  |  |  | 31 | copy( $vba_project, $dir . '/xl/vbaProject.bin' ); | 
| 921 |  |  |  |  |  |  | } | 
| 922 |  |  |  |  |  |  |  | 
| 923 |  |  |  |  |  |  |  | 
| 924 |  |  |  |  |  |  | ############################################################################### | 
| 925 |  |  |  |  |  |  | # | 
| 926 |  |  |  |  |  |  | # _mkdir() | 
| 927 |  |  |  |  |  |  | # | 
| 928 |  |  |  |  |  |  | # Wrapper function for Perl's mkdir to allow error trapping. | 
| 929 |  |  |  |  |  |  | # | 
| 930 |  |  |  |  |  |  | sub _mkdir { | 
| 931 |  |  |  |  |  |  |  | 
| 932 | 14521 |  |  | 14521 |  | 139132 | my $dir = shift; | 
| 933 |  |  |  |  |  |  |  | 
| 934 | 14521 | 100 |  |  |  | 243425 | return if -e $dir; | 
| 935 |  |  |  |  |  |  |  | 
| 936 | 6806 |  |  |  |  | 281155 | my $ret = mkdir( $dir ); | 
| 937 |  |  |  |  |  |  |  | 
| 938 | 6806 | 50 |  |  |  | 36400 | if ( !$ret ) { | 
| 939 | 0 |  |  |  |  |  | croak "Couldn't create sub directory $dir: $!"; | 
| 940 |  |  |  |  |  |  | } | 
| 941 |  |  |  |  |  |  | } | 
| 942 |  |  |  |  |  |  |  | 
| 943 |  |  |  |  |  |  |  | 
| 944 |  |  |  |  |  |  | 1; | 
| 945 |  |  |  |  |  |  |  | 
| 946 |  |  |  |  |  |  |  | 
| 947 |  |  |  |  |  |  | __END__ |