source: trunk/gsdl/perllib/plugins/ExcelPlug.pm@ 10580

Last change on this file since 10580 was 10580, checked in by kjdon, 19 years ago

if created from pluginfo.pl (self->info_only == 1)then don't load up the secondary plugins

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1###########################################################################
2#
3# ExcelPlug.pm -- plugin for importing Microsoft Excel files.
4# (currently only versions 95 and 97)
5#
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 2002 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28package ExcelPlug;
29
30use ConvertToPlug;
31use strict;
32no strict 'refs'; # allow filehandles to be variables and viceversa
33
34sub BEGIN {
35 @ExcelPlug::ISA = ('ConvertToPlug');
36}
37
38my $arguments =
39 [ { 'name' => "process_exp",
40 'desc' => "{BasPlug.process_exp}",
41 'type' => "regexp",
42 'reqd' => "no",
43 'deft' => &get_default_process_exp() }
44 ];
45
46my $options = { 'name' => "ExcelPlug",
47 'desc' => "{ExcelPlug.desc}",
48 'abstract' => "no",
49 'inherits' => "yes",
50 'args' => $arguments };
51
52sub new {
53 my ($class) = shift (@_);
54 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
55 push(@$pluginlist, $class);
56
57 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
58 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
59
60 my $self = (defined $hashArgOptLists)? new ConvertToPlug($pluginlist,$inputargs,$hashArgOptLists): new ConvertToPlug($pluginlist,$inputargs);
61
62 if ($self->{'info_only'}) {
63 # don't worry about any options etc
64 return bless $self, $class;
65 }
66
67 my $secondary_plugin_options = $self->{'secondary_plugin_options'};
68 if (!defined $secondary_plugin_options->{'HTMLPlug'}) {
69 $secondary_plugin_options->{'HTMLPlug'} = [];
70 }
71 my $html_options = $secondary_plugin_options->{'HTMLPlug'};
72
73 #$self->{'input_encoding'} = "utf8";
74 #$self->{'extract_language'} = 1;
75 push(@$html_options, "-input_encoding", "utf8");
76 push(@$html_options,"-extract_language");
77 $self = bless $self, $class;
78
79 $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
80 return bless $self;
81}
82
83sub convert_post_process
84{
85 my $self = shift (@_);
86 my ($conv_filename) = @_;
87
88 my $outhandle=$self->{'outhandle'};
89
90 my ($language, $encoding) = $self->textcat_get_language_encoding ($conv_filename);
91
92 # read in file ($text will be in utf8)
93 my $text = "";
94 $self->read_file ($conv_filename, $encoding, $language, \$text);
95
96 # turn any high bytes that aren't valid utf-8 into utf-8.
97 #unicode::ensure_utf8(\$text);
98
99 # Write it out again!
100 #$self->utf8_write_file (\$text, $conv_filename);
101}
102
103sub get_default_process_exp {
104 my $self = shift (@_);
105 return q^(?i)\.xls$^;
106}
107
108sub process {
109 my $self = shift (@_);
110 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
111
112 return $self->process_type("xls",$base_dir,$file,$doc_obj);
113}
114
1151;
Note: See TracBrowser for help on using the repository browser.