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