1 |
# |
2 |
# -*- Perl -*- |
3 |
# Copyright (C) 2001 wakaba <wakaba@suika.fam.cx> |
4 |
# This is free software with ABSOLUTELY NO WARRANTY. |
5 |
# |
6 |
# This program is free software; you can redistribute it and/or modify |
7 |
# it under the terms of the GNU General Public License as published by |
8 |
# the Free Software Foundation; either versions 2, or (at your option) |
9 |
# any later version. |
10 |
# |
11 |
# This program is distributed in the hope that it will be useful |
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
# GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License |
17 |
# along with this program; if not, write to the Free Software |
18 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
19 |
# 02111-1307, USA |
20 |
# |
21 |
# This file must be encoded in EUC-JP encoding |
22 |
# |
23 |
|
24 |
package cwj; |
25 |
no strict; |
26 |
require 'util.pl'; |
27 |
require 'gfilter.pl'; |
28 |
|
29 |
sub mediatype() { |
30 |
return ('application/x-craris-works'); |
31 |
} |
32 |
|
33 |
sub status() { |
34 |
return 'yes'; |
35 |
} |
36 |
|
37 |
sub recursive() { |
38 |
return 0; |
39 |
} |
40 |
|
41 |
sub pre_codeconv() { |
42 |
return 0; |
43 |
} |
44 |
|
45 |
sub post_codeconv () { |
46 |
return 1; |
47 |
} |
48 |
|
49 |
sub add_magic ($) { |
50 |
my ($magic) = @_; |
51 |
|
52 |
$magic->addSpecials("application/x-craris-works", |
53 |
"^\x04\x07\x76\x00\x43\x57\x4B\x4A"); |
54 |
$magic->addFileExts('\\.cwj$' => 'application/x-craris-works'); |
55 |
|
56 |
return; |
57 |
} |
58 |
|
59 |
sub filter ($$$$$) { |
60 |
my ($orig_cfile, $cont, $weighted_str, $headings, $fields) |
61 |
= @_; |
62 |
my $cfile = defined $orig_cfile ? $$orig_cfile : ''; |
63 |
|
64 |
util::vprint("Processing Craris Works 4 document...\n"); |
65 |
|
66 |
cwj_filter($cont, $weighted_str, $fields); |
67 |
|
68 |
gfilter::line_adjust_filter($cont); |
69 |
gfilter::line_adjust_filter($weighted_str); |
70 |
gfilter::white_space_adjust_filter($cont); |
71 |
gfilter::show_filter_debug_info($cont, $weighted_str, |
72 |
$fields, $headings); |
73 |
return undef; |
74 |
} |
75 |
|
76 |
sub cwj_filter ($$$) { |
77 |
my ($contref, $weighted_str, $fields) = @_; |
78 |
|
79 |
$$contref =~ s/[\x0D\x0A\x20]+/\x20/g; |
80 |
$$contref =~ s/[\x00-\x1F\x7F\xFD-\xFF]+//g; |
81 |
my $t = $$contref; my $r = ""; |
82 |
$t =~ s{((?:(?:[\x81-\xFC][\x40-\x7E\x80-\xFC])+|(?:[\x20-\x7E]+))+)}{ |
83 |
$r .= $1; |
84 |
}gesx; |
85 |
#use Jcode; |
86 |
#Jcode::convert(\$r,'euc','sjis'); |
87 |
$$contref = $r; |
88 |
} |
89 |
|
90 |
1; |