[2564] | 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 |
|
---|
[3540] | 27 | # 12/05/02 Added usage datastructure - John Thompson
|
---|
| 28 |
|
---|
[2564] | 29 | package RTFPlug;
|
---|
| 30 |
|
---|
| 31 | use ConvertToPlug;
|
---|
[10254] | 32 | use strict;
|
---|
| 33 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[2564] | 34 |
|
---|
| 35 | sub BEGIN {
|
---|
[10254] | 36 | @RTFPlug::ISA = ('ConvertToPlug');
|
---|
[2564] | 37 | }
|
---|
| 38 |
|
---|
[4744] | 39 | my $arguments =
|
---|
| 40 | [ { 'name' => "process_exp",
|
---|
[4873] | 41 | 'desc' => "{BasPlug.process_exp}",
|
---|
[6408] | 42 | 'type' => "regexp",
|
---|
[4744] | 43 | 'deft' => &get_default_process_exp(),
|
---|
[10514] | 44 | 'reqd' => "no" },
|
---|
| 45 | { 'name' => "description_tags",
|
---|
| 46 | 'desc' => "{HTMLPlug.description_tags}",
|
---|
| 47 | 'type' => "flag" }
|
---|
| 48 | ];
|
---|
[3540] | 49 |
|
---|
| 50 | my $options = { 'name' => "RTFPlug",
|
---|
[5680] | 51 | 'desc' => "{RTFPlug.desc}",
|
---|
[6408] | 52 | 'abstract' => "no",
|
---|
[3540] | 53 | 'inherits' => "yes",
|
---|
| 54 | 'args' => $arguments };
|
---|
| 55 |
|
---|
| 56 | sub new {
|
---|
[10218] | 57 | my ($class) = shift (@_);
|
---|
| 58 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 59 | push(@$pluginlist, $class);
|
---|
[3540] | 60 |
|
---|
[10218] | 61 | if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
|
---|
| 62 | if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
|
---|
[10425] | 63 |
|
---|
[12169] | 64 | my $self = new ConvertToPlug($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[10218] | 65 |
|
---|
[10580] | 66 | if ($self->{'info_only'}) {
|
---|
| 67 | # don't worry about any options etc
|
---|
| 68 | return bless $self, $class;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[10425] | 71 | my $secondary_plugin_options = $self->{'secondary_plugin_options'};
|
---|
| 72 | if (!defined $secondary_plugin_options->{'TEXTPlug'}) {
|
---|
| 73 | $secondary_plugin_options->{'TEXTPlug'} = [];
|
---|
| 74 | }
|
---|
| 75 | if (!defined $secondary_plugin_options->{'HTMLPlug'}) {
|
---|
| 76 | $secondary_plugin_options->{'HTMLPlug'} = [];
|
---|
| 77 | }
|
---|
| 78 | my $text_options = $secondary_plugin_options->{'TEXTPlug'};
|
---|
| 79 | my $html_options = $secondary_plugin_options->{'HTMLPlug'};
|
---|
| 80 |
|
---|
| 81 | #$self->{'input_encoding'} = "utf8";
|
---|
| 82 | #$self->{'extract_language'} = 1;
|
---|
| 83 | push(@$text_options, "-input_encoding", "utf8");
|
---|
[12834] | 84 | push(@$text_options,"-extract_language") if $self->{'extract_language'};
|
---|
| 85 | push(@$html_options, "-description_tags") if $self->{'description_tags'};
|
---|
| 86 | push(@$html_options,"-extract_language") if $self->{'extract_language'};
|
---|
[10425] | 87 |
|
---|
[10272] | 88 | $self = bless $self, $class;
|
---|
| 89 |
|
---|
[10425] | 90 | $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
|
---|
[10272] | 91 |
|
---|
| 92 | return $self;
|
---|
[3540] | 93 | }
|
---|
| 94 |
|
---|
[2564] | 95 | sub get_default_process_exp {
|
---|
| 96 | my $self = shift (@_);
|
---|
| 97 | return q^(?i)\.rtf$^;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | sub process {
|
---|
| 101 | my $self = shift (@_);
|
---|
[10272] | 102 | my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
|
---|
[2785] | 103 |
|
---|
[10272] | 104 | return $self->process_type("rtf",$base_dir,$file,$doc_obj);
|
---|
[2564] | 105 | }
|
---|
| 106 |
|
---|
| 107 | 1;
|
---|