Libcroco
cr-doc-handler.h
Go to the documentation of this file.
1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2 
3 /*
4  * This file is part of The Croco Library
5  *
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.
9  *
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.
14  *
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
18  * USA
19  *
20  * See the COPYRIGHTS file for copyright information.
21  */
22 
23 #ifndef __CR_DOC_HANDLER_H__
24 #define __CR_DOC_HANDLER_H__
25 
26 /**
27  *@file
28  *The declaration of the #CRDocumentHandler class.
29  *This class is actually the parsing events handler.
30  */
31 
32 #include <glib.h>
33 #include "cr-utils.h"
34 #include "cr-input.h"
35 #include "cr-stylesheet.h"
36 
37 G_BEGIN_DECLS
38 
39 
40 typedef struct _CRDocHandler CRDocHandler ;
41 
42 struct _CRDocHandlerPriv ;
44 
45 
46 /**
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.
52  */
54 {
56 
57  /**
58  *This pointer is to be used by the application for
59  *it custom needs. It is there to extend the doc handler.
60  */
61  gpointer app_data ;
62 
63  /**
64  *Is called at the beginning of the parsing of the document.
65  *@param a_this a pointer to the current instance of
66  *#CRDocHandler.
67  */
68  void (*start_document) (CRDocHandler *a_this) ;
69 
70  /**
71  *Is called to notify the end of the parsing of the document.
72  *@param a_this a pointer to the current instance of
73  *#CRDocHandler.
74  */
75  void (*end_document) (CRDocHandler *a_this) ;
76 
77  /**
78  *Is called to notify an at charset rule.
79  *@param a_this the document handler.
80  *@param a_charset the declared charset.
81  */
82  void (*charset) (CRDocHandler *a_this,
83  CRString *a_charset,
84  CRParsingLocation *a_charset_sym_location) ;
85 
86  /**
87  *Is called to notify an import statement in
88  *the stylesheet.
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'
96  *keyword.
97  *of the imported style sheet.
98  */
99  void (*import_style) (CRDocHandler *a_this,
100  GList *a_media_list,
101  CRString *a_uri,
102  CRString *a_uri_default_ns,
103  CRParsingLocation *a_location) ;
104 
106  GList *a_media_list,
107  CRString *a_uri,
108  CRString *a_uri_default_ns,
109  CRStyleSheet *a_sheet) ;
110 
111  /**
112  *Is called to notify a namespace declaration.
113  *Not used yet.
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.
118  */
120  CRString *a_prefix,
121  CRString *a_uri,
122  CRParsingLocation *a_location) ;
123 
124  /**
125  *Is called to notify a comment.
126  *@param a_this a pointer to the current instance
127  *of #CRDocHandler.
128  *@param a_comment the comment.
129  */
130  void (*comment) (CRDocHandler *a_this,
131  CRString *a_comment) ;
132 
133  /**
134  *Is called to notify the beginning of a rule
135  *statement.
136  *@param a_this the current instance of #CRDocHandler.
137  *@param a_selector_list the list of selectors that precedes
138  *the rule declarations.
139  */
140  void (*start_selector) (CRDocHandler * a_this,
141  CRSelector *a_selector_list) ;
142 
143  /**
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() ;
149  */
150  void (*end_selector) (CRDocHandler *a_this,
151  CRSelector *a_selector_list) ;
152 
153 
154  /**
155  *Is called to notify a declaration.
156  *@param a_this a pointer to the current instance
157  *of #CRDocHandler.
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.
163  *
164  */
165  void (*property) (CRDocHandler *a_this,
166  CRString *a_name,
167  CRTerm *a_expression,
168  gboolean a_is_important) ;
169  /**
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.
175  *
176  *@param a_this a pointer to the current instance of
177  *#CRDocHandler.
178  *@param a_location the parsing location of the "\@font-face"
179  *keyword.
180  */
181  void (*start_font_face) (CRDocHandler *a_this,
182  CRParsingLocation *a_location) ;
183 
184  /**
185  *Is called to notify the end of a font face statement.
186  *@param a_this a pointer to the current instance of
187  *#CRDocHandler.
188  */
189  void (*end_font_face) (CRDocHandler *a_this) ;
190 
191 
192  /**
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()
197  *event.
198  *@param a_this a pointer to the current instance of
199  *#CRDocHandler.
200  *@param a_media_list a double linked list of
201  #CRString * objects.
202  *Each CRString objects is actually a destination media for
203  *the style information.
204  */
205  void (*start_media) (CRDocHandler *a_this,
206  GList *a_media_list,
207  CRParsingLocation *a_location) ;
208 
209  /**
210  *Is called to notify the end of a media statement.
211  *@param a_this a pointer to the current instance
212  *of #CRDocHandler.
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.
216  */
217  void (*end_media) (CRDocHandler *a_this,
218  GList *a_media_list) ;
219 
220  /**
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
225  *start_page() event.
226  *@param a_this a pointer to the current instance of
227  *#CRDocHandler.
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.
231  */
232  void (*start_page) (CRDocHandler *a_this,
233  CRString *a_name,
234  CRString *a_pseudo_page,
235  CRParsingLocation *a_location) ;
236 
237  /**
238  *Is called to notify the end of a page statement.
239  *@param a_this a pointer to the current instance of
240  *#CRDocHandler.
241  *@param a_name the name of the page (if any, null otherwise).
242  *@param a_pseudo_page the pseudo page (if any, null otherwise).
243  */
244  void (*end_page) (CRDocHandler *a_this,
245  CRString *a_name,
246  CRString *pseudo_page) ;
247 
248  /**
249  *Is Called to notify an unknown at-rule not supported
250  *by this parser.
251  */
252  void (*ignorable_at_rule) (CRDocHandler *a_this,
253  CRString *a_name) ;
254 
255  /**
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.
261  */
262  void (*error) (CRDocHandler *a_this) ;
263 
264  /**
265  *Is called to notify an unrecoverable parsing error.
266  *This is the place to put emergency routines that free allocated
267  *resources.
268  */
269  void (*unrecoverable_error) (CRDocHandler *a_this) ;
270 
271  gboolean resolve_import ;
272  gulong ref_count ;
273 } ;
274 
276 
277 enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ;
278 
279 enum CRStatus cr_doc_handler_get_result (CRDocHandler const *a_this, gpointer * a_result) ;
280 
281 enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ;
282 
283 enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler const *a_this, gpointer * a_ctxt) ;
284 
286 
288  gpointer a_parser) ;
289 
290 void cr_doc_handler_ref (CRDocHandler *a_this) ;
291 
292 gboolean cr_doc_handler_unref (CRDocHandler *a_this) ;
293 
294 void cr_doc_handler_destroy (CRDocHandler *a_this) ;
295 
296 G_END_DECLS
297 
298 #endif /*__CR_DOC_HANDLER_H__*/
_CRDocHandler::end_page
void(* end_page)(CRDocHandler *a_this, CRString *a_name, CRString *pseudo_page)
Is called to notify the end of a page statement.
Definition: cr-doc-handler.h:244
_CRDocHandler::import_style_result
void(* import_style_result)(CRDocHandler *a_this, GList *a_media_list, CRString *a_uri, CRString *a_uri_default_ns, CRStyleSheet *a_sheet)
Definition: cr-doc-handler.h:105
_CRDocHandler::property
void(* property)(CRDocHandler *a_this, CRString *a_name, CRTerm *a_expression, gboolean a_is_important)
Is called to notify a declaration.
Definition: cr-doc-handler.h:165
_CRDocHandler::unrecoverable_error
void(* unrecoverable_error)(CRDocHandler *a_this)
Is called to notify an unrecoverable parsing error.
Definition: cr-doc-handler.h:269
cr-input.h
cr_doc_handler_get_result
enum CRStatus cr_doc_handler_get_result(CRDocHandler const *a_this, gpointer *a_result)
cr_doc_handler_get_result: @a_this: the current instance of CRDocHandler @a_result: out parameter.
Definition: cr-doc-handler.c:141
_CRDocHandler::resolve_import
gboolean resolve_import
Definition: cr-doc-handler.h:271
_CRStyleSheet
An abstraction of a css stylesheet as defined by the css2 spec in chapter 4.
Definition: cr-stylesheet.h:57
_CRDocHandler::app_data
gpointer app_data
This pointer is to be used by the application for it custom needs.
Definition: cr-doc-handler.h:61
_CRDocHandler::charset
void(* charset)(CRDocHandler *a_this, CRString *a_charset, CRParsingLocation *a_charset_sym_location)
Is called to notify an at charset rule.
Definition: cr-doc-handler.h:82
_CRDocHandler::namespace_declaration
void(* namespace_declaration)(CRDocHandler *a_this, CRString *a_prefix, CRString *a_uri, CRParsingLocation *a_location)
Is called to notify a namespace declaration.
Definition: cr-doc-handler.h:119
cr_doc_handler_new
CRDocHandler * cr_doc_handler_new(void)
cr_doc_handler_new: Constructor of CRDocHandler.
Definition: cr-doc-handler.c:70
cr_doc_handler_set_result
enum CRStatus cr_doc_handler_set_result(CRDocHandler *a_this, gpointer a_result)
cr_doc_handler_set_result: @a_this: the current instance of CRDocHandler @a_result: the new result.
Definition: cr-doc-handler.c:161
_CRDocHandler::priv
CRDocHandlerPriv * priv
Definition: cr-doc-handler.h:55
CRString
typedefG_BEGIN_DECLS struct _CRString CRString
Definition: cr-string.h:37
_CRDocHandler::comment
void(* comment)(CRDocHandler *a_this, CRString *a_comment)
Is called to notify a comment.
Definition: cr-doc-handler.h:130
CRDocHandler
typedefG_BEGIN_DECLS struct _CRDocHandler CRDocHandler
Definition: cr-doc-handler.h:40
_CRDocHandler::start_font_face
void(* start_font_face)(CRDocHandler *a_this, CRParsingLocation *a_location)
Is called to notify the start of a font face statement.
Definition: cr-doc-handler.h:181
_CRDocHandler::end_font_face
void(* end_font_face)(CRDocHandler *a_this)
Is called to notify the end of a font face statement.
Definition: cr-doc-handler.h:189
_CRDocHandler
The SAC document handler.
Definition: cr-doc-handler.h:53
cr-stylesheet.h
cr_doc_handler_ref
void cr_doc_handler_ref(CRDocHandler *a_this)
cr_doc_handler_ref: @a_this: the current instance of CRDocHandler.
Definition: cr-doc-handler.c:210
_CRDocHandler::start_document
void(* start_document)(CRDocHandler *a_this)
Is called at the beginning of the parsing of the document.
Definition: cr-doc-handler.h:68
_CRDocHandler::end_document
void(* end_document)(CRDocHandler *a_this)
Is called to notify the end of the parsing of the document.
Definition: cr-doc-handler.h:75
cr_doc_handler_associate_a_parser
void cr_doc_handler_associate_a_parser(CRDocHandler *a_this, gpointer a_parser)
cr_doc_handler_associate_a_parser: Associates a parser to the current document handler
Definition: cr-doc-handler.c:269
_CRDocHandler::start_page
void(* start_page)(CRDocHandler *a_this, CRString *a_name, CRString *a_pseudo_page, CRParsingLocation *a_location)
Is called to notify the beginning of a page statement.
Definition: cr-doc-handler.h:232
_CRParsingLocation
Definition: cr-parsing-location.h:39
cr_doc_handler_get_ctxt
enum CRStatus cr_doc_handler_get_ctxt(CRDocHandler const *a_this, gpointer *a_ctxt)
cr_doc_handler_get_ctxt: @a_this: the current instance of CRDocHandler.
Definition: cr-doc-handler.c:104
cr_doc_handler_destroy
void cr_doc_handler_destroy(CRDocHandler *a_this)
cr_doc_handler_destroy: @a_this: the instance of CRDocHandler to destroy.
Definition: cr-doc-handler.c:250
_CRDocHandler::ref_count
gulong ref_count
Definition: cr-doc-handler.h:272
_CRDocHandler::start_selector
void(* start_selector)(CRDocHandler *a_this, CRSelector *a_selector_list)
Is called to notify the beginning of a rule statement.
Definition: cr-doc-handler.h:140
cr_doc_handler_set_default_sac_handler
enum CRStatus cr_doc_handler_set_default_sac_handler(CRDocHandler *a_this)
cr_doc_handler_set_default_sac_handler: @a_this: a pointer to the current instance of CRDocHandler.
Definition: cr-doc-handler.c:181
_CRDocHandler::start_media
void(* start_media)(CRDocHandler *a_this, GList *a_media_list, CRParsingLocation *a_location)
Is called to notify the beginning of a media statement.
Definition: cr-doc-handler.h:205
_CRDocHandler::end_selector
void(* end_selector)(CRDocHandler *a_this, CRSelector *a_selector_list)
Is called to notify the end of a rule statement.
Definition: cr-doc-handler.h:150
_CRDocHandler::import_style
void(* import_style)(CRDocHandler *a_this, GList *a_media_list, CRString *a_uri, CRString *a_uri_default_ns, CRParsingLocation *a_location)
Is called to notify an import statement in the stylesheet.
Definition: cr-doc-handler.h:99
_CRTerm
An abstraction of a css2 term as defined in the CSS2 spec in appendix D.1: term ::= [ NUMBER S* | PER...
Definition: cr-term.h:82
CRStatus
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
CRSelector
typedefG_BEGIN_DECLS struct _CRSelector CRSelector
Definition: cr-selector.h:40
cr-utils.h
_CRDocHandler::error
void(* error)(CRDocHandler *a_this)
Is called to notify a parsing error.
Definition: cr-doc-handler.h:262
cr_doc_handler_unref
gboolean cr_doc_handler_unref(CRDocHandler *a_this)
cr_doc_handler_unref: @a_this: the currrent instance of CRDocHandler.
Definition: cr-doc-handler.c:227
_CRDocHandler::ignorable_at_rule
void(* ignorable_at_rule)(CRDocHandler *a_this, CRString *a_name)
Is Called to notify an unknown at-rule not supported by this parser.
Definition: cr-doc-handler.h:252
_CRDocHandler::end_media
void(* end_media)(CRDocHandler *a_this, GList *a_media_list)
Is called to notify the end of a media statement.
Definition: cr-doc-handler.h:217
cr_doc_handler_set_ctxt
enum CRStatus cr_doc_handler_set_ctxt(CRDocHandler *a_this, gpointer a_ctxt)
cr_doc_handler_set_ctxt: @a_this: the current instance of CRDocHandler @a_ctxt: a pointer to the pars...
Definition: cr-doc-handler.c:123
_CRDocHandlerPriv
Definition: cr-doc-handler.c:38