1 /* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
4 * This file is part of The Croco Library
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2.1 of the GNU Lesser General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * See the COPYRIGHTS file for copyright information.
23 #ifndef __CR_DOC_HANDLER_H__
24 #define __CR_DOC_HANDLER_H__
28 *The declaration of the #CRDocumentHandler class.
29 *This class is actually the parsing events handler.
35 #include "cr-stylesheet.h"
40 typedef struct _CRDocHandler CRDocHandler ;
42 struct _CRDocHandlerPriv ;
43 typedef struct _CRDocHandlerPriv CRDocHandlerPriv ;
47 *The SAC document handler.
48 *An instance of this class is to
49 *be passed to a parser. Then, during the parsing
50 *the parser calls the convenient function pointer
51 *whenever a particular event (a css construction) occurs.
55 CRDocHandlerPriv *priv ;
58 *This pointer is to be used by the application for
59 *it custom needs. It is there to extend the doc handler.
64 *Is called at the beginning of the parsing of the document.
65 *@param a_this a pointer to the current instance of
68 void (*start_document) (CRDocHandler *a_this) ;
71 *Is called to notify the end of the parsing of the document.
72 *@param a_this a pointer to the current instance of
75 void (*end_document) (CRDocHandler *a_this) ;
78 *Is called to notify an at charset rule.
79 *@param a_this the document handler.
80 *@param a_charset the declared charset.
82 void (*charset) (CRDocHandler *a_this,
84 CRParsingLocation *a_charset_sym_location) ;
87 *Is called to notify an import statement in
89 *@param a_this the current instance of #CRDocHandler.
90 *@param a_media_list a doubly linked list of GString objects.
91 *Each GString object contains a string which is the
92 *destination media for style information.
93 *@param a_uri the uri of the imported style sheet.
94 *@param a_uri_default_ns the default namespace of URI
95 *@param a_location the parsing location of the '@import'
97 *of the imported style sheet.
99 void (*import_style) (CRDocHandler *a_this,
102 CRString *a_uri_default_ns,
103 CRParsingLocation *a_location) ;
105 void (*import_style_result) (CRDocHandler *a_this,
108 CRString *a_uri_default_ns,
109 CRStyleSheet *a_sheet) ;
112 *Is called to notify a namespace declaration.
114 *@param a_this the current instance of #CRDocHandler.
115 *@param a_prefix the prefix of the namespace.
116 *@param a_uri the uri of the namespace.
117 *@param a_location the location of the "@namespace" keyword.
119 void (*namespace_declaration) (CRDocHandler *a_this,
122 CRParsingLocation *a_location) ;
125 *Is called to notify a comment.
126 *@param a_this a pointer to the current instance
128 *@param a_comment the comment.
130 void (*comment) (CRDocHandler *a_this,
131 CRString *a_comment) ;
134 *Is called to notify the beginning of a rule
136 *@param a_this the current instance of #CRDocHandler.
137 *@param a_selector_list the list of selectors that precedes
138 *the rule declarations.
140 void (*start_selector) (CRDocHandler * a_this,
141 CRSelector *a_selector_list) ;
144 *Is called to notify the end of a rule statement.
145 *@param a_this the current instance of #CRDocHandler.
146 *@param a_selector_list the list of selectors that precedes
147 *the rule declarations. This pointer is the same as
148 *the one passed to start_selector() ;
150 void (*end_selector) (CRDocHandler *a_this,
151 CRSelector *a_selector_list) ;
155 *Is called to notify a declaration.
156 *@param a_this a pointer to the current instance
158 *@param a_name the name of the parsed property.
159 *@param a_expression a css expression that represents
160 *the value of the property. A css expression is
161 *actually a linked list of 'terms'. Each term can
162 *be linked to other using operators.
165 void (*property) (CRDocHandler *a_this,
167 CRTerm *a_expression,
168 gboolean a_is_important) ;
170 *Is called to notify the start of a font face statement.
171 *The parser invokes this method at the beginning of every
172 *font face statement in the style sheet. There will
173 *be a corresponding end_font_face () event for every
174 *start_font_face () event.
176 *@param a_this a pointer to the current instance of
178 *@param a_location the parsing location of the "@font-face"
181 void (*start_font_face) (CRDocHandler *a_this,
182 CRParsingLocation *a_location) ;
185 *Is called to notify the end of a font face statement.
186 *@param a_this a pointer to the current instance of
189 void (*end_font_face) (CRDocHandler *a_this) ;
193 *Is called to notify the beginning of a media statement.
194 *The parser will invoke this method at the beginning of
195 *every media statement in the style sheet. There will be
196 *a corresponding end_media() event for every start_media()
198 *@param a_this a pointer to the current instance of
200 *@param a_media_list a double linked list of
202 *Each CRString objects is actually a destination media for
203 *the style information.
205 void (*start_media) (CRDocHandler *a_this,
207 CRParsingLocation *a_location) ;
210 *Is called to notify the end of a media statement.
211 *@param a_this a pointer to the current instance
213 *@param a_media_list a double linked list of GString * objects.
214 *Each GString objects is actually a destination media for
215 *the style information.
217 void (*end_media) (CRDocHandler *a_this,
218 GList *a_media_list) ;
221 *Is called to notify the beginning of a page statement.
222 *The parser invokes this function at the beginning of
223 *every page statement in the style sheet. There will be
224 *a corresponding end_page() event for every single
226 *@param a_this a pointer to the current instance of
228 *@param a_name the name of the page (if any, null otherwise).
229 *@param a_pseudo_page the pseudo page (if any, null otherwise).
230 *@param a_location the parsing location of the "@page" keyword.
232 void (*start_page) (CRDocHandler *a_this,
234 CRString *a_pseudo_page,
235 CRParsingLocation *a_location) ;
238 *Is called to notify the end of a page statement.
239 *@param a_this a pointer to the current instance of
241 *@param a_name the name of the page (if any, null otherwise).
242 *@parap a_pseudo_page the pseudo page (if any, null otherwise).
244 void (*end_page) (CRDocHandler *a_this,
246 CRString *pseudo_page) ;
249 *Is Called to notify an unknown at-rule not supported
252 void (*ignorable_at_rule) (CRDocHandler *a_this,
256 *Is called to notify a parsing error. After this error
257 *the application must ignore the rule being parsed, if
258 *any. After completion of this callback,
259 *the parser will then try to resume the parsing,
260 *ignoring the current error.
262 void (*error) (CRDocHandler *a_this) ;
265 *Is called to notify an unrecoverable parsing error.
266 *This is the place to put emergency routines that free allocated
269 void (*unrecoverable_error) (CRDocHandler *a_this) ;
271 gboolean resolve_import ;
275 CRDocHandler * cr_doc_handler_new (void) ;
277 enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ;
279 enum CRStatus cr_doc_handler_get_result (CRDocHandler *a_this, gpointer * a_result) ;
281 enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ;
283 enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler *a_this, gpointer * a_ctxt) ;
285 enum CRStatus cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ;
287 void cr_doc_handler_associate_a_parser (CRDocHandler *a_this,
290 void cr_doc_handler_ref (CRDocHandler *a_this) ;
292 gboolean cr_doc_handler_unref (CRDocHandler *a_this) ;
294 void cr_doc_handler_destroy (CRDocHandler *a_this) ;
298 #endif /*__CR_DOC_HANDLER_H__*/