summaryrefslogtreecommitdiffstats
path: root/quanta/parts/kafka/htmlenhancer.h
blob: 73c62251b2f687d4bb9c5999bf66fc00c4e5de54 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/***************************************************************************
                            htmlenhancer.h
                             -------------------

    copyright            : (C) 2003, 2004 - Nicolas Deschildre
    email                : ndeschildre@kdewebdev.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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef HTMLENHANCER_H
#define HTMLENHANCER_H

#include <kurl.h>

#include "nodeenhancer.h"

class KConfig;
class Node;
class KafkaDocument;
class KStandardDirs;

/**
 * This class takes care of the following tasks for [X]HTML DTDs :
 * - Add a TBODY DOM::Node to TABLE DOM::Node if necessary.
 * - Update the src attr of the DOM::Node.
 * - Display an little icon for scripts.
 * - Load the CSS informations into the DOM tree.
 * - Add a colourfull border to FORM, OL, DL, UL
 */

class HTMLEnhancer : public NodeEnhancer
{
public:
	HTMLEnhancer(KafkaDocument *_wkafkapart);
	virtual ~HTMLEnhancer();

	/**
	 * This function modify the DOM::Node of the node.
	 * The DOM::Node must be built before calling this
	 * function.
	 * @param node The Node we want to enhance.
	 * @param tqparentDNode the tqparent DOM::Node of the root DOM::Node of node.
	 * @param nextDNode the DOM::Node next to the root DOM::Node of node.
	 */
	virtual bool enhanceNode(Node *node, DOM::Node tqparentDNode, DOM::Node nextDNode);

	/**
	 * This functions is called once the whole DOM::Node tree is built. It will add empty
	 * TEXT DOM::Node around block element or inside element when necessary
	 * so that the user can access every single part of kafka with the cursor.
	 * @param domNode The node we want to add these empty text around.
	 */
	virtual void postEnhanceNode(DOM::Node domNode);

	/**
	 * This function do the opposite of postEnhanceNode. Usefull to remove the
	 * extra Text DOM::Nodes when deleting a DOM::Node.
	 */
	virtual void postUnenhanceNode(DOM::Node domNode);

	/**
	* Read the config.
	* @m_config The config to read.
	*/
	void readConfig(KConfig *m_config);

	/**
	 * Set the base URL of the current document to update src attrs.
	 * @param baseURL The base URL of the current Document.
	 */
	void setBaseURL(KURL baseURL) {m_baseURL = baseURL;}

	/**
	 * Get the current base URL.
	 * @return Returns the current base URL.
	 */
	KURL baseURL() {return m_baseURL;}

	/**
	 * @return Specifies if we should show icons for scripts.
	 */
	bool showIconsForScripts() {return m_showIconForScripts;}

	/**
	 * Set if we should these little icons.
	 * @param showIcons Should we show these icons?
	 */
	void showIconsForScripts(bool showIcons) {m_showIconForScripts = showIcons;}

private:
	KURL m_baseURL;
	bool m_showIconForScripts;
	KafkaDocument *m_wkafkapart;
	KStandardDirs *m_stddirs;
};

#endif