00001 /* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */ 00002 00003 /* 00004 * This file is part of The Croco Library 00005 * 00006 * Copyright (C) 2002-2003 Dodji Seketeli <dodji@seketeli.org> 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of version 2.1 of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 */ 00022 00023 #ifndef __CR_DOC_HANDLER_H__ 00024 #define __CR_DOC_HANDLER_H__ 00025 00026 /** 00027 *@file 00028 *The declaration of the #CRDocumentHandler class. 00029 *This class is actually the parsing events handler. 00030 */ 00031 00032 #include <glib.h> 00033 #include "cr-utils.h" 00034 #include "cr-parser-input.h" 00035 #include "cr-stylesheet.h" 00036 00037 G_BEGIN_DECLS 00038 00039 00040 typedef struct _CRDocHandler CRDocHandler ; 00041 00042 struct _CRDocHandlerPriv ; 00043 typedef struct _CRDocHandlerPriv CRDocHandlerPriv ; 00044 00045 00046 /** 00047 *The SAC document handler. 00048 *An instance of this class is to 00049 *be passed to a parser. Then, during the parsing 00050 *the parser calls the convenient function pointer 00051 *whenever a particular event (a css construction) occurs. 00052 */ 00053 struct _CRDocHandler 00054 { 00055 CRDocHandlerPriv *priv ; 00056 00057 /** 00058 *This pointer is to be used by the application for 00059 *it custom needs. It is there to extend the doc handler. 00060 */ 00061 gpointer app_data ; 00062 00063 /** 00064 *Is called at the beginning of the parsing of the document. 00065 *@param a_this a pointer to the current instance of 00066 *#CRDocHandler. 00067 */ 00068 void (*start_document) (CRDocHandler *a_this) ; 00069 00070 /** 00071 *Is called to notify the end of the parsing of the document. 00072 *@param a_this a pointer to the current instance of 00073 *#CRDocHandler. 00074 */ 00075 void (*end_document) (CRDocHandler *a_this) ; 00076 00077 /** 00078 *Is called to notify an at charset rule. 00079 *@param a_this the document handler. 00080 *@param a_charset the declared charset. 00081 */ 00082 void (*charset) (CRDocHandler *a_this, GString *a_charset) ; 00083 00084 /** 00085 *Is called to notify an import statement in 00086 *the stylesheet. 00087 *@param a_this the current instance of #CRDocHandler. 00088 *@param a_media_list a doubly linked list of GString objects. 00089 *Each GString object contains a string which is the 00090 *destination media for style information. 00091 *@param a_uri the uri of the imported style sheet. 00092 *@param a_uri_default_ns the default namespace of URI 00093 *of the imported style sheet. 00094 */ 00095 void (*import_style) (CRDocHandler *a_this, 00096 GList *a_media_list, 00097 GString *a_uri, 00098 GString *a_uri_default_ns) ; 00099 00100 void (*import_style_result) (CRDocHandler *a_this, 00101 GList *a_media_list, 00102 GString *a_uri, 00103 GString *a_uri_default_ns, 00104 CRStyleSheet *a_sheet) ; 00105 00106 /** 00107 *Is called to notify a namespace declaration. 00108 *Not used yet. 00109 *@param a_this the current instance of #CRDocHandler. 00110 *@param a_prefix the prefix of the namespace. 00111 *@param a_uri the uri of the namespace. 00112 */ 00113 void (*namespace_declaration) (CRDocHandler *a_this, 00114 GString *a_prefix, 00115 GString *a_uri) ; 00116 00117 /** 00118 *Is called to notify a comment. 00119 *@param a_this a pointer to the current instance 00120 *of #CRDocHandler. 00121 *@param a_comment the comment. 00122 */ 00123 void (*comment) (CRDocHandler *a_this, 00124 GString *a_comment) ; 00125 00126 /** 00127 *Is called to notify the beginning of a rule 00128 *statement. 00129 *@param a_this the current instance of #CRDocHandler. 00130 *@param a_selector_list the list of selectors that precedes 00131 *the rule declarations. The GList named a_selector_list 00132 *is a chained list of instances of #CRSimpleSel 00133 * 00134 */ 00135 void (*start_selector) (CRDocHandler * a_this, 00136 CRSelector *a_selector_list) ; 00137 00138 /** 00139 *Is called to notify the end of a rule statement. 00140 *@param a_this the current instance of #CRDocHandler. 00141 *@param a_selector_list the list of selectors that precedes 00142 *the rule declarations. This pointer is the same as 00143 *the one passed to start_selector() ; 00144 */ 00145 void (*end_selector) (CRDocHandler *a_this, 00146 CRSelector *a_selector_list) ; 00147 00148 00149 /** 00150 *Is called to notify a declaration. 00151 *@param a_this a pointer to the current instance 00152 *of #CRDocHandler. 00153 *@param a_name the name of the parsed property. 00154 *@param a_expression a css expression that represents 00155 *the value of the property. A css expression is 00156 *actually a linked list of 'terms'. Each term can 00157 *be linked to other using operators. 00158 * 00159 */ 00160 void (*property) (CRDocHandler *a_this, 00161 GString *a_name, 00162 CRTerm *a_expression) ; 00163 00164 /** 00165 *Is called to notify the start of a font face statement. 00166 *The parser invokes this method at the beginning of every 00167 *font face statement in the style sheet. There will 00168 *be a corresponding end_font_face () event for every 00169 *start_font_face () event. 00170 * 00171 *@param a_this a pointer to the current instance of 00172 *#CRDocHandler. 00173 */ 00174 void (*start_font_face) (CRDocHandler *a_this) ; 00175 00176 /** 00177 *Is called to notify the end of a font face statement. 00178 *@param a_this a pointer to the current instance of 00179 *#CRDocHandler. 00180 */ 00181 void (*end_font_face) (CRDocHandler *a_this) ; 00182 00183 00184 /** 00185 *Is called to notify the beginning of a media statement. 00186 *The parser will invoke this method at the beginning of 00187 *every media statement in the style sheet. There will be 00188 *a corresponding end_media() event for every start_media() 00189 *event. 00190 *@param a_this a pointer to the current instance of 00191 *#CRDocHandler. 00192 *@param a_media_list a double linked list of GString * objects. 00193 *Each GString objects is actually a destination media for 00194 *the style information. 00195 */ 00196 void (*start_media) (CRDocHandler *a_this, 00197 GList *a_media_list) ; 00198 00199 /** 00200 *Is called to notify the end of a media statement. 00201 *@param a_this a pointer to the current instance 00202 *of #CRDocHandler. 00203 *@param a_media_list a double linked list of GString * objects. 00204 *Each GString objects is actually a destination media for 00205 *the style information. 00206 */ 00207 void (*end_media) (CRDocHandler *a_this, 00208 GList *a_media_list) ; 00209 00210 /** 00211 *Is called to notify the beginning of a page statement. 00212 *The parser invokes this function at the beginning of 00213 *every page statement in the style sheet. There will be 00214 *a corresponding end_page() event for every single 00215 *start_page() event. 00216 *@param a_this a pointer to the current instance of 00217 *#CRDocHandler. 00218 *@param a_name the name of the page (if any, null otherwise). 00219 *@param a_pseudo_page the pseudo page (if any, null otherwise). 00220 */ 00221 void (*start_page) (CRDocHandler *a_this, 00222 GString *a_name, 00223 GString *a_pseudo_page) ; 00224 00225 /** 00226 *Is called to notify the end of a page statement. 00227 *@param a_this a pointer to the current instance of 00228 *#CRDocHandler. 00229 *@param a_name the name of the page (if any, null otherwise). 00230 *@parap a_pseudo_page the pseudo page (if any, null otherwise). 00231 */ 00232 void (*end_page) (CRDocHandler *a_this, 00233 GString *a_name, 00234 GString *pseudo_page) ; 00235 00236 /** 00237 *Is Called to notify an unknown at-rule not supported 00238 *by this parser. 00239 */ 00240 void (*ignorable_at_rule) (CRDocHandler *a_this, 00241 GString *a_name) ; 00242 00243 /** 00244 *Is called to notify a parsing error. After this error 00245 *the application must ignore the rule being parsed, if 00246 *any. After completion of this callback, 00247 *the parser will then try to resume the parsing, 00248 *ignoring the current error. 00249 */ 00250 void (*error) (CRDocHandler *a_this) ; 00251 00252 /** 00253 *Is called to notify an unrecoverable parsing error. 00254 *This is the place to put emergency routines that free allocated 00255 *resources. 00256 */ 00257 void (*unrecoverable_error) (CRDocHandler *a_this) ; 00258 00259 gboolean resolve_import ; 00260 gulong ref_count ; 00261 } ; 00262 00263 CRDocHandler * cr_doc_handler_new (void) ; 00264 00265 enum CRStatus 00266 cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ; 00267 00268 enum CRStatus 00269 cr_doc_handler_get_result (CRDocHandler *a_this, gpointer * a_result) ; 00270 00271 enum CRStatus 00272 cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ; 00273 00274 enum CRStatus 00275 cr_doc_handler_get_ctxt (CRDocHandler *a_this, gpointer * a_ctxt) ; 00276 00277 enum CRStatus 00278 cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ; 00279 00280 void cr_doc_handler_ref (CRDocHandler *a_this) ; 00281 gboolean cr_doc_handler_unref (CRDocHandler *a_this) ; 00282 00283 void cr_doc_handler_destroy (CRDocHandler *a_this) ; 00284 00285 G_END_DECLS 00286 00287 #endif /*__CR_DOC_HANDLER_H__*/