1/* -*- Mode: C; indent-tabs-mode: ni; 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 37G_BEGIN_DECLS 38 39 40typedef struct _CRDocHandler CRDocHandler ; 41 42struct _CRDocHandlerPriv ; 43typedef struct _CRDocHandlerPriv 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 */ 53struct _CRDocHandler 54{ 55 CRDocHandlerPriv *priv ; 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 105 void (*import_style_result) (CRDocHandler *a_this, 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 */ 119 void (*namespace_declaration) (CRDocHandler *a_this, 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 *@parap 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 275CRDocHandler * cr_doc_handler_new (void) ; 276 277enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ; 278 279enum CRStatus cr_doc_handler_get_result (CRDocHandler *a_this, gpointer * a_result) ; 280 281enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ; 282 283enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler *a_this, gpointer * a_ctxt) ; 284 285enum CRStatus cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ; 286 287void cr_doc_handler_associate_a_parser (CRDocHandler *a_this, 288 gpointer a_parser) ; 289 290void cr_doc_handler_ref (CRDocHandler *a_this) ; 291 292gboolean cr_doc_handler_unref (CRDocHandler *a_this) ; 293 294void cr_doc_handler_destroy (CRDocHandler *a_this) ; 295 296G_END_DECLS 297 298#endif /*__CR_DOC_HANDLER_H__*/ 299