summaryrefslogtreecommitdiffstats
path: root/src/st/croco/cr-doc-handler.h
blob: d12673f31308d6ec7fb338b9229ef798a1f8afc9 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */

/*
 * This file is part of The Croco Library
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * 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 Lesser 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
 *
 * See the COPYRIGHTS file for copyright information.
 */

#ifndef __CR_DOC_HANDLER_H__
#define __CR_DOC_HANDLER_H__

/**
 *@file
 *The declaration of the #CRDocumentHandler class.
 *This class is actually the parsing events handler.
 */

#include <glib.h>
#include "cr-utils.h"
#include "cr-input.h"
#include "cr-stylesheet.h"

G_BEGIN_DECLS


typedef struct _CRDocHandler CRDocHandler ;

struct _CRDocHandlerPriv ;
typedef struct _CRDocHandlerPriv CRDocHandlerPriv ;


/**
 *The SAC document handler.
 *An instance of this class is to
 *be passed to a parser. Then, during the parsing
 *the parser calls the convenient function pointer
 *whenever a particular event (a css construction) occurs.
 */
struct _CRDocHandler
{
	CRDocHandlerPriv *priv ;

	/**
	 *This pointer is to be used by the application for
	 *it custom needs. It is there to extend the doc handler.
	 */
	gpointer app_data ;

	/**
	 *Is called at the beginning of the parsing of the document.
	 *@param a_this a pointer to the current instance of
	 *#CRDocHandler.
	 */
	void (*start_document) (CRDocHandler *a_this) ;

	/**
	 *Is called to notify the end of the parsing of the document.
	 *@param a_this a pointer to the current instance of
	 *#CRDocHandler.
	 */
	void (*end_document) (CRDocHandler *a_this) ;

	/**
	 *Is called to notify an at charset rule.
	 *@param a_this the document handler.
	 *@param a_charset the declared charset.
	 */
	void (*charset) (CRDocHandler *a_this, 
			 CRString *a_charset,
			 CRParsingLocation *a_charset_sym_location) ;

	/**
	 *Is called to notify an import statement in 
	 *the stylesheet.
	 *@param a_this the current instance of #CRDocHandler.
	 *@param a_media_list a doubly linked list of GString objects.
	 *Each GString object contains a string which is the
	 *destination media for style information.
	 *@param a_uri the uri of the imported style sheet.
	 *@param a_uri_default_ns the default namespace of URI
	 *@param a_location the parsing location of the '\@import' 
	 *keyword.
	 *of the imported style sheet.
	 */
	void (*import_style) (CRDocHandler *a_this,
			      GList *a_media_list,
			      CRString *a_uri,
			      CRString *a_uri_default_ns,
			      CRParsingLocation *a_location) ;

	void (*import_style_result) (CRDocHandler *a_this,
				     GList *a_media_list,
				     CRString *a_uri,
				     CRString *a_uri_default_ns,
				     CRStyleSheet *a_sheet) ;

	/**
	 *Is called to notify a namespace declaration.
	 *Not used yet.
	 *@param a_this the current instance of #CRDocHandler.
	 *@param a_prefix the prefix of the namespace.
	 *@param a_uri the uri of the namespace.
	 *@param a_location the location of the "@namespace" keyword.
	 */
	void (*namespace_declaration) (CRDocHandler *a_this,
				       CRString *a_prefix,
				       CRString *a_uri,
				       CRParsingLocation *a_location) ;
		
	/**
	 *Is called to notify a comment.
	 *@param a_this a pointer to the current instance
	 *of #CRDocHandler.
	 *@param a_comment the comment.
	 */
	void (*comment) (CRDocHandler *a_this,
			 CRString *a_comment) ;

	/**
	 *Is called to notify the beginning of a rule
	 *statement.
	 *@param a_this the current instance of #CRDocHandler.
	 *@param a_selector_list the list of selectors that precedes
	 *the rule declarations.
	 */
	void (*start_selector) (CRDocHandler * a_this,
				CRSelector *a_selector_list) ;

	/**
	 *Is called to notify the end of a rule statement.
	 *@param a_this the current instance of #CRDocHandler.
	 *@param a_selector_list the list of selectors that precedes
	 *the rule declarations. This pointer is the same as
	 *the one passed to start_selector() ;
	 */
	void (*end_selector) (CRDocHandler *a_this,
			      CRSelector *a_selector_list) ;


	/**
	 *Is called to notify a declaration.
	 *@param a_this a pointer to the current instance
	 *of #CRDocHandler.
	 *@param a_name the name of the parsed property.
	 *@param a_expression a css expression that represents
	 *the value of the property. A css expression is
	 *actually a linked list of 'terms'. Each term can
	 *be linked to other using operators.
	 *
	 */
	void (*property) (CRDocHandler *a_this,
			  CRString *a_name,
			  CRTerm *a_expression,
			  gboolean a_is_important) ;
	/**
	 *Is called to notify the start of a font face statement.
	 *The parser invokes this method at the beginning of every
	 *font face statement in the style sheet. There will
	 *be a corresponding end_font_face () event for every
	 *start_font_face () event.
	 *
	 *@param a_this a pointer to the current instance of
	 *#CRDocHandler.
	 *@param a_location the parsing location of the "\@font-face"
	 *keyword.
	 */
	void (*start_font_face) (CRDocHandler *a_this,
				 CRParsingLocation *a_location) ;

	/**
	 *Is called to notify the end of a font face statement.
	 *@param a_this a pointer to the current instance of
	 *#CRDocHandler.
	 */
	void (*end_font_face) (CRDocHandler *a_this) ;


	/**
	 *Is called to notify the beginning of a media statement.
	 *The parser will invoke this method at the beginning of
	 *every media statement in the style sheet. There will be
	 *a corresponding end_media() event for every start_media()
	 *event.
	 *@param a_this a pointer to the current instance of 
	 *#CRDocHandler.
	 *@param a_media_list a double linked list of 
	 #CRString * objects.
	 *Each CRString objects is actually a destination media for
	 *the style information.
	 */
	void (*start_media) (CRDocHandler *a_this,
			     GList *a_media_list,
			     CRParsingLocation *a_location) ;

	/**
	 *Is called to notify the end of a media statement.
	 *@param a_this a pointer to the current instance
	 *of #CRDocHandler.
	 *@param a_media_list a double linked list of GString * objects.
	 *Each GString objects is actually a destination media for
	 *the style information.
	 */
	void (*end_media) (CRDocHandler *a_this,
			   GList *a_media_list) ;

	/**
	 *Is called to notify the beginning of a page statement.
	 *The parser invokes this function at the beginning of
	 *every page statement in the style sheet. There will be
	 *a corresponding end_page() event for every single 
	 *start_page() event.
	 *@param a_this a pointer to the current instance of
	 *#CRDocHandler.
	 *@param a_name the name of the page (if any, null otherwise).
	 *@param a_pseudo_page the pseudo page (if any, null otherwise).
	 *@param a_location the parsing location of the "\@page" keyword.
	 */
	void (*start_page) (CRDocHandler *a_this,
			    CRString *a_name, 
			    CRString *a_pseudo_page,
			    CRParsingLocation *a_location) ;

	/**
	 *Is called to notify the end of a page statement.
	 *@param a_this a pointer to the current instance of
	 *#CRDocHandler.
	 *@param a_name the name of the page (if any, null otherwise).
	 *@param a_pseudo_page the pseudo page (if any, null otherwise).
	 */
	void (*end_page) (CRDocHandler *a_this,
			  CRString *a_name,
			  CRString *pseudo_page) ;
		
	/**
	 *Is Called to notify an unknown at-rule not supported
	 *by this parser.
	 */
	void (*ignorable_at_rule) (CRDocHandler *a_this,
				   CRString *a_name) ;

	/**
	 *Is called to notify a parsing error. After this error
	 *the application must ignore the rule being parsed, if
	 *any. After completion of this callback, 
	 *the parser will then try to resume the parsing,
	 *ignoring the current error.
	 */
	void (*error) (CRDocHandler *a_this) ;

	/**
	 *Is called to notify an unrecoverable parsing error.
	 *This is the place to put emergency routines that free allocated
	 *resources.
	 */
	void (*unrecoverable_error) (CRDocHandler *a_this) ;

	gboolean resolve_import ;
	gulong ref_count ;
} ;

CRDocHandler * cr_doc_handler_new (void) ;

enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ;

enum CRStatus cr_doc_handler_get_result (CRDocHandler const *a_this, gpointer * a_result) ;

enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ;

enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler const *a_this, gpointer * a_ctxt) ;

enum CRStatus cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ;

void cr_doc_handler_associate_a_parser (CRDocHandler *a_this,
					gpointer a_parser) ;

void cr_doc_handler_ref (CRDocHandler *a_this) ;

gboolean cr_doc_handler_unref (CRDocHandler *a_this) ;

void cr_doc_handler_destroy (CRDocHandler *a_this) ;

G_END_DECLS

#endif /*__CR_DOC_HANDLER_H__*/