source: gsdl/trunk/perllib/plugins/RTFPlug.pm@ 15114

Last change on this file since 15114 was 15114, checked in by ak19, 16 years ago

Added srcreplaceable option to work with new script replace_srcdoc_with_html.pl

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
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
27# 12/05/02 Added usage datastructure - John Thompson
28
29package RTFPlug;
30
31use ConvertToPlug;
32use strict;
33no strict 'refs'; # allow filehandles to be variables and viceversa
34
35sub BEGIN {
36 @RTFPlug::ISA = ('ConvertToPlug');
37}
38
39my $arguments =
40 [ { 'name' => "process_exp",
41 'desc' => "{BasPlug.process_exp}",
42 'type' => "regexp",
43 'deft' => &get_default_process_exp(),
44 'reqd' => "no" },
45 { 'name' => "description_tags",
46 'desc' => "{HTMLPlug.description_tags}",
47 'type' => "flag" }
48];
49
50my $options = { 'name' => "RTFPlug",
51 'desc' => "{RTFPlug.desc}",
52 'abstract' => "no",
53 'inherits' => "yes",
54 'srcreplaceable' => "yes", # Source docs in rtf can be replaced with GS-generated html
55 'args' => $arguments };
56
57sub new {
58 my ($class) = shift (@_);
59 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
60 push(@$pluginlist, $class);
61
62 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
63 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
64
65 my $self = new ConvertToPlug($pluginlist, $inputargs, $hashArgOptLists);
66
67 if ($self->{'info_only'}) {
68 # don't worry about any options etc
69 return bless $self, $class;
70 }
71
72 my $secondary_plugin_options = $self->{'secondary_plugin_options'};
73 if (!defined $secondary_plugin_options->{'TEXTPlug'}) {
74 $secondary_plugin_options->{'TEXTPlug'} = [];
75 }
76 if (!defined $secondary_plugin_options->{'HTMLPlug'}) {
77 $secondary_plugin_options->{'HTMLPlug'} = [];
78 }
79 my $text_options = $secondary_plugin_options->{'TEXTPlug'};
80 my $html_options = $secondary_plugin_options->{'HTMLPlug'};
81
82 #$self->{'input_encoding'} = "utf8";
83 #$self->{'extract_language'} = 1;
84 push(@$text_options, "-input_encoding", "utf8");
85 push(@$text_options,"-extract_language") if $self->{'extract_language'};
86 push(@$html_options, "-description_tags") if $self->{'description_tags'};
87 push(@$html_options,"-extract_language") if $self->{'extract_language'};
88
89 $self = bless $self, $class;
90
91 $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
92
93 return $self;
94}
95
96sub get_default_process_exp {
97 my $self = shift (@_);
98 return q^(?i)\.rtf$^;
99}
100
101sub process {
102 my $self = shift (@_);
103 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
104
105 return $self->process_type("rtf",$base_dir,$file,$doc_obj);
106}
107
1081;
Note: See TracBrowser for help on using the repository browser.