summaryrefslogtreecommitdiffstats
path: root/src/exporters/htmlexporter.h
blob: 95cee4cf9437f7ce62f75a6990cc626472e1362c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/***************************************************************************
*   Copyright (C) 2003-2006 by                                            *
*   Jason Kivlighn (jkivlighn@gmail.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.                                   *
***************************************************************************/

#ifndef HTMLEXPORTER_H
#define HTMLEXPORTER_H

#include <tqdom.h>
#include <tqmap.h>

#include "baseexporter.h"
#include "klomanager.h"

class RecipeDB;
class KProgress;

/**
  * Exports a given recipe list as HTML
  * @author Jason Kivlighn
  */
class HTMLExporter : public BaseExporter, protected KLOManager
{
public:
	HTMLExporter( const TQString&, const TQString& );
	virtual ~HTMLExporter();

	virtual int supportedItems() const;

	static void removeHTMLFiles( const TQString &filename, int recipe_id );
	static void removeHTMLFiles( const TQString &filename, const TQValueList<int> &recipe_ids );

	void setTemplate( const TQString &filename );
	void setStyle( const TQString &filename );

protected:
	TQString createContent( const Recipe& recipe );
	virtual TQString createContent( const RecipeList & );
	virtual TQString createHeader( const RecipeList & );
	virtual TQString createFooter();

	virtual int progressInterval() const { return 1; }

	virtual void loadBackgroundColor( const TQString &obj, const TQColor& );
	virtual void loadFont( const TQString &obj, const TQFont& );
	virtual void loadTextColor( const TQString &obj, const TQColor& );
	virtual void loadVisibility( const TQString &obj, bool );
	virtual void loadAlignment( const TQString &obj, int );
	virtual void loadBorder( const TQString &obj, const KreBorder& );
	virtual void loadColumns( const TQString & obj, int cols );

	virtual void beginObject( const TQString &obj );
	virtual void endObject();

	static TQString escape( const TQString & );

	TQString m_templateContent;

private:
	void storePhoto( const Recipe &recipe );
	void populateTemplate( const Recipe &recipe, TQString &content );
	void replaceIfVisible( TQString &content, const TQString &name, const TQString &html );
	TQString HTMLIfVisible( const TQString &name, const TQString &html );

	TQString m_layoutFilename;
	TQString m_templateFilename;
	TQString m_cachedCSS;
	TQMap<TQString,bool> m_visibilityMap;
	TQMap<TQString,int> m_columnsMap;
	bool m_error;
};

#endif //HTMLEXPORTER_H