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

Last change on this file since 10465 was 10465, checked in by chi, 19 years ago

To add the convert_post_process() to handle some encoding problems for now.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 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 my $secondary_plugin_options = $self->{'secondary_plugin_options'};
63 if (!defined $secondary_plugin_options->{'HTMLPlug'}) {
64 $secondary_plugin_options->{'HTMLPlug'} = [];
65 }
66 my $html_options = $secondary_plugin_options->{'HTMLPlug'};
67
68 #$self->{'input_encoding'} = "utf8";
69 #$self->{'extract_language'} = 1;
70 push(@$html_options, "-input_encoding", "utf8");
71 push(@$html_options,"-extract_language");
72 $self = bless $self, $class;
73
74 $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
75 return bless $self;
76}
77
78sub convert_post_process
79{
80 my $self = shift (@_);
81 my ($conv_filename) = @_;
82
83 my $outhandle=$self->{'outhandle'};
84
85 my ($language, $encoding) = $self->textcat_get_language_encoding ($conv_filename);
86
87 # read in file ($text will be in utf8)
88 my $text = "";
89 $self->read_file ($conv_filename, $encoding, $language, \$text);
90
91 # turn any high bytes that aren't valid utf-8 into utf-8.
92 #unicode::ensure_utf8(\$text);
93
94 # Write it out again!
95 #$self->utf8_write_file (\$text, $conv_filename);
96}
97
98sub get_default_process_exp {
99 my $self = shift (@_);
100 return q^(?i)\.xls$^;
101}
102
103sub process {
104 my $self = shift (@_);
105 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
106
107 return $self->process_type("xls",$base_dir,$file,$doc_obj);
108}
109
1101;
Note: See TracBrowser for help on using the repository browser.