package Excel::Writer::XLSX::Package::Theme;
###############################################################################
#
# Theme - A class for writing the Excel XLSX Theme file.
#
# Used in conjunction with Excel::Writer::XLSX
#
# Copyright 2000-2016, John McNamara, jmcnamara@cpan.org
#
# Documentation after __END__
#
# perltidy with the following options: -mbl=2 -pt=0 -nola
###############################################################################
#
# NOTE: This class doesn't try to create the Excel theme1.xml programmatically.
# Instead it just writes a stored default theme. This is mainly to
# facilitate easier comparisons during testing. The theme1.xml file
# isn't actually required.
use 5.008002;
use strict;
use warnings;
use Exporter;
use Carp;
use IO::File;
use utf8;
our @ISA = qw(Exporter);
our $VERSION = '0.95';
###############################################################################
#
# Public and private API methods.
#
###############################################################################
###############################################################################
#
# new()
#
# Constructor.
#
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
###############################################################################
#
# _assemble_xml_file()
#
# Assemble and write the XML file.
#
sub _assemble_xml_file {
my $self = shift;
$self->_write_theme_file();
}
###############################################################################
#
# _set_xml_writer()
#
# Set the filehandle only. This class doesn't use a real XML writer class.
#
sub _set_xml_writer {
my $self = shift;
my $filename = shift;
my $fh = IO::File->new( $filename, 'w' );
croak "Couldn't open file $filename for writing.\n" unless $fh;
binmode $fh, ':utf8';
$self->{_fh} = $fh;
}
###############################################################################
#
# Internal methods.
#
###############################################################################
# Sparklines styles. Used by the Worksheet class.
our @spark_styles = (
{ # 0
series => { _theme => "4", _tint => "-0.499984740745262" },
negative => { _theme => "5" },
markers => { _theme => "4", _tint => "-0.499984740745262" },
first => { _theme => "4", _tint => "0.39997558519241921" },
last => { _theme => "4", _tint => "0.39997558519241921" },
high => { _theme => "4" },
low => { _theme => "4" },
},
{ # 1
series => { _theme => "4", _tint => "-0.499984740745262" },
negative => { _theme => "5" },
markers => { _theme => "4", _tint => "-0.499984740745262" },
first => { _theme => "4", _tint => "0.39997558519241921" },
last => { _theme => "4", _tint => "0.39997558519241921" },
high => { _theme => "4" },
low => { _theme => "4" },
},
{ # 2
series => { _theme => "5", _tint => "-0.499984740745262" },
negative => { _theme => "6" },
markers => { _theme => "5", _tint => "-0.499984740745262" },
first => { _theme => "5", _tint => "0.39997558519241921" },
last => { _theme => "5", _tint => "0.39997558519241921" },
high => { _theme => "5" },
low => { _theme => "5" },
},
{ # 3
series => { _theme => "6", _tint => "-0.499984740745262" },
negative => { _theme => "7" },
markers => { _theme => "6", _tint => "-0.499984740745262" },
first => { _theme => "6", _tint => "0.39997558519241921" },
last => { _theme => "6", _tint => "0.39997558519241921" },
high => { _theme => "6" },
low => { _theme => "6" },
},
{ # 4
series => { _theme => "7", _tint => "-0.499984740745262" },
negative => { _theme => "8" },
markers => { _theme => "7", _tint => "-0.499984740745262" },
first => { _theme => "7", _tint => "0.39997558519241921" },
last => { _theme => "7", _tint => "0.39997558519241921" },
high => { _theme => "7" },
low => { _theme => "7" },
},
{ # 5
series => { _theme => "8", _tint => "-0.499984740745262" },
negative => { _theme => "9" },
markers => { _theme => "8", _tint => "-0.499984740745262" },
first => { _theme => "8", _tint => "0.39997558519241921" },
last => { _theme => "8", _tint => "0.39997558519241921" },
high => { _theme => "8" },
low => { _theme => "8" },
},
{ # 6
series => { _theme => "9", _tint => "-0.499984740745262" },
negative => { _theme => "4" },
markers => { _theme => "9", _tint => "-0.499984740745262" },
first => { _theme => "9", _tint => "0.39997558519241921" },
last => { _theme => "9", _tint => "0.39997558519241921" },
high => { _theme => "9" },
low => { _theme => "9" },
},
{ # 7
series => { _theme => "4", _tint => "-0.249977111117893" },
negative => { _theme => "5" },
markers => { _theme => "5", _tint => "-0.249977111117893" },
first => { _theme => "5", _tint => "-0.249977111117893" },
last => { _theme => "5", _tint => "-0.249977111117893" },
high => { _theme => "5", _tint => "-0.249977111117893" },
low => { _theme => "5", _tint => "-0.249977111117893" },
},
{ # 8
series => { _theme => "5", _tint => "-0.249977111117893" },
negative => { _theme => "6" },
markers => { _theme => "6", _tint => "-0.249977111117893" },
first => { _theme => "6", _tint => "-0.249977111117893" },
last => { _theme => "6", _tint => "-0.249977111117893" },
high => { _theme => "6", _tint => "-0.249977111117893" },
low => { _theme => "6", _tint => "-0.249977111117893" },
},
{ # 9
series => { _theme => "6", _tint => "-0.249977111117893" },
negative => { _theme => "7" },
markers => { _theme => "7", _tint => "-0.249977111117893" },
first => { _theme => "7", _tint => "-0.249977111117893" },
last => { _theme => "7", _tint => "-0.249977111117893" },
high => { _theme => "7", _tint => "-0.249977111117893" },
low => { _theme => "7", _tint => "-0.249977111117893" },
},
{ # 10
series => { _theme => "7", _tint => "-0.249977111117893" },
negative => { _theme => "8" },
markers => { _theme => "8", _tint => "-0.249977111117893" },
first => { _theme => "8", _tint => "-0.249977111117893" },
last => { _theme => "8", _tint => "-0.249977111117893" },
high => { _theme => "8", _tint => "-0.249977111117893" },
low => { _theme => "8", _tint => "-0.249977111117893" },
},
{ # 11
series => { _theme => "8", _tint => "-0.249977111117893" },
negative => { _theme => "9" },
markers => { _theme => "9", _tint => "-0.249977111117893" },
first => { _theme => "9", _tint => "-0.249977111117893" },
last => { _theme => "9", _tint => "-0.249977111117893" },
high => { _theme => "9", _tint => "-0.249977111117893" },
low => { _theme => "9", _tint => "-0.249977111117893" },
},
{ # 12
series => { _theme => "9", _tint => "-0.249977111117893" },
negative => { _theme => "4" },
markers => { _theme => "4", _tint => "-0.249977111117893" },
first => { _theme => "4", _tint => "-0.249977111117893" },
last => { _theme => "4", _tint => "-0.249977111117893" },
high => { _theme => "4", _tint => "-0.249977111117893" },
low => { _theme => "4", _tint => "-0.249977111117893" },
},
{ # 13
series => { _theme => "4" },
negative => { _theme => "5" },
markers => { _theme => "4", _tint => "-0.249977111117893" },
first => { _theme => "4", _tint => "-0.249977111117893" },
last => { _theme => "4", _tint => "-0.249977111117893" },
high => { _theme => "4", _tint => "-0.249977111117893" },
low => { _theme => "4", _tint => "-0.249977111117893" },
},
{ # 14
series => { _theme => "5" },
negative => { _theme => "6" },
markers => { _theme => "5", _tint => "-0.249977111117893" },
first => { _theme => "5", _tint => "-0.249977111117893" },
last => { _theme => "5", _tint => "-0.249977111117893" },
high => { _theme => "5", _tint => "-0.249977111117893" },
low => { _theme => "5", _tint => "-0.249977111117893" },
},
{ # 15
series => { _theme => "6" },
negative => { _theme => "7" },
markers => { _theme => "6", _tint => "-0.249977111117893" },
first => { _theme => "6", _tint => "-0.249977111117893" },
last => { _theme => "6", _tint => "-0.249977111117893" },
high => { _theme => "6", _tint => "-0.249977111117893" },
low => { _theme => "6", _tint => "-0.249977111117893" },
},
{ # 16
series => { _theme => "7" },
negative => { _theme => "8" },
markers => { _theme => "7", _tint => "-0.249977111117893" },
first => { _theme => "7", _tint => "-0.249977111117893" },
last => { _theme => "7", _tint => "-0.249977111117893" },
high => { _theme => "7", _tint => "-0.249977111117893" },
low => { _theme => "7", _tint => "-0.249977111117893" },
},
{ # 17
series => { _theme => "8" },
negative => { _theme => "9" },
markers => { _theme => "8", _tint => "-0.249977111117893" },
first => { _theme => "8", _tint => "-0.249977111117893" },
last => { _theme => "8", _tint => "-0.249977111117893" },
high => { _theme => "8", _tint => "-0.249977111117893" },
low => { _theme => "8", _tint => "-0.249977111117893" },
},
{ # 18
series => { _theme => "9" },
negative => { _theme => "4" },
markers => { _theme => "9", _tint => "-0.249977111117893" },
first => { _theme => "9", _tint => "-0.249977111117893" },
last => { _theme => "9", _tint => "-0.249977111117893" },
high => { _theme => "9", _tint => "-0.249977111117893" },
low => { _theme => "9", _tint => "-0.249977111117893" },
},
{ # 19
series => { _theme => "4", _tint => "0.39997558519241921" },
negative => { _theme => "0", _tint => "-0.499984740745262" },
markers => { _theme => "4", _tint => "0.79998168889431442" },
first => { _theme => "4", _tint => "-0.249977111117893" },
last => { _theme => "4", _tint => "-0.249977111117893" },
high => { _theme => "4", _tint => "-0.499984740745262" },
low => { _theme => "4", _tint => "-0.499984740745262" },
},
{ # 20
series => { _theme => "5", _tint => "0.39997558519241921" },
negative => { _theme => "0", _tint => "-0.499984740745262" },
markers => { _theme => "5", _tint => "0.79998168889431442" },
first => { _theme => "5", _tint => "-0.249977111117893" },
last => { _theme => "5", _tint => "-0.249977111117893" },
high => { _theme => "5", _tint => "-0.499984740745262" },
low => { _theme => "5", _tint => "-0.499984740745262" },
},
{ # 21
series => { _theme => "6", _tint => "0.39997558519241921" },
negative => { _theme => "0", _tint => "-0.499984740745262" },
markers => { _theme => "6", _tint => "0.79998168889431442" },
first => { _theme => "6", _tint => "-0.249977111117893" },
last => { _theme => "6", _tint => "-0.249977111117893" },
high => { _theme => "6", _tint => "-0.499984740745262" },
low => { _theme => "6", _tint => "-0.499984740745262" },
},
{ # 22
series => { _theme => "7", _tint => "0.39997558519241921" },
negative => { _theme => "0", _tint => "-0.499984740745262" },
markers => { _theme => "7", _tint => "0.79998168889431442" },
first => { _theme => "7", _tint => "-0.249977111117893" },
last => { _theme => "7", _tint => "-0.249977111117893" },
high => { _theme => "7", _tint => "-0.499984740745262" },
low => { _theme => "7", _tint => "-0.499984740745262" },
},
{ # 23
series => { _theme => "8", _tint => "0.39997558519241921" },
negative => { _theme => "0", _tint => "-0.499984740745262" },
markers => { _theme => "8", _tint => "0.79998168889431442" },
first => { _theme => "8", _tint => "-0.249977111117893" },
last => { _theme => "8", _tint => "-0.249977111117893" },
high => { _theme => "8", _tint => "-0.499984740745262" },
low => { _theme => "8", _tint => "-0.499984740745262" },
},
{ # 24
series => { _theme => "9", _tint => "0.39997558519241921" },
negative => { _theme => "0", _tint => "-0.499984740745262" },
markers => { _theme => "9", _tint => "0.79998168889431442" },
first => { _theme => "9", _tint => "-0.249977111117893" },
last => { _theme => "9", _tint => "-0.249977111117893" },
high => { _theme => "9", _tint => "-0.499984740745262" },
low => { _theme => "9", _tint => "-0.499984740745262" },
},
{ # 25
series => { _theme => "1", _tint => "0.499984740745262" },
negative => { _theme => "1", _tint => "0.249977111117893" },
markers => { _theme => "1", _tint => "0.249977111117893" },
first => { _theme => "1", _tint => "0.249977111117893" },
last => { _theme => "1", _tint => "0.249977111117893" },
high => { _theme => "1", _tint => "0.249977111117893" },
low => { _theme => "1", _tint => "0.249977111117893" },
},
{ # 26
series => { _theme => "1", _tint => "0.34998626667073579" },
negative => { _theme => "0", _tint => "-0.249977111117893" },
markers => { _theme => "0", _tint => "-0.249977111117893" },
first => { _theme => "0", _tint => "-0.249977111117893" },
last => { _theme => "0", _tint => "-0.249977111117893" },
high => { _theme => "0", _tint => "-0.249977111117893" },
low => { _theme => "0", _tint => "-0.249977111117893" },
},
{ # 27
series => { _rgb => "FF323232" },
negative => { _rgb => "FFD00000" },
markers => { _rgb => "FFD00000" },
first => { _rgb => "FFD00000" },
last => { _rgb => "FFD00000" },
high => { _rgb => "FFD00000" },
low => { _rgb => "FFD00000" },
},
{ # 28
series => { _rgb => "FF000000" },
negative => { _rgb => "FF0070C0" },
markers => { _rgb => "FF0070C0" },
first => { _rgb => "FF0070C0" },
last => { _rgb => "FF0070C0" },
high => { _rgb => "FF0070C0" },
low => { _rgb => "FF0070C0" },
},
{ # 29
series => { _rgb => "FF376092" },
negative => { _rgb => "FFD00000" },
markers => { _rgb => "FFD00000" },
first => { _rgb => "FFD00000" },
last => { _rgb => "FFD00000" },
high => { _rgb => "FFD00000" },
low => { _rgb => "FFD00000" },
},
{ # 30
series => { _rgb => "FF0070C0" },
negative => { _rgb => "FF000000" },
markers => { _rgb => "FF000000" },
first => { _rgb => "FF000000" },
last => { _rgb => "FF000000" },
high => { _rgb => "FF000000" },
low => { _rgb => "FF000000" },
},
{ # 31
series => { _rgb => "FF5F5F5F" },
negative => { _rgb => "FFFFB620" },
markers => { _rgb => "FFD70077" },
first => { _rgb => "FF5687C2" },
last => { _rgb => "FF359CEB" },
high => { _rgb => "FF56BE79" },
low => { _rgb => "FFFF5055" },
},
{ # 32
series => { _rgb => "FF5687C2" },
negative => { _rgb => "FFFFB620" },
markers => { _rgb => "FFD70077" },
first => { _rgb => "FF777777" },
last => { _rgb => "FF359CEB" },
high => { _rgb => "FF56BE79" },
low => { _rgb => "FFFF5055" },
},
{ # 33
series => { _rgb => "FFC6EFCE" },
negative => { _rgb => "FFFFC7CE" },
markers => { _rgb => "FF8CADD6" },
first => { _rgb => "FFFFDC47" },
last => { _rgb => "FFFFEB9C" },
high => { _rgb => "FF60D276" },
low => { _rgb => "FFFF5367" },
},
{ # 34
series => { _rgb => "FF00B050" },
negative => { _rgb => "FFFF0000" },
markers => { _rgb => "FF0070C0" },
first => { _rgb => "FFFFC000" },
last => { _rgb => "FFFFC000" },
high => { _rgb => "FF00B050" },
low => { _rgb => "FFFF0000" },
},
{ # 35
series => { _theme => "3" },
negative => { _theme => "9" },
markers => { _theme => "8" },
first => { _theme => "4" },
last => { _theme => "5" },
high => { _theme => "6" },
low => { _theme => "7" },
},
{ # 36
series => { _theme => "1" },
negative => { _theme => "9" },
markers => { _theme => "8" },
first => { _theme => "4" },
last => { _theme => "5" },
high => { _theme => "6" },
low => { _theme => "7" },
},
);
###############################################################################
#
# XML writing methods.
#
###############################################################################
###############################################################################
#
# _write_theme_file()
#
# Write a default theme.xml file.
#
sub _write_theme_file {
my $self = shift;
my $theme = << 'XML_DATA';
XML_DATA
local $\ = undef; # Protect print from -l on commandline.
print { $self->{_fh} } $theme;
}
1;
__END__
=pod
=head1 NAME
Theme - A class for writing the Excel XLSX Theme file.
=head1 SYNOPSIS
See the documentation for L.
=head1 DESCRIPTION
This module is used in conjunction with L.
=head1 AUTHOR
John McNamara jmcnamara@cpan.org
=head1 COPYRIGHT
(c) MM-MMXVI, John McNamara.
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
=head1 LICENSE
Either the Perl Artistic Licence L or the GPL L.
=head1 DISCLAIMER OF WARRANTY
See the documentation for L.
=cut