Beispiel #1
0
static void
start_media (CRDocHandler * a_this, 
             GList * a_media_list,
             CRParsingLocation *a_location)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;
        GList *media_list = NULL;

        (void) a_location;

        g_return_if_fail (a_this);
	ctxtptr = &ctxt;
        status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);
        g_return_if_fail (status == CR_OK && ctxt);

        g_return_if_fail (ctxt
                          && ctxt->cur_stmt == NULL
                          && ctxt->cur_media_stmt == NULL
                          && ctxt->stylesheet);
        if (a_media_list) {
                /*duplicate the media_list */
                media_list = cr_utils_dup_glist_of_cr_string 
                        (a_media_list);
        }
        ctxt->cur_media_stmt =
                cr_statement_new_at_media_rule
                (ctxt->stylesheet, NULL, media_list);

}
Beispiel #2
0
static void
import_style (CRDocHandler * a_this, 
              GList * a_media_list,
              CRString * a_uri, 
              CRString * a_uri_default_ns,
              CRParsingLocation *a_location)
{
        enum CRStatus status = CR_OK;
        CRString *uri = NULL;
        CRStatement *stmt = NULL,
                *stmt2 = NULL;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;
        GList *media_list = NULL ;

        g_return_if_fail (a_this);
	ctxtptr = &ctxt;
        status = cr_doc_handler_get_ctxt (a_this, (gpointer *) ctxtptr);
        g_return_if_fail (status == CR_OK && ctxt);
        g_return_if_fail (ctxt->stylesheet);

        uri = cr_string_dup (a_uri) ;
        if (a_media_list)
                media_list = cr_utils_dup_glist_of_cr_string (a_media_list) ;
        stmt = cr_statement_new_at_import_rule
                (ctxt->stylesheet, uri, media_list, NULL);
        if (!stmt)
                goto error;

        if (ctxt->cur_stmt) {
                stmt2 = cr_statement_append (ctxt->cur_stmt, stmt);
                if (!stmt2)
                        goto error;
                ctxt->cur_stmt = stmt2;
                stmt2 = NULL;
                stmt = NULL;
        } else {
                stmt2 = cr_statement_append (ctxt->stylesheet->statements,
                                             stmt);
                if (!stmt2)
                        goto error;
                ctxt->stylesheet->statements = stmt2;
                stmt2 = NULL;
                stmt = NULL;
        }

        return;

      error:
        if (uri) {
                cr_string_destroy (uri);
        }

        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        }
        a_uri_default_ns = NULL; /*keep compiler happy */
}