cr-doc-handler.h

Go to the documentation of this file.
00001 /* -*- Mode: C; indent-tabs-mode: ni; c-basic-offset: 8 -*- */
00002 
00003 /*
00004  * This file is part of The Croco Library
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of version 2.1 of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00018  * USA
00019  *
00020  * See the COPYRIGHTS file for copyright information.
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-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, 
00083                          CRString *a_charset,
00084                          CRParsingLocation *a_charset_sym_location) ;
00085 
00086         /**
00087          *Is called to notify an import statement in 
00088          *the stylesheet.
00089          *@param a_this the current instance of #CRDocHandler.
00090          *@param a_media_list a doubly linked list of GString objects.
00091          *Each GString object contains a string which is the
00092          *destination media for style information.
00093          *@param a_uri the uri of the imported style sheet.
00094          *@param a_uri_default_ns the default namespace of URI
00095          *@param a_location the parsing location of the '@import' 
00096          *keyword.
00097          *of the imported style sheet.
00098          */
00099         void (*import_style) (CRDocHandler *a_this,
00100                               GList *a_media_list,
00101                               CRString *a_uri,
00102                               CRString *a_uri_default_ns,
00103                               CRParsingLocation *a_location) ;
00104 
00105         void (*import_style_result) (CRDocHandler *a_this,
00106                                      GList *a_media_list,
00107                                      CRString *a_uri,
00108                                      CRString *a_uri_default_ns,
00109                                      CRStyleSheet *a_sheet) ;
00110 
00111         /**
00112          *Is called to notify a namespace declaration.
00113          *Not used yet.
00114          *@param a_this the current instance of #CRDocHandler.
00115          *@param a_prefix the prefix of the namespace.
00116          *@param a_uri the uri of the namespace.
00117          *@param a_location the location of the "@namespace" keyword.
00118          */
00119         void (*namespace_declaration) (CRDocHandler *a_this,
00120                                        CRString *a_prefix,
00121                                        CRString *a_uri,
00122                                        CRParsingLocation *a_location) ;
00123                 
00124         /**
00125          *Is called to notify a comment.
00126          *@param a_this a pointer to the current instance
00127          *of #CRDocHandler.
00128          *@param a_comment the comment.
00129          */
00130         void (*comment) (CRDocHandler *a_this,
00131                          CRString *a_comment) ;
00132 
00133         /**
00134          *Is called to notify the beginning of a rule
00135          *statement.
00136          *@param a_this the current instance of #CRDocHandler.
00137          *@param a_selector_list the list of selectors that precedes
00138          *the rule declarations.
00139          */
00140         void (*start_selector) (CRDocHandler * a_this,
00141                                 CRSelector *a_selector_list) ;
00142 
00143         /**
00144          *Is called to notify the end of a rule statement.
00145          *@param a_this the current instance of #CRDocHandler.
00146          *@param a_selector_list the list of selectors that precedes
00147          *the rule declarations. This pointer is the same as
00148          *the one passed to start_selector() ;
00149          */
00150         void (*end_selector) (CRDocHandler *a_this,
00151                               CRSelector *a_selector_list) ;
00152 
00153 
00154         /**
00155          *Is called to notify a declaration.
00156          *@param a_this a pointer to the current instance
00157          *of #CRDocHandler.
00158          *@param a_name the name of the parsed property.
00159          *@param a_expression a css expression that represents
00160          *the value of the property. A css expression is
00161          *actually a linked list of 'terms'. Each term can
00162          *be linked to other using operators.
00163          *
00164          */
00165         void (*property) (CRDocHandler *a_this,
00166                           CRString *a_name,
00167                           CRTerm *a_expression,
00168                           gboolean a_is_important) ;
00169         /**
00170          *Is called to notify the start of a font face statement.
00171          *The parser invokes this method at the beginning of every
00172          *font face statement in the style sheet. There will
00173          *be a corresponding end_font_face () event for every
00174          *start_font_face () event.
00175          *
00176          *@param a_this a pointer to the current instance of
00177          *#CRDocHandler.
00178          *@param a_location the parsing location of the "@font-face"
00179          *keyword.
00180          */
00181         void (*start_font_face) (CRDocHandler *a_this,
00182                                  CRParsingLocation *a_location) ;
00183 
00184         /**
00185          *Is called to notify the end of a font face statement.
00186          *@param a_this a pointer to the current instance of
00187          *#CRDocHandler.
00188          */
00189         void (*end_font_face) (CRDocHandler *a_this) ;
00190 
00191 
00192         /**
00193          *Is called to notify the beginning of a media statement.
00194          *The parser will invoke this method at the beginning of
00195          *every media statement in the style sheet. There will be
00196          *a corresponding end_media() event for every start_media()
00197          *event.
00198          *@param a_this a pointer to the current instance of 
00199          *#CRDocHandler.
00200          *@param a_media_list a double linked list of 
00201          #CRString * objects.
00202          *Each CRString objects is actually a destination media for
00203          *the style information.
00204          */
00205         void (*start_media) (CRDocHandler *a_this,
00206                              GList *a_media_list,
00207                              CRParsingLocation *a_location) ;
00208 
00209         /**
00210          *Is called to notify the end of a media statement.
00211          *@param a_this a pointer to the current instance
00212          *of #CRDocHandler.
00213          *@param a_media_list a double linked list of GString * objects.
00214          *Each GString objects is actually a destination media for
00215          *the style information.
00216          */
00217         void (*end_media) (CRDocHandler *a_this,
00218                            GList *a_media_list) ;
00219 
00220         /**
00221          *Is called to notify the beginning of a page statement.
00222          *The parser invokes this function at the beginning of
00223          *every page statement in the style sheet. There will be
00224          *a corresponding end_page() event for every single 
00225          *start_page() event.
00226          *@param a_this a pointer to the current instance of
00227          *#CRDocHandler.
00228          *@param a_name the name of the page (if any, null otherwise).
00229          *@param a_pseudo_page the pseudo page (if any, null otherwise).
00230          *@param a_location the parsing location of the "@page" keyword.
00231          */
00232         void (*start_page) (CRDocHandler *a_this,
00233                             CRString *a_name, 
00234                             CRString *a_pseudo_page,
00235                             CRParsingLocation *a_location) ;
00236 
00237         /**
00238          *Is called to notify the end of a page statement.
00239          *@param a_this a pointer to the current instance of
00240          *#CRDocHandler.
00241          *@param a_name the name of the page (if any, null otherwise).
00242          *@parap a_pseudo_page the pseudo page (if any, null otherwise).
00243          */
00244         void (*end_page) (CRDocHandler *a_this,
00245                           CRString *a_name,
00246                           CRString *pseudo_page) ;
00247                 
00248         /**
00249          *Is Called to notify an unknown at-rule not supported
00250          *by this parser.
00251          */
00252         void (*ignorable_at_rule) (CRDocHandler *a_this,
00253                                    CRString *a_name) ;
00254 
00255         /**
00256          *Is called to notify a parsing error. After this error
00257          *the application must ignore the rule being parsed, if
00258          *any. After completion of this callback, 
00259          *the parser will then try to resume the parsing,
00260          *ignoring the current error.
00261          */
00262         void (*error) (CRDocHandler *a_this) ;
00263 
00264         /**
00265          *Is called to notify an unrecoverable parsing error.
00266          *This is the place to put emergency routines that free allocated
00267          *resources.
00268          */
00269         void (*unrecoverable_error) (CRDocHandler *a_this) ;
00270 
00271         gboolean resolve_import ;
00272         gulong ref_count ;
00273 } ;
00274 
00275 CRDocHandler * cr_doc_handler_new (void) ;
00276 
00277 enum CRStatus cr_doc_handler_set_result (CRDocHandler *a_this, gpointer a_result) ;
00278 
00279 enum CRStatus cr_doc_handler_get_result (CRDocHandler *a_this, gpointer * a_result) ;
00280 
00281 enum CRStatus cr_doc_handler_set_ctxt (CRDocHandler *a_this, gpointer a_ctxt) ;
00282 
00283 enum CRStatus cr_doc_handler_get_ctxt (CRDocHandler *a_this, gpointer * a_ctxt) ;
00284 
00285 enum CRStatus cr_doc_handler_set_default_sac_handler (CRDocHandler *a_this) ;
00286 
00287 void cr_doc_handler_associate_a_parser (CRDocHandler *a_this,
00288                                         gpointer a_parser) ;
00289 
00290 void cr_doc_handler_ref (CRDocHandler *a_this) ;
00291 
00292 gboolean cr_doc_handler_unref (CRDocHandler *a_this) ;
00293 
00294 void cr_doc_handler_destroy (CRDocHandler *a_this) ;
00295 
00296 G_END_DECLS
00297 
00298 #endif /*__CR_DOC_HANDLER_H__*/

Generated on Thu Mar 9 19:19:08 2006 for Libcroco by  doxygen 1.4.6