Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc:[1377] trunk/gdata/inst/perl
Brought to you by:
warnes
|
From: <wa...@us...> - 2010-01-23 02:30:15
|
Revision: 1377
http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1377&view=rev
Author: warnes
Date: 2010-01-23 02:30:09 +0000 (Sat, 23 Jan 2010)
Log Message:
-----------
Add perl scripts to extract worksheet names and sheet count from Excel files
Added Paths:
-----------
trunk/gdata/inst/perl/sheetCount.pl
trunk/gdata/inst/perl/sheetNames.pl
Added: trunk/gdata/inst/perl/sheetCount.pl
===================================================================
--- trunk/gdata/inst/perl/sheetCount.pl (rev 0)
+++ trunk/gdata/inst/perl/sheetCount.pl 2010-01-23 02:30:09 UTC (rev 1377)
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+BEGIN {
+use File::Basename;
+unshift(@INC, dirname $0);
+}
+
+use strict;
+use Spreadsheet::ParseExcel;
+
+# declare some varibles local
+my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename);
+
+##
+## Usage information
+##
+$usage = <<EOF;
+
+sheetCount.pl <excel file>
+
+Output is the number of sheets in the excel file.
+
+EOF
+
+##
+## parse arguments
+##
+
+if(!defined($ARGV[0]))
+ {
+ print $usage;
+ exit 1;
+ }
+
+my $fileName=$ARGV[0];
+
+##
+## open spreadsheet
+##
+
+my $oExcel = new Spreadsheet::ParseExcel;
+
+open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n";
+close(FH);
+
+my $oBook = $oExcel->Parse($fileName);
+
+print $oBook->{SheetCount} , "\n";
+
Added: trunk/gdata/inst/perl/sheetNames.pl
===================================================================
--- trunk/gdata/inst/perl/sheetNames.pl (rev 0)
+++ trunk/gdata/inst/perl/sheetNames.pl 2010-01-23 02:30:09 UTC (rev 1377)
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+
+BEGIN {
+use File::Basename;
+unshift(@INC, dirname $0);
+}
+
+use strict;
+use Spreadsheet::ParseExcel;
+
+# declare some varibles local
+my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename);
+
+##
+## Usage information
+##
+$usage = <<EOF;
+
+sheetCount.pl <excel file>
+
+Output is the number of sheets in the excel file.
+
+EOF
+
+##
+## parse arguments
+##
+
+if(!defined($ARGV[0]))
+ {
+ print $usage;
+ exit 1;
+ }
+
+my $fileName=$ARGV[0];
+
+##
+## open spreadsheet
+##
+
+my $oExcel = new Spreadsheet::ParseExcel;
+
+open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n";
+close(FH);
+
+my $oBook = $oExcel->Parse($fileName);
+
+## Get list all worksheets in the file
+my @sheetlist = (@{$oBook->{Worksheet}});
+
+foreach my $sheet (@sheetlist)
+{
+ print "\"$sheet->{Name}\" ";
+}
+
+print "\n";
+
Property changes on: trunk/gdata/inst/perl/sheetNames.pl
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2010-01-23 04:35:00
|
Revision: 1378
http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1378&view=rev
Author: warnes
Date: 2010-01-23 04:34:54 +0000 (Sat, 23 Jan 2010)
Log Message:
-----------
Modify xls2csv.pl script to:
- Use tab-delimiter and .tsv or .tab extension if called with the name
xls2tsv.pl or xls2tab.pl, respectively. This allows a single source
file and two symlinks to be used intstead of maintaining several
almost-identical files.
- Allow selection of sheets by name
- Provide better error checking
- Other code improvements
Modified Paths:
--------------
trunk/gdata/inst/perl/xls2csv.pl
Added Paths:
-----------
trunk/gdata/inst/perl/xls2tab.pl
trunk/gdata/inst/perl/xls2tsv.pl
Removed Paths:
-------------
trunk/gdata/inst/perl/xls2tab.pl
Modified: trunk/gdata/inst/perl/xls2csv.pl
===================================================================
--- trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 02:30:09 UTC (rev 1377)
+++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 04:34:54 UTC (rev 1378)
@@ -1,4 +1,4 @@
-#!/bin/env perl
+#!/usr/bin/perl
BEGIN {
use File::Basename;
@@ -7,27 +7,66 @@
use strict;
use Spreadsheet::ParseExcel;
+use POSIX;
+use File::Spec::Functions;
# declare some varibles local
-my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename);
+my($row, $col, $sheet, $cell, $usage,
+ $targetfile,$basename, $sheetnumber,
+ $filename, $volume, $directories, $whoami,
+ $sep, $sepName, $sepLabel, $sepExt);
+
##
+## Figure out whether I'm called as xls2csv.pl or xls2tab.pl
+##
+($volume,$directories,$whoami) = File::Spec->splitpath( $0 );
+
+if($whoami eq "xls2csv.pl")
+ {
+ $sep=",";
+ $sepName="comma";
+ $sepLabel="CSV";
+ $sepExt="csv";
+
+ }
+elsif ($whoami eq "xls2tsv.pl")
+ {
+ $sep="\t";
+ $sepName="tab";
+ $sepLabel="TSV";
+ $sepExt="tsv";
+ }
+elsif ($whoami eq "xls2tab.pl")
+ {
+ $sep="\t";
+ $sepName="tab";
+ $sepLabel="TAB";
+ $sepExt="tab";
+ }
+else
+ {
+ die("This script is named '$whoami', but must be named either 'xls2csv.pl' or 'xls2tab.pl' to function properly.\n");
+ }
+
+
+##
## Usage information
##
$usage = <<EOF;
-xls2csv.pl <excel file> [<output file>] [<worksheet number>]
+$whoami <excel file> [<output file>] [<worksheet number>]
Translate the Microsoft Excel spreadsheet file contained in
-<excel file> into comma separated value format (CSV) and store
-in <output file>.
+<excel file> into $sepName separated value format ($sepLabel) and
+store in <output file>.
-If <output file> is not specified, the output file will have the
-same name as the input file with '.xls' or '.XLS' (if any)
-removed and '.csv' appended.
+If <output file> is not specified, the output file will have the same
+name as the input file with '.xls', or 'xlsx' removed and '.$sepExt'
+appended.
If no worksheet number is given, each worksheet will be written to
-a separate file with the name '<output file>_<worksheet name>.csv'.
+a separate file with the name '<output file>_<worksheet name>.$sepExt'.
EOF
@@ -35,26 +74,37 @@
## parse arguments
##
-if(!defined($ARGV[0]))
+if( !defined($ARGV[0]) )
{
print $usage;
exit 1;
}
-$basename = $ARGV[1];
-$basename =~ s/.csv//;
-if ($basename eq "")
- {
- my @path;
- @path = split(/[\/\\]/, $ARGV[0]); # split on file separator
- $basename = $path[$#path];
- $basename =~ s/.xls//i;
- }
+if( defined($ARGV[1]) )
+ {
+ $basename = $targetfile = $ARGV[1];
+ $basename =~ s/\.$sepExt$//i;
+ }
+else
+ {
+ ($volume,$directories,$basename) = File::Spec->splitpath( $ARGV[0] );
+ $basename =~ s/\.xlsx*//i;
+ }
+my $targetsheetname;
+my $sheetnumber;
+
if(defined($ARGV[2]) )
{
- $sheetnumber = $ARGV[2];
- die "Sheetnumber must be an integer larger than 0." if $sheetnumber < 1;
+ if ( isdigit($ARGV[2]) )
+ {
+ $sheetnumber = $ARGV[2];
+ die "Sheetnumber must be an integer larger than 0.\n" if $sheetnumber < 1;
+ }
+ else
+ {
+ $targetsheetname = $ARGV[2];
+ }
}
##
@@ -63,45 +113,79 @@
my $oExcel = new Spreadsheet::ParseExcel;
-print "Loading $ARGV[0] ...\n";
-
open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n";
close(FH);
+print "Loading '$ARGV[0]'...\n";
my $oBook = $oExcel->Parse($ARGV[0]);
+print "Done.\n";
print "\n";
-print "Orignal Filename :", $oBook->{File} , "\n";
-print "Number of Sheets :", $oBook->{SheetCount} , "\n";
-print "Author :", $oBook->{Author} , "\n";
+print "Orignal Filename: ", $oBook->{File} , "\n";
+print "Number of Sheets: ", $oBook->{SheetCount} , "\n";
+print "Author : ", $oBook->{Author} , "\n";
print "\n";
+## Get list all worksheets in the file
my @sheetlist = (@{$oBook->{Worksheet}});
-if (defined($sheetnumber))
+my $sheet;
+
+## If we want a specific sheet drop everything else
+if ( defined($sheetnumber) )
{
- @sheetlist=($sheetlist[$sheetnumber-1]);
+ $sheet = $oBook->Worksheet($sheetnumber-1) or die "No sheet number $sheetnumber.\n";
+ @sheetlist = ( $sheet );
+
}
+elsif ( defined($targetsheetname) )
+ {
+ $sheet = $oBook->Worksheet($targetsheetname) or die "No sheet named '$targetsheetname'.\n";
+ @sheetlist = ( $sheet );
+ }
+
##
## iterate across each worksheet, writing out a separat csv file
##
my $i=0;
+my $sheetname;
+my $found=0;
foreach my $sheet (@sheetlist)
{
$i++;
- my $sheetname = $sheet->{Name};
- if(defined($sheetnumber))
+
+ $sheetname = $sheet->{Name};
+
+ if( defined($sheetnumber) || defined($targetsheetname) )
{
- $filename = "${basename}.csv";
+ if( defined($targetfile) )
+ {
+ $filename = $targetfile;
+ }
+ else
+ {
+ $filename = "${basename}.$sepExt";
+ }
}
else
{
- $filename = "${basename}_${sheetname}.csv";
+ $filename = "${basename}_${sheetname}.$sepExt";
}
- print "Writing Sheet number $i ('$sheetname') to file '$filename'\n";
+ if( defined($sheetnumber) )
+ {
+ print "Writing sheet number $sheetnumber ('$sheetname') to file '$filename'\n";
+ }
+ elsif ( defined($targetsheetname) )
+ {
+ print "Writing sheet '$sheetname' to file '$filename'\n";
+ }
+ else
+ {
+ print "Writing sheet number $i ('$sheetname') to file '$filename'\n";
+ }
open(OutFile,">$filename");
@@ -139,15 +223,13 @@
$outputLine .= "\"" . $_ . "\"" if(length($_)>0);
- # separate cells with commas
- $outputLine .= "," if( $col != $maxcol) ;
+ # separate cells with specified separator
+ $outputLine .= $sep if( $col != $maxcol) ;
}
- #$outputLine =~ s/[, ]+$//g; ## strip off trailing blanks and commas
-
# skip blank/empty lines
- if( $outputLine =~ /^[, ]*$/ )
+ if( $outputLine =~ /^[$sep ]*$/ )
{
$cumulativeBlankLines++
}
Deleted: trunk/gdata/inst/perl/xls2tab.pl
===================================================================
--- trunk/gdata/inst/perl/xls2tab.pl 2010-01-23 02:30:09 UTC (rev 1377)
+++ trunk/gdata/inst/perl/xls2tab.pl 2010-01-23 04:34:54 UTC (rev 1378)
@@ -1,166 +0,0 @@
-#!/bin/env perl
-
-BEGIN {
-use File::Basename;
-unshift(@INC, dirname $0);
-}
-
-use strict;
-use Spreadsheet::ParseExcel;
-
-# declare some varibles local
-my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename);
-
-##
-## Usage information
-##
-$usage = <<EOF;
-
-xls2tab.pl <excel file> [<output file>] [<worksheet number>]
-
-Translate the Microsoft Excel spreadsheet file contained in
-<excel file> into tab separated value format (TAB) and store
-in <output file>.
-
-If <output file> is not specified, the output file will have the
-same name as the input file with '.xls' or '.XLS' (if any)
-removed and '.tab' appended.
-
-If no worksheet number is given, each worksheet will be written to
-a separate file with the name '<output file>_<worksheet name>.tab'.
-
-EOF
-
-##
-## parse arguments
-##
-
-if(!defined($ARGV[0]))
- {
- print $usage;
- exit 1;
- }
-
-$basename = $ARGV[1];
-$basename =~ s/.tab//;
-if ($basename eq "")
- {
- my @path;
- @path = split(/[\/\\]/, $ARGV[0]); # split on file separator
- $basename = $path[$#path];
- $basename =~ s/.xls//i;
- }
-
-if(defined($ARGV[2]) )
- {
- $sheetnumber = $ARGV[2];
- die "Sheetnumber must be an integer larger than 0." if $sheetnumber < 1;
- }
-
-##
-## open spreadsheet
-##
-
-my $oExcel = new Spreadsheet::ParseExcel;
-
-print "Loading $ARGV[0] ...\n";
-
-open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n";
-close(FH);
-
-my $oBook = $oExcel->Parse($ARGV[0]);
-
-print "\n";
-print "Orignal Filename :", $oBook->{File} , "\n";
-print "Number of Sheets :", $oBook->{SheetCount} , "\n";
-print "Author :", $oBook->{Author} , "\n";
-print "\n";
-
-my @sheetlist = (@{$oBook->{Worksheet}});
-if (defined($sheetnumber))
- {
- @sheetlist=($sheetlist[$sheetnumber-1]);
- }
-
-##
-## iterate across each worksheet, writing out a separat tab file
-##
-
-my $i=0;
-foreach my $sheet (@sheetlist)
-{
- $i++;
-
- my $sheetname = $sheet->{Name};
- if(defined($sheetnumber))
- {
- $filename = "${basename}.tab";
- }
- else
- {
- $filename = "${basename}_${sheetname}.tab";
- }
-
- print "Writing Sheet number $i ('$sheetname') to file '$filename'\n";
-
- open(OutFile,">$filename");
-
- my $cumulativeBlankLines=0;
-
- my $minrow = $sheet->{MinRow};
- my $maxrow = $sheet->{MaxRow};
- my $mincol = $sheet->{MinCol};
- my $maxcol = $sheet->{MaxCol};
-
- print "Minrow=$minrow Maxrow=$maxrow Mincol=$mincol Maxcol=$maxcol\n";
-
- for(my $row = $minrow; $row <= $maxrow; $row++)
- {
- my $outputLine = "";
-
- for(my $col = $mincol; $col <= $maxcol; $col++)
- {
- my $cell = $sheet->{Cells}[$row][$col];
- if( defined($cell) )
- {
- $_=$cell->Value; #{Val};
-
- # convert '#NUM!' strings to missing (empty) values
- s/#NUM!//;
-
- # escape double-quote characters in the data since
- # they are used as field delimiters
- s/\"/\\\"/g;
- }
- else
- {
- $_ = '';
- }
-
- $outputLine .= "\"" . $_ . "\"" if(length($_)>0);
-
- # separate cells with tabs
- $outputLine .= "\t" if( $col != $maxcol) ;
-
- }
-
- #$outputLine =~ s/[\t ]+$//g; ## strip off trailing blanks and tabs
-
- # skip blank/empty lines
- if( $outputLine =~ /^[\t ]*$/ )
- {
- $cumulativeBlankLines++
- }
- else
- {
- print OutFile "$outputLine \n"
- }
- }
-
- close OutFile;
-
- print " (Ignored $cumulativeBlankLines blank lines.)\n"
- if ($cumulativeBlankLines);
- print "\n";
-}
-
Added: trunk/gdata/inst/perl/xls2tab.pl
===================================================================
--- trunk/gdata/inst/perl/xls2tab.pl (rev 0)
+++ trunk/gdata/inst/perl/xls2tab.pl 2010-01-23 04:34:54 UTC (rev 1378)
@@ -0,0 +1 @@
+link xls2csv.pl
\ No newline at end of file
Property changes on: trunk/gdata/inst/perl/xls2tab.pl
___________________________________________________________________
Added: svn:special
+ *
Added: trunk/gdata/inst/perl/xls2tsv.pl
===================================================================
--- trunk/gdata/inst/perl/xls2tsv.pl (rev 0)
+++ trunk/gdata/inst/perl/xls2tsv.pl 2010-01-23 04:34:54 UTC (rev 1378)
@@ -0,0 +1 @@
+link xls2csv.pl
\ No newline at end of file
Property changes on: trunk/gdata/inst/perl/xls2tsv.pl
___________________________________________________________________
Added: svn:special
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2010-01-24 07:27:05
|
Revision: 1391
http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1391&view=rev
Author: warnes
Date: 2010-01-24 07:26:58 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Complete changes to handle Excel 2007 'xlsx' files
Modified Paths:
--------------
trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm
trunk/gdata/inst/perl/Spreadsheet/XLSX.pm
trunk/gdata/inst/perl/xls2csv.pl
Modified: trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm
===================================================================
--- trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm 2010-01-24 05:36:58 UTC (rev 1390)
+++ trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm 2010-01-24 07:26:58 UTC (rev 1391)
@@ -6,6 +6,7 @@
package Spreadsheet::XLSX::Fmt2007;
use strict;
use warnings;
+use POSIX;
use Spreadsheet::XLSX::Utility2007 qw(ExcelFmt);
our $VERSION = '0.12'; #
@@ -34,7 +35,7 @@
0x14 => 'h:mm',
0x15 => 'h:mm:ss',
0x16 => 'm-d-yy h:mm',
-#0x17-0x24 -- Differs in Natinal
+#0x17-0x24 -- Differs in National
0x25 => '(#,##0_);(#,##0)',
0x26 => '(#,##0_);[RED](#,##0)',
0x27 => '(#,##0.00);(#,##0.00)',
@@ -93,27 +94,49 @@
if ($oCell->{Type} eq 'Numeric') {
if($oCell->{Format}){
$sFmtStr=$oCell->{Format};
- } elsif(int($oCell->{Val}) != $oCell->{Val}) {
- $sFmtStr = '0.00';
- }
- else {
+ }
+ # Integer
+ elsif( isdigit($oCell->{Val}) ){
$sFmtStr = '0';
- }
- }
+ }
+ # Floating Point
+ else{
+ $sFmtStr = '0.000000000000000';
+ }
+ }
elsif($oCell->{Type} eq 'Date') {
if($oCell->{Format}){
$sFmtStr=$oCell->{Format};
- } elsif(int($oCell->{Val}) <= 0) {
- $sFmtStr = 'h:mm:ss';
- }
+ }
+ # Fraction < 1 --> Time
+ elsif(int($oCell->{Val}) <= 0){
+ $sFmtStr = 'hh:mm:ss';
+ }
+ # Whole number --> Date
+ elsif(int($oCell->{Val}) != $oCell->{Val}){
+ $sFmtStr = 'hh:mm:ss';
+ }
+ # Otherwise both Date and Time
else {
- $sFmtStr = 'm-d-yy';
- }
- }
- else {
+ $sFmtStr = 'mm-dd-yyyy hh:mm:ss';
+ }
+ }
+ elsif($oCell->{Type} eq 'Time')
+ {
+ if($oCell->{Format})
+ {
+ $sFmtStr=$oCell->{Format};
+ }
+ elsif(int($oCell->{Val}) <= 0)
+ {
+ $sFmtStr = 'hh:mm:ss';
+ }
+ }
+ else
+ {
$sFmtStr = '@';
- }
- }
+ }
+ }
return $sFmtStr;
}
#------------------------------------------------------------------------------
Modified: trunk/gdata/inst/perl/Spreadsheet/XLSX.pm
===================================================================
--- trunk/gdata/inst/perl/Spreadsheet/XLSX.pm 2010-01-24 05:36:58 UTC (rev 1390)
+++ trunk/gdata/inst/perl/Spreadsheet/XLSX.pm 2010-01-24 07:26:58 UTC (rev 1391)
@@ -60,7 +60,8 @@
my $formatCode = $1 || '';
if ($formatCode eq $default || not($formatCode)){
if ($t1 == 9 || $t1==10){ $formatCode="0.00000%";}
- elsif ($t1 == 14){ $formatCode="m-d-yy";}
+ elsif ($t1 == 14){ $formatCode="yyyy-mm-dd";}
+ elsif ($t1 == 20){ $formatCode="h:mm";}
else {
$formatCode="";
}
@@ -159,7 +160,7 @@
$s = m/t=\"s\"/ ? 1 : 0;
$s2 = m/t=\"str\"/ ? 1 : 0;
- $sty = m/s="([0-9]+)"/ ? $1 : 0;
+ $sty = m/s="([0-9]+)"/ ? $1 : 0;
}
elsif (/^<v/) {
Modified: trunk/gdata/inst/perl/xls2csv.pl
===================================================================
--- trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 05:36:58 UTC (rev 1390)
+++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 07:26:58 UTC (rev 1391)
@@ -2,11 +2,13 @@
BEGIN {
use File::Basename;
-unshift(@INC, dirname $0);
+# Add current path to perl library search path
+use lib dirname($0);
}
use strict;
use Spreadsheet::ParseExcel;
+use Spreadsheet::XLSX;
use POSIX;
use File::Spec::Functions;
@@ -111,19 +113,32 @@
## open spreadsheet
##
-my $oExcel = new Spreadsheet::ParseExcel;
+my $oExcel;
+my $oBook;
+$oExcel = new Spreadsheet::ParseExcel;
+
open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n";
close(FH);
print "Loading '$ARGV[0]'...\n";
-my $oBook = $oExcel->Parse($ARGV[0]) or die "Error parsing file '$ARGV[0]'.\n";
+
+## First try as a Excel 2007+ 'xml' file
+eval
+ {
+ local $SIG{__WARN__} = sub {};
+ $oBook = Spreadsheet::XLSX -> new ($ARGV[0]);
+ };
+if($@)
+ {
+ $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \
+ die "Error parsing file '$ARGV[0]'.\n";
+ }
print "Done.\n";
print "\n";
-print "Orignal Filename: ", $oBook->{File} , "\n";
+print "Orignal Filename: ", $ARGV[0], "\n";
print "Number of Sheets: ", $oBook->{SheetCount} , "\n";
-print "Author : ", $oBook->{Author} , "\n";
print "\n";
## Get list all worksheets in the file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2010-01-24 07:49:23
|
Revision: 1392
http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1392&view=rev
Author: warnes
Date: 2010-01-24 07:49:16 +0000 (Sun, 24 Jan 2010)
Log Message:
-----------
Combine sheetCount.pl and sheetNames.pl and modify to support Excel 2007 'xlsx' format
Modified Paths:
--------------
trunk/gdata/inst/perl/sheetCount.pl
trunk/gdata/inst/perl/xls2csv.pl
Added Paths:
-----------
trunk/gdata/inst/perl/sheetNames.pl
Removed Paths:
-------------
trunk/gdata/inst/perl/sheetNames.pl
Modified: trunk/gdata/inst/perl/sheetCount.pl
===================================================================
--- trunk/gdata/inst/perl/sheetCount.pl 2010-01-24 07:26:58 UTC (rev 1391)
+++ trunk/gdata/inst/perl/sheetCount.pl 2010-01-24 07:49:16 UTC (rev 1392)
@@ -2,23 +2,48 @@
BEGIN {
use File::Basename;
-unshift(@INC, dirname $0);
+# Add current path to perl library search path
+use lib dirname($0);
}
use strict;
use Spreadsheet::ParseExcel;
+use Spreadsheet::XLSX;
+use File::Spec::Functions;
# declare some varibles local
-my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename);
+my($row, $col, $sheet, $cell, $usage,
+ $filename, $volume, $directories, $whoami,
+ $basename, $sheetnumber, $filename,
+ $text);
+
##
+## Figure out whether I'm called as sheetCount.pl or sheetNames.pl
+##
+($volume,$directories,$whoami) = File::Spec->splitpath( $0 );
+
+if($whoami eq "sheetCount.pl")
+ {
+ $text="number";
+ }
+elsif ($whoami eq "sheetNames.pl")
+ {
+ $text="names";
+ }
+else
+ {
+ die("This script is named '$whoami', but must be named either 'sheetCount.pl' or 'sheetNames.pl' to function properly.\n");
+ }
+
+##
## Usage information
##
$usage = <<EOF;
sheetCount.pl <excel file>
-Output is the number of sheets in the excel file.
+Output is the $text of sheets in the excel file.
EOF
@@ -38,12 +63,44 @@
## open spreadsheet
##
-my $oExcel = new Spreadsheet::ParseExcel;
-
open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n";
close(FH);
-my $oBook = $oExcel->Parse($fileName);
+my $oBook;
-print $oBook->{SheetCount} , "\n";
+## First try as a Excel 2007+ 'xml' file
+eval
+ {
+ local $SIG{__WARN__} = sub {};
+ $oBook = Spreadsheet::XLSX -> new ($ARGV[0]);
+ };
+## Then Excel 97-2004 Format
+if($@)
+ {
+ $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \
+ die "Error parsing file '$ARGV[0]'.\n";
+ }
+
+if($whoami eq "sheetCount.pl")
+ {
+ print $oBook->{SheetCount} , "\n";
+ }
+elsif ($whoami eq "sheetNames.pl")
+ {
+ ## Get list all worksheets in the file
+ my @sheetlist = (@{$oBook->{Worksheet}});
+
+ foreach my $sheet (@sheetlist)
+ {
+ print "\"$sheet->{Name}\" ";
+ }
+
+ print "\n";
+ }
+else
+ {
+ die("This script is named '$whoami', but must be named either 'sheetCount.pl' or 'sheetNames.pl' to function properly.\n");
+ }
+
+
Deleted: trunk/gdata/inst/perl/sheetNames.pl
===================================================================
--- trunk/gdata/inst/perl/sheetNames.pl 2010-01-24 07:26:58 UTC (rev 1391)
+++ trunk/gdata/inst/perl/sheetNames.pl 2010-01-24 07:49:16 UTC (rev 1392)
@@ -1,57 +0,0 @@
-#!/usr/bin/perl
-
-BEGIN {
-use File::Basename;
-unshift(@INC, dirname $0);
-}
-
-use strict;
-use Spreadsheet::ParseExcel;
-
-# declare some varibles local
-my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename);
-
-##
-## Usage information
-##
-$usage = <<EOF;
-
-sheetCount.pl <excel file>
-
-Output is the number of sheets in the excel file.
-
-EOF
-
-##
-## parse arguments
-##
-
-if(!defined($ARGV[0]))
- {
- print $usage;
- exit 1;
- }
-
-my $fileName=$ARGV[0];
-
-##
-## open spreadsheet
-##
-
-my $oExcel = new Spreadsheet::ParseExcel;
-
-open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n";
-close(FH);
-
-my $oBook = $oExcel->Parse($fileName);
-
-## Get list all worksheets in the file
-my @sheetlist = (@{$oBook->{Worksheet}});
-
-foreach my $sheet (@sheetlist)
-{
- print "\"$sheet->{Name}\" ";
-}
-
-print "\n";
-
Added: trunk/gdata/inst/perl/sheetNames.pl
===================================================================
--- trunk/gdata/inst/perl/sheetNames.pl (rev 0)
+++ trunk/gdata/inst/perl/sheetNames.pl 2010-01-24 07:49:16 UTC (rev 1392)
@@ -0,0 +1 @@
+link sheetCount.pl
\ No newline at end of file
Property changes on: trunk/gdata/inst/perl/sheetNames.pl
___________________________________________________________________
Added: svn:special
+ *
Modified: trunk/gdata/inst/perl/xls2csv.pl
===================================================================
--- trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 07:26:58 UTC (rev 1391)
+++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 07:49:16 UTC (rev 1392)
@@ -122,13 +122,13 @@
close(FH);
print "Loading '$ARGV[0]'...\n";
-
## First try as a Excel 2007+ 'xml' file
eval
{
local $SIG{__WARN__} = sub {};
$oBook = Spreadsheet::XLSX -> new ($ARGV[0]);
};
+## Then Excel 97-2004 Format
if($@)
{
$oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2014-08-28 01:28:29
|
Revision: 1873
http://sourceforge.net/p/r-gregmisc/code/1873
Author: warnes
Date: 2014-08-28 01:28:23 +0000 (Thu, 28 Aug 2014)
Log Message:
-----------
Update Spreadsheet::ParseExcel, add Spreadsheet:ParseXLSX, add dependencies
Modified Paths:
--------------
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Cell.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Dump.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/FmtDefault.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/FmtJapan.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/FmtJapan2.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/FmtUnicode.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Font.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Format.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/SaveParser/Workbook.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/SaveParser/Worksheet.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/SaveParser.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Utility.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Workbook.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel/Worksheet.pm
trunk/gdata/inst/perl/Spreadsheet/ParseExcel.pm
trunk/gdata/inst/perl/Spreadsheet/XLSX.pm
Added Paths:
-----------
trunk/gdata/inst/perl/Crypt/
trunk/gdata/inst/perl/Crypt/.exists
trunk/gdata/inst/perl/Crypt/RC4.pm
trunk/gdata/inst/perl/Digest/
trunk/gdata/inst/perl/Digest/Perl/
trunk/gdata/inst/perl/Digest/Perl/MD5.pm
trunk/gdata/inst/perl/Graphics/
trunk/gdata/inst/perl/Graphics/ColorUtils.pm
trunk/gdata/inst/perl/Spreadsheet/ParseXLSX.pm
trunk/gdata/inst/perl/XML/
trunk/gdata/inst/perl/XML/.exists
trunk/gdata/inst/perl/XML/Twig/
trunk/gdata/inst/perl/XML/Twig/XPath.pm
trunk/gdata/inst/perl/XML/Twig.pm
Added: trunk/gdata/inst/perl/Crypt/.exists
===================================================================
Added: trunk/gdata/inst/perl/Crypt/RC4.pm
===================================================================
--- trunk/gdata/inst/perl/Crypt/RC4.pm (rev 0)
+++ trunk/gdata/inst/perl/Crypt/RC4.pm 2014-08-28 01:28:23 UTC (rev 1873)
@@ -0,0 +1,165 @@
+#--------------------------------------------------------------------#
+# Crypt::RC4
+# Date Written: 07-Jun-2000 04:15:55 PM
+# Last Modified: 13-Dec-2001 03:33:49 PM
+# Author: Kurt Kincaid (sif...@ya...)
+# Copyright (c) 2001, Kurt Kincaid
+# All Rights Reserved.
+#
+# This is free software and may be modified and/or
+# redistributed under the same terms as Perl itself.
+#--------------------------------------------------------------------#
+
+package Crypt::RC4;
+
+use strict;
+use vars qw( $VERSION @ISA @EXPORT $MAX_CHUNK_SIZE );
+
+$MAX_CHUNK_SIZE = 1024 unless $MAX_CHUNK_SIZE;
+
+require Exporter;
+
+@ISA = qw(Exporter);
+@EXPORT = qw(RC4);
+$VERSION = '2.02';
+
+sub new {
+ my ( $class, $key ) = @_;
+ my $self = bless {}, $class;
+ $self->{state} = Setup( $key );
+ $self->{x} = 0;
+ $self->{y} = 0;
+ $self;
+}
+
+sub RC4 {
+ my $self;
+ my( @state, $x, $y );
+ if ( ref $_[0] ) {
+ $self = shift;
+ @state = @{ $self->{state} };
+ $x = $self->{x};
+ $y = $self->{y};
+ } else {
+ @state = Setup( shift );
+ $x = $y = 0;
+ }
+ my $message = shift;
+ my $num_pieces = do {
+ my $num = length($message) / $MAX_CHUNK_SIZE;
+ my $int = int $num;
+ $int == $num ? $int : $int+1;
+ };
+ for my $piece ( 0..$num_pieces - 1 ) {
+ my @message = unpack "C*", substr($message, $piece * $MAX_CHUNK_SIZE, $MAX_CHUNK_SIZE);
+ for ( @message ) {
+ $x = 0 if ++$x > 255;
+ $y -= 256 if ($y += $state[$x]) > 255;
+ @state[$x, $y] = @state[$y, $x];
+ $_ ^= $state[( $state[$x] + $state[$y] ) % 256];
+ }
+ substr($message, $piece * $MAX_CHUNK_SIZE, $MAX_CHUNK_SIZE) = pack "C*", @message;
+ }
+ if ($self) {
+ $self->{state} = \@state;
+ $self->{x} = $x;
+ $self->{y} = $y;
+ }
+ $message;
+}
+
+sub Setup {
+ my @k = unpack( 'C*', shift );
+ my @state = 0..255;
+ my $y = 0;
+ for my $x (0..255) {
+ $y = ( $k[$x % @k] + $state[$x] + $y ) % 256;
+ @state[$x, $y] = @state[$y, $x];
+ }
+ wantarray ? @state : \@state;
+}
+
+
+1;
+__END__
+
+=head1 NAME
+
+Crypt::RC4 - Perl implementation of the RC4 encryption algorithm
+
+=head1 SYNOPSIS
+
+# Functional Style
+ use Crypt::RC4;
+ $encrypted = RC4( $passphrase, $plaintext );
+ $decrypt = RC4( $passphrase, $encrypted );
+
+# OO Style
+ use Crypt::RC4;
+ $ref = Crypt::RC4->new( $passphrase );
+ $encrypted = $ref->RC4( $plaintext );
+
+ $ref2 = Crypt::RC4->new( $passphrase );
+ $decrypted = $ref2->RC4( $encrypted );
+
+# process an entire file, one line at a time
+# (Warning: Encrypted file leaks line lengths.)
+ $ref3 = Crypt::RC4->new( $passphrase );
+ while (<FILE>) {
+ chomp;
+ print $ref3->RC4($_), "\n";
+ }
+
+=head1 DESCRIPTION
+
+A simple implementation of the RC4 algorithm, developed by RSA Security, Inc. Here is the description
+from RSA's website:
+
+RC4 is a stream cipher designed by Rivest for RSA Data Security (now RSA Security). It is a variable
+key-size stream cipher with byte-oriented operations. The algorithm is based on the use of a random
+permutation. Analysis shows that the period of the cipher is overwhelmingly likely to be greater than
+10100. Eight to sixteen machine operations are required per output byte, and the cipher can be
+expected to run very quickly in software. Independent analysts have scrutinized the algorithm and it
+is considered secure.
+
+Based substantially on the "RC4 in 3 lines of perl" found at http://www.cypherspace.org
+
+A major bug in v1.0 was fixed by David Hook (dg...@wu...). Thanks, David.
+
+=head1 AUTHOR
+
+Kurt Kincaid (sif...@ya...)
+Ronald Rivest for RSA Security, Inc.
+
+=head1 BUGS
+
+Disclaimer: Strictly speaking, this module uses the "alleged" RC4
+algorithm. The Algorithm known as "RC4" is a trademark of RSA Security
+Inc., and this document makes no claims one way or another that this
+is the correct algorithm, and further, make no claims about the
+quality of the source code nor any licensing requirements for
+commercial use.
+
+There's nothing preventing you from using this module in an insecure
+way which leaks information. For example, encrypting multilple
+messages with the same passphrase may allow an attacker to decode all of
+them with little effort, even though they'll appear to be secured. If
+serious crypto is your goal, be careful. Be very careful.
+
+It's a pure-Perl implementation, so that rating of "Eight
+to sixteen machine operations" is good for nothing but a good laugh.
+If encryption and decryption are a bottleneck for you, please re-write
+this module to use native code wherever practical.
+
+=head1 LICENSE
+
+This is free software and may be modified and/or
+redistributed under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<perl>, L<http://www.cypherspace.org>, L<http://www.rsasecurity.com>,
+L<http://www.achtung.com/crypto/rc4.html>,
+L<http://www.columbia.edu/~ariel/ssleay/rrc4.html>
+
+=cut
Added: trunk/gdata/inst/perl/Digest/Perl/MD5.pm
===================================================================
--- trunk/gdata/inst/perl/Digest/Perl/MD5.pm (rev 0)
+++ trunk/gdata/inst/perl/Digest/Perl/MD5.pm 2014-08-28 01:28:23 UTC (rev 1873)
@@ -0,0 +1,476 @@
+package Digest::Perl::MD5;
+use strict;
+use integer;
+use Exporter;
+use vars qw($VERSION @ISA @EXPORTER @EXPORT_OK);
+
+@EXPORT_OK = qw(md5 md5_hex md5_base64);
+
+@ISA = 'Exporter';
+$VERSION = '1.9';
+
+# I-Vektor
+sub A() { 0x67_45_23_01 }
+sub B() { 0xef_cd_ab_89 }
+sub C() { 0x98_ba_dc_fe }
+sub D() { 0x10_32_54_76 }
+
+# for internal use
+sub MAX() { 0xFFFFFFFF }
+
+# pad a message to a multiple of 64
+sub padding {
+ my $l = length (my $msg = shift() . chr(128));
+ $msg .= "\0" x (($l%64<=56?56:120)-$l%64);
+ $l = ($l-1)*8;
+ $msg .= pack 'VV', $l & MAX , ($l >> 16 >> 16);
+}
+
+
+sub rotate_left($$) {
+ #$_[0] << $_[1] | $_[0] >> (32 - $_[1]);
+ #my $right = $_[0] >> (32 - $_[1]);
+ #my $rmask = (1 << $_[1]) - 1;
+ ($_[0] << $_[1]) | (( $_[0] >> (32 - $_[1]) ) & ((1 << $_[1]) - 1));
+ #$_[0] << $_[1] | (($_[0]>> (32 - $_[1])) & (1 << (32 - $_[1])) - 1);
+}
+
+sub gen_code {
+ # Discard upper 32 bits on 64 bit archs.
+ my $MSK = ((1 << 16) << 16) ? ' & ' . MAX : '';
+# FF => "X0=rotate_left(((X1&X2)|(~X1&X3))+X0+X4+X6$MSK,X5)+X1$MSK;",
+# GG => "X0=rotate_left(((X1&X3)|(X2&(~X3)))+X0+X4+X6$MSK,X5)+X1$MSK;",
+ my %f = (
+ FF => "X0=rotate_left((X3^(X1&(X2^X3)))+X0+X4+X6$MSK,X5)+X1$MSK;",
+ GG => "X0=rotate_left((X2^(X3&(X1^X2)))+X0+X4+X6$MSK,X5)+X1$MSK;",
+ HH => "X0=rotate_left((X1^X2^X3)+X0+X4+X6$MSK,X5)+X1$MSK;",
+ II => "X0=rotate_left((X2^(X1|(~X3)))+X0+X4+X6$MSK,X5)+X1$MSK;",
+ );
+ #unless ( (1 << 16) << 16) { %f = %{$CODES{'32bit'}} }
+ #else { %f = %{$CODES{'64bit'}} }
+
+ my %s = ( # shift lengths
+ S11 => 7, S12 => 12, S13 => 17, S14 => 22, S21 => 5, S22 => 9, S23 => 14,
+ S24 => 20, S31 => 4, S32 => 11, S33 => 16, S34 => 23, S41 => 6, S42 => 10,
+ S43 => 15, S44 => 21
+ );
+
+ my $insert = "\n";
+ while(defined( my $data = <DATA> )) {
+ chomp $data;
+ next unless $data =~ /^[FGHI]/;
+ my ($func,@x) = split /,/, $data;
+ my $c = $f{$func};
+ $c =~ s/X(\d)/$x[$1]/g;
+ $c =~ s/(S\d{2})/$s{$1}/;
+ $c =~ s/^(.*)=rotate_left\((.*),(.*)\)\+(.*)$//;
+
+ my $su = 32 - $3;
+ my $sh = (1 << $3) - 1;
+
+ $c = "$1=(((\$r=$2)<<$3)|((\$r>>$su)&$sh))+$4";
+
+ #my $rotate = "(($2 << $3) || (($2 >> (32 - $3)) & (1 << $2) - 1)))";
+ # $c = "\$r = $2;
+ # $1 = ((\$r << $3) | ((\$r >> (32 - $3)) & ((1 << $3) - 1))) + $4";
+ $insert .= "\t$c\n";
+ }
+ close DATA;
+
+ my $dump = '
+ sub round {
+ my ($a,$b,$c,$d) = @_[0 .. 3];
+ my $r;' . $insert . '
+ $_[0]+$a' . $MSK . ', $_[1]+$b ' . $MSK .
+ ', $_[2]+$c' . $MSK . ', $_[3]+$d' . $MSK . ';
+ }';
+ eval $dump;
+ # print "$dump\n";
+ # exit 0;
+}
+
+gen_code();
+
+#########################################
+# Private output converter functions:
+sub _encode_hex { unpack 'H*', $_[0] }
+sub _encode_base64 {
+ my $res;
+ while ($_[0] =~ /(.{1,45})/gs) {
+ $res .= substr pack('u', $1), 1;
+ chop $res;
+ }
+ $res =~ tr|` -_|AA-Za-z0-9+/|;#`
+ chop $res; chop $res;
+ $res
+}
+
+#########################################
+# OOP interface:
+sub new {
+ my $proto = shift;
+ my $class = ref $proto || $proto;
+ my $self = {};
+ bless $self, $class;
+ $self->reset();
+ $self
+}
+
+sub reset {
+ my $self = shift;
+ delete $self->{_data};
+ $self->{_state} = [A,B,C,D];
+ $self->{_length} = 0;
+ $self
+}
+
+sub add {
+ my $self = shift;
+ $self->{_data} .= join '', @_ if @_;
+ my ($i,$c);
+ for $i (0 .. (length $self->{_data})/64-1) {
+ my @X = unpack 'V16', substr $self->{_data}, $i*64, 64;
+ @{$self->{_state}} = round(@{$self->{_state}},@X);
+ ++$c;
+ }
+ if ($c) {
+ substr ($self->{_data}, 0, $c*64) = '';
+ $self->{_length} += $c*64;
+ }
+ $self
+}
+
+sub finalize {
+ my $self = shift;
+ $self->{_data} .= chr(128);
+ my $l = $self->{_length} + length $self->{_data};
+ $self->{_data} .= "\0" x (($l%64<=56?56:120)-$l%64);
+ $l = ($l-1)*8;
+ $self->{_data} .= pack 'VV', $l & MAX , ($l >> 16 >> 16);
+ $self->add();
+ $self
+}
+
+sub addfile {
+ my ($self,$fh) = @_;
+ if (!ref($fh) && ref(\$fh) ne "GLOB") {
+ require Symbol;
+ $fh = Symbol::qualify($fh, scalar caller);
+ }
+ # $self->{_data} .= do{local$/;<$fh>};
+ my $read = 0;
+ my $buffer = '';
+ $self->add($buffer) while $read = read $fh, $buffer, 8192;
+ die __PACKAGE__, " read failed: $!" unless defined $read;
+ $self
+}
+
+sub add_bits {
+ my $self = shift;
+ return $self->add( pack 'B*', shift ) if @_ == 1;
+ my ($b,$n) = @_;
+ die __PACKAGE__, " Invalid number of bits\n" if $n%8;
+ $self->add( substr $b, 0, $n/8 )
+}
+
+sub digest {
+ my $self = shift;
+ $self->finalize();
+ my $res = pack 'V4', @{$self->{_state}};
+ $self->reset();
+ $res
+}
+
+sub hexdigest {
+ _encode_hex($_[0]->digest)
+}
+
+sub b64digest {
+ _encode_base64($_[0]->digest)
+}
+
+sub clone {
+ my $self = shift;
+ my $clone = {
+ _state => [@{$self->{_state}}],
+ _length => $self->{_length},
+ _data => $self->{_data}
+ };
+ bless $clone, ref $self || $self;
+}
+
+#########################################
+# Procedural interface:
+sub md5 {
+ my $message = padding(join'',@_);
+ my ($a,$b,$c,$d) = (A,B,C,D);
+ my $i;
+ for $i (0 .. (length $message)/64-1) {
+ my @X = unpack 'V16', substr $message,$i*64,64;
+ ($a,$b,$c,$d) = round($a,$b,$c,$d,@X);
+ }
+ pack 'V4',$a,$b,$c,$d;
+}
+sub md5_hex { _encode_hex &md5 }
+sub md5_base64 { _encode_base64 &md5 }
+
+
+1;
+
+=head1 NAME
+
+Digest::MD5::Perl - Perl implementation of Ron Rivests MD5 Algorithm
+
+=head1 DISCLAIMER
+
+This is B<not> an interface (like C<Digest::MD5>) but a Perl implementation of MD5.
+It is written in perl only and because of this it is slow but it works without C-Code.
+You should use C<Digest::MD5> instead of this module if it is available.
+This module is only useful for
+
+=over 4
+
+=item
+
+computers where you cannot install C<Digest::MD5> (e.g. lack of a C-Compiler)
+
+=item
+
+encrypting only small amounts of data (less than one million bytes). I use it to
+hash passwords.
+
+=item
+
+educational purposes
+
+=back
+
+=head1 SYNOPSIS
+
+ # Functional style
+ use Digest::MD5 qw(md5 md5_hex md5_base64);
+
+ $hash = md5 $data;
+ $hash = md5_hex $data;
+ $hash = md5_base64 $data;
+
+
+ # OO style
+ use Digest::MD5;
+
+ $ctx = Digest::MD5->new;
+
+ $ctx->add($data);
+ $ctx->addfile(*FILE);
+
+ $digest = $ctx->digest;
+ $digest = $ctx->hexdigest;
+ $digest = $ctx->b64digest;
+
+=head1 DESCRIPTION
+
+This modules has the same interface as the much faster C<Digest::MD5>. So you can
+easily exchange them, e.g.
+
+ BEGIN {
+ eval {
+ require Digest::MD5;
+ import Digest::MD5 'md5_hex'
+ };
+ if ($@) { # ups, no Digest::MD5
+ require Digest::Perl::MD5;
+ import Digest::Perl::MD5 'md5_hex'
+ }
+ }
+
+If the C<Digest::MD5> module is available it is used and if not you take
+C<Digest::Perl::MD5>.
+
+You can also install the Perl part of Digest::MD5 together with Digest::Perl::MD5
+and use Digest::MD5 as normal, it falls back to Digest::Perl::MD5 if it
+cannot load its object files.
+
+For a detailed Documentation see the C<Digest::MD5> module.
+
+=head1 EXAMPLES
+
+The simplest way to use this library is to import the md5_hex()
+function (or one of its cousins):
+
+ use Digest::Perl::MD5 'md5_hex';
+ print 'Digest is ', md5_hex('foobarbaz'), "\n";
+
+The above example would print out the message
+
+ Digest is 6df23dc03f9b54cc38a0fc1483df6e21
+
+provided that the implementation is working correctly. The same
+checksum can also be calculated in OO style:
+
+ use Digest::MD5;
+
+ $md5 = Digest::MD5->new;
+ $md5->add('foo', 'bar');
+ $md5->add('baz');
+ $digest = $md5->hexdigest;
+
+ print "Digest is $digest\n";
+
+The digest methods are destructive. That means you can only call them
+once and the $md5 objects is reset after use. You can make a copy with clone:
+
+ $md5->clone->hexdigest
+
+=head1 LIMITATIONS
+
+This implementation of the MD5 algorithm has some limitations:
+
+=over 4
+
+=item
+
+It's slow, very slow. I've done my very best but Digest::MD5 is still about 100 times faster.
+You can only encrypt Data up to one million bytes in an acceptable time. But it's very useful
+for encrypting small amounts of data like passwords.
+
+=item
+
+You can only encrypt up to 2^32 bits = 512 MB on 32bit archs. But You should
+use C<Digest::MD5> for those amounts of data anyway.
+
+=back
+
+=head1 SEE ALSO
+
+L<Digest::MD5>
+
+L<md5(1)>
+
+RFC 1321
+
+tools/md5: a small BSD compatible md5 tool written in pure perl.
+
+=head1 COPYRIGHT
+
+This library is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+ Copyright 2000 Christian Lackas, Imperia Software Solutions
+ Copyright 1998-1999 Gisle Aas.
+ Copyright 1995-1996 Neil Winton.
+ Copyright 1991-1992 RSA Data Security, Inc.
+
+The MD5 algorithm is defined in RFC 1321. The basic C code
+implementing the algorithm is derived from that in the RFC and is
+covered by the following copyright:
+
+=over 4
+
+=item
+
+Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+
+=back
+
+This copyright does not prohibit distribution of any version of Perl
+containing this extension under the terms of the GNU or Artistic
+licenses.
+
+=head1 AUTHORS
+
+The original MD5 interface was written by Neil Winton
+(<N.Winton (at) axion.bt.co.uk>).
+
+C<Digest::MD5> was made by Gisle Aas <gisle (at) aas.no> (I took his Interface
+and part of the documentation).
+
+Thanks to Guido Flohr for his 'use integer'-hint.
+
+This release was made by Christian Lackas <delta (at) lackas.net>.
+
+=cut
+
+__DATA__
+FF,$a,$b,$c,$d,$_[4],7,0xd76aa478,/* 1 */
+FF,$d,$a,$b,$c,$_[5],12,0xe8c7b756,/* 2 */
+FF,$c,$d,$a,$b,$_[6],17,0x242070db,/* 3 */
+FF,$b,$c,$d,$a,$_[7],22,0xc1bdceee,/* 4 */
+FF,$a,$b,$c,$d,$_[8],7,0xf57c0faf,/* 5 */
+FF,$d,$a,$b,$c,$_[9],12,0x4787c62a,/* 6 */
+FF,$c,$d,$a,$b,$_[10],17,0xa8304613,/* 7 */
+FF,$b,$c,$d,$a,$_[11],22,0xfd469501,/* 8 */
+FF,$a,$b,$c,$d,$_[12],7,0x698098d8,/* 9 */
+FF,$d,$a,$b,$c,$_[13],12,0x8b44f7af,/* 10 */
+FF,$c,$d,$a,$b,$_[14],17,0xffff5bb1,/* 11 */
+FF,$b,$c,$d,$a,$_[15],22,0x895cd7be,/* 12 */
+FF,$a,$b,$c,$d,$_[16],7,0x6b901122,/* 13 */
+FF,$d,$a,$b,$c,$_[17],12,0xfd987193,/* 14 */
+FF,$c,$d,$a,$b,$_[18],17,0xa679438e,/* 15 */
+FF,$b,$c,$d,$a,$_[19],22,0x49b40821,/* 16 */
+GG,$a,$b,$c,$d,$_[5],5,0xf61e2562,/* 17 */
+GG,$d,$a,$b,$c,$_[10],9,0xc040b340,/* 18 */
+GG,$c,$d,$a,$b,$_[15],14,0x265e5a51,/* 19 */
+GG,$b,$c,$d,$a,$_[4],20,0xe9b6c7aa,/* 20 */
+GG,$a,$b,$c,$d,$_[9],5,0xd62f105d,/* 21 */
+GG,$d,$a,$b,$c,$_[14],9,0x2441453,/* 22 */
+GG,$c,$d,$a,$b,$_[19],14,0xd8a1e681,/* 23 */
+GG,$b,$c,$d,$a,$_[8],20,0xe7d3fbc8,/* 24 */
+GG,$a,$b,$c,$d,$_[13],5,0x21e1cde6,/* 25 */
+GG,$d,$a,$b,$c,$_[18],9,0xc33707d6,/* 26 */
+GG,$c,$d,$a,$b,$_[7],14,0xf4d50d87,/* 27 */
+GG,$b,$c,$d,$a,$_[12],20,0x455a14ed,/* 28 */
+GG,$a,$b,$c,$d,$_[17],5,0xa9e3e905,/* 29 */
+GG,$d,$a,$b,$c,$_[6],9,0xfcefa3f8,/* 30 */
+GG,$c,$d,$a,$b,$_[11],14,0x676f02d9,/* 31 */
+GG,$b,$c,$d,$a,$_[16],20,0x8d2a4c8a,/* 32 */
+HH,$a,$b,$c,$d,$_[9],4,0xfffa3942,/* 33 */
+HH,$d,$a,$b,$c,$_[12],11,0x8771f681,/* 34 */
+HH,$c,$d,$a,$b,$_[15],16,0x6d9d6122,/* 35 */
+HH,$b,$c,$d,$a,$_[18],23,0xfde5380c,/* 36 */
+HH,$a,$b,$c,$d,$_[5],4,0xa4beea44,/* 37 */
+HH,$d,$a,$b,$c,$_[8],11,0x4bdecfa9,/* 38 */
+HH,$c,$d,$a,$b,$_[11],16,0xf6bb4b60,/* 39 */
+HH,$b,$c,$d,$a,$_[14],23,0xbebfbc70,/* 40 */
+HH,$a,$b,$c,$d,$_[17],4,0x289b7ec6,/* 41 */
+HH,$d,$a,$b,$c,$_[4],11,0xeaa127fa,/* 42 */
+HH,$c,$d,$a,$b,$_[7],16,0xd4ef3085,/* 43 */
+HH,$b,$c,$d,$a,$_[10],23,0x4881d05,/* 44 */
+HH,$a,$b,$c,$d,$_[13],4,0xd9d4d039,/* 45 */
+HH,$d,$a,$b,$c,$_[16],11,0xe6db99e5,/* 46 */
+HH,$c,$d,$a,$b,$_[19],16,0x1fa27cf8,/* 47 */
+HH,$b,$c,$d,$a,$_[6],23,0xc4ac5665,/* 48 */
+II,$a,$b,$c,$d,$_[4],6,0xf4292244,/* 49 */
+II,$d,$a,$b,$c,$_[11],10,0x432aff97,/* 50 */
+II,$c,$d,$a,$b,$_[18],15,0xab9423a7,/* 51 */
+II,$b,$c,$d,$a,$_[9],21,0xfc93a039,/* 52 */
+II,$a,$b,$c,$d,$_[16],6,0x655b59c3,/* 53 */
+II,$d,$a,$b,$c,$_[7],10,0x8f0ccc92,/* 54 */
+II,$c,$d,$a,$b,$_[14],15,0xffeff47d,/* 55 */
+II,$b,$c,$d,$a,$_[5],21,0x85845dd1,/* 56 */
+II,$a,$b,$c,$d,$_[12],6,0x6fa87e4f,/* 57 */
+II,$d,$a,$b,$c,$_[19],10,0xfe2ce6e0,/* 58 */
+II,$c,$d,$a,$b,$_[10],15,0xa3014314,/* 59 */
+II,$b,$c,$d,$a,$_[17],21,0x4e0811a1,/* 60 */
+II,$a,$b,$c,$d,$_[8],6,0xf7537e82,/* 61 */
+II,$d,$a,$b,$c,$_[15],10,0xbd3af235,/* 62 */
+II,$c,$d,$a,$b,$_[6],15,0x2ad7d2bb,/* 63 */
+II,$b,$c,$d,$a,$_[13],21,0xeb86d391,/* 64 */
Property changes on: trunk/gdata/inst/perl/Digest/Perl/MD5.pm
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/gdata/inst/perl/Graphics/ColorUtils.pm
===================================================================
--- trunk/gdata/inst/perl/Graphics/ColorUtils.pm (rev 0)
+++ trunk/gdata/inst/perl/Graphics/ColorUtils.pm 2014-08-28 01:28:23 UTC (rev 1873)
@@ -0,0 +1,1393 @@
+
+package Graphics::ColorUtils;
+
+use 5.008003;
+use strict;
+use warnings;
+
+use Carp;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+
+our %EXPORT_TAGS = ( 'gradients' => [ qw( gradient
+ grad2rgb
+ available_gradients
+ register_gradient) ],
+ 'names' => [ qw( name2rgb
+ available_names
+ register_name
+ set_default_namespace
+ get_default_namespace ) ],
+ 'all' => [ qw( rgb2yiq yiq2rgb
+ rgb2cmy cmy2rgb
+ rgb2hls hls2rgb
+ rgb2hsv hsv2rgb
+ gradient
+ grad2rgb
+ available_gradients
+ register_gradient
+ name2rgb
+ available_names
+ register_name
+ set_default_namespace
+ get_default_namespace ) ],
+ );
+
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+
+our @EXPORT = qw( rgb2yiq yiq2rgb
+ rgb2cmy cmy2rgb
+ rgb2hls hls2rgb
+ rgb2hsv hsv2rgb );
+
+our $VERSION = '0.17';
+
+# ==================================================
+# ++++++++++++++++++++++++++++++++++++++++++++++++++
+# ==================================================
+
+# ==================================================
+# Utility
+
+# Takes a (r,g,b) triple of numbers (possibly floats) and returns
+# - a string like '#33FF21' in scalar context
+# - a triple of corresponding integers in array context
+sub _fmt {
+ return wantarray ? map { int } @_ : sprintf( "#%02x%02x%02x", @_ );
+}
+
+# ==================================================
+# YIQ
+
+sub rgb2yiq {
+ # $r, $g, $b : 0..255
+ my ( $r, $g, $b ) = map { $_/255.0 } @_; # Scale RGB to 0..1
+
+ my $y = 0.299*$r + 0.587*$g + 0.114*$b;
+ my $i = 0.596*$r - 0.275*$g - 0.321*$b;
+ my $q = 0.212*$r - 0.523*$g + 0.311*$b;
+
+ return ( $y, $i, $q );
+}
+
+sub yiq2rgb {
+ # $y, $i, $q : 0..1
+ my ( $y, $i, $q ) = @_;
+
+ my $r = 255.0*( $y + 0.956*$i + 0.621*$q );
+ my $g = 255.0*( $y - 0.272*$i - 0.647*$q );
+ my $b = 255.0*( $y - 1.105*$i + 1.705*$q );
+
+ return _fmt( $r, $g, $b );
+}
+
+# ==================================================
+# CMY
+
+sub rgb2cmy {
+ # $r, $g, $b : 0..255
+ my ( $r, $g, $b ) = map { $_/255.0 } @_; # Scale RGB to 0..1
+
+ return ( 1.0 - $r, 1.0 - $g, 1.0 - $b );
+}
+
+sub cmy2rgb {
+ # $c, $m, $y : 0..1
+ my ( $c, $m, $y ) = @_;
+
+ return _fmt( 255*(1.0-$c), 255*(1.0-$m), 255*(1.0-$y) );
+}
+
+# ==================================================
+# HLS
+
+# Foley, van Dam, et al:
+# Computer Grapics-Principles and Practice (1990) p595f
+
+sub rgb2hls {
+ # $r, $g, $b : 0..255
+ # Note special name '$bb' to avoid conflict with ($a,$b) in sort()
+ my ( $r, $g, $bb ) = map { $_/255.0 } @_; # Scale RGB to 0..1
+
+ my ( $minc, $maxc ) = ( sort { $a <=> $b } ( $r, $g, $bb ) )[0,2];
+
+ my $m = $minc + $maxc; # "Mean"
+
+ if( $maxc == $minc ) { return ( 0, 0.5*$m, 0 ); } # Achromatic case
+
+ my $d = $maxc - $minc; # "Delta"
+ my $s = ( $m <= 1.0 ) ? $d/$m : $d/(2.0-$m ); # Saturation
+
+ my $h = 0; # Hue
+ if( $r == $maxc ) { $h = ( $g-$bb )/$d; }
+ elsif( $g == $maxc ) { $h = 2 + ( $bb-$r )/$d; }
+ elsif( $bb == $maxc ) { $h = 4 + ( $r-$g )/$d; }
+ else {
+ # Never get here!
+ croak "Internal Error: Unexpected value ,$maxc, in Graphics::ColorUtils::rgb2hls( $r, $g, $bb )";
+ }
+
+ $h *= 60; # Convert to degrees
+ if( $h < 0 ) { $h += 360; } # Ensure positive hue
+
+ return ( $h, 0.5*$m, $s );
+}
+
+sub hls2rgb {
+ # $h: 0..360 (red=0->yellow->green=120->cyan->blue=240->magenta steps of 60)
+ # $l, $s : 0..1 (inclusive)
+ my ( $h, $l, $s ) = @_;
+
+ if( $s == 0.0 ) { return _fmt(255*$l, 255*$l, 255*$l); } # achromatic (grey)
+
+# This is the INCORRECT line as it is in the book quoted above:
+# my $m2 = ( $l <= 0.5 ) ? ($l*($l+$s)) : ($l - $l*$s + $s);
+# This is the CORRECT line: (first alternative: 1 vs $l)
+ my $m2 = ( $l <= 0.5 ) ? ($l*(1+$s)) : ($l - $l*$s + $s);
+ my $m1 = 2.0*$l - $m2;
+
+ my $r = 255 * _value( $m1, $m2, $h + 120 );
+ my $g = 255 * _value( $m1, $m2, $h );
+ my $b = 255 * _value( $m1, $m2, $h - 120 );
+
+ return _fmt( $r, $g, $b );
+}
+
+sub _value {
+ my ( $n1, $n2, $hue ) = @_;
+
+ if( $hue > 360 ) { $hue -= 360; }
+ elsif( $hue < 0 ) { $hue += 360; }
+
+ if( $hue < 60 ) { return $n1 + $hue * ( $n2-$n1 )/60.0; }
+ elsif( $hue < 180 ) { return $n2; }
+ elsif( $hue < 240 ) { return $n1 + ( 240-$hue ) * ( $n2-$n1 )/60.0; }
+ else { return $n1; }
+}
+
+# ==================================================
+# HSV
+
+# Foley, van Dam, et al:
+# Computer Grapics-Principles and Practice (1990) p592f
+
+sub rgb2hsv {
+ # $r, $g, $b : 0..25
+ # Note special name '$bb' to avoid conflict with ($a,$b) in sort()
+ my ( $r, $g, $bb ) = map { $_/255.0 } @_; # Scale RGB to 0..1
+
+ my ( $minc, $maxc ) = ( sort { $a <=> $b } ( $r, $g, $bb ) )[0,2];
+
+ my $v = $maxc; # Value
+ my $d = $maxc - $minc; # "Delta"
+ my $s = ( $maxc == 0 ) ? 0 : $d/$maxc; # No saturation if R=G=B=0
+
+ if( $s == 0 ) { return ( 0, 0, $v ); } # Achromatic case
+
+ my $h = 0; # Hue
+ if( $r == $maxc ) { $h = ( $g-$bb )/$d; }
+ elsif( $g == $maxc ) { $h = 2 + ( $bb-$r )/$d; }
+ elsif( $bb == $maxc ) { $h = 4 + ( $r-$g )/$d; }
+ else {
+ # Never get here!
+ croak "Internal Error: Unexpected value ,$maxc, in Graphics::ColorUtils::rgb2hsv( $r, $g, $bb )";
+ }
+
+ $h *= 60; # Convert to degrees
+ if( $h < 0 ) { $h += 360; } # Ensure positive hue
+
+ return ( $h, $s, $v );
+}
+
+sub hsv2rgb {
+ # $h: 0..360 (red=0->yellow->green=120->cyan->blue=240->magenta steps of 60)
+ # (tolerates larger values of $h by reducing them to the standard circle)
+ # $s, $v : 0..1 (inclusive)
+ my ( $h, $s, $v ) = @_;
+
+ $v *= 255;
+ if( $s == 0 ) { return _fmt( $v, $v, $v ); } # achromatic (grey)
+
+ my $i = int( $h/60 ); # sector 0 to 5
+ my $f = ($h/60) - $i; # fractional part of h/60
+
+ my $p = $v * ( 1 - $s );
+ my $q = $v * ( 1 - $s * $f );
+ my $t = $v * ( 1 - $s * ( 1 - $f ) );
+
+ $i %= 6; # tolerate values of $h larger than 360
+ if( $i==0 ) { return _fmt( $v, $t, $p ); }
+ elsif( $i==1 ) { return _fmt( $q, $v, $p ); }
+ elsif( $i==2 ) { return _fmt( $p, $v, $t ); }
+ elsif( $i==3 ) { return _fmt( $p, $q, $v ); }
+ elsif( $i==4 ) { return _fmt( $t, $p, $v ); }
+ elsif( $i==5 ) { return _fmt( $v, $p, $q ); }
+ else {
+ # Never get here!
+ croak "Internal Error: Unexpected value ,$i, in Graphics::ColorUtils::hsv2rgb( $h, $s, $v )";
+ }
+}
+
+# ==================================================
+# Gradients
+
+# Gradients grey, heat, map, and rainbow have been inspired by similar
+# ideas in Yorick.
+# For Yorick, cf http://yorick.sourceforge.net
+# and also http://www.maumae.net/yorick/doc/index.php
+# as well as http://www.mhatt.aps.anl.gov/dohn/software/yorick/
+
+BEGIN {
+my %_gradients = (
+ 'grey' => [
+ [ 0, 0, 0],[ 1, 1, 1],[ 2, 2, 2],[ 3, 3, 3],[ 4, 4, 4],
+ [ 5, 5, 5],[ 6, 6, 6],[ 7, 7, 7],[ 9, 9, 9],[ 10, 10, 10],
+ [ 11, 11, 11],[ 12, 12, 12],[ 13, 13, 13],[ 14, 14, 14],[ 15, 15, 15],
+ [ 16, 16, 16],[ 17, 17, 17],[ 18, 18, 18],[ 19, 19, 19],[ 20, 20, 20],
+ [ 21, 21, 21],[ 22, 22, 22],[ 23, 23, 23],[ 25, 25, 25],[ 26, 26, 26],
+ [ 27, 27, 27],[ 28, 28, 28],[ 29, 29, 29],[ 30, 30, 30],[ 31, 31, 31],
+ [ 32, 32, 32],[ 33, 33, 33],[ 34, 34, 34],[ 35, 35, 35],[ 36, 36, 36],
+ [ 37, 37, 37],[ 38, 38, 38],[ 39, 39, 39],[ 41, 41, 41],[ 42, 42, 42],
+ [ 43, 43, 43],[ 44, 44, 44],[ 45, 45, 45],[ 46, 46, 46],[ 47, 47, 47],
+ [ 48, 48, 48],[ 49, 49, 49],[ 50, 50, 50],[ 51, 51, 51],[ 52, 52, 52],
+ [ 53, 53, 53],[ 54, 54, 54],[ 55, 55, 55],[ 57, 57, 57],[ 58, 58, 58],
+ [ 59, 59, 59],[ 60, 60, 60],[ 61, 61, 61],[ 62, 62, 62],[ 63, 63, 63],
+ [ 64, 64, 64],[ 65, 65, 65],[ 66, 66, 66],[ 67, 67, 67],[ 68, 68, 68],
+ [ 69, 69, 69],[ 70, 70, 70],[ 71, 71, 71],[ 73, 73, 73],[ 74, 74, 74],
+ [ 75, 75, 75],[ 76, 76, 76],[ 77, 77, 77],[ 78, 78, 78],[ 79, 79, 79],
+ [ 80, 80, 80],[ 81, 81, 81],[ 82, 82, 82],[ 83, 83, 83],[ 84, 84, 84],
+ [ 85, 85, 85],[ 86, 86, 86],[ 87, 87, 87],[ 89, 89, 89],[ 90, 90, 90],
+ [ 91, 91, 91],[ 92, 92, 92],[ 93, 93, 93],[ 94, 94, 94],[ 95, 95, 95],
+ [ 96, 96, 96],[ 97, 97, 97],[ 98, 98, 98],[ 99, 99, 99],[100,100,100],
+ [101,101,101],[102,102,102],[103,103,103],[105,105,105],[106,106,106],
+ [107,107,107],[108,108,108],[109,109,109],[110,110,110],[111,111,111],
+ [112,112,112],[113,113,113],[114,114,114],[115,115,115],[116,116,116],
+ [117,117,117],[118,118,118],[119,119,119],[121,121,121],[122,122,122],
+ [123,123,123],[124,124,124],[125,125,125],[126,126,126],[127,127,127],
+ [128,128,128],[129,129,129],[130,130,130],[131,131,131],[132,132,132],
+ [133,133,133],[134,134,134],[135,135,135],[137,137,137],[138,138,138],
+ [139,139,139],[140,140,140],[141,141,141],[142,142,142],[143,143,143],
+ [144,144,144],[145,145,145],[146,146,146],[147,147,147],[148,148,148],
+ [149,149,149],[150,150,150],[151,151,151],[153,153,153],[154,154,154],
+ [155,155,155],[156,156,156],[157,157,157],[158,158,158],[159,159,159],
+ [160,160,160],[161,161,161],[162,162,162],[163,163,163],[164,164,164],
+ [165,165,165],[166,166,166],[167,167,167],[169,169,169],[170,170,170],
+ [171,171,171],[172,172,172],[173,173,173],[174,174,174],[175,175,175],
+ [176,176,176],[177,177,177],[178,178,178],[179,179,179],[180,180,180],
+ [181,181,181],[182,182,182],[183,183,183],[185,185,185],[186,186,186],
+ [187,187,187],[188,188,188],[189,189,189],[190,190,190],[191,191,191],
+ [192,192,192],[193,193,193],[194,194,194],[195,195,195],[196,196,196],
+ [197,197,197],[198,198,198],[199,199,199],[201,201,201],[202,202,202],
+ [203,203,203],[204,204,204],[205,205,205],[206,206,206],[207,207,207],
+ [208,208,208],[209,209,209],[210,210,210],[211,211,211],[212,212,212],
+ [213,213,213],[214,214,214],[215,215,215],[217,217,217],[218,218,218],
+ [219,219,219],[220,220,220],[221,221,221],[222,222,222],[223,223,223],
+ [224,224,224],[225,225,225],[226,226,226],[227,227,227],[228,228,228],
+ [229,229,229],[230,230,230],[231,231,231],[233,233,233],[234,234,234],
+ [235,235,235],[236,236,236],[237,237,237],[238,238,238],[239,239,239],
+ [240,240,240],[241,241,241],[242,242,242],[243,243,243],[244,244,244],
+ [245,245,245],[246,246,246],[247,247,247],[249,249,249],[250,250,250],
+ [251,251,251],[252,252,252],[253,253,253],[254,254,254],[255,255,255]
+ ],
+ 'heat' => [
+ [ 0, 0, 0],[ 1, 0, 0],[ 2, 0, 0],[ 4, 0, 0],[ 5, 0, 0],
+ [ 7, 0, 0],[ 8, 0, 0],[ 10, 0, 0],[ 11, 0, 0],[ 13, 0, 0],
+ [ 15, 0, 0],[ 17, 0, 0],[ 18, 0, 0],[ 20, 0, 0],[ 21, 0, 0],
+ [ 23, 0, 0],[ 24, 0, 0],[ 26, 0, 0],[ 27, 0, 0],[ 28, 0, 0],
+ [ 30, 0, 0],[ 31, 0, 0],[ 33, 0, 0],[ 34, 0, 0],[ 36, 0, 0],
+ [ 37, 0, 0],[ 39, 0, 0],[ 40, 0, 0],[ 42, 0, 0],[ 43, 0, 0],
+ [ 46, 0, 0],[ 47, 0, 0],[ 49, 0, 0],[ 50, 0, 0],[ 52, 0, 0],
+ [ 53, 0, 0],[ 55, 0, 0],[ 56, 0, 0],[ 57, 0, 0],[ 59, 0, 0],
+ [ 60, 0, 0],[ 62, 0, 0],[ 63, 0, 0],[ 65, 0, 0],[ 66, 0, 0],
+ [ 68, 0, 0],[ 69, 0, 0],[ 70, 0, 0],[ 72, 0, 0],[ 73, 0, 0],
+ [ 76, 0, 0],[ 78, 0, 0],[ 79, 0, 0],[ 81, 0, 0],[ 82, 0, 0],
+ [ 84, 0, 0],[ 85, 0, 0],[ 86, 0, 0],[ 88, 0, 0],[ 89, 0, 0],
+ [ 92, 0, 0],[ 94, 0, 0],[ 95, 0, 0],[ 97, 0, 0],[ 98, 0, 0],
+ [ 99, 0, 0],[101, 0, 0],[102, 0, 0],[104, 0, 0],[105, 0, 0],
+ [108, 0, 0],[110, 0, 0],[111, 0, 0],[113, 0, 0],[114, 0, 0],
+ [115, 0, 0],[117, 0, 0],[118, 0, 0],[120, 0, 0],[121, 0, 0],
+ [123, 0, 0],[124, 0, 0],[126, 0, 0],[127, 0, 0],[128, 0, 0],
+ [130, 0, 0],[131, 0, 0],[133, 0, 0],[134, 0, 0],[136, 0, 0],
+ [139, 0, 0],[140, 0, 0],[141, 0, 0],[143, 0, 0],[144, 0, 0],
+ [146, 0, 0],[147, 0, 0],[149, 0, 0],[150, 0, 0],[152, 0, 0],
+ [153, 0, 0],[155, 0, 0],[156, 0, 0],[157, 0, 0],[159, 0, 0],
+ [160, 0, 0],[162, 0, 0],[163, 0, 0],[165, 0, 0],[166, 0, 0],
+ [169, 0, 0],[170, 0, 0],[172, 0, 0],[173, 0, 0],[175, 1, 0],
+ [176, 3, 0],[178, 5, 0],[179, 7, 0],[181, 9, 0],[182, 11, 0],
+ [185, 15, 0],[186, 17, 0],[188, 18, 0],[189, 20, 0],[191, 22, 0],
+ [192, 24, 0],[194, 26, 0],[195, 28, 0],[197, 30, 0],[198, 32, 0],
+ [201, 35, 0],[202, 37, 0],[204, 39, 0],[205, 41, 0],[207, 43, 0],
+ [208, 45, 0],[210, 47, 0],[211, 49, 0],[212, 51, 0],[214, 52, 0],
+ [215, 54, 0],[217, 56, 0],[218, 58, 0],[220, 60, 0],[221, 62, 0],
+ [223, 64, 0],[224, 66, 0],[226, 68, 0],[227, 69, 0],[228, 71, 0],
+ [231, 75, 0],[233, 77, 0],[234, 79, 0],[236, 81, 0],[237, 83, 0],
+ [239, 85, 0],[240, 86, 0],[241, 88, 0],[243, 90, 0],[244, 92, 0],
+ [246, 94, 0],[247, 96, 0],[249, 98, 0],[250,100, 0],[252,102, 0],
+ [253,103, 0],[255,105, 0],[255,107, 0],[255,109, 0],[255,111, 0],
+ [255,115, 0],[255,117, 0],[255,119, 0],[255,120, 0],[255,122, 0],
+ [255,124, 0],[255,126, 0],[255,128, 0],[255,130, 0],[255,132, 0],
+ [255,136, 7],[255,137, 11],[255,139, 15],[255,141, 19],[255,143, 23],
+ [255,145, 27],[255,147, 31],[255,149, 35],[255,151, 39],[255,153, 43],
+ [255,156, 51],[255,158, 54],[255,160, 58],[255,162, 62],[255,164, 66],
+ [255,166, 70],[255,168, 74],[255,170, 78],[255,171, 82],[255,173, 86],
+ [255,175, 90],[255,177, 94],[255,179, 98],[255,181,102],[255,183,105],
+ [255,185,109],[255,187,113],[255,188,117],[255,190,121],[255,192,125],
+ [255,196,133],[255,198,137],[255,200,141],[255,202,145],[255,204,149],
+ [255,205,153],[255,207,156],[255,209,160],[255,211,164],[255,213,168],
+ [255,215,172],[255,217,176],[255,219,180],[255,221,184],[255,222,188],
+ [255,224,192],[255,226,196],[255,228,200],[255,230,204],[255,232,207],
+ [255,236,215],[255,238,219],[255,239,223],[255,241,227],[255,243,231],
+ [255,245,235],[255,247,239],[255,249,243],[255,251,247],[255,253,251]
+ ],
+ 'map' => [
+ [ 0, 0, 0],[ 0, 0, 46],[ 0, 0, 58],[ 0, 0, 69],[ 0, 0, 81],
+ [ 0, 0, 92],[ 0, 0,104],[ 0, 0,116],[ 0, 3,116],[ 1, 6,116],
+ [ 2, 8,116],[ 2, 11,116],[ 3, 13,117],[ 4, 16,117],[ 5, 18,117],
+ [ 5, 21,117],[ 6, 23,117],[ 7, 26,118],[ 8, 28,118],[ 8, 31,118],
+ [ 9, 33,118],[ 10, 36,118],[ 11, 38,119],[ 11, 41,119],[ 12, 43,119],
+ [ 13, 45,119],[ 14, 48,119],[ 15, 50,120],[ 15, 52,120],[ 16, 55,120],
+ [ 17, 57,120],[ 18, 59,120],[ 18, 61,121],[ 19, 64,121],[ 20, 66,121],
+ [ 21, 68,121],[ 22, 70,121],[ 22, 72,122],[ 23, 74,122],[ 24, 77,122],
+ [ 25, 79,122],[ 26, 81,122],[ 26, 83,123],[ 27, 85,123],[ 28, 87,123],
+ [ 29, 89,123],[ 30, 91,123],[ 31, 93,124],[ 31, 95,124],[ 32, 97,124],
+ [ 33, 99,124],[ 34,100,124],[ 35,102,125],[ 36,104,125],[ 36,106,125],
+ [ 37,108,125],[ 38,109,125],[ 39,111,126],[ 40,113,126],[ 41,115,126],
+ [ 41,116,126],[ 42,118,126],[ 43,120,127],[ 44,121,127],[ 45,123,127],
+ [ 46,125,127],[ 47,126,127],[ 48,128,128],[ 48,128,126],[ 48,129,125],
+ [ 49,129,124],[ 49,130,123],[ 50,131,122],[ 50,131,120],[ 51,132,119],
+ [ 51,133,118],[ 52,133,117],[ 52,134,115],[ 53,134,114],[ 53,135,113],
+ [ 54,136,111],[ 54,136,110],[ 55,137,109],[ 55,138,108],[ 56,138,106],
+ [ 56,139,105],[ 57,140,104],[ 57,140,102],[ 58,141,101],[ 58,141,100],
+ [ 59,142, 98],[ 59,143, 97],[ 60,143, 96],[ 61,144, 94],[ 61,145, 93],
+ [ 62,145, 92],[ 62,146, 90],[ 63,146, 89],[ 63,147, 88],[ 64,148, 86],
+ [ 64,148, 85],[ 65,149, 84],[ 65,150, 82],[ 66,150, 81],[ 67,151, 80],
+ [ 67,151, 78],[ 68,152, 77],[ 68,153, 76],[ 69,153, 74],[ 69,154, 73],
+ [ 70,155, 71],[ 71,155, 70],[ 73,156, 71],[ 76,156, 72],[ 78,157, 72],
+ [ 81,158, 73],[ 83,158, 73],[ 86,159, 74],[ 88,160, 75],[ 91,160, 75],
+ [ 94,161, 76],[ 96,161, 76],[ 99,162, 77],[101,163, 77],[104,163, 78],
+ [106,164, 79],[109,165, 79],[111,165, 80],[114,166, 80],[117,166, 81],
+ [119,167, 82],[121,168, 82],[122,168, 82],[124,168, 83],[126,169, 83],
+ [128,169, 83],[129,170, 84],[131,170, 84],[133,171, 84],[135,171, 85],
+ [136,172, 85],[138,172, 85],[140,172, 86],[141,173, 86],[143,173, 86],
+ [145,174, 87],[147,174, 87],[149,175, 87],[150,175, 88],[152,175, 88],
+ [154,176, 88],[156,176, 89],[157,177, 89],[159,177, 89],[161,178, 90],
+ [163,178, 90],[165,179, 90],[166,179, 91],[168,179, 91],[170,180, 91],
+ [172,180, 92],[174,181, 92],[175,181, 92],[177,182, 93],[179,182, 93],
+ [181,183, 93],[183,183, 94],[183,182, 94],[184,181, 94],[184,181, 95],
+ [185,180, 95],[185,179, 95],[186,178, 96],[186,177, 96],[187,176, 97],
+ [187,175, 97],[187,174, 97],[188,173, 98],[188,172, 98],[189,171, 98],
+ [189,170, 99],[190,169, 99],[190,168, 99],[190,167,100],[191,166,100],
+ [191,165,100],[192,164,101],[192,163,101],[193,163,104],[195,164,106],
+ [196,164,108],[197,165,111],[198,165,113],[199,166,116],[201,167,118],
+ [202,167,121],[203,168,123],[204,169,126],[205,170,129],[207,171,131],
+ [208,172,134],[209,173,137],[210,174,139],[211,175,142],[213,176,145],
+ [214,177,148],[215,178,150],[216,179,153],[217,181,156],[219,182,159],
+ [220,184,162],[221,185,165],[222,187,168],[223,188,170],[225,190,173],
+ [226,192,176],[227,194,179],[228,196,182],[229,198,185],[231,200,189],
+ [232,202,192],[233,204,195],[234,206,198],[235,208,201],[237,211,204],
+ [238,213,207],[239,215,211],[240,218,214],[241,221,217],[243,223,220],
+ [244,226,224],[245,229,227],[246,232,230],[247,235,234],[249,238,237],
+ [250,241,241],[251,244,244],[252,248,248],[253,251,251],[255,255,255]
+ ],
+ 'rainbow' => [
+ [255, 0, 42],[255, 0, 36],[255, 0, 31],[255, 0, 26],[255, 0, 20],
+ [255, 0, 15],[255, 0, 10],[255, 0, 4],[255, 5, 0],[255, 11, 0],
+ [255, 16, 0],[255, 22, 0],[255, 27, 0],[255, 32, 0],[255, 38, 0],
+ [255, 43, 0],[255, 48, 0],[255, 54, 0],[255, 59, 0],[255, 65, 0],
+ [255, 70, 0],[255, 75, 0],[255, 81, 0],[255, 91, 0],[255, 97, 0],
+ [255,102, 0],[255,108, 0],[255,113, 0],[255,118, 0],[255,124, 0],
+ [255,129, 0],[255,135, 0],[255,140, 0],[255,145, 0],[255,151, 0],
+ [255,156, 0],[255,161, 0],[255,167, 0],[255,178, 0],[255,183, 0],
+ [255,188, 0],[255,194, 0],[255,199, 0],[255,204, 0],[255,210, 0],
+ [255,215, 0],[255,221, 0],[255,226, 0],[255,231, 0],[255,237, 0],
+ [255,242, 0],[255,247, 0],[255,253, 0],[245,255, 0],[240,255, 0],
+ [235,255, 0],[229,255, 0],[224,255, 0],[219,255, 0],[213,255, 0],
+ [208,255, 0],[202,255, 0],[197,255, 0],[192,255, 0],[186,255, 0],
+ [181,255, 0],[175,255, 0],[170,255, 0],[159,255, 0],[154,255, 0],
+ [149,255, 0],[143,255, 0],[138,255, 0],[132,255, 0],[127,255, 0],
+ [122,255, 0],[116,255, 0],[111,255, 0],[106,255, 0],[100,255, 0],
+ [ 95,255, 0],[ 89,255, 0],[ 84,255, 0],[ 73,255, 0],[ 68,255, 0],
+ [ 63,255, 0],[ 57,255, 0],[ 52,255, 0],[ 46,255, 0],[ 41,255, 0],
+ [ 36,255, 0],[ 30,255, 0],[ 25,255, 0],[ 19,255, 0],[ 14,255, 0],
+ [ 9,255, 0],[ 3,255, 0],[ 0,255, 1],[ 0,255, 12],[ 0,255, 17],
+ [ 0,255, 23],[ 0,255, 28],[ 0,255, 33],[ 0,255, 39],[ 0,255, 44],
+ [ 0,255, 49],[ 0,255, 55],[ 0,255, 60],[ 0,255, 66],[ 0,255, 71],
+ [ 0,255, 76],[ 0,255, 82],[ 0,255, 87],[ 0,255, 98],[ 0,255,103],
+ [ 0,255,109],[ 0,255,114],[ 0,255,119],[ 0,255,125],[ 0,255,130],
+ [ 0,255,135],[ 0,255,141],[ 0,255,146],[ 0,255,152],[ 0,255,157],
+ [ 0,255,162],[ 0,255,168],[ 0,255,173],[ 0,255,184],[ 0,255,189],
+ [ 0,255,195],[ 0,255,200],[ 0,255,205],[ 0,255,211],[ 0,255,216],
+ [ 0,255,222],[ 0,255,227],[ 0,255,232],[ 0,255,238],[ 0,255,243],
+ [ 0,255,248],[ 0,255,254],[ 0,250,255],[ 0,239,255],[ 0,234,255],
+ [ 0,228,255],[ 0,223,255],[ 0,218,255],[ 0,212,255],[ 0,207,255],
+ [ 0,201,255],[ 0,196,255],[ 0,191,255],[ 0,185,255],[ 0,180,255],
+ [ 0,174,255],[ 0,169,255],[ 0,164,255],[ 0,153,255],[ 0,148,255],
+ [ 0,142,255],[ 0,137,255],[ 0,131,255],[ 0,126,255],[ 0,121,255],
+ [ 0,115,255],[ 0,110,255],[ 0,105,255],[ 0, 99,255],[ 0, 94,255],
+ [ 0, 88,255],[ 0, 83,255],[ 0, 78,255],[ 0, 67,255],[ 0, 62,255],
+ [ 0, 56,255],[ 0, 51,255],[ 0, 45,255],[ 0, 40,255],[ 0, 35,255],
+ [ 0, 29,255],[ 0, 24,255],[ 0, 18,255],[ 0, 13,255],[ 0, 8,255],
+ [ 0, 2,255],[ 2, 0,255],[ 7, 0,255],[ 18, 0,255],[ 24, 0,255],
+ [ 29, 0,255],[ 34, 0,255],[ 40, 0,255],[ 45, 0,255],[ 50, 0,255],
+ [ 56, 0,255],[ 61, 0,255],[ 67, 0,255],[ 72, 0,255],[ 77, 0,255],
+ [ 83, 0,255],[ 88, 0,255],[ 93, 0,255],[104, 0,255],[110, 0,255],
+ [115, 0,255],[120, 0,255],[126, 0,255],[131, 0,255],[136, 0,255],
+ [142, 0,255],[147, 0,255],[153, 0,255],[158, 0,255],[163, 0,255],
+ [169, 0,255],[174, 0,255],[180, 0,255],[190, 0,255],[196, 0,255],
+ [201, 0,255],[206, 0,255],[212, 0,255],[217, 0,255],[223, 0,255],
+ [228, 0,255],[233, 0,255],[239, 0,255],[244, 0,255],[249, 0,255],
+ [255, 0,254],[255, 0,249],[255, 0,243],[255, 0,233],[255, 0,227],
+ [255, 0,222],[255, 0,217],[255, 0,211],[255, 0,206],[255, 0,201]
+ ]
+ );
+
+# Returns a hash: gradient-name => color-count
+sub available_gradients {
+ return map { $_, scalar( @{ $_gradients{$_} } ) } keys %_gradients;
+}
+
+# Returns array-ref of rgb-triples, undef if gradient-name not found
+sub gradient {
+ my ( $name ) = @_;
+
+ unless( exists $_gradients{ $name } ) { return; }
+
+ return $_gradients{$name};
+}
+
+# Returns the color corresponding to the position in the gradient given by f.
+# Returns undef when gradient not found or f outside valid range.
+sub grad2rgb {
+ my ( $name, $frac ) = @_;
+
+ unless( exists $_gradients{ $name } ) { return; }
+ if( $frac < 0.0 || $frac >= 1.0 ) { return; }
+
+ my $idx = int( $frac * scalar( @{$_gradients{$name}} ) );
+ return _fmt( @{ $_gradients{$name}[$idx] } );
+}
+
+# Expects a gradient and and array-ref to an array of rgb triples.
+# If the name already exists, the function returns the old array; undef otherws
+sub register_gradient {
+ my ( $name, $array_ref ) = @_;
+
+ if( exists $_gradients{ $name } ) {
+ my $old = $_gradients{ $name };
+ $_gradients{ $name } = $array_ref;
+ return $old;
+ }
+
+ $_gradients{ $name } = $array_ref;
+ return undef;
+}
+
+} # end BEGIN (Gradients)
+
+# ==================================================
+# Names
+
+BEGIN {
+
+my $_default_namespace = 'x11';
+
+my %_colors = (
+ 'www:aqua' => [ 0,255,255],'www:black' => [ 0, 0, 0],
+ 'www:blue' => [ 0, 0,255],'www:fuchsia' => [255, 0,255],
+ 'www:gray' => [190,190,190],'www:green' => [ 0,128, 0],
+ 'www:lime' => [ 0,255, 0],'www:maroon' => [128, 0, 0],
+ 'www:navy' => [ 0, 0,128],'www:olive' => [128,128, 0],
+ 'www:purple' => [128, 0,128],'www:red' => [255, 0, 0],
+ 'www:silver' => [192,192,192],'www:teal' => [ 0,128,128],
+ 'www:white' => [255,255,255],'www:yellow' => [255,255, 0],
+ 'www:orange' => [255,165, 0],
+
+'svg:palevioletred' => [219,112,147],'svg:mediumslateblue' => [123,104,238],
+'svg:gold' => [255,215,0],'svg:gainsboro' => [220,220,220],
+'svg:yellow' => [255,255,0],'svg:limegreen' => [50,205,50],
+'svg:lightgoldenrodyellow' => [250,250,210],'svg:lavenderblush' => [255,240,245],
+'svg:darkmagenta' => [139,0,139],'svg:darkgrey' => [169,169,169],
+'svg:blanchedalmond' => [255,235,205],'svg:ghostwhite' => [248,248,255],
+'svg:floralwhite' => [255,250,240],'svg:coral' => [255,127,80],
+'svg:honeydew' => [240,255,240],'svg:mistyrose' => [255,228,225],
+'svg:slateblue' => [106,90,205],'svg:goldenrod' => [218,165,32],
+'svg:darkcyan' => [0,139,139],'svg:moccasin' => [255,228,181],
+'svg:mediumvioletred' => [199,21,133],'svg:maroon' => [128,0,0],
+'svg:lightpink' => [255,182,193],'svg:lightsalmon' => [255,160,122],
+'svg:paleturquoise' => [175,238,238],'svg:darksalmon' => [233,150,122],
+'svg:yellowgreen' => [154,205,50],'svg:mediumturquoise' => [72,209,204],
+'svg:chartreuse' => [127,255,0],'svg:peru' => [205,133,63],
+'svg:palegoldenrod' => [238,232,170],'svg:red' => [255,0,0],
+'svg:lavender' => [230,230,250],'svg:lightseagreen' => [32,178,170],
+'svg:powderblue' => [176,224,230],'svg:orchid' => [218,112,214],
+'svg:cornsilk' => [255,248,220],'svg:seagreen' => [46,139,87],
+'svg:royalblue' => [65,105,225],'svg:ivory' => [255,255,240],
+'svg:tan' => [210,180,140],'svg:linen' => [250,240,230],
+'svg:darkorchid' => [153,50,204],'svg:tomato' => [255,99,71],
+'svg:lightcyan' => [224,255,255],'svg:darkolivegreen' => [85,107,47],
+'svg:sienna' => [160,82,45],'svg:lightsteelblue' => [176,196,222],
+'svg:indigo' => [75,0,130],'svg:peachpuff' => [255,218,185],
+'svg:lime' => [0,255,0],'svg:mediumspringgreen' => [0,250,154],
+'svg:silver' => [192,192,192],'svg:saddlebrown' => [139,69,19],
+'svg:lightyellow' => [255,255,224],'svg:grey' => [128,128,128],
+'svg:thistle' => [216,191,216],'svg:deepskyblue' => [0,191,255],
+'svg:lightgreen' => [144,238,144],'svg:blueviolet' => [138,43,226],
+'svg:aqua' => [0,255,255],'svg:cyan' => [0,255,255],
+'svg:papayawhip' => [255,239,213],'svg:deeppink' => [255,20,147],
+'svg:firebrick' => [178,34,34],'svg:navy' => [0,0,128],
+'svg:hotpink' => [255,105,180],'svg:pink' => [255,192,203],
+'svg:darkturquoise' => [0,206,209],'svg:navajowhite' => [255,222,173],
+'svg:lightslategrey' => [119,136,153],'svg:lawngreen' => [124,252,0],
+'svg:lightcoral' => [240,128,128],'svg:palegreen' => [152,251,152],
+'svg:dodgerblue' => [30,144,255],'svg:greenyellow' => [173,255,47],
+'svg:lightskyblue' => [135,206,250],'svg:brown' => [165,42,42],
+'svg:dimgrey' => [105,105,105],'svg:aquamarine' => [127,255,212],
+'svg:darkseagreen' => [143,188,143],'svg:fuchsia' => [255,0,255],
+'svg:magenta' => [255,0,255],'svg:chocolate' => [210,105,30],
+'svg:mediumseagreen' => [60,179,113],'svg:cadetblue' => [95,158,160],
+'svg:purple' => [128,0,128],'svg:turquoise' => [64,224,208],
+'svg:darkkhaki' => [189,183,107],'svg:antiquewhite' => [250,235,215],
+'svg:skyblue' => [135,206,235],'svg:sandybrown' => [244,164,96],
+'svg:mediumblue' => [0,0,205],'svg:steelblue' => [70,130,180],
+'svg:indianred' => [205,92,92],'svg:khaki' => [240,230,140],
+'svg:lightblue' => [173,216,230],'svg:green' => [0,128,0],
+'svg:olive' => [128,128,0],'svg:mediumorchid' => [186,85,211],
+'svg:blue' => [0,0,255],'svg:snow' => [255,250,250],
+'svg:rosybrown' => [188,143,143],'svg:orange' => [255,165,0],
+'svg:slategrey' => [112,128,144],'svg:darkorange' => [255,140,0],
+'svg:violet' => [238,130,238],'svg:darkslategrey' => [47,79,79],
+'svg:whitesmoke' => [245,245,245],'svg:burlywood' => [222,184,135],
+'svg:darkgreen' => [0,100,0],'svg:lemonchiffon' => [255,250,205],
+'svg:midnightblue' => [25,25,112],'svg:mintcream' => [245,255,250],
+'svg:oldlace' => [253,245,230],'svg:black' => [0,0,0],
+'svg:bisque' => [255,228,196],'svg:mediumaquamarine' => [102,205,170],
+'svg:olivedrab' => [107,142,35],'svg:salmon' => [250,128,114],
+'svg:teal' => [0,128,128],'svg:seashell' => [255,245,238],
+'svg:springgreen' => [0,255,127],'svg:plum' => [221,160,221],
+'svg:darkviolet' => [148,0,211],'svg:wheat' => [245,222,179],
+'svg:mediumpurple' => [147,112,219],'svg:cornflowerblue' => [100,149,237],
+'svg:forestgreen' => [34,139,34],'svg:darkgoldenrod' => [184,134,11],
+'svg:aliceblue' => [240,248,255],'svg:white' => [255,255,255],
+'svg:darkblue' => [0,0,139],'svg:azure' => [240,255,255],
+'svg:darkred' => [139,0,0],'svg:orangered' => [255,69,0],
+'svg:darkslateblue' => [72,61,139],'svg:crimson' => [220,20,60],
+'svg:lightgrey' => [211,211,211],'svg:beige' => [245,245,220],
+
+'x11:deepskyblue3' => [0,154,205],'x11:gold' => [255,215,0],
+'x11:gold1' => [255,215,0],'x11:mediumpurple3' => [137,104,205],
+'x11:royalblue3' => [58,95,205],'x11:lightgoldenrodyellow' => [250,250,210],
+'x11:lavenderblush' => [255,240,245],'x11:lavenderblush1' => [255,240,245],
+'x11:pink1' => [255,181,197],'x11:green3' => [0,205,0],
+'x11:lightsteelblue1' => [202,225,255],'x11:blanchedalmond' => [255,235,205],
+'x11:salmon1' => [255,140,105],'x11:ghostwhite' => [248,248,255],
+'x11:floralwhite' => [255,250,240],'x11:dodgerblue4' => [16,78,139],
+'x11:grey43' => [110,110,110],'x11:indianred4' => [139,58,58],
+'x11:mistyrose1' => [255,228,225],'x11:mistyrose' => [255,228,225],
+'x11:dodgerblue2' => [28,134,238],'x11:grey37' => [94,94,94],
+'x11:grey9' => [23,23,23],'x11:purple4' => [85,26,139],
+'x11:orchid2' => [238,122,233],'x11:cornsilk3' => [205,200,177],
+'x11:goldenrod' => [218,165,32],'x11:hotpink4' => [139,58,98],
+'x11:lightpink' => [255,182,193],'x11:coral2' => [238,106,80],
+'x11:cyan2' => [0,238,238],'x11:grey87' => [222,222,222],
+'x11:grey91' => [232,232,232],'x11:violetred4' => [139,34,82],
+'x11:violetred2' => [238,58,140],'x11:indianred2' => [238,99,99],
+'x11:lightyellow3' => [205,205,180],'x11:darkolivegreen2' => [188,238,104],
+'x11:magenta3' => [205,0,205],'x11:grey64' => [163,163,163],
+'x11:honeydew3' => [193,205,193],'x11:lightsalmon3' => [205,129,98],
+'x11:springgreen4' => [0,139,69],'x11:grey57' => [145,145,145],
+'x11:grey50' => [127,127,127],'x11:grey66' => [168,168,168],
+'x11:antiquewhite1' => [255,239,219],'x11:paleturquoise' => [175,238,238],
+'x11:navajowhite2' => [238,207,161],'x11:lightpink3' => [205,140,149],
+'x11:darksalmon' => [233,150,122],'x11:grey52' => [133,133,133],
+'x11:slategrey3' => [159,182,205],'x11:darkseagreen4' => [105,139,105],
+'x11:chartreuse' => [127,255,0],'x11:chartreuse1' => [127,255,0],
+'x11:grey42' => [107,107,107],'x11:peru' => [205,133,63],
+'x11:tan3' => [205,133,63],'x11:grey19' => [48,48,48],
+'x11:palegreen3' => [124,205,124],'x11:lavender' => [230,230,250],
+'x11:red3' => [205,0,0],'x11:orchid' => [218,112,214],
+'x11:powderblue' => [176,224,230],'x11:grey35' => [89,89,89],
+'x11:plum4' => [139,102,139],'x11:cornsilk' => [255,248,220],
+'x11:cornsilk1' => [255,248,220],'x11:royalblue' => [65,105,225],
+'x11:darkgoldenrod2' => [238,173,14],'x11:lightpink4' => [139,95,101],
+'x11:springgreen2' => [0,238,118],'x11:tan' => [210,180,140],
+'x11:lightslateblue' => [132,112,255],'x11:darkorchid' => [153,50,204],
+'x11:orangered2' => [238,64,0],'x11:palevioletred1' => [255,130,171],
+'x11:grey63' => [161,161,161],'x11:maroon2' => [238,48,167],
+'x11:blue2' => [0,0,238],'x11:turquoise4' => [0,134,139],
+'x11:lightcyan1' => [224,255,255],'x11:lightcyan' => [224,255,255],
+'x11:springgreen3' => [0,205,102],'x11:darkorchid4' => [104,34,139],
+'x11:sienna' => [160,82,45],'x11:goldenrod2' => [238,180,34],
+'x11:lightgoldenrod3' => [205,190,112],'x11:green' => [0,255,0],
+'x11:green1' => [0,255,0],'x11:peachpuff1' => [255,218,185],
+'x11:peachpuff' => [255,218,185],'x11:yellow3' => [205,205,0],
+'x11:mediumspringgreen' => [0,250,154],'x11:cadetblue3' => [122,197,205],
+'x11:royalblue1' => [72,118,255],'x11:deepskyblue1' => [0,191,255],
+'x11:deepskyblue' => [0,191,255],'x11:firebrick1' => [255,48,48],
+'x11:grey80' => [204,204,204],'x11:grey28' => [71,71,71],
+'x11:palegreen2' => [144,238,144],'x11:lightgreen' => [144,238,144],
+'x11:blueviolet' => [138,43,226],'x11:deeppink1' => [255,20,147],
+'x11:deeppink' => [255,20,147],'x11:deeppink2' => [238,18,137],
+'x11:lightskyblue2' => [164,211,238],'x11:grey77' => [196,196,196],
+'x11:grey72' => [184,184,184],'x11:tomato2' => [238,92,66],
+'x11:steelblue2' => [92,172,238],'x11:hotpink' => [255,105,180],
+'x11:slateblue4' => [71,60,139],'x11:pink' => [255,192,203],
+'x11:darkturquoise' => [0,206,209],'x11:antiquewhite3' => [205,192,176],
+'x11:grey32' => [82,82,82],'x11:lightyellow2' => [238,238,209],
+'x11:olivedrab4' => [105,139,34],'x11:lightblue4' => [104,131,139],
+'x11:royalblue2' => [67,110,238],'x11:navajowhite1' => [255,222,173],
+'x11:navajowhite' => [255,222,173],'x11:lightgoldenrod' => [238,221,130],
+'x11:grey85' => [217,217,217],'x11:maroon4' => [139,28,98],
+'x11:grey90' => [229,229,229],'x11:grey17' => [43,43,43],
+'x11:seashell4' => [139,134,130],'x11:greenyellow' => [173,255,47],
+'x11:dodgerblue1' => [30,144,255],'x11:dodgerblue' => [30,144,255],
+'x11:grey89' => [227,227,227],'x11:brown2' => [238,59,59],
+'x11:paleturquoise2' => [174,238,238],'x11:lightskyblue' => [135,206,250],
+'x11:salmon4' => [139,76,57],'x11:chocolate3' => [205,102,29],
+'x11:grey70' => [179,179,179],'x11:grey25' => [64,64,64],
+'x11:darkolivegreen4' => [110,139,61],'x11:mediumorchid2' => [209,95,238],
+'x11:brown' => [165,42,42],'x11:grey67' => [171,171,171],
+'x11:grey41' => [105,105,105],'x11:dimgrey' => [105,105,105],
+'x11:grey60' => [153,153,153],'x11:indianred3' => [205,85,85],
+'x11:chocolate' => [210,105,30],'x11:darkslategrey1' => [151,255,255],
+'x11:grey2' => [5,5,5],'x11:firebrick3' => [205,38,38],
+'x11:snow4' => [139,137,137],'x11:mediumseagreen' => [60,179,113],
+'x11:darkorchid1' => [191,62,255],'x11:pink3' => [205,145,158],
+'x11:violetred1' => [255,62,150],'x11:grey83' => [212,212,212],
+'x11:olivedrab1' => [192,255,62],'x11:darkkhaki' => [189,183,107],
+'x11:deepskyblue4' => [0,104,139],'x11:darkorchid2' => [178,58,238],
+'x11:skyblue' => [135,206,235],'x11:mediumorchid3' => [180,82,205],
+'x11:rosybrown4' => [139,105,105],'x11:grey16' => [41,41,41],
+'x11:yellow4' => [139,139,0],'x11:maroon' => [176,48,96],
+'x11:turquoise2' => [0,229,238],'x11:mistyrose2' => [238,213,210],
+'x11:blue3' => [0,0,205],'x11:mediumblue' => [0,0,205],
+'x11:grey4' => [10,10,10],'x11:pink2' => [238,169,184],
+'x11:chocolate2' => [238,118,33],'x11:lightyellow4' => [139,139,122],
+'x11:grey99' => [252,252,252],'x11:red2' => [238,0,0],
+'x11:tan4' => [139,90,43],'x11:yellow2' => [238,238,0],
+'x11:grey12' => [31,31,31],'x11:deeppink4' => [139,10,80],
+'x11:lightsalmon4' => [139,87,66],'x11:lightcyan4' => [122,139,139],
+'x11:snow1' => [255,250,250],'x11:snow' => [255,250,250],
+'x11:brown4' => [139,35,35],'x11:darkseagreen2' => [180,238,180],
+'x11:lightsteelblue2' => [188,210,238],'x11:rosybrown' => [188,143,143],
+'x11:maroon1' => [255,52,179],'x11:slategrey' => [112,128,144],
+'x11:orange' => [255,165,0],'x11:orange1' => [255,165,0],
+'x11:orangered3' => [205,55,0],'x11:plum3' => [205,150,205],
+'x11:turquoise3' => [0,197,205],'x11:pink4' => [139,99,108],
+'x11:violet' => [238,130,238],'x11:grey96' => [245,245,245],
+'x11:whitesmoke' => [245,245,245],'x11:lightgoldenrod1' => [255,236,139],
+'x11:darkorange1' => [255,127,0],'x11:seashell2' => [238,229,222],
+'x11:midnightblue' => [25,25,112],'x11:grey27' => [69,69,69],
+'x11:mediumpurple2' => [159,121,238],'x11:bisque4' => [139,125,107],
+'x11:black' => [0,0,0],'x11:grey0' => [0,0,0],
+'x11:lavenderblush4' => [139,131,134],'x11:bisque1' => [255,228,196],
+'x11:bisque' => [255,228,196],'x11:mediumaquamarine' => [102,205,170],
+'x11:aquamarine3' => [102,205,170],'x11:goldenrod1' => [255,193,37],
+'x11:green4' => [0,139,0],'x11:bisque3' => [205,183,158],
+'x11:salmon' => [250,128,114],'x11:grey1' => [3,3,3],
+'x11:purple3' => [125,38,205],'x11:khaki4' => [139,134,78],
+'x11:grey' => [190,190,190],'x11:cadetblue4' => [83,134,139],
+'x11:cadetblue1' => [152,245,255],'x11:hotpink3' => [205,96,144],
+'x11:antiquewhite2' => [238,223,204],'x11:darkorange4' => [139,69,0],
+'x11:cornsilk2' => [238,232,205],'x11:grey93' => [237,237,237],
+'x11:thistle3' => [205,181,205],'x11:plum2' => [238,174,238],
+'x11:burlywood2' => [238,197,145],'x11:skyblue4' => [74,112,139],
+'x11:peachpuff2' => [238,203,173],'x11:grey62' => [158,158,158],
+'x11:paleturquoise3' => [150,205,205],'x11:lightblue1' => [191,239,255],
+'x11:mediumpurple' => [147,112,219],'x11:peachpuff3' => [205,175,149],
+'x11:grey49' => [125,125,125],'x11:grey3' => [8,8,8],
+'x11:steelblue1' => [99,184,255],'x11:grey73' => [186,186,186],
+'x11:grey44' => [112,112,112],'x11:palevioletred4' => [139,71,93],
+'x11:khaki2' => [238,230,133],'x11:gold3' => [205,173,0],
+'x11:grey47' => [120,120,120],'x11:aliceblue' => [240,248,255],
+'x11:grey58' => [148,148,148],'x11:darkslategrey4' => [82,139,139],
+'x11:mediumorchid4' => [122,55,139],'x11:thistle1' => [255,225,255],
+'x11:mistyrose4' => [139,125,123],'x11:orchid1' => [255,131,250],
+'x11:hotpink2' => [238,106,167],'x11:azure' => [240,255,255],
+'x11:azure1' => [240,255,255],'x11:darkred' => [139,0,0],
+'x11:red4' => [139,0,0],'x11:chartreuse2' => [118,238,0],
+'x11:slateblue1' => [131,111,255],'x11:grey15' => [38,38,38],
+'x11:grey71' => [181,181,181],'x11:darkslategrey2' => [141,238,238],
+'x11:snow3' => [205,201,201],'x11:bisque2' => [238,213,183],
+'x11:darkslateblue' => [72,61,139],'x11:coral4' => [139,62,47],
+'x11:grey69' => [176,176,176],'x11:burlywood4' => [139,115,85],
+'x11:coral3' => [205,91,69],'x11:purple' => [160,32,240],
+'x11:grey36' => [92,92,92],'x11:grey94' => [240,240,240],
+'x11:palevioletred2' => [238,121,159],'x11:grey46' => [117,117,117],
+'x11:palevioletred' => [219,112,147],'x11:mediumslateblue' => [123,104,238],
+'x11:seagreen1' => [84,255,159],'x11:gainsboro' => [220,220,220],
+'x11:yellow1' => [255,255,0],'x11:yellow' => [255,255,0],
+'x11:limegreen' => [50,205,50],'x11:darkgrey' => [169,169,169],
+'x11:darkmagenta' => [139,0,139],'x11:magenta4' => [139,0,139],
+'x11:grey59' => [150,150,150],'x11:firebrick2' => [238,44,44],
+'x11:coral' => [255,127,80],'x11:honeydew' => [240,255,240],
+'x11:honeydew1' => [240,255,240],'x11:grey86' => [219,219,219],
+'x11:grey13' => [33,33,33],'x11:purple1' => [155,48,255],
+'x11:grey82' => [209,209,209],'x11:grey65' => [166,166,166],
+'x11:grey97' => [247,247,247],'x11:azure4' => [131,139,139],
+'x11:darkslategrey3' => [121,205,205],'x11:lightcyan3' => [180,205,205],
+'x11:aquamarine2' => [118,238,198],'x11:grey92' => [235,235,235],
+'x11:slateblue' => [106,90,205],'x11:darkcyan' => [0,139,139],
+'x11:cyan4' => [0,139,139],'x11:chartreuse3' => [102,205,0],
+'x11:moccasin' => [255,228,181],'x11:mediumvioletred' => [199,21,133],
+'x11:tomato3' => [205,79,57],'x11:grey31' => [79,79,79],
+'x11:sienna2' => [238,121,66],'x11:grey98' => [250,250,250],
+'x11:gold4' => [139,117,0],'x11:slateblue3' => [105,89,205],
+'x11:grey14' => [36,36,36],'x11:honeydew4' => [131,139,131],
+'x11:grey61' => [156,156,156],'x11:violetred3' => [205,50,120],
+'x11:grey39' => [99,99,99],'x11:aquamarine4' => [69,139,116],
+'x11:darkgoldenrod4' => [139,101,8],'x11:mediumpurple1' => [171,130,255],
+'x11:lightsalmon1' => [255,160,122],'x11:lightsalmon' => [255,160,122],
+'x11:darkolivegreen3' => [162,205,90],'x11:grey10' => [26,26,26],
+'x11:khaki3' => [205,198,115],'x11:navajowhite3' => [205,179,139],
+'x11:lightpink1' => [255,174,185],'x11:grey81' => [207,207,207],
+'x11:grey45' => [115,115,115],'x11:wheat3' => [205,186,150],
+'x11:steelblue4' => [54,100,139],'x11:grey48' => [122,122,122],
+'x11:olivedrab3' => [154,205,50],'x11:yellowgreen' => [154,205,50],
+'x11:mediumturquoise' => [72,209,204],'x11:palegoldenrod' => [238,232,170],
+'x11:ivory2' => [238,238,224],'x11:darkolivegreen1' => [202,255,112],
+'x11:red1' => [255,0,0],'x11:red' => [255,0,0],
+'x11:lemonchiffon4' => [139,137,112],'x11:lightseagreen' => [32,178,170],
+'x11:seagreen4' => [46,139,87],'x11:seagreen' => [46,139,87],
+'x11:ivory' => [255,255,240],'x11:ivory1' => [255,255,240],
+'x11:linen' => [250,240,230],'x11:grey34' => [87,87,87],
+'x11:thistle2' => [238,2...
[truncated message content] |
|
From: <wa...@us...> - 2014-08-28 01:50:55
|
Revision: 1874
http://sourceforge.net/p/r-gregmisc/code/1874
Author: warnes
Date: 2014-08-28 01:50:46 +0000 (Thu, 28 Aug 2014)
Log Message:
-----------
Modify code to use latest version of Spreadsheet::ParseExcel and to replace Spreadsheet::XLSX woth Spreadsheet::ParseXLSX
Modified Paths:
--------------
trunk/gdata/inst/perl/module_tools.pl
trunk/gdata/inst/perl/sheetCount.pl
trunk/gdata/inst/perl/xls2csv.pl
Modified: trunk/gdata/inst/perl/module_tools.pl
===================================================================
--- trunk/gdata/inst/perl/module_tools.pl 2014-08-28 01:28:23 UTC (rev 1873)
+++ trunk/gdata/inst/perl/module_tools.pl 2014-08-28 01:50:46 UTC (rev 1874)
@@ -37,9 +37,9 @@
};
eval
{
- require Spreadsheet::XLSX;
+ require Spreadsheet::ParseXLSX;
$HAS_Spreadsheet_XLSX=1;
- print "Loaded Spreadsheet::XLSX\n" if $VERBOSE;
+ print "Loaded Spreadsheet::ParseXLSX\n" if $VERBOSE;
};
if($VERBOSE)
@@ -48,7 +48,7 @@
if !$HAS_Spreadsheet_ParseExcel;
print "ERROR: Unable to load Compress::Raw::Zlib perl module! \n"
if ! $HAS_Compress_Raw_Zlib;
- print "ERROR: Unable to load Spreadsheet::XLSX perl module! \n"
+ print "ERROR: Unable to load Spreadsheet::ParseXLSX perl module! \n"
if ! $HAS_Spreadsheet_XLSX;
}
@@ -69,7 +69,7 @@
warn("WARNING: Perl module Compress::Raw::Zlib cannot be loaded.\n");
$HAS_Spreadsheet_XLSX or
- warn("WARNING: Perl module Spreadsheet::XLSX cannot be loaded.\n");
+ warn("WARNING: Perl module Spreadsheet::ParseXLSX cannot be loaded.\n");
($HAS_Compress_Raw_Zlib && $HAS_Spreadsheet_XLSX ) or
warn("WARNING: Microsoft Excel 2007 'XLSX' formatted files will not be processed.\n");
@@ -98,7 +98,7 @@
#return 0;
# install the libraries we want
- for $mod (qw( Compress::Raw::Zlib Spreadsheet::XLSX )){
+ for $mod (qw( Compress::Raw::Zlib Spreadsheet::ParseXLSX )){
my $obj = CPAN::Shell->expand('Module',$mod);
$obj->install;
}
Modified: trunk/gdata/inst/perl/sheetCount.pl
===================================================================
--- trunk/gdata/inst/perl/sheetCount.pl 2014-08-28 01:28:23 UTC (rev 1873)
+++ trunk/gdata/inst/perl/sheetCount.pl 2014-08-28 01:50:46 UTC (rev 1874)
@@ -24,7 +24,7 @@
my($row, $col, $sheet, $cell, $usage,
$filename, $volume, $directories, $whoami,
$basename, $sheetnumber, $filename,
- $text);
+ $text, $parser);
##
@@ -78,15 +78,18 @@
my $oBook;
## First try as a Excel 2007+ 'xml' file
+## First try as a Excel 2007+ 'xml' file
eval
{
local $SIG{__WARN__} = sub {};
- $oBook = Spreadsheet::XLSX -> new ($ARGV[0]);
+ $parser = Spreadsheet::ParseXLSX -> new();
+ $oBook = $parser->parse ($ARGV[0]);
};
## Then Excel 97-2004 Format
-if($@)
+if ( !defined $oBook )
{
- $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \
+ $parser = Spreadsheet::ParseExcel -> new();
+ $oBook = $parser->parse($ARGV[0]) or \
die "Error parsing file '$ARGV[0]'.\n";
}
Modified: trunk/gdata/inst/perl/xls2csv.pl
===================================================================
--- trunk/gdata/inst/perl/xls2csv.pl 2014-08-28 01:28:23 UTC (rev 1873)
+++ trunk/gdata/inst/perl/xls2csv.pl 2014-08-28 01:50:46 UTC (rev 1874)
@@ -8,7 +8,7 @@
use strict;
#use Spreadsheet::ParseExcel;
-#use Spreadsheet::XLSX;
+#use Spreadsheet::ParseXLSX;
use POSIX;
use File::Spec::Functions;
use Getopt::Std;
@@ -28,7 +28,9 @@
$targetfile,$basename, $sheetnumber,
$filename, $volume, $directories, $whoami,
$sep, $sepName, $sepLabel, $sepExt,
- $skipBlankLines, %switches);
+ $skipBlankLines, %switches,
+ $parser, $oBook
+);
##
## Figure out whether I'm called as xls2csv.pl or xls2tab.pl
@@ -143,12 +145,14 @@
eval
{
local $SIG{__WARN__} = sub {};
- $oBook = Spreadsheet::XLSX -> new ($ARGV[0]);
+ $parser = Spreadsheet::ParseXLSX -> new();
+ $oBook = $parser->parse ($ARGV[0]);
};
## Then Excel 97-2004 Format
-if($@)
+if ( !defined $oBook )
{
- $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \
+ $parser = Spreadsheet::ParseExcel -> new();
+ $oBook = $parser->parse($ARGV[0]) or \
die "Error parsing file '$ARGV[0]'.\n";
}
print "Done.\n";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2014-08-28 03:08:28
|
Revision: 1878
http://sourceforge.net/p/r-gregmisc/code/1878
Author: warnes
Date: 2014-08-28 03:08:23 +0000 (Thu, 28 Aug 2014)
Log Message:
-----------
Remove dotfiles
Removed Paths:
-------------
trunk/gdata/inst/perl/Crypt/.exists
trunk/gdata/inst/perl/XML/.exists
Deleted: trunk/gdata/inst/perl/Crypt/.exists
===================================================================
Deleted: trunk/gdata/inst/perl/XML/.exists
===================================================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2014-08-28 04:57:05
|
Revision: 1880
http://sourceforge.net/p/r-gregmisc/code/1880
Author: warnes
Date: 2014-08-28 04:56:57 +0000 (Thu, 28 Aug 2014)
Log Message:
-----------
Complete transition from Spreadsheet::XLSX to Spreadsheet::ParseXLSX
Modified Paths:
--------------
trunk/gdata/inst/perl/install_modules.pl
trunk/gdata/inst/perl/module_tools.pl
trunk/gdata/inst/perl/sheetCount.pl
trunk/gdata/inst/perl/supportedFormats.pl
Removed Paths:
-------------
trunk/gdata/inst/perl/Spreadsheet/XLSX/
trunk/gdata/inst/perl/Spreadsheet/XLSX.pm
Deleted: trunk/gdata/inst/perl/Spreadsheet/XLSX.pm
===================================================================
--- trunk/gdata/inst/perl/Spreadsheet/XLSX.pm 2014-08-28 04:55:11 UTC (rev 1879)
+++ trunk/gdata/inst/perl/Spreadsheet/XLSX.pm 2014-08-28 04:56:57 UTC (rev 1880)
@@ -1,351 +0,0 @@
-package Spreadsheet::XLSX;
-
-use 5.006000;
-use strict;
-use warnings;
-
-our @ISA = qw();
-
-our $VERSION = '0.12';
-
-use Archive::Zip;
-use Spreadsheet::XLSX::Fmt2007;
-use Data::Dumper;
-use Spreadsheet::ParseExcel;
-
-################################################################################
-
-sub new {
-
- my ($class, $filename, $converter) = @_;
-
- my $self = {};
-
- $self -> {zip} = Archive::Zip -> new ($filename) or die ("Cant't open $filename as a zip file\n");
-
- my $member_shared_strings = $self -> {zip} -> memberNamed ('xl/sharedStrings.xml');
-
- my @shared_strings = ();
-
- if ($member_shared_strings) {
-
- my $mstr = $member_shared_strings->contents;
- $mstr =~ s/<t\/>/<t><\/t>/gsm; # this handles an empty t tag in the xml <t/>
- foreach my $si ($mstr =~ /<si.*?>(.*?)<\/si/gsm) {
- my $str;
- foreach my $t ($si =~ /<t.*?>(.*?)<\/t/gsm) {
- $t = $converter -> convert ($t) if $converter;
- $str .= $t;
- }
- push @shared_strings, $str;
- }
- }
- my $member_styles = $self -> {zip} -> memberNamed ('xl/styles.xml');
-
- my @styles = ();
-
- my %style_info = ();
-
- if ($member_styles) {
-
- foreach my $t ($member_styles -> contents =~ /xf\ numFmtId="([^"]*)"(?!.*\/cellStyleXfs)/gsm) { #"
- # $t = $converter -> convert ($t) if $converter;
- push @styles, $t;
-
- }
- my $default = $1 || '';
-
- foreach my $t1 (@styles){
- $member_styles -> contents =~ /numFmtId="$t1" formatCode="([^"]*)/;
- my $formatCode = $1 || '';
- if ($formatCode eq $default || not($formatCode)){
- if ($t1 == 9 || $t1==10){ $formatCode="0.00000%";}
- elsif ($t1 == 14){ $formatCode="yyyy-mm-dd";}
- elsif ($t1 == 20){ $formatCode="h:mm";}
- else {
- $formatCode="";
- }
- }
- $style_info{$t1} = $formatCode;
- $default = $1 || '';
- }
-
- }
-
- my $member_rels = $self -> {zip} -> memberNamed ('xl/_rels/workbook.xml.rels') or die ("xl/_rels/workbook.xml.rels not found in this zip\n");
-
- my %rels = ();
-
- foreach ($member_rels -> contents =~ /\<Relationship (.*?)\/?\>/g) {
-
- /^Id="(.*?)".*?Target="(.*?)"/ or next;
-
- $rels {$1} = $2;
-
- }
-
- my $member_workbook = $self -> {zip} -> memberNamed ('xl/workbook.xml') or die ("xl/workbook.xml not found in this zip\n");
- my $oBook = Spreadsheet::ParseExcel::Workbook->new;
- $oBook->{SheetCount} = 0;
- $oBook->{FmtClass} = Spreadsheet::XLSX::Fmt2007->new;
- $oBook->{Flg1904}=0;
- if ($member_workbook->contents =~ /date1904="1"/){
- $oBook->{Flg1904}=1;
- }
- my @Worksheet = ();
-
- foreach ($member_workbook -> contents =~ /\<(.*?)\/?\>/g) {
-
- /^(\w+)\s+/;
-
- my ($tag, $other) = ($1, $'); #'
-
- my @pairs = split /\" /, $other;
-
- $tag eq 'sheet' or next;
-
- my $sheet = {
- MaxRow => 0,
- MaxCol => 0,
- MinRow => 1000000,
- MinCol => 1000000,
- };
-
- foreach ($other =~ /(\S+=".*?")/gsm) {
-
- my ($k, $v) = split /=?"/; #"
-
- if ($k eq 'name') {
- $sheet -> {Name} = $v;
- $sheet -> {Name} = $converter -> convert ($sheet -> {Name}) if $converter;
- }
- elsif ($k eq 'r:id') {
-
- $sheet -> {path} = $rels {$v};
-
- };
-
- }
- my $wsheet = Spreadsheet::ParseExcel::Worksheet->new(%$sheet);
- push @Worksheet, $wsheet;
- $oBook->{Worksheet}[$oBook->{SheetCount}] = $wsheet;
- $oBook->{SheetCount}+=1;
-
- }
-
- $self -> {Worksheet} = \@Worksheet;
-
- foreach my $sheet (@Worksheet) {
-
- my $member_sheet = $self -> {zip} -> memberNamed ("xl/$sheet->{path}") or next;
-
- my ($row, $col);
-
- my $flag = 0;
- my $s = 0;
- my $s2 = 0;
- my $sty = 0;
- foreach ($member_sheet -> contents =~ /(\<.*?\/?\>|.*?(?=\<))/g) {
- if (/^\<c r=\"([A-Z])([A-Z]?)([A-Z]?)(\d+)\"/) {
-
- $col = ord ($1) - 65;
-
- if ($2) {
- $col++;
- $col *= 26;
- $col += (ord ($2) - 65);
- }
-
- if ($3) {
- $col++;
- $col *= 26;
- $col += (ord ($3) - 65);
- }
-
- $row = $3 - 1;
-
- $s = m/t=\"s\"/ ? 1 : 0;
- $s2 = m/t=\"str\"/ ? 1 : 0;
- $sty = m/s="([0-9]+)"/ ? $1 : 0;
-
- }
- elsif (/^<v/) {
- $flag = 1;
- }
- elsif (/^<\/v/) {
- $flag = 0;
- }
- elsif (length ($_) && $flag) {
- my $v = $s ? $shared_strings [$_] : $_;
- if ($v eq "</c>"){$v="";}
- my $type = "Text";
- my $thisstyle = "";
- if (not($s) && not($s2)){
- $type="Numeric";
- $thisstyle = $style_info{$styles[$sty]};
- if ($thisstyle =~ /(?<!Re)d|m|y/){
- $type="Date";
- }
- }
- $sheet -> {MaxRow} = $row if $sheet -> {MaxRow} < $row;
- $sheet -> {MaxCol} = $col if $sheet -> {MaxCol} < $col;
- $sheet -> {MinRow} = $row if $sheet -> {MinRow} > $row;
- $sheet -> {MinCol} = $col if $sheet -> {MinCol} > $col;
- if ($v =~ /(.*)E\-(.*)/gsm && $type eq "Numeric"){
- $v=$1/(10**$2); # this handles scientific notation for very small numbers
- }
- my $cell =Spreadsheet::ParseExcel::Cell->new(
-
- Val => $v,
- Format => $thisstyle,
- Type => $type
-
- );
-
- $cell->{_Value} = $oBook->{FmtClass}->ValFmt($cell, $oBook);
- if ($type eq "Date" && $v<1){ #then this is Excel time field
- $cell->{Type}="Text";
- $cell->{Val}=$cell->{_Value};
- }
- $sheet -> {Cells} [$row] [$col] = $cell;
- }
-
- }
-
- $sheet -> {MinRow} = 0 if $sheet -> {MinRow} > $sheet -> {MaxRow};
- $sheet -> {MinCol} = 0 if $sheet -> {MinCol} > $sheet -> {MaxCol};
-
- }
-foreach my $stys (keys %style_info){
-}
- bless ($self, $class);
-
- return $oBook;
-
-}
-
-1;
-__END__
-
-=head1 NAME
-
-Spreadsheet::XLSX - Perl extension for reading MS Excel 2007 files;
-
-=head1 SYNOPSIS
-
- use Text::Iconv;
- my $converter = Text::Iconv -> new ("utf-8", "windows-1251");
-
- # Text::Iconv is not really required.
- # This can be any object with the convert method. Or nothing.
-
- use Spreadsheet::XLSX;
-
- my $excel = Spreadsheet::XLSX -> new ('test.xlsx', $converter);
-
- foreach my $sheet (@{$excel -> {Worksheet}}) {
-
- printf("Sheet: %s\n", $sheet->{Name});
-
- $sheet -> {MaxRow} ||= $sheet -> {MinRow};
-
- foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) {
-
- $sheet -> {MaxCol} ||= $sheet -> {MinCol};
-
- foreach my $col ($sheet -> {MinCol} .. $sheet -> {MaxCol}) {
-
- my $cell = $sheet -> {Cells} [$row] [$col];
-
- if ($cell) {
- printf("( %s , %s ) => %s\n", $row, $col, $cell -> {Val});
- }
-
- }
-
- }
-
- }
-
-=head1 DESCRIPTION
-
-This module is a (quick and dirty) emulation of Spreadsheet::ParseExcel for
-Excel 2007 (.xlsx) file format. It supports styles and many of Excel's quirks,
-but not all. It populates the classes from Spreadsheet::ParseExcel for interoperability;
-including Workbook, Worksheet, and Cell.
-
-=head1 SEE ALSO
-
-=over 2
-
-=item Text::CSV_XS, Text::CSV_PP
-
-http://search.cpan.org/~hmbrand/
-
-A pure perl version is available on http://search.cpan.org/~makamaka/
-
-=item Spreadsheet::ParseExcel
-
-http://search.cpan.org/~kwitknr/
-
-=item Spreadsheet::ReadSXC
-
-http://search.cpan.org/~terhechte/
-
-=item Spreadsheet::BasicRead
-
-http://search.cpan.org/~gng/ for xlscat likewise functionality (Excel only)
-
-=item Spreadsheet::ConvertAA
-
-http://search.cpan.org/~nkh/ for an alternative set of cell2cr () /
-cr2cell () pair
-
-=item Spreadsheet::Perl
-
-http://search.cpan.org/~nkh/ offers a Pure Perl implementation of a
-spreadsheet engine. Users that want this format to be supported in
-Spreadsheet::Read are hereby motivated to offer patches. It's not high
-on my todo-list.
-
-=item xls2csv
-
-http://search.cpan.org/~ken/ offers an alternative for my C<xlscat -c>,
-in the xls2csv tool, but this tool focusses on character encoding
-transparency, and requires some other modules.
-
-=item Spreadsheet::Read
-
-http://search.cpan.org/~hmbrand/ read the data from a spreadsheet (interface
-module)
-
-=back
-
-=head1 AUTHOR
-
-Dmitry Ovsyanko, E<lt>do...@el...<gt>, http://eludia.ru/wiki/
-
-Patches by:
-
- Steve Simms
- Joerg Meltzer
- Loreyna Yeung
- Rob Polocz
- Gregor Herrmann
- H.Merijn Brand
- endacoe
- Pat Mariani
-
-=head1 ACKNOWLEDGEMENTS
-
- Thanks to TrackVia Inc. (http://www.trackvia.com) for paying for Rob Polocz working time.
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2008 by Dmitry Ovsyanko
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.8.8 or,
-at your option, any later version of Perl 5 you may have available.
-
-=cut
Modified: trunk/gdata/inst/perl/install_modules.pl
===================================================================
--- trunk/gdata/inst/perl/install_modules.pl 2014-08-28 04:55:11 UTC (rev 1879)
+++ trunk/gdata/inst/perl/install_modules.pl 2014-08-28 04:56:57 UTC (rev 1880)
@@ -8,12 +8,12 @@
require 'module_tools.pl';
-my( $HAS_Spreadsheet_ParseExcel, $HAS_Compress_Raw_Zlib, $HAS_Spreadsheet_XLSX);
+my( $HAS_Spreadsheet_ParseExcel, $HAS_Compress_Raw_Zlib, $HAS_Spreadsheet_ParseXLSX);
# check if we need to do anything
($HAS_Spreadsheet_ParseExcel,
$HAS_Compress_Raw_Zlib,
- $HAS_Spreadsheet_XLSX) = check_modules(0);
+ $HAS_Spreadsheet_ParseXLSX) = check_modules(0);
install_modules() unless $HAS_Compress_Raw_Zlib;
Modified: trunk/gdata/inst/perl/module_tools.pl
===================================================================
--- trunk/gdata/inst/perl/module_tools.pl 2014-08-28 04:55:11 UTC (rev 1879)
+++ trunk/gdata/inst/perl/module_tools.pl 2014-08-28 04:56:57 UTC (rev 1880)
@@ -17,7 +17,7 @@
$VERBOSE,
$HAS_Spreadsheet_ParseExcel,
$HAS_Compress_Raw_Zlib,
- $HAS_Spreadsheet_XLSX
+ $HAS_Spreadsheet_ParseXLSX
);
$VERBOSE=$_[0];
@@ -25,9 +25,9 @@
eval
{
require Spreadsheet::ParseExcel;
+ use Spreadsheet::ParseExcel::Utility qw(ExcelFmt);
$HAS_Spreadsheet_ParseExcel=1;
print "Loaded Spreadsheet::ParseExcel\n" if $VERBOSE;
-
};
eval
{
@@ -38,7 +38,7 @@
eval
{
require Spreadsheet::ParseXLSX;
- $HAS_Spreadsheet_XLSX=1;
+ $HAS_Spreadsheet_ParseXLSX=1;
print "Loaded Spreadsheet::ParseXLSX\n" if $VERBOSE;
};
@@ -49,10 +49,10 @@
print "ERROR: Unable to load Compress::Raw::Zlib perl module! \n"
if ! $HAS_Compress_Raw_Zlib;
print "ERROR: Unable to load Spreadsheet::ParseXLSX perl module! \n"
- if ! $HAS_Spreadsheet_XLSX;
+ if ! $HAS_Spreadsheet_ParseXLSX;
}
- return $HAS_Spreadsheet_ParseExcel, $HAS_Compress_Raw_Zlib, $HAS_Spreadsheet_XLSX;
+ return $HAS_Spreadsheet_ParseExcel, $HAS_Compress_Raw_Zlib, $HAS_Spreadsheet_ParseXLSX;
}
sub check_modules_and_notify()
@@ -60,7 +60,7 @@
my(
$HAS_Spreadsheet_ParseExcel,
$HAS_Compress_Raw_Zlib,
- $HAS_Spreadsheet_XLSX) = check_modules(0);
+ $HAS_Spreadsheet_ParseXLSX) = check_modules(0);
$HAS_Spreadsheet_ParseExcel or
die("ERROR: Perl module Spreadsheet::ParseExcel cannot be loaded. Exiting.\n");
@@ -68,12 +68,12 @@
$HAS_Compress_Raw_Zlib or
warn("WARNING: Perl module Compress::Raw::Zlib cannot be loaded.\n");
- $HAS_Spreadsheet_XLSX or
+ $HAS_Spreadsheet_ParseXLSX or
warn("WARNING: Perl module Spreadsheet::ParseXLSX cannot be loaded.\n");
- ($HAS_Compress_Raw_Zlib && $HAS_Spreadsheet_XLSX ) or
+ ($HAS_Compress_Raw_Zlib && $HAS_Spreadsheet_ParseXLSX ) or
warn("WARNING: Microsoft Excel 2007 'XLSX' formatted files will not be processed.\n");
- return $HAS_Spreadsheet_ParseExcel, $HAS_Compress_Raw_Zlib, $HAS_Spreadsheet_XLSX;
+ return $HAS_Spreadsheet_ParseExcel, $HAS_Compress_Raw_Zlib, $HAS_Spreadsheet_ParseXLSX;
}
sub install_modules()
Modified: trunk/gdata/inst/perl/sheetCount.pl
===================================================================
--- trunk/gdata/inst/perl/sheetCount.pl 2014-08-28 04:55:11 UTC (rev 1879)
+++ trunk/gdata/inst/perl/sheetCount.pl 2014-08-28 04:56:57 UTC (rev 1880)
@@ -15,7 +15,7 @@
my(
$HAS_Spreadsheet_ParseExcel,
$HAS_Compress_Raw_Zlib,
- $HAS_Spreadsheet_XLSX
+ $HAS_Spreadsheet_ParseXLSX
) = check_modules_and_notify();
use File::Spec::Functions;
Modified: trunk/gdata/inst/perl/supportedFormats.pl
===================================================================
--- trunk/gdata/inst/perl/supportedFormats.pl 2014-08-28 04:55:11 UTC (rev 1879)
+++ trunk/gdata/inst/perl/supportedFormats.pl 2014-08-28 04:56:57 UTC (rev 1880)
@@ -10,12 +10,12 @@
my( $HAS_Spreadsheet_ParseExcel,
$HAS_Compress_Raw_Zlib,
- $HAS_Spreadsheet_XLSX) = check_modules(0);
+ $HAS_Spreadsheet_ParseXLSX) = check_modules(0);
$XLS_Support = $HAS_Spreadsheet_ParseExcel;
$XLSX_Support = $HAS_Spreadsheet_ParseExcel &&
$HAS_Compress_Raw_Zlib &&
- $HAS_Spreadsheet_XLSX;
+ $HAS_Spreadsheet_ParseXLSX;
printf "Supported formats: ";
printf "XLS " if ( $XLS_Support );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|