RTF-HTML-Converter-API-0.1/0040755000076400010010000000000007436246574015442 5ustar AdministratorNoneRTF-HTML-Converter-API-0.1/API.pm0100444000076400010010000001064107436244110016366 0ustar AdministratorNonepackage RTF::HTML::Converter::API; use Carp; use strict; use warnings; use RTF::HTML::Converter; our $VERSION = 0.1; our $CHAT = 0; =head1 NAME RTF::HTML::Converter:API - an OO API to Philippe Verdret's RTF::HTML::Convertor =head1 SYNOPSIS use RTF::HTML::Converter::API; my $rtf = new RTF::HTML::Converter::API (dir => "D:/temp/",); $rtf->process; foreach (@{$rtf->{files}}){ warn $_; warn $_->{filename}; warn $_->{html},"//end//"; warn "\n"; } my $rtf = new RTF::HTML::Converter::API; warn $rtf->convert_file("D:/temp/rtf-test.rtf"); foreach (@{$rtf->{files}}){ warn $_; warn $_->{filename}; warn $_->{html},"//end//"; warn "\n"; } exit; =head1 DESCRIPTION An OO API to Philippe Verdret's L module. Define the class variable C to have a value if you wish realtime output of what's going on. =head1 CONSTRUCTOR new Arguments in Cvalue> pairs: =over 4 =item dir: the directory to process. =back =cut sub new { my $class = shift; warn "Making new __PACKAGE__" if $CHAT; unless (defined $class) { carp "Usage: ".__PACKAGE__."->new( {key=>value} )\n"; return undef; } my %args; # Take parameters and place in object slots/set as instance variables if (ref $_[0] eq 'HASH'){ %args = %{$_[0]} } elsif (not ref $_[0]){ %args = @_ } else { carp "Usage: $class->new( { key=>values, } )"; return undef; } my $self = bless {}, $class; # Set/overwrite public slots with user's values foreach (keys %args) { $self->{lc $_} = $args{$_}; warn "$_ => $args{$_}\n" if $CHAT; } $self->{files} = []; # Array holding hashes, keys of which are filename, html if (exists $self->{dir} and not -e $self->{dir}){ croak "The directory you supplied, <$self->{dir}>, does not exist."; } if (exists $self->{dir} and not -d $self->{dir}){ croak "The path you supplied is not a directory."; } return $self; } =head2 METHOD process Does everything in one method call. =cut sub process { my $self=shift; warn "Processing" if $CHAT; $self->get_filenames; $self->convert_files; } =head2 METHOD get_filenames Optional argument is a directory to process: default is in C<$self->{dir}> required at construction time. =cut sub get_filenames { my ($self,$dir) = (shift,shift); $dir = $self->{dir} if not defined $dir; warn "Getting filenames from directory <$dir>" if $CHAT; local *DIR; opendir DIR,$dir or carp "Couldn't open directory <$dir> to read: $!." and return undef; foreach (grep /.*?\.rtf$/, readdir DIR){ push @{$self->{files}}, {filename=>$_, html=>'',}; warn "\tfilename: <$_>" if $CHAT; } closedir DIR; } =head2 METHOD convert_files Calls the C (see L) on every file in our C list: takes the filenames from the C slot of each hash, and placing the resulting HTML into the C slot fo each hash. =cut sub convert_files { my $self = shift; warn "Converting all files" if $CHAT; foreach (@{$self->{files}} ){ warn "Converting <$_->{filename}>" if $CHAT; my $rtf = new RTF::HTML::Converter(Output => \$_->{html}); $rtf->parse_stream($self->{dir}."/".$_->{filename}); } } =head2 METHOD convert_file Accepts the object reference and the path to a file to convert. Pushes into the object's C array a hash with a key C against the passed filename, and a key C with the value returned by the C (see L). Incidentally returns a reference to the HTML created. Does not check to see if the object already contains the processed result. Does not use the object's C slot. =cut sub convert_file { my ($self,$filepath) = (shift,shift); croak "No filepath passed" if not defined $filepath; croak "No such file as the passed <$filepath>" if not -e $filepath; warn "Converting <$filepath>" if $CHAT; my $html; my $rtf = new RTF::HTML::Converter(Output => \$html); $rtf->parse_stream($filepath); push @{$self->{files}}, {filename=>$filepath, html=>$html, }; return \$_->{html}; } 1; # Return cleanly =head1 AUTHOR L (L). =head1 COPYRIGHT Copyright (C) Lee Goddard, 2002. All rights reserved. This software is made available under the same terms as Perl itself. RTF-HTML-Converter-API-0.1/README0100444000076400010010000000450007436243626016307 0ustar AdministratorNoneRTF/HTML/Converter/API version 0.01 =================================== NAME RTF::HTML::Converter:API - an OO API to Philippe Verdret's RTF::HTML::Convertor. SYNOPSIS use RTF::HTML::Converter::API; my $rtf = new RTF::HTML::Converter::API (dir => "D:/temp/",); $rtf->process; foreach (@{$rtf->{files}}){ warn $_; warn $_->{filename}; warn $_->{html},"//end//"; warn "\n"; } my $rtf = new RTF::HTML::Converter::API; warn $rtf->convert_file("D:/temp/rtf-test.rtf"); foreach (@{$rtf->{files}}){ warn $_; warn $_->{filename}; warn $_->{html},"//end//"; warn "\n"; } exit; DESCRIPTION An OO API to Philippe Verdret's RTF::HTML::Convertor module. Define the class variable "CHAT" to have a value if you wish realtime output of what's going on. CONSTRUCTOR new Arguments in "key="value> pairs: dir: the directory to process. METHOD process Does everything in one method call. METHOD get_filenames Optional argument is a directory to process: default is in "$self-"{dir}> required at construction time. METHOD convert_files Calls the "RTF::HTML::Converter" (see the RTF::HTML::Converter manpage) on every file in our "files" list: takes the filenames from the "filename" slot of each hash, and placing the resulting HTML into the "html" slot fo each hash. METHOD convert_file Accepts the object reference and the path to a file to convert. Pushes into the object's "files" array a hash with a key "filename" against the passed filename, and a key "html" with the value returned by the "RTF::HTML::Converter" (see the RTF::HTML::Converter manpage). Incidentally returns a reference to the HTML created. Does not check to see if the object already contains the processed result. Does not use the object's "dir" slot. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: RTF::HTML::Convertor AUTHOR Lee Goddard (lgoddard@CPAN.org). COPYRIGHT AND LICENCE Copyright (C) Lee Goddard, 2002. All rights reserved. This software is made available under the same terms as Perl itself. RTF-HTML-Converter-API-0.1/Makefile.PL0100444000076400010010000000077607436244124017406 0ustar AdministratorNoneuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'RTF::HTML::Converter::API', 'VERSION_FROM' => 'API.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'API.pm', # retrieve abstract from module AUTHOR => 'Lee Goddard ') : ()), ); RTF-HTML-Converter-API-0.1/Changes0100444000076400010010000000027407436241772016726 0ustar AdministratorNoneRevision history for Perl extension RTF::HTML::Converter::API. 0.01 Sun Feb 24 20:50:16 2002 - original version; created by h2xs 1.21 with options -X RTF::HTML::Converter::API RTF-HTML-Converter-API-0.1/MANIFEST0100444000076400010010000000010707436243642016555 0ustar AdministratorNoneAPI.pm Changes Makefile.PL MANIFEST README test.pl t/rtf-test.rtfRTF-HTML-Converter-API-0.1/test.pl0100444000076400010010000000214607436243504016742 0ustar AdministratorNone# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test; BEGIN { plan tests => 5 }; use RTF::HTML::Converter::API; ok(1); # If we made it this far, we're ok. ######################### my $rtf = new RTF::HTML::Converter::API (dir => "t"); ok($rtf); $rtf->process; ok(1); ok('rtf-test.rtf', $rtf->{files}[0]->{filename} ); ok($rtf->{files}[0]->{html}, <<__END_HTML__

This is a test document.

Heading One.

Heading Two.

Heading Three.

Italic.

Bold.

Indented one tab.

Author : LG

Creation date: 2002-2-24-19-54

Modification date: 2002-2-24-19-55

__END_HTML__ ); RTF-HTML-Converter-API-0.1/t/0040755000076400010010000000000007436246574015705 5ustar AdministratorNoneRTF-HTML-Converter-API-0.1/t/rtf-test.rtf0100444000076400010010000001154607436233422020160 0ustar AdministratorNone{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;} {\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f28\froman\fcharset238\fprq2 Times New Roman CE;}{\f29\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f31\froman\fcharset161\fprq2 Times New Roman Greek;} {\f32\froman\fcharset162\fprq2 Times New Roman Tur;}{\f33\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f34\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f35\froman\fcharset186\fprq2 Times New Roman Baltic;} {\f36\fswiss\fcharset238\fprq2 Arial CE;}{\f37\fswiss\fcharset204\fprq2 Arial Cyr;}{\f39\fswiss\fcharset161\fprq2 Arial Greek;}{\f40\fswiss\fcharset162\fprq2 Arial Tur;}{\f41\fswiss\fcharset177\fprq2 Arial (Hebrew);} {\f42\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f43\fswiss\fcharset186\fprq2 Arial Baltic;}{\f44\fmodern\fcharset238\fprq1 Courier New CE;}{\f45\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f47\fmodern\fcharset161\fprq1 Courier New Greek;} {\f48\fmodern\fcharset162\fprq1 Courier New Tur;}{\f49\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f50\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f51\fmodern\fcharset186\fprq1 Courier New Baltic;}}{\colortbl;\red0\green0\blue0; \red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128; \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \snext0 Normal;}{ \s1\ql \li0\ri0\sb240\sa60\keepn\widctlpar\brdrb\brdrs\brdrw10\brsp20 \aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \b\f1\fs32\lang2057\langfe1033\kerning32\cgrid\langnp2057\langfenp1033 \sbasedon0 \snext0 heading 1;}{ \s2\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \b\i\f1\fs28\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \sbasedon0 \snext0 heading 2;}{ \s3\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \b\f1\fs26\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 \sbasedon0 \snext0 heading 3;}{\*\cs10 \additive Default Paragraph Font;}{\*\cs15 \additive \f2 \sbasedon10 code;}}{\info{\title This is a test document}{\author LG}{\operator LG}{\creatim\yr2002\mo2\dy24\hr19\min54}{\revtim\yr2002\mo2\dy24\hr19\min55}{\version1}{\edmins1}{\nofpages1}{\nofwords0}{\nofchars0}{\*\company LBL}{\nofcharsws0}{\vern8247}} \paperw11906\paperh16838 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1 \jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule \fet0\sectd \linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5 \pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 { This is a test document. \par }\pard\plain \s1\ql \li0\ri0\sb240\sa60\keepn\widctlpar\brdrb\brdrs\brdrw10\brsp20 \aspalpha\aspnum\faauto\outlinelevel0\adjustright\rin0\lin0\itap0 \b\f1\fs32\lang2057\langfe1033\kerning32\cgrid\langnp2057\langfenp1033 {Heading One. \par }\pard\plain \s2\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel1\adjustright\rin0\lin0\itap0 \b\i\f1\fs28\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Heading Two. \par }\pard\plain \s3\ql \li0\ri0\sb240\sa60\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel2\adjustright\rin0\lin0\itap0 \b\f1\fs26\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Heading Three. \par }\pard\plain \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\i Italic. \par }{\b Bold. \par }\pard \ql \fi720\li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {Indented one tab. \par }}