r5231 - in
/packages/libspreadsheet-parseexcel-perl/branches/upstream/current:
Build.PL Changes MANIFEST META.yml Makefile.PL README
lib/Spreadsheet/ParseExcel.pm lib/Spreadsheet/ParseExcel/SaveParser.pm
t/basic.t t/memory_leak.t t/parse.t
ntyni-guest at users.alioth.debian.org
ntyni-guest at users.alioth.debian.org
Fri Apr 20 10:45:14 UTC 2007
Author: ntyni-guest
Date: Fri Apr 20 10:45:08 2007
New Revision: 5231
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5231
Log:
[svn-upgrade] Integrating new upstream version, libspreadsheet-parseexcel-perl (0.30)
Added:
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/memory_leak.t
Modified:
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Build.PL
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Changes
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/MANIFEST
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/META.yml
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Makefile.PL
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/README
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel.pm
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel/SaveParser.pm
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/basic.t
packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/parse.t
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Build.PL?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Build.PL (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Build.PL Fri Apr 20 10:45:08 2007
@@ -1,19 +1,28 @@
use strict;
use warnings;
use Module::Build;
+use Config;
+
+my %deps = (
+ 'OLE::Storage_Lite' => 0.08,
+ 'IO::File' => 0,
+ 'Scalar::Util' => 0,
+ 'IO::Scalar' => 0,
+);
+
+if (exists $Config{useperlio} && $Config{useperlio} eq "define") {
+ delete $deps{'IO::Scalar'};
+}
+
my $builder = Module::Build->new(
module_name => 'Spreadsheet::ParseExcel',
license => 'perl',
dist_author => 'Kawai Takanori',
- create_makefile_pl => 'traditional',
+ #create_makefile_pl => 'traditional',
create_readme => 0,
recursive_test_files => 1,
- requires => {
- 'OLE::Storage_Lite' => 0.08,
- 'IO::Scalar' => 0,
- 'IO::File' => 0,
- },
+ requires => \%deps,
build_requires => {
'Test::More' => '0.47',
},
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Changes?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Changes (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Changes Fri Apr 20 10:45:08 2007
@@ -1,4 +1,16 @@
Revision history for Perl extension Spreadsheet::ParseExcel.
+
+0.30 2007.03.31
+ - add some more tests
+ - add test to see memory leak using Proc::ProcessTable
+ - Start using Scalar::Util qw(weaken) to (hopefully) avoid memory leak
+ - It seems we did not check correctly if PERLIO is available in Makefile.PL
+ now it is the same test we do in the code itself.
+ - Flag1904 renamed to Flg1904 in documentation (Chad) RT #24293
+
+0.29 2007.03.30
+ - clean up basic.t to skip tests that need additional and missing module
+ - No more need for IO::Scalar if PERLIO is available (H.Merijn Brand)
0.28 Wed Jan 7, 2007
- Documentation update
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/MANIFEST?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/MANIFEST Fri Apr 20 10:45:08 2007
@@ -10,6 +10,7 @@
t/basic.t
t/sample.t
t/parse.t
+t/memory_leak.t
t/pod.t
t/examples/sample_j.t
t/examples/sample.t
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/META.yml?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/META.yml (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/META.yml Fri Apr 20 10:45:08 2007
@@ -1,6 +1,6 @@
---
name: Spreadsheet-ParseExcel
-version: 0.28
+version: 0.30
author:
- Kawai Takanori
abstract: Get information from Excel file
@@ -9,14 +9,14 @@
license: http://dev.perl.org/licenses/
requires:
IO::File: 0
- IO::Scalar: 0
OLE::Storage_Lite: 0.08
+ Scalar::Util: 0
build_requires:
Test::More: 0.47
provides:
Spreadsheet::ParseExcel:
file: lib/Spreadsheet/ParseExcel.pm
- version: 0.28
+ version: 0.30
Spreadsheet::ParseExcel::Cell:
file: lib/Spreadsheet/ParseExcel.pm
Spreadsheet::ParseExcel::Dump:
@@ -40,13 +40,13 @@
file: lib/Spreadsheet/ParseExcel.pm
Spreadsheet::ParseExcel::SaveParser:
file: lib/Spreadsheet/ParseExcel/SaveParser.pm
- version: 0.01
+ version: 0.06
Spreadsheet::ParseExcel::SaveParser::Workbook:
file: lib/Spreadsheet/ParseExcel/SaveParser.pm
version: 0.06
Spreadsheet::ParseExcel::SaveParser::Worksheet:
file: lib/Spreadsheet/ParseExcel/SaveParser.pm
- version: 0.01
+ version: 0.06
Spreadsheet::ParseExcel::Utility:
file: lib/Spreadsheet/ParseExcel/Utility.pm
version: 0.06
@@ -54,7 +54,7 @@
file: lib/Spreadsheet/ParseExcel.pm
Spreadsheet::ParseExcel::Worksheet:
file: lib/Spreadsheet/ParseExcel.pm
-generated_by: Module::Build version 0.2805
+generated_by: Module::Build version 0.2806
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Makefile.PL?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Makefile.PL (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/Makefile.PL Fri Apr 20 10:45:08 2007
@@ -1,17 +1,27 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use strict;
+use warnings;
use ExtUtils::MakeMaker;
-WriteMakefile
-(
- 'PL_FILES' => {},
- 'INSTALLDIRS' => 'site',
- 'NAME' => 'Spreadsheet::ParseExcel',
- 'EXE_FILES' => [],
+use Config;
+
+my %deps = (
+ 'OLE::Storage_Lite' => 0.08,
+ 'IO::File' => 0,
+ 'Scalar::Util' => 0,
+ 'IO::Scalar' => 0,
+ 'Test::More' => '0.47',
+);
+if (exists $Config{useperlio} && $Config{useperlio} eq "define") {
+ delete $deps{'IO::Scalar'};
+}
+
+WriteMakefile(
+ 'PL_FILES' => {},
+ 'INSTALLDIRS' => 'site',
+ 'NAME' => 'Spreadsheet::ParseExcel',
+ 'EXE_FILES' => [],
'VERSION_FROM' => 'lib/Spreadsheet/ParseExcel.pm',
- 'PREREQ_PM' => {
- 'Test::More' => '0.47',
- 'IO::Scalar' => 0,
- 'IO::File' => 0,
- 'OLE::Storage_Lite' => '0.08'
- }
- )
-;
+ 'PREREQ_PM' => \%deps,
+
+ test => {TESTS => 't/*.t t/examples/*t'}
+
+);
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/README?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/README (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/README Fri Apr 20 10:45:08 2007
@@ -16,6 +16,8 @@
OLE::Storage_Lite
Jcode.pm (if you are using FmtJapan, or FmtJapan2)
Unicode::Map (if you are using FmtJapan2 or FmtUnicode)
+ IO::Scalar if PERLIO is not available
+ Spreadsheet::WriteExcel (to use Spreadsheet::ParseExcel::SaveParser)
INSTALLATION
The module can be installed using the standard Perl procedure:
@@ -55,18 +57,19 @@
# Don't remove this line
-VERSION
- This document refers to version 0.2602 of Spreadsheet::ParseExcel,
- released Jul 15, 2002.
+AUTHOR
+ Current maintainer: Gabor Szabo (szabgab at cpan.org)
-AUTHOR
- Kawai Takanori (kwitknr at cpan.org)
+ Original author: Kawai Takanori (kwitknr at cpan.org)
+
SUPPORT
- Of course, I'll welcome e-mails.
- And now, I have a Wiki-clone. If you have a question or suggestion,
- please let me know with Wiki.
+ Please use RT for bug reports and CPAN::Forum for general questions
+ and discussion.
- KbWiki
- http://www.hippo2000.info/cgi-bin/KbWikiE/KbWiki.pl (English)
- http://www.hippo2000.info/cgi-bin/KbWiki/KbWiki.pl (Japanese)
+ In case you want to show an example Excel file with a problem, either
+ attach it to your RT report or contact the maintainer by e-mail.
+
+ Test cases are always welcome.
+
+
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel.pm?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel.pm (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel.pm Fri Apr 20 10:45:08 2007
@@ -14,26 +14,26 @@
use warnings;
sub new {
- my ($sClass) = @_;
- my $oThis = {};
- bless $oThis, $sClass;
+ my ($class) = @_;
+ my $self = {};
+ bless $self, $class;
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel::Workbook->ParseAbort
#------------------------------------------------------------------------------
sub ParseAbort {
- my($oThis, $sVal) =@_;
- $oThis->{_ParseAbort} = $sVal;
+ my($self, $val) =@_;
+ $self->{_ParseAbort} = $val;
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel::Workbook->Parse
#------------------------------------------------------------------------------
sub Parse {
- my($sClass, $sFile, $oFmt) =@_;
- my $_oEx = Spreadsheet::ParseExcel->new;
- my $oBook = $_oEx->Parse($sFile, $oFmt);
- $oBook->{_Excel} = $_oEx;
- $oBook;
+ my($class, $source, $oFmt) =@_;
+ my $excel = Spreadsheet::ParseExcel->new;
+ my $workbook = $excel->Parse($source, $oFmt);
+ $workbook->{_Excel} = $excel;
+ return $workbook;
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel::Workbook Worksheet
@@ -49,6 +49,11 @@
}
return undef;
}
+
+#DESTROY {
+# my ($self) = @_;
+# warn "DESTROY $self called\n"
+#}
#==============================================================================
# Spreadsheet::ParseExcel::Worksheet
#==============================================================================
@@ -59,14 +64,16 @@
'0+' => \&sheetNo,
'fallback' => 1,
;
+use Scalar::Util qw(weaken);
sub new {
- my ($sClass, %rhIni) = @_;
- my $oThis = \%rhIni;
-
- $oThis->{Cells}=undef;
- $oThis->{DefColWidth}=8.38;
- bless $oThis, $sClass;
+ my ($class, %rhIni) = @_;
+ my $self = \%rhIni;
+ weaken $self->{_Book};
+
+ $self->{Cells}=undef;
+ $self->{DefColWidth}=8.38;
+ bless $self, $class;
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel::Worksheet->sheetNo
@@ -115,6 +122,10 @@
return($iMin, $iMax);
}
+#DESTROY {
+# my ($self) = @_;
+# warn "DESTROY $self called\n"
+#}
#==============================================================================
# Spreadsheet::ParseExcel::Font
#==============================================================================
@@ -123,11 +134,16 @@
use warnings;
sub new {
- my($sClass, %rhIni) = @_;
- my $oThis = \%rhIni;
-
- bless $oThis, $sClass;
-}
+ my($class, %rhIni) = @_;
+ my $self = \%rhIni;
+
+ bless $self, $class;
+}
+#DESTROY {
+# my ($self) = @_;
+# warn "DESTROY $self called\n"
+#}
+
#==============================================================================
# Spreadsheet::ParseExcel::Format
#==============================================================================
@@ -136,11 +152,16 @@
use warnings;
sub new {
- my($sClass, %rhIni) = @_;
- my $oThis = \%rhIni;
-
- bless $oThis, $sClass;
-}
+ my($class, %rhIni) = @_;
+ my $self = \%rhIni;
+
+ bless $self, $class;
+}
+
+#DESTROY {
+# my ($self) = @_;
+# warn "DESTROY $self called\n"
+#}
#==============================================================================
# Spreadsheet::ParseExcel::Cell
@@ -152,15 +173,20 @@
sub new {
my($sPkg, %rhKey)=@_;
my($sWk, $iLen);
- my $oThis = \%rhKey;
-
- bless $oThis, $sPkg;
+ my $self = \%rhKey;
+
+ bless $self, $sPkg;
}
sub Value {
- my($oThis)=@_;
- return $oThis->{_Value};
-}
+ my($self)=@_;
+ return $self->{_Value};
+}
+#DESTROY {
+# my ($self) = @_;
+# warn "DESTROY $self called\n"
+#}
+
#==============================================================================
# Spreadsheet::ParseExcel
#==============================================================================
@@ -169,9 +195,9 @@
use warnings;
use OLE::Storage_Lite;
-use IO::Scalar;
use IO::File;
-our $VERSION = '0.28';
+use Config;
+our $VERSION = '0.30';
my @aColor =
(
@@ -273,140 +299,103 @@
my $_CellHandler;
my $_NotSetCell;
my $_Object;
+my $_use_perlio;
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel->new
#------------------------------------------------------------------------------
sub new {
- my ($sPkg, %hParam) =@_;
-
-#0. Check ENDIAN(Little: Interl etc. BIG: Sparc etc)
+ my ($class, %hParam) =@_;
+
+ if (not defined $_use_perlio) {
+ if (exists $Config{useperlio} && $Config{useperlio} eq "define") {
+ $_use_perlio = 1;
+ } else {
+ $_use_perlio = 0;
+ require IO::Scalar;
+ import IO::Scalar;
+ }
+ }
+
+ # Check ENDIAN(Little: Interl etc. BIG: Sparc etc)
$BIGENDIAN = (defined $hParam{Endian})? $hParam{Endian} :
(unpack("H08", pack("L", 2)) eq '02000000')? 0: 1;
- my $oThis = {};
- bless $oThis, $sPkg;
-
-#1. Set Parameter
-#1.1 Get Content
- $oThis->{GetContent} = \&_subGetContent;
-
-#1.2 Set Event Handler
- if($hParam{EventHandlers}) {
- $oThis->SetEventHandlers($hParam{EventHandlers});
- }
- else {
- $oThis->SetEventHandlers(\%ProcTbl);
+ my $self = {};
+ bless $self, $class;
+
+ $self->{GetContent} = \&_subGetContent;
+
+ if ($hParam{EventHandlers}) {
+ $self->SetEventHandlers($hParam{EventHandlers});
+ } else {
+ $self->SetEventHandlers(\%ProcTbl);
}
if($hParam{AddHandlers}) {
foreach my $sKey (keys(%{$hParam{AddHandlers}})) {
- $oThis->SetEventHandler($sKey, $hParam{AddHandlers}->{$sKey});
- }
- }
-#Experimental
+ $self->SetEventHandler($sKey, $hParam{AddHandlers}->{$sKey});
+ }
+ }
$_CellHandler = $hParam{CellHandler} if($hParam{CellHandler});
$_NotSetCell = $hParam{NotSetCell};
$_Object = $hParam{Object};
- return $oThis;
+ return $self;
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel->SetEventHandler
#------------------------------------------------------------------------------
sub SetEventHandler {
- my($oThis, $sKey, $oFunc) = @_;
- $oThis->{FuncTbl}->{$sKey} = $oFunc;
+ my($self, $key, $sub_ref) = @_;
+ $self->{FuncTbl}->{$key} = $sub_ref;
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel->SetEventHandlers
#------------------------------------------------------------------------------
sub SetEventHandlers {
- my($oThis, $rhTbl) = @_;
- $oThis->{FuncTbl} = undef;
+ my($self, $rhTbl) = @_;
+ $self->{FuncTbl} = undef;
foreach my $sKey (keys %$rhTbl) {
- $oThis->{FuncTbl}->{$sKey} = $rhTbl->{$sKey};
+ $self->{FuncTbl}->{$sKey} = $rhTbl->{$sKey};
}
}
#------------------------------------------------------------------------------
# Spreadsheet::ParseExcel->Parse
#------------------------------------------------------------------------------
sub Parse {
- my($oThis, $sFile, $oWkFmt)=@_;
- my($sWk, $bLen);
-
-#0. New $oBook
+ my($self, $source, $oWkFmt)=@_;
+
my $oBook = Spreadsheet::ParseExcel::Workbook->new;
$oBook->{SheetCount} = 0;
-#1.Get content
- my($sBIFF, $iLen);
-
- if(ref($sFile) eq "SCALAR") {
-#1.1 Specified by Buffer
- ($sBIFF, $iLen) = $oThis->{GetContent}->($sFile);
- return undef unless($sBIFF);
- }
-#1.2 Specified by Other Things(HASH reference etc)
-# elsif(ref($sFile)) {
-# return undef;
-# }
-#1.2 Specified by GLOB reference
- elsif((ref($sFile) =~ /GLOB/) or
- (ref($sFile) eq 'Fh')) { #For CGI.pm (Light FileHandle)
- binmode($sFile);
- my $sWk;
- my $sBuff='';
- while(read($sFile, $sWk, 4096)) {
- $sBuff .= $sWk;
- }
- ($sBIFF, $iLen) = $oThis->{GetContent}->(\$sBuff);
- return undef unless($sBIFF);
- }
- elsif(ref($sFile) eq 'ARRAY') {
-#1.3 Specified by File content
- $oBook->{File} = undef;
- my $sData = join('', @$sFile);
- ($sBIFF, $iLen) = $oThis->{GetContent}->(\$sData);
- return undef unless($sBIFF);
- }
- else {
-#1.4 Specified by File name
- $oBook->{File} = $sFile;
- return undef unless (-e $sFile);
- ($sBIFF, $iLen) = $oThis->{GetContent}->($sFile);
- return undef unless($sBIFF);
- }
-
-#2. Ready for format
+ my ($sBIFF, $iLen) = $self->_get_content($source, $oBook);
+ return undef if not $sBIFF;
+
if ($oWkFmt) {
$oBook->{FmtClass} = $oWkFmt;
- }
- else {
-# require Spreadsheet::ParseExcel::FmtDefault;
+ } else {
$oBook->{FmtClass} = Spreadsheet::ParseExcel::FmtDefault->new;
}
-#3. Parse content
+ #3. Parse content
my $lPos = 0;
- $sWk = substr($sBIFF, $lPos, 4);
+ my $sWk = substr($sBIFF, $lPos, 4);
$lPos += 4;
my $iEfFlg = 0;
while($lPos<=$iLen) {
my($bOp, $bLen) = unpack("v2", $sWk);
- if($bLen) {
+ if($bLen) {
$sWk = substr($sBIFF, $lPos, $bLen);
$lPos += $bLen;
}
-#printf STDERR "%4X:%s\n", $bOp, 'UNDEFIND---:' . unpack("H*", $sWk) unless($NameTbl{$bOp});
+ #printf STDERR "%4X:%s\n", $bOp, 'UNDEFIND---:' . unpack("H*", $sWk) unless($NameTbl{$bOp});
#Check EF, EOF
if($bOp == 0xEF) { #EF
$iEfFlg = $bOp;
- }
- elsif($bOp == 0x0A) { #EOF
+ } elsif($bOp == 0x0A) { #EOF
undef $iEfFlg;
}
- unless($iEfFlg) {
#1. Formula String with No String
- if($oBook->{_PrevPos} && (defined $oThis->{FuncTbl}->{$bOp}) &&
- ($bOp != 0x207)) {
+ if (not $iEfFlg) {
+ if($oBook->{_PrevPos} && (defined $self->{FuncTbl}->{$bOp}) && ($bOp != 0x207)) {
my $iPos = $oBook->{_PrevPos};
$oBook->{_PrevPos} = undef;
my ($iR, $iC, $iF) = @$iPos;
@@ -421,29 +410,67 @@
Book => $oBook,
);
}
- if(defined $oThis->{FuncTbl}->{$bOp}) {
- $oThis->{FuncTbl}->{$bOp}->($oBook, $bOp, $bLen, $sWk);
+ if(defined $self->{FuncTbl}->{$bOp}) {
+ $self->{FuncTbl}->{$bOp}->($oBook, $bOp, $bLen, $sWk);
}
$PREFUNC = $bOp if ($bOp != 0x3C); #Not Continue
}
- $sWk = substr($sBIFF, $lPos, 4) if(($lPos+4) <= $iLen);
+ if (($lPos+4) <= $iLen) {
+ $sWk = substr($sBIFF, $lPos, 4);
+ }
$lPos += 4;
- #Abort Parse
- if(defined $oBook->{_ParseAbort}) {
- return $oBook;
- }
- }
-#4.return $oBook
+ return $oBook if defined $oBook->{_ParseAbort};
+ }
return $oBook;
}
+
+# $source is either filename or open filehandle or array of string or scalar
+# referernce
+# $oBook is passed to be updated
+sub _get_content {
+ my ($self, $source, $oBook) = @_;
+
+ if(ref($source) eq "SCALAR") {
+ #1.1 Specified by Buffer
+ my ($sBIFF, $iLen) = $self->{GetContent}->($source);
+ return $sBIFF ? ($sBIFF, $iLen) : (undef);
+ }
+ #1.2 Specified by Other Things(HASH reference etc)
+ # elsif(ref($source)) {
+ # return undef;
+ # }
+ #1.2 Specified by GLOB reference
+ elsif((ref($source) =~ /GLOB/) or
+ (ref($source) eq 'Fh')) { #For CGI.pm (Light FileHandle)
+ binmode($source);
+ my $sWk;
+ my $sBuff='';
+ while(read($source, $sWk, 4096)) {
+ $sBuff .= $sWk;
+ }
+ my ($sBIFF, $iLen) = $self->{GetContent}->(\$sBuff);
+ return $sBIFF ? ($sBIFF, $iLen) : (undef);
+ } elsif(ref($source) eq 'ARRAY') {
+ #1.3 Specified by File content
+ $oBook->{File} = undef;
+ my $sData = join('', @$source);
+ my ($sBIFF, $iLen) = $self->{GetContent}->(\$sData);
+ return $sBIFF ? ($sBIFF, $iLen) : (undef);
+ } else {
+ #1.4 Specified by File name
+ $oBook->{File} = $source;
+ return undef unless (-e $source);
+ my ($sBIFF, $iLen) = $self->{GetContent}->($source);
+ return $sBIFF ? ($sBIFF, $iLen) : (undef);
+ }
+}
+
+
#------------------------------------------------------------------------------
# _subGetContent (for Spreadsheet::ParseExcel)
#------------------------------------------------------------------------------
sub _subGetContent {
-
- my($sFile)=@_;
-
- # warn qq{_subGetContent called; sFile:}, ref $sFile;
+ my ($sFile) = @_;
my $oOl = OLE::Storage_Lite->new($sFile);
return (undef, undef) unless($oOl);
@@ -452,39 +479,42 @@
OLE::Storage_Lite::Asc2Ucs('Workbook')], 1, 1);
return (undef, undef) if($#aRes < 0);
#Hack from Herbert
- unless($aRes[0]->{Data}) {
- #Same as OLE::Storage_Lite
- my $oIo;
- #1. $sFile is Ref of scalar
- if(ref($sFile) eq 'SCALAR') {
+ if ($aRes[0]->{Data}) {
+ return ($aRes[0]->{Data}, length($aRes[0]->{Data}));
+ }
+
+ #Same as OLE::Storage_Lite
+ my $oIo;
+ #1. $sFile is Ref of scalar
+ if(ref($sFile) eq 'SCALAR') {
+ if ($_use_perlio) {
+ open $oIo, "<", \$sFile;
+ } else {
$oIo = IO::Scalar->new;
$oIo->open($sFile);
}
- #2. $sFile is a IO::Handle object
- elsif(UNIVERSAL::isa($sFile, 'IO::Handle')) {
- $oIo = $sFile;
- binmode($oIo);
- }
- #3. $sFile is a simple filename string
- elsif(!ref($sFile)) {
- $oIo = IO::File->new;
- $oIo->open("<$sFile") || return undef;
- binmode($oIo);
- }
- my $sWk;
- my $sBuff ='';
-
- while($oIo->read($sWk, 4096)) { #4_096 has no special meanings
- $sBuff .= $sWk;
- }
- $oIo->close();
- #Not Excel file (simple method)
- return (undef, undef) if (substr($sBuff, 0, 1) ne "\x09");
- return ($sBuff, length($sBuff));
- }
- else {
- return ($aRes[0]->{Data}, length($aRes[0]->{Data}));
- }
+ }
+ #2. $sFile is a IO::Handle object
+ elsif(UNIVERSAL::isa($sFile, 'IO::Handle')) {
+ $oIo = $sFile;
+ binmode($oIo);
+ }
+ #3. $sFile is a simple filename string
+ elsif(!ref($sFile)) {
+ $oIo = IO::File->new;
+ $oIo->open("<$sFile") || return undef;
+ binmode($oIo);
+ }
+ my $sWk;
+ my $sBuff ='';
+
+ while($oIo->read($sWk, 4096)) { #4_096 has no special meanings
+ $sBuff .= $sWk;
+ }
+ $oIo->close();
+ #Not Excel file (simple method)
+ return (undef, undef) if (substr($sBuff, 0, 1) ne "\x09");
+ return ($sBuff, length($sBuff));
}
#------------------------------------------------------------------------------
# _subBOF (for Spreadsheet::ParseExcel) Developers' Kit : P303
@@ -502,7 +532,7 @@
$oBook->{_CurSheet_} = -1;
}
#Worksheeet or Dialogsheet
- elsif($iDt != 0x0020) { #if($iDt == 0x0010) {
+ elsif($iDt != 0x0020) { #if($iDt == 0x0010)
if(defined $oBook->{_CurSheet_}) {
$oBook->{_CurSheet} = $oBook->{_CurSheet_} + 1;
$oBook->{_CurSheet_}++;
@@ -1006,8 +1036,8 @@
#------------------------------------------------------------------------------
sub _subContinue {
my($oBook, $bOp, $bLen, $sWk) = @_;
- #if(defined $oThis->{FuncTbl}->{$bOp}) {
- # $oThis->{FuncTbl}->{$PREFUNC}->($oBook, $bOp, $bLen, $sWk);
+ #if(defined $self->{FuncTbl}->{$bOp}) {
+ # $self->{FuncTbl}->{$PREFUNC}->($oBook, $bOp, $bLen, $sWk);
#}
_subStrWk($oBook, $sWk, 1) if($PREFUNC == 0xFC);
@@ -1918,6 +1948,12 @@
my($sPkg, $iIdx) = @_;
return ((defined $aColor[$iIdx])? $aColor[$iIdx] : $aColor[0]);
}
+
+#DESTROY {
+# my ($self) = @_;
+# warn "DESTROY $self called\n"
+#}
+
1;
__END__
@@ -2082,7 +2118,7 @@
Author of the file
-=item Flag1904
+=item Flg1904
If this flag is on, date of the file count from 1904.
@@ -2560,11 +2596,11 @@
=head1 AUTHOR
-Maintainer: Gabor Szabo szabgab at cpan.org
+Current maintainer: Gabor Szabo szabgab at cpan.org
http://www.szabgab.com/
-Kawai Takanori (Hippo2000) kwitknr at cpan.org
+Original author: Kawai Takanori (Hippo2000) kwitknr at cpan.org
http://member.nifty.ne.jp/hippo2000/ (Japanese)
http://member.nifty.ne.jp/hippo2000/index_e.htm (English)
@@ -2578,6 +2614,8 @@
XLSTools: http://perl.jonallen.info/projects/xlstools
=head1 TODO
+
+- Add tests, and more tests
- Spreadsheet::ParseExcel :
Password protected data, Formulas support, HyperLink support,
@@ -2586,8 +2624,22 @@
- Spreadsheet::ParseExcel::SaveParser :
Catch up Spreadsheet::WriteExce feature, Create new Excel fle
+See also:
+
+ L<http://www.cpanforum.com/dist/Spreadsheet-ParseExcel>
+
+ and
+
+ http://www.perlmonks.org/index.pl?node_id=490656
+ http://www.perlmonks.org/index.pl?node_id=379743
+ http://www.perlmonks.org/index.pl?node_id=433192
+ http://www.perlmonks.org/index.pl?node_id=422147
+
+
+
=head1 COPYRIGHT
+Copyright (c) 2006-2007 Gabor Szabo
Copyright (c) 2000-2006 Kawai Takanori
All rights reserved.
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel/SaveParser.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel/SaveParser.pm?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel/SaveParser.pm (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/lib/Spreadsheet/ParseExcel/SaveParser.pm Fri Apr 20 10:45:08 2007
@@ -331,7 +331,7 @@
use warnings;
use base 'Spreadsheet::ParseExcel::Worksheet';
-our $VERSION = '0.01';
+our $VERSION = '0.06';
sub new {
@@ -365,7 +365,7 @@
use Spreadsheet::WriteExcel;
use base 'Spreadsheet::ParseExcel';
-our $VERSION = '0.01';
+our $VERSION = '0.06';
use constant MagicCol => 1.14;
#------------------------------------------------------------------------------
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/basic.t?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/basic.t (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/basic.t Fri Apr 20 10:45:08 2007
@@ -4,12 +4,30 @@
use Test::More tests => 8;
+
use_ok('Spreadsheet::ParseExcel');
use_ok('Spreadsheet::ParseExcel::Dump');
use_ok('Spreadsheet::ParseExcel::FmtDefault');
-use_ok('Spreadsheet::ParseExcel::FmtJapan');
-use_ok('Spreadsheet::ParseExcel::FmtJapan2');
-use_ok('Spreadsheet::ParseExcel::FmtUnicode');
-use_ok('Spreadsheet::ParseExcel::SaveParser');
use_ok('Spreadsheet::ParseExcel::Utility');
+SKIP: {
+ eval "use Jcode";
+ skip "Need Jcode for additional tests", 2 if $@;
+ use_ok('Spreadsheet::ParseExcel::FmtJapan');
+ use_ok('Spreadsheet::ParseExcel::FmtJapan2');
+}
+
+SKIP: {
+ eval "use Unicode::Map";
+ skip "Need Unicode::Map for additional tests", 1 if $@;
+ use_ok('Spreadsheet::ParseExcel::FmtUnicode');
+}
+
+SKIP: {
+ eval "use Spreadsheet::WriteExcel";
+ skip "Need Spreadsheet::WriteExcel for additional tests", 1 if $@;
+ use_ok('Spreadsheet::ParseExcel::SaveParser');
+}
+
+
+
Added: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/memory_leak.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/memory_leak.t?rev=5231&op=file
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/memory_leak.t (added)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/memory_leak.t Fri Apr 20 10:45:08 2007
@@ -1,0 +1,82 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+# USe it either as a regular test file or by typing something like this:
+# perl -Ilib t/memory_leak.t --file sample/Excel/AuthorK.xls --count 100
+
+use Test::More;
+use Getopt::Long qw(GetOptions);
+my $tests;
+
+eval {
+ require Proc::ProcessTable;
+};
+if ($@) {
+ plan skip_all => "Proc::ProcessTable is needed for this test";
+}
+else {
+ plan tests => $tests;
+}
+
+my $count = 10;
+my $file = 'sample/Excel/Test95.xls';
+GetOptions(
+ "count" => \$count,
+ "file" => \$file,
+) or die;
+
+
+sub get_process_size {
+ my ($pid) = @_;
+ my $pt = Proc::ProcessTable->new;
+ foreach my $p ( @{$pt->table} ) {
+ return $p->size if $pid == $p->pid;
+ }
+ return;
+}
+
+
+use_ok('Spreadsheet::ParseExcel');
+BEGIN { $tests += 1; }
+
+diag "using version $Proc::ProcessTable::VERSION of Proc::ProcessTable";
+diag "Testing version $Spreadsheet::ParseExcel::VERSION of Spreadsheet::ParseExcel";
+
+# 1: 131072 - 135168
+# 5: 270336
+# 8: 405504
+# 10: 540672
+# 13: 675840
+# 15: 811008
+# 18: 946176
+# 21: 1077248
+# ...
+# 100: 5218304
+
+my $begin_size = get_process_size($$);
+do_something();
+my $start_size = get_process_size($$);
+my $memory_consumption = $start_size - $begin_size;
+diag "Memory consumption by one call is $memory_consumption";
+# This value was about 286720 - 290816 when using version 0.29
+
+diag "Testing memory leak, running $count times";
+diag "Start size: $start_size";
+foreach (2..$count) {
+ do_something();
+ my $size = get_process_size($$);
+ #diag ("$_: " . ($size - $start_size));
+}
+my $end_size = get_process_size($$);
+my $size_change = $end_size - $start_size;
+diag "End size: $end_size";
+diag "Size change was: $size_change";
+cmp_ok($size_change, '<', 100,
+ 'normally it should be 0 but we are not that picky');
+BEGIN { $tests += 1; }
+
+sub do_something {
+ my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($file);
+}
+
Modified: packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/parse.t?rev=5231&op=diff
==============================================================================
--- packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/parse.t (original)
+++ packages/libspreadsheet-parseexcel-perl/branches/upstream/current/t/parse.t Fri Apr 20 10:45:08 2007
@@ -32,14 +32,47 @@
BEGIN { $tests += 2; }
}
+my $workbook_1;
{
- my $excel = Spreadsheet::ParseExcel::Workbook->Parse('sample/Excel/Test95.xls');
- is(ref($excel), 'Spreadsheet::ParseExcel::Workbook',
+ my $workbook = Spreadsheet::ParseExcel::Workbook->Parse('sample/Excel/Test95.xls');
+ $workbook_1 = $workbook;
+ use Data::Dumper;
+ #diag Dumper $excel;
+ #_save_file('dump.txt', Dumper $excel);
+ is(ref($workbook), 'Spreadsheet::ParseExcel::Workbook',
'Spreadsheet::ParseExcel::Workbook created');
- isa_ok($excel->{_Excel}, 'Spreadsheet::ParseExcel',
+ my $excel = $workbook->{_Excel};
+ isa_ok($excel, 'Spreadsheet::ParseExcel',
'Parse method creates _Excel object');
+ is(ref($excel->{FuncTbl}), 'HASH');
+ is(ref($excel->{GetContent}), 'CODE');
- my @sheets = @{$excel->{Worksheet}};
+
+ # meta data
+ is($workbook->{_CurSheet_}, 1, 'current sheet is 1');
+ is($workbook->{_CurSheet}, 1);
+ is($workbook->{Flg1904}, 0);
+ isa_ok($workbook->{FmtClass}, 'Spreadsheet::ParseExcel::FmtDefault');
+
+ # TODO more tests in Format
+ is(ref($workbook->{Format}), 'ARRAY');
+ my $formats = $workbook->{Format};
+ is(scalar(@$formats), 22);
+ # all but 2 are 'Spreadsheet::ParseExcel::Format' objects
+ is(ref($workbook->{FormatStr}), 'HASH');
+ is($workbook->{SheetCount}, 2);
+ my $fonts = $workbook->{Font};
+ is(ref($fonts), 'ARRAY');
+ is(scalar(@$fonts), 6);
+
+ is($workbook->{Version}, 1280);
+ is($workbook->{BIFFVersion}, 8);
+ is($workbook->{File}, 'sample/Excel/Test95.xls');
+ is($workbook->{Author}, 'kawait');
+
+
+
+ my @sheets = @{$workbook->{Worksheet}};
is (@sheets, 2, "two sheets");
is($sheets[0]->{Name}, 'Sheet1-ASC'); # Open Office shows: 'Sheet1_ASC'
is($sheets[1]->{Name}, 'Sheet1-ASC (2)'); # OO shows 'Sheet1_ASC_2_'
@@ -55,6 +88,47 @@
is($sheets[1]->{MinRow}, 0);
is($sheets[1]->{MaxRow}, 5);
- BEGIN { $tests += 10; }
+
+ BEGIN { $tests += 26; }
}
+{
+ open my $fh, '<','sample/Excel/Test95.xls';
+ my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($fh);
+ isnt($workbook, $workbook_1);
+ delete $workbook_1->{File}; # when give a filehandlres this field is not set
+ is_deeply($workbook, $workbook_1);
+ BEGIN { $tests += 2; }
+}
+
+# pass a reference to a scalar containing the file content
+{
+ my $data;
+ if (open my $fh, '<','sample/Excel/Test95.xls') {
+ binmode($fh);
+ local $/ = undef;
+ $data = <$fh>;
+ }
+ my $workbook = Spreadsheet::ParseExcel::Workbook->Parse(\$data);
+ isnt($workbook, $workbook_1);
+ is_deeply($workbook, $workbook_1);
+ BEGIN { $tests += 2; }
+}
+{
+ open my $fh, '<','sample/Excel/Test95.xls';
+ binmode($fh);
+ my @data = <$fh>;
+ my $workbook = Spreadsheet::ParseExcel::Workbook->Parse(\@data);
+ isnt($workbook, $workbook_1);
+ $workbook_1->{File} = undef;
+ is_deeply($workbook, $workbook_1);
+ BEGIN { $tests += 2; }
+}
+
+
+sub _save_file {
+ my ($file, $data) = @_;
+ if (open my $fh, '>', $file) {
+ print {$fh} $data;
+ }
+}
More information about the Pkg-perl-cvs-commits
mailing list