| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | ############################################################################### | 
| 3 |  |  |  |  |  |  | # | 
| 4 |  |  |  |  |  |  | # Chartsheet - A class for writing the Excel XLSX Chartsheet files. | 
| 5 |  |  |  |  |  |  | # | 
| 6 |  |  |  |  |  |  | # Used in conjunction with Excel::Writer::XLSX | 
| 7 |  |  |  |  |  |  | # | 
| 8 |  |  |  |  |  |  | # Copyright 2000-2021, John McNamara, jmcnamara@cpan.org | 
| 9 |  |  |  |  |  |  | # | 
| 10 |  |  |  |  |  |  | # Documentation after __END__ | 
| 11 |  |  |  |  |  |  | # | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | # perltidy with the following options: -mbl=2 -pt=0 -nola | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | use 5.008002; | 
| 16 | 1124 |  |  | 1124 |  | 25668 | use strict; | 
|  | 1124 |  |  |  |  | 4625 |  | 
| 17 | 1124 |  |  | 1124 |  | 7065 | use warnings; | 
|  | 1124 |  |  |  |  | 2187 |  | 
|  | 1124 |  |  |  |  | 24461 |  | 
| 18 | 1124 |  |  | 1124 |  | 6377 | use Exporter; | 
|  | 1124 |  |  |  |  | 2100 |  | 
|  | 1124 |  |  |  |  | 30191 |  | 
| 19 | 1124 |  |  | 1124 |  | 6338 | use Excel::Writer::XLSX::Worksheet; | 
|  | 1124 |  |  |  |  | 3078 |  | 
|  | 1124 |  |  |  |  | 31759 |  | 
| 20 | 1124 |  |  | 1124 |  | 6209 |  | 
|  | 1124 |  |  |  |  | 3897 |  | 
|  | 1124 |  |  |  |  | 804296 |  | 
| 21 |  |  |  |  |  |  | our @ISA     = qw(Excel::Writer::XLSX::Worksheet); | 
| 22 |  |  |  |  |  |  | our $VERSION = '1.09'; | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | ############################################################################### | 
| 26 |  |  |  |  |  |  | # | 
| 27 |  |  |  |  |  |  | # Public and private API methods. | 
| 28 |  |  |  |  |  |  | # | 
| 29 |  |  |  |  |  |  | ############################################################################### | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | ############################################################################### | 
| 33 |  |  |  |  |  |  | # | 
| 34 |  |  |  |  |  |  | # new() | 
| 35 |  |  |  |  |  |  | # | 
| 36 |  |  |  |  |  |  | # Constructor. | 
| 37 |  |  |  |  |  |  | # | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | my $class = shift; | 
| 40 |  |  |  |  |  |  | my $self  = Excel::Writer::XLSX::Worksheet->new( @_ ); | 
| 41 | 29 |  |  | 29 | 0 | 6134 |  | 
| 42 | 29 |  |  |  |  | 196 | $self->{_drawing}           = 1; | 
| 43 |  |  |  |  |  |  | $self->{_is_chartsheet}     = 1; | 
| 44 | 29 |  |  |  |  | 85 | $self->{_chart}             = undef; | 
| 45 | 29 |  |  |  |  | 70 | $self->{_charts}            = [1]; | 
| 46 | 29 |  |  |  |  | 62 | $self->{_zoom_scale_normal} = 0; | 
| 47 | 29 |  |  |  |  | 85 | $self->{_orientation}       = 0; | 
| 48 | 29 |  |  |  |  | 60 |  | 
| 49 | 29 |  |  |  |  | 54 | bless $self, $class; | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 29 |  |  |  |  | 54 | return $self; | 
| 52 |  |  |  |  |  |  | } | 
| 53 | 29 |  |  |  |  | 70 |  | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | ############################################################################### | 
| 56 |  |  |  |  |  |  | # | 
| 57 |  |  |  |  |  |  | # _assemble_xml_file() | 
| 58 |  |  |  |  |  |  | # | 
| 59 |  |  |  |  |  |  | # Assemble and write the XML file. | 
| 60 |  |  |  |  |  |  | # | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | my $self = shift; | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | $self->xml_declaration; | 
| 65 | 21 |  |  | 21 |  | 67 |  | 
| 66 |  |  |  |  |  |  | # Write the root chartsheet element. | 
| 67 | 21 |  |  |  |  | 226 | $self->_write_chartsheet(); | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | # Write the worksheet properties. | 
| 70 | 21 |  |  |  |  | 100 | $self->_write_sheet_pr(); | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | # Write the sheet view properties. | 
| 73 | 21 |  |  |  |  | 85 | $self->_write_sheet_views(); | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | # Write the sheetProtection element. | 
| 76 | 21 |  |  |  |  | 127 | $self->_write_sheet_protection(); | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | # Write the printOptions element. | 
| 79 | 21 |  |  |  |  | 104 | $self->_write_print_options(); | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | # Write the worksheet page_margins. | 
| 82 | 21 |  |  |  |  | 202 | $self->_write_page_margins(); | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | # Write the worksheet page setup. | 
| 85 | 21 |  |  |  |  | 93 | $self->_write_page_setup(); | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | # Write the headerFooter element. | 
| 88 | 21 |  |  |  |  | 100 | $self->_write_header_footer(); | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | # Write the drawing element. | 
| 91 | 21 |  |  |  |  | 111 | $self->_write_drawings(); | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | # Close the worksheet tag. | 
| 94 | 21 |  |  |  |  | 99 | $self->xml_end_tag( 'chartsheet' ); | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | # Close the XML writer filehandle. | 
| 97 | 21 |  |  |  |  | 81 | $self->xml_get_fh()->close(); | 
| 98 |  |  |  |  |  |  | } | 
| 99 |  |  |  |  |  |  |  | 
| 100 | 21 |  |  |  |  | 91 |  | 
| 101 |  |  |  |  |  |  | ############################################################################### | 
| 102 |  |  |  |  |  |  | # | 
| 103 |  |  |  |  |  |  | # Public methods. | 
| 104 |  |  |  |  |  |  | # | 
| 105 |  |  |  |  |  |  | ############################################################################### | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | # Over-ride parent protect() method to protect both worksheet and chart. | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | my $self         = shift; | 
| 110 |  |  |  |  |  |  | my $password     = shift || ''; | 
| 111 |  |  |  |  |  |  | my $user_options = shift; | 
| 112 |  |  |  |  |  |  | my $options      = {}; | 
| 113 | 8 |  |  | 8 | 0 | 134 |  | 
| 114 | 8 |  | 100 |  |  | 24 | # Objects are default on for chartsheets. | 
| 115 | 8 |  |  |  |  | 16 | if ( defined $user_options->{objects} ) { | 
| 116 | 8 |  |  |  |  | 13 | $options->{objects} = not $user_options->{objects}; | 
| 117 |  |  |  |  |  |  | } | 
| 118 |  |  |  |  |  |  | else { | 
| 119 | 8 | 100 |  |  |  | 22 | $options->{objects} = 0; | 
| 120 | 4 |  |  |  |  | 12 | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | if ( defined $user_options->{content} ) { | 
| 123 | 4 |  |  |  |  | 13 | $options->{content} = $user_options->{content}; | 
| 124 |  |  |  |  |  |  | } | 
| 125 |  |  |  |  |  |  | else { | 
| 126 | 8 | 100 |  |  |  | 24 | $options->{content} = 1; | 
| 127 | 3 |  |  |  |  | 6 | } | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | # If objects and content are off then the chartsheet isn't locked, except | 
| 130 | 5 |  |  |  |  | 10 | # if it has a password. | 
| 131 |  |  |  |  |  |  | if ( $password eq '' && $options->{objects} && !$options->{content} ) { | 
| 132 |  |  |  |  |  |  | return; | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 | 8 | 100 | 100 |  |  | 34 | $self->{_chart}->{_protection} = 1; | 
|  |  |  | 100 |  |  |  |  | 
| 136 | 1 |  |  |  |  | 4 |  | 
| 137 |  |  |  |  |  |  | # Turn off worksheet defaults. | 
| 138 |  |  |  |  |  |  | $options->{sheet}     = 0; | 
| 139 | 7 |  |  |  |  | 20 | $options->{scenarios} = 1; | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | $self->SUPER::protect( $password, $options ); | 
| 142 | 7 |  |  |  |  | 15 | } | 
| 143 | 7 |  |  |  |  | 11 |  | 
| 144 |  |  |  |  |  |  |  | 
| 145 | 7 |  |  |  |  | 25 | ############################################################################### | 
| 146 |  |  |  |  |  |  | # | 
| 147 |  |  |  |  |  |  | # Encapsulated Chart methods. | 
| 148 |  |  |  |  |  |  | # | 
| 149 |  |  |  |  |  |  | ############################################################################### | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | ############################################################################### | 
| 155 | 56 |  |  | 56 | 0 | 448 | # | 
| 156 | 0 |  |  | 0 | 0 | 0 | # Internal methods. | 
| 157 | 1 |  |  | 1 | 0 | 15 | # | 
| 158 | 1 |  |  | 1 | 0 | 12 | ############################################################################### | 
| 159 | 0 |  |  | 0 | 0 | 0 |  | 
| 160 | 0 |  |  | 0 | 0 | 0 |  | 
| 161 | 1 |  |  | 1 | 0 | 13 | ############################################################################### | 
| 162 | 1 |  |  | 1 | 0 | 12 | # | 
| 163 | 0 |  |  | 0 | 0 | 0 | # _prepare_chart() | 
| 164 | 0 |  |  | 0 | 0 | 0 | # | 
| 165 | 0 |  |  | 0 | 0 | 0 | # Set up chart/drawings. | 
| 166 | 1 |  |  | 1 | 0 | 8 | # | 
| 167 | 0 |  |  | 0 | 0 | 0 |  | 
| 168 | 0 |  |  | 0 | 0 | 0 | my $self       = shift; | 
| 169 | 0 |  |  | 0 | 0 | 0 | my $index      = shift; | 
| 170 | 0 |  |  | 0 | 0 | 0 | my $chart_id   = shift; | 
| 171 | 0 |  |  | 0 | 0 | 0 | my $drawing_id = shift; | 
| 172 | 0 |  |  | 0 | 0 | 0 |  | 
| 173 |  |  |  |  |  |  | $self->{_chart}->{_id} = $chart_id -1; | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | my $drawing = Excel::Writer::XLSX::Drawing->new(); | 
| 176 |  |  |  |  |  |  | $self->{_drawing} = $drawing; | 
| 177 |  |  |  |  |  |  | $self->{_drawing}->{_orientation} = $self->{_orientation}; | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | push @{ $self->{_external_drawing_links} }, | 
| 180 |  |  |  |  |  |  | [ '/drawing', '../drawings/drawing' . $drawing_id . '.xml' ]; | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | push @{ $self->{_drawing_links} }, | 
| 183 |  |  |  |  |  |  | [ '/chart', '../charts/chart' . $chart_id . '.xml' ]; | 
| 184 |  |  |  |  |  |  | } | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  | ############################################################################### | 
| 188 |  |  |  |  |  |  | # | 
| 189 |  |  |  |  |  |  | # XML writing methods. | 
| 190 |  |  |  |  |  |  | # | 
| 191 | 20 |  |  | 20 |  | 39 | ############################################################################### | 
| 192 | 20 |  |  |  |  | 41 |  | 
| 193 | 20 |  |  |  |  | 35 |  | 
| 194 | 20 |  |  |  |  | 33 | ############################################################################### | 
| 195 |  |  |  |  |  |  | # | 
| 196 | 20 |  |  |  |  | 62 | # _write_chartsheet() | 
| 197 |  |  |  |  |  |  | # | 
| 198 | 20 |  |  |  |  | 88 | # Write the <chartsheet> element. This is the root element of Chartsheet. | 
| 199 | 20 |  |  |  |  | 175 | # | 
| 200 | 20 |  |  |  |  | 85 |  | 
| 201 |  |  |  |  |  |  | my $self                   = shift; | 
| 202 | 20 |  |  |  |  | 37 | my $schema                 = 'http://schemas.openxmlformats.org/'; | 
|  | 20 |  |  |  |  | 120 |  | 
| 203 |  |  |  |  |  |  | my $xmlns                  = $schema . 'spreadsheetml/2006/main'; | 
| 204 |  |  |  |  |  |  | my $xmlns_r                = $schema . 'officeDocument/2006/relationships'; | 
| 205 | 20 |  |  |  |  | 47 | my $xmlns_mc               = $schema . 'markup-compatibility/2006'; | 
|  | 20 |  |  |  |  | 135 |  | 
| 206 |  |  |  |  |  |  | my $xmlns_mv               = 'urn:schemas-microsoft-com:mac:vml'; | 
| 207 |  |  |  |  |  |  | my $mc_ignorable           = 'mv'; | 
| 208 |  |  |  |  |  |  | my $mc_preserve_attributes = 'mv:*'; | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | my @attributes = ( | 
| 211 |  |  |  |  |  |  | 'xmlns'   => $xmlns, | 
| 212 |  |  |  |  |  |  | 'xmlns:r' => $xmlns_r, | 
| 213 |  |  |  |  |  |  | ); | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  | $self->xml_start_tag( 'chartsheet', @attributes ); | 
| 216 |  |  |  |  |  |  | } | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  | ############################################################################### | 
| 220 |  |  |  |  |  |  | # | 
| 221 |  |  |  |  |  |  | # _write_sheet_pr() | 
| 222 |  |  |  |  |  |  | # | 
| 223 |  |  |  |  |  |  | # Write the <sheetPr> element for Sheet level properties. | 
| 224 |  |  |  |  |  |  | # | 
| 225 | 21 |  |  | 21 |  | 45 |  | 
| 226 | 21 |  |  |  |  | 56 | my $self       = shift; | 
| 227 | 21 |  |  |  |  | 66 | my @attributes = (); | 
| 228 | 21 |  |  |  |  | 53 |  | 
| 229 | 21 |  |  |  |  | 50 |  | 
| 230 | 21 |  |  |  |  | 52 | push @attributes, ( 'filterMode' => 1 ) if $self->{_filter_on}; | 
| 231 | 21 |  |  |  |  | 39 |  | 
| 232 | 21 |  |  |  |  | 37 | if ( $self->{_fit_page} || $self->{_tab_color} ) { | 
| 233 |  |  |  |  |  |  | $self->xml_start_tag( 'sheetPr', @attributes ); | 
| 234 | 21 |  |  |  |  | 71 | $self->_write_tab_color(); | 
| 235 |  |  |  |  |  |  | $self->_write_page_set_up_pr(); | 
| 236 |  |  |  |  |  |  | $self->xml_end_tag( 'sheetPr' ); | 
| 237 |  |  |  |  |  |  | } | 
| 238 |  |  |  |  |  |  | else { | 
| 239 | 21 |  |  |  |  | 222 | $self->xml_empty_tag( 'sheetPr', @attributes ); | 
| 240 |  |  |  |  |  |  | } | 
| 241 |  |  |  |  |  |  | } | 
| 242 |  |  |  |  |  |  |  | 
| 243 |  |  |  |  |  |  | 1; | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  |  | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | =pod | 
| 248 |  |  |  |  |  |  |  | 
| 249 |  |  |  |  |  |  | =head1 NAME | 
| 250 |  |  |  |  |  |  |  | 
| 251 | 21 |  |  | 21 |  | 40 | Chartsheet - A class for writing the Excel XLSX Chartsheet files. | 
| 252 | 21 |  |  |  |  | 56 |  | 
| 253 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 254 |  |  |  |  |  |  |  | 
| 255 | 21 | 50 |  |  |  | 126 | See the documentation for L<Excel::Writer::XLSX>. | 
| 256 |  |  |  |  |  |  |  | 
| 257 | 21 | 100 | 66 |  |  | 176 | =head1 DESCRIPTION | 
| 258 | 1 |  |  |  |  | 3 |  | 
| 259 | 1 |  |  |  |  | 6 | This module is used in conjunction with L<Excel::Writer::XLSX>. | 
| 260 | 1 |  |  |  |  | 5 |  | 
| 261 | 1 |  |  |  |  | 4 | =head1 AUTHOR | 
| 262 |  |  |  |  |  |  |  | 
| 263 |  |  |  |  |  |  | John McNamara jmcnamara@cpan.org | 
| 264 | 20 |  |  |  |  | 148 |  | 
| 265 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 266 |  |  |  |  |  |  |  | 
| 267 |  |  |  |  |  |  | (c) MM-MMXXI, John McNamara. | 
| 268 |  |  |  |  |  |  |  | 
| 269 |  |  |  |  |  |  | All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. | 
| 270 |  |  |  |  |  |  |  | 
| 271 |  |  |  |  |  |  | =head1 LICENSE | 
| 272 |  |  |  |  |  |  |  | 
| 273 |  |  |  |  |  |  | Either the Perl Artistic Licence L<http://dev.perl.org/licenses/artistic.html> or the GPL L<http://www.opensource.org/licenses/gpl-license.php>. | 
| 274 |  |  |  |  |  |  |  | 
| 275 |  |  |  |  |  |  | =head1 DISCLAIMER OF WARRANTY | 
| 276 |  |  |  |  |  |  |  | 
| 277 |  |  |  |  |  |  | See the documentation for L<Excel::Writer::XLSX>. | 
| 278 |  |  |  |  |  |  |  | 
| 279 |  |  |  |  |  |  | =cut |