source: main/trunk/greenstone2/perllib/plugins/RTFPlugin.pm@ 21746

Last change on this file since 21746 was 20790, checked in by kjdon, 15 years ago

set -processing_tmp_files option to secondary HTML and PagedImage plugins so that the associated files in tmp are not stored as source associated files (used by incremental build to work out what needs reimporting)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 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 # tell the secondary plugins that they are processing tmp files
94 push(@$html_options, "-processing_tmp_files");
95
96 $self = bless $self, $class;
97
98 $self->load_secondary_plugins($class,$secondary_plugin_options, $hashArgOptLists);
99
100 return $self;
101}
102
103sub get_default_process_exp {
104 my $self = shift (@_);
105 return q^(?i)\.rtf$^;
106}
107
1081;
Note: See TracBrowser for help on using the repository browser.