[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 |
|
---|
[22597] | 37 | # currently only converts to HTML
|
---|
| 38 | my $convert_to_list =
|
---|
| 39 | [ { 'name' => "html",
|
---|
| 40 | 'desc' => "{ConvertBinaryFile.convert_to.html}" } ];
|
---|
| 41 |
|
---|
[4744] | 42 | my $arguments =
|
---|
[22597] | 43 | [ { 'name' => "convert_to",
|
---|
| 44 | 'desc' => "{ConvertBinaryFile.convert_to}",
|
---|
| 45 | 'type' => "enum",
|
---|
| 46 | 'reqd' => "yes",
|
---|
| 47 | 'list' => $convert_to_list,
|
---|
| 48 | 'deft' => "html" },
|
---|
| 49 | { 'name' => "process_exp",
|
---|
[15872] | 50 | 'desc' => "{BasePlugin.process_exp}",
|
---|
[6408] | 51 | 'type' => "regexp",
|
---|
[4744] | 52 | 'deft' => &get_default_process_exp(),
|
---|
[10514] | 53 | 'reqd' => "no" },
|
---|
| 54 | { 'name' => "description_tags",
|
---|
[15872] | 55 | 'desc' => "{HTMLPlugin.description_tags}",
|
---|
[10514] | 56 | 'type' => "flag" }
|
---|
| 57 | ];
|
---|
[3540] | 58 |
|
---|
[15872] | 59 | my $options = { 'name' => "RTFPlugin",
|
---|
| 60 | 'desc' => "{RTFPlugin.desc}",
|
---|
[6408] | 61 | 'abstract' => "no",
|
---|
[3540] | 62 | 'inherits' => "yes",
|
---|
[15114] | 63 | 'srcreplaceable' => "yes", # Source docs in rtf can be replaced with GS-generated html
|
---|
[3540] | 64 | 'args' => $arguments };
|
---|
| 65 |
|
---|
| 66 | sub new {
|
---|
[10218] | 67 | my ($class) = shift (@_);
|
---|
| 68 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 69 | push(@$pluginlist, $class);
|
---|
[3540] | 70 |
|
---|
[15872] | 71 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 72 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
[10425] | 73 |
|
---|
[15872] | 74 | my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[10218] | 75 |
|
---|
[10580] | 76 | if ($self->{'info_only'}) {
|
---|
| 77 | # don't worry about any options etc
|
---|
| 78 | return bless $self, $class;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[15872] | 81 | $self->{'file_type'} = "RTF";
|
---|
| 82 |
|
---|
[22597] | 83 | # set convert_to_plugin and convert_to_ext
|
---|
[22860] | 84 | $self->set_standard_convert_settings();
|
---|
[22597] | 85 | my $secondary_plugin_name = $self->{'convert_to_plugin'};
|
---|
[10425] | 86 | my $secondary_plugin_options = $self->{'secondary_plugin_options'};
|
---|
[22597] | 87 |
|
---|
| 88 | if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
|
---|
| 89 | $secondary_plugin_options->{$secondary_plugin_name} = [];
|
---|
[10425] | 90 | }
|
---|
[22597] | 91 | my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
|
---|
| 92 |
|
---|
| 93 | push(@$specific_options, "-file_rename_method", "none");
|
---|
| 94 | push(@$specific_options, "-extract_language") if $self->{'extract_language'};
|
---|
| 95 | if ($secondary_plugin_name eq "TextPlugin") {
|
---|
| 96 | push(@$specific_options, "-input_encoding", "utf8");
|
---|
[10425] | 97 | }
|
---|
[22597] | 98 | elsif ($secondary_plugin_name eq "HTMLPlugin") {
|
---|
| 99 | push(@$specific_options, "-description_tags") if $self->{'description_tags'};
|
---|
| 100 | push(@$specific_options, "-processing_tmp_files");
|
---|
| 101 | }
|
---|
[10425] | 102 |
|
---|
[10272] | 103 | $self = bless $self, $class;
|
---|
| 104 |
|
---|
[10425] | 105 | $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
|
---|
[10272] | 106 |
|
---|
| 107 | return $self;
|
---|
[3540] | 108 | }
|
---|
| 109 |
|
---|
[2564] | 110 | sub get_default_process_exp {
|
---|
| 111 | my $self = shift (@_);
|
---|
| 112 | return q^(?i)\.rtf$^;
|
---|
| 113 | }
|
---|
[2785] | 114 |
|
---|
[2564] | 115 | 1;
|
---|