#! /usr/bin/perl -w
# vim:syntax=perl
use strict;

use lib '/usr/local/share/perl5';

use Lire::Config;
use Lire::Program qw( :msg $PROG );
use Lire::ReportParser::ChartWriter;

use Getopt::Long;

my %opts = ( format	=> $Lire::Config::LR_IMAGE_FORMAT,
	     outputdir	=> ".",
	   );
GetOptions( \%opts, "format=s", "outputdir=s" ) && @ARGV == 0
  or lr_err( "Usage $PROG [--format png|jpeg|gif] [--outputdir dir ] < report.xml" );

lr_info( "will generate charts for each subreports with a charttype" );

my $parser = new Lire::ReportParser::ChartWriter( %opts );
eval {
    $parser->parse(\*STDIN);
};
lr_err( $@ ) if $@;
lr_info( "parsing xml finished" );

exit 0;

__END__

=pod

=head1 NAME

lr_xml2png - generate charts from an XML report

=head1 SYNOPSIS

B<lr_xml2png> B<[> I<options> B<]> I<file.xml>

=head1 OPTIONS

=item B<-f> I<format>

The graphic format to use for the charts. It can be one of jpeg, gif
or png. Default is taken from the LR_IMAGE_FORMAT environment
variable. The usual defaults is PNG.

=item B<-o> I<outputdir>

The directory where the charts should be written. It defaults to the
current working directory.

=head1 DESCRIPTION

B<lr_xml2png> reads an xml report from stdin, and generates charts for
the subreport that have a charttype attribute. The charts will be
written in the directory specified through the B<-o> option or the
current directory if that option isn't used. It will output on STDOUT
a modified version of the input report with the proper lire:image
elements referring to the charts added.

The CPAN perl modules GD::Graph is used.

This script gets called by lr_xml2pdf(1) and lr_xml2html(1).

=head1 SEE ALSO
 
lr_dlf2xml(1), lr_log2report(1)
 
=head1 VERSION
 
$Id: lr_xml2png.in,v 1.21 2002/07/02 16:25:07 flacoste Exp $
 
=head1 COPYRIGHT
 
Copyright (C) 2000-2001 Stichting LogReport Foundation LogReport@LogReport.org
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
=head1 AUTHOR
 
Egon Willighagen
 
=cut

# Local Variables:
# mode: cperl
# End:
