[2564] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
[15872] | 3 | # RTFPlugin.pm -- plugin for importing Rich Text Format files.
|
---|
[2564] | 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 |
|
---|
[15872] | 27 | package RTFPlugin;
|
---|
[3540] | 28 |
|
---|
[15872] | 29 | use ConvertBinaryFile;
|
---|
[10254] | 30 | use strict;
|
---|
| 31 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[2564] | 32 |
|
---|
| 33 | sub BEGIN {
|
---|
[15872] | 34 | @RTFPlugin::ISA = ('ConvertBinaryFile');
|
---|
[2564] | 35 | }
|
---|
| 36 |
|
---|
[4744] | 37 | my $arguments =
|
---|
| 38 | [ { 'name' => "process_exp",
|
---|
[15872] | 39 | 'desc' => "{BasePlugin.process_exp}",
|
---|
[6408] | 40 | 'type' => "regexp",
|
---|
[4744] | 41 | 'deft' => &get_default_process_exp(),
|
---|
[10514] | 42 | 'reqd' => "no" },
|
---|
| 43 | { 'name' => "description_tags",
|
---|
[15872] | 44 | 'desc' => "{HTMLPlugin.description_tags}",
|
---|
[10514] | 45 | 'type' => "flag" }
|
---|
| 46 | ];
|
---|
[3540] | 47 |
|
---|
[15872] | 48 | my $options = { 'name' => "RTFPlugin",
|
---|
| 49 | 'desc' => "{RTFPlugin.desc}",
|
---|
[6408] | 50 | 'abstract' => "no",
|
---|
[3540] | 51 | 'inherits' => "yes",
|
---|
[15114] | 52 | 'srcreplaceable' => "yes", # Source docs in rtf can be replaced with GS-generated html
|
---|
[3540] | 53 | 'args' => $arguments };
|
---|
| 54 |
|
---|
| 55 | sub new {
|
---|
[10218] | 56 | my ($class) = shift (@_);
|
---|
| 57 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 58 | push(@$pluginlist, $class);
|
---|
[3540] | 59 |
|
---|
[15872] | 60 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 61 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
[10425] | 62 |
|
---|
[15872] | 63 | my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[10218] | 64 |
|
---|
[10580] | 65 | if ($self->{'info_only'}) {
|
---|
| 66 | # don't worry about any options etc
|
---|
| 67 | return bless $self, $class;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[15872] | 70 | $self->{'filename_extension'} = "rtf";
|
---|
| 71 | $self->{'file_type'} = "RTF";
|
---|
| 72 |
|
---|
[10425] | 73 | my $secondary_plugin_options = $self->{'secondary_plugin_options'};
|
---|
[15872] | 74 | if (!defined $secondary_plugin_options->{'TextPlugin'}) {
|
---|
| 75 | $secondary_plugin_options->{'TextPlugin'} = [];
|
---|
[10425] | 76 | }
|
---|
[15872] | 77 | if (!defined $secondary_plugin_options->{'HTMLPlugin'}) {
|
---|
| 78 | $secondary_plugin_options->{'HTMLPlugin'} = [];
|
---|
[10425] | 79 | }
|
---|
[15872] | 80 | my $text_options = $secondary_plugin_options->{'TextPlugin'};
|
---|
| 81 | my $html_options = $secondary_plugin_options->{'HTMLPlugin'};
|
---|
[10425] | 82 |
|
---|
| 83 | #$self->{'input_encoding'} = "utf8";
|
---|
| 84 | #$self->{'extract_language'} = 1;
|
---|
| 85 | push(@$text_options, "-input_encoding", "utf8");
|
---|
[12834] | 86 | push(@$text_options,"-extract_language") if $self->{'extract_language'};
|
---|
| 87 | push(@$html_options, "-description_tags") if $self->{'description_tags'};
|
---|
| 88 | push(@$html_options,"-extract_language") if $self->{'extract_language'};
|
---|
[10425] | 89 |
|
---|
[10272] | 90 | $self = bless $self, $class;
|
---|
| 91 |
|
---|
[10425] | 92 | $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
|
---|
[10272] | 93 |
|
---|
| 94 | return $self;
|
---|
[3540] | 95 | }
|
---|
| 96 |
|
---|
[2564] | 97 | sub get_default_process_exp {
|
---|
| 98 | my $self = shift (@_);
|
---|
| 99 | return q^(?i)\.rtf$^;
|
---|
| 100 | }
|
---|
[2785] | 101 |
|
---|
[2564] | 102 | 1;
|
---|