1 | ###########################################################################
|
---|
2 | #
|
---|
3 | # RTFPlug.pm -- plugin for importing Rich Text Format files.
|
---|
4 | #
|
---|
5 | # A component of the Greenstone digital library software
|
---|
6 | # from the New Zealand Digital Library Project at the
|
---|
7 | # University of Waikato, New Zealand.
|
---|
8 | #
|
---|
9 | # Copyright (C) 2001 New Zealand Digital Library Project
|
---|
10 | #
|
---|
11 | # This program is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # This program is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with this program; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
24 | #
|
---|
25 | ###########################################################################
|
---|
26 |
|
---|
27 | # 12/05/02 Added usage datastructure - John Thompson
|
---|
28 |
|
---|
29 | package RTFPlug;
|
---|
30 |
|
---|
31 | use ConvertToPlug;
|
---|
32 | use strict;
|
---|
33 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
34 |
|
---|
35 | sub BEGIN {
|
---|
36 | @RTFPlug::ISA = ('ConvertToPlug');
|
---|
37 | }
|
---|
38 |
|
---|
39 | my $arguments =
|
---|
40 | [ { 'name' => "process_exp",
|
---|
41 | 'desc' => "{BasPlug.process_exp}",
|
---|
42 | 'type' => "regexp",
|
---|
43 | 'deft' => &get_default_process_exp(),
|
---|
44 | 'reqd' => "no" } ];
|
---|
45 |
|
---|
46 | my $options = { 'name' => "RTFPlug",
|
---|
47 | 'desc' => "{RTFPlug.desc}",
|
---|
48 | 'abstract' => "no",
|
---|
49 | 'inherits' => "yes",
|
---|
50 | 'args' => $arguments };
|
---|
51 |
|
---|
52 | sub 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->{'TEXTPlug'}) {
|
---|
64 | $secondary_plugin_options->{'TEXTPlug'} = [];
|
---|
65 | }
|
---|
66 | if (!defined $secondary_plugin_options->{'HTMLPlug'}) {
|
---|
67 | $secondary_plugin_options->{'HTMLPlug'} = [];
|
---|
68 | }
|
---|
69 | my $text_options = $secondary_plugin_options->{'TEXTPlug'};
|
---|
70 | my $html_options = $secondary_plugin_options->{'HTMLPlug'};
|
---|
71 |
|
---|
72 | #$self->{'input_encoding'} = "utf8";
|
---|
73 | #$self->{'extract_language'} = 1;
|
---|
74 | push(@$text_options, "-input_encoding", "utf8");
|
---|
75 | push(@$text_options,"-extract_language");
|
---|
76 |
|
---|
77 |
|
---|
78 | $self = bless $self, $class;
|
---|
79 |
|
---|
80 | $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
|
---|
81 |
|
---|
82 | return $self;
|
---|
83 | }
|
---|
84 |
|
---|
85 | sub get_default_process_exp {
|
---|
86 | my $self = shift (@_);
|
---|
87 | return q^(?i)\.rtf$^;
|
---|
88 | }
|
---|
89 |
|
---|
90 | sub process {
|
---|
91 | my $self = shift (@_);
|
---|
92 | my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
|
---|
93 |
|
---|
94 | return $self->process_type("rtf",$base_dir,$file,$doc_obj);
|
---|
95 | }
|
---|
96 |
|
---|
97 | 1;
|
---|