/***************************************************************************
 *   Copyright (C) 2006 by Ian Reinhart Geiser   *
 *   geiseri@yahoo.com   *
 *                                                                         *
 *   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.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef PDFSLIDEREPORTER_H
#define PDFSLIDEREPORTER_H

#include <QString>

class MindMap;
class Block;
class QRectF;
class QTextDocument;
class QTextCursor;
class QPainter;
class QPrinter;
class QSizeF;
class QImage;

/**
 * Generates a set of PDF slides suitable for presentations or handouts.  The mind map is broken into a set of slides in the following way:
 * @li Block 1 - Title on title page
 * @li Block 2 (First child of block 1) - Title on first page
 * @li Block 3 (First child of block 2) - First bullet point of content.
 * Bullet levels will go up to 5 levels deep this means that a mind map should only have 8 levels from the root node to the child node.

	@author Ian Reinhart Geiser <geiseri@yahoo.com>
*/
class PDFSlideReporter
{
	public:
		PDFSlideReporter();

		~PDFSlideReporter();

		void generateReport( MindMap *map, const QString &fileName );

		void printTextBox( const QRectF &box, QTextDocument *text, QPainter *painter );
		void printTextBox( const QRectF &box, const QString &text, QPainter *painter );
		void printImageBox( const QRectF &box, const QImage &img, QPainter *painter );

		QRectF generatePageRect( const QSizeF &pageSize, const QRectF &sourceRect );
	private:
		void generateTitlePage( Block *block );
		void generateContentPage( Block *block, QPainter *painter, const QSizeF &size ); // generate the page itself (title, body, etc...)
		void generateContentPageList( Block *block, QString *writer ); // generate the outline html for the page
		QRectF readTemplateRect( MindMap *map, const QString &field, const QRectF &defaultRect );
		struct Cell {
			qreal x1;
			qreal y1;
			qreal x2;
			qreal y2;
		};

	private:
		QPrinter *m_pdfPrinter;
		QPainter *m_painter;
};

#endif

