source: gsdl/trunk/perllib/plugins/RTFPlugin.pm@ 18406

Last change on this file since 18406 was 18406, checked in by ak19, 15 years ago

Modified srcreplaceable plugins (plugins which operate on docs where the source file can be replaced with their converted htmls) to set the file_rename_method to none for secondary plugins (for Text, HTML, and PagedImage plugins) so that the file is not renamed several times.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
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
27package RTFPlugin;
28
29use ConvertBinaryFile;
30use strict;
31no strict 'refs'; # allow filehandles to be variables and viceversa
32
33sub BEGIN {
34 @RTFPlugin::ISA = ('ConvertBinaryFile');
35}
36
37my $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
48my $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
55sub 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 push(@$html_options, "-file_rename_method", "none");
91 push(@$text_options, "-file_rename_method", "none");
92
93 $self = bless $self, $class;
94
95 $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
96
97 return $self;
98}
99
100sub get_default_process_exp {
101 my $self = shift (@_);
102 return q^(?i)\.rtf$^;
103}
104
1051;
Note: See TracBrowser for help on using the repository browser.