예제 #1
0
static void
end_selector (CRDocHandler * a_this, CRSelector * a_selector_list)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;

        (void) a_selector_list;

        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->cur_stmt && ctxt->stylesheet);

        if (ctxt->cur_stmt) {
                CRStatement *stmts = NULL;

                if (ctxt->cur_media_stmt) {
                        CRAtMediaRule *media_rule = NULL;

                        media_rule = ctxt->cur_media_stmt->kind.media_rule;

                        stmts = cr_statement_append
                                (media_rule->rulesets, ctxt->cur_stmt);

                        if (!stmts) {
                                cr_utils_trace_info
                                        ("Could not append a new statement");
                                cr_statement_destroy (media_rule->rulesets);
                                ctxt->cur_media_stmt->
                                        kind.media_rule->rulesets = NULL;
                                return;
                        }
                        media_rule->rulesets = stmts;
                        ctxt->cur_stmt = NULL;
                } else {
                        stmts = cr_statement_append
                                (ctxt->stylesheet->statements,
                                 ctxt->cur_stmt);
                        if (!stmts) {
                                cr_utils_trace_info
                                        ("Could not append a new statement");
                                cr_statement_destroy (ctxt->cur_stmt);
                                ctxt->cur_stmt = NULL;
                                return;
                        }
                        ctxt->stylesheet->statements = stmts;
                        ctxt->cur_stmt = NULL;
                }

        }

        a_selector_list = NULL; /*keep compiler happy */
}
예제 #2
0
static void
end_media (CRDocHandler * a_this, GList * a_media_list)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;
        CRStatement *stmts = 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
                          && ctxt->cur_media_stmt
                          && ctxt->cur_media_stmt->type == AT_MEDIA_RULE_STMT
                          && ctxt->stylesheet);

        stmts = cr_statement_append (ctxt->stylesheet->statements,
                                     ctxt->cur_media_stmt);
        if (!stmts) {
                cr_statement_destroy (ctxt->cur_media_stmt);
                ctxt->cur_media_stmt = NULL;
        }

        ctxt->stylesheet->statements = stmts;
        stmts = NULL;

        ctxt->cur_stmt = NULL ;
        ctxt->cur_media_stmt = NULL ;
        a_media_list = NULL;
}
예제 #3
0
static void
end_page (CRDocHandler * a_this, 
          CRString * a_page, 
          CRString * a_pseudo_page)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;
        CRStatement *stmt = 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->cur_stmt
                          && ctxt->cur_stmt->type == AT_PAGE_RULE_STMT
                          && ctxt->stylesheet);

        stmt = cr_statement_append (ctxt->stylesheet->statements,
                                    ctxt->cur_stmt);

        if (stmt) {
                ctxt->stylesheet->statements = stmt;
                stmt = NULL;
                ctxt->cur_stmt = NULL;
        }

        if (ctxt->cur_stmt) {
                cr_statement_destroy (ctxt->cur_stmt);
                ctxt->cur_stmt = NULL;
        }
        a_page = NULL;          /*keep compiler happy */
        a_pseudo_page = NULL;   /*keep compiler happy */
}
예제 #4
0
static void
charset (CRDocHandler * a_this, CRString * a_charset,
         CRParsingLocation *a_location)
{
        enum CRStatus status = CR_OK;
        CRStatement *stmt = NULL,
                *stmt2 = NULL;
        CRString *charset = NULL;

        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = 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);

        charset = cr_string_dup (a_charset) ;
        stmt = cr_statement_new_at_charset_rule (ctxt->stylesheet, charset);
        g_return_if_fail (stmt);
        stmt2 = cr_statement_append (ctxt->stylesheet->statements, stmt);
        if (!stmt2) {
                if (stmt) {
                        cr_statement_destroy (stmt);
                        stmt = NULL;
                }
                if (charset) {
                        cr_string_destroy (charset);
                }
                return;
        }
        ctxt->stylesheet->statements = stmt2;
        stmt2 = NULL;
}
예제 #5
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 */
}
예제 #6
0
static void
end_font_face (CRDocHandler * a_this)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = NULL;
        CRStatement *stmts = NULL;

        g_return_if_fail (a_this);

        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->cur_stmt
                 && ctxt->cur_stmt->type == AT_FONT_FACE_RULE_STMT
                 && ctxt->stylesheet);

        stmts = cr_statement_append (ctxt->stylesheet->statements,
                                     ctxt->cur_stmt);
        if (!stmts)
                goto error;

        ctxt->stylesheet->statements = stmts;
        stmts = NULL;
        ctxt->cur_stmt = NULL;

        return;

      error:

        if (ctxt->cur_stmt) {
                cr_statement_destroy (ctxt->cur_stmt);
                ctxt->cur_stmt = NULL;
        }

        if (!stmts) {
                cr_statement_destroy (stmts);
                stmts = NULL;
        }
}
예제 #7
0
/**
 *Destructor of the #CRStyleSheet class.
 *@param a_this the current instance of the #CRStyleSheet class.
 */
void
cr_stylesheet_destroy (CRStyleSheet * a_this)
{
        g_return_if_fail (a_this);

        if (a_this->statements) {
                cr_statement_destroy (a_this->statements);
                a_this->statements = NULL;
        }
        g_free (a_this);
}
예제 #8
0
static enum CRStatus
test_cr_statement_at_page_rule_parse_from_buf (void)
{
        CRStatement *stmt = NULL ;
        
        stmt = cr_statement_at_page_rule_parse_from_buf 
                (gv_at_page_buf, CR_UTF_8) ;
        if (!stmt) {
                return CR_ERROR ;                
        }
        cr_statement_destroy (stmt) ;        
        return CR_OK ;
}
예제 #9
0
static enum CRStatus
test_cr_statement_ruleset_parse (void)
{
        CRStatement *stmt = NULL;

        stmt = cr_statement_ruleset_parse_from_buf (gv_ruleset_buf, CR_UTF_8);
        g_return_val_if_fail (stmt, CR_ERROR);

        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        }
        return CR_OK;
}
예제 #10
0
static void
destroy_context (ParsingContext * a_ctxt)
{
        g_return_if_fail (a_ctxt);

        if (a_ctxt->stylesheet) {
                cr_stylesheet_destroy (a_ctxt->stylesheet);
                a_ctxt->stylesheet = NULL;
        }
        if (a_ctxt->cur_stmt) {
                cr_statement_destroy (a_ctxt->cur_stmt);
                a_ctxt->cur_stmt = NULL;
        }
        g_free (a_ctxt);
}
예제 #11
0
static void
error (CRDocHandler * a_this)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = 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);

        if (ctxt->cur_stmt) {
                cr_statement_destroy (ctxt->cur_stmt);
                ctxt->cur_stmt = NULL;
        }
}
예제 #12
0
static void
start_page (CRDocHandler * a_this, 
            CRString * a_page, 
            CRString * a_pseudo,
            CRParsingLocation *a_location)
{
        enum CRStatus status = CR_OK;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = 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->cur_stmt == NULL);

        ctxt->cur_stmt = cr_statement_new_at_page_rule
                (ctxt->stylesheet, NULL, NULL, NULL);
        if (a_page) {
                ctxt->cur_stmt->kind.page_rule->name =
                        cr_string_dup (a_page) ;

                if (!ctxt->cur_stmt->kind.page_rule->name) {
                        goto error;
                }
        }
        if (a_pseudo) {
                ctxt->cur_stmt->kind.page_rule->pseudo =
                        cr_string_dup (a_pseudo) ;
                if (!ctxt->cur_stmt->kind.page_rule->pseudo) {
                        goto error;
                }
        }
        return;

 error:
        if (ctxt->cur_stmt) {
                cr_statement_destroy (ctxt->cur_stmt);
                ctxt->cur_stmt = NULL;
        }
}
예제 #13
0
static enum CRStatus
test_cr_statement_parse_from_buf (void)
{
        CRStatement *stmt = NULL;

        stmt = cr_statement_parse_from_buf (gv_ruleset_buf, CR_UTF_8);
        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        } else {
                return CR_ERROR;
        }
        stmt = cr_statement_parse_from_buf (gv_at_media_buf, CR_UTF_8);
        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        } else {
                return CR_ERROR;
        }
        stmt = cr_statement_parse_from_buf (gv_at_page_buf, CR_UTF_8);
        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        } else {
                return CR_ERROR;
        }
        stmt = cr_statement_parse_from_buf (gv_at_charset_buf, CR_UTF_8);
        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        } else {
                return CR_ERROR;
        }
        stmt = cr_statement_parse_from_buf (gv_at_font_face_buf, CR_UTF_8);
        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        } else {
                return CR_ERROR;
        }
        stmt = cr_statement_parse_from_buf (gv_at_import_buf, CR_UTF_8);
        if (stmt) {
                cr_statement_destroy (stmt);
                stmt = NULL;
        } else {
                return CR_ERROR;
        }

        return CR_OK;
}
예제 #14
0
static void
start_selector (CRDocHandler * a_this, CRSelector * a_selector_list)
{
        enum CRStatus status = CR_OK ;
        ParsingContext *ctxt = NULL;
        ParsingContext **ctxtptr = 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);
        if (ctxt->cur_stmt) {
                /*hmm, this should be NULL so free it */
                cr_statement_destroy (ctxt->cur_stmt);
                ctxt->cur_stmt = NULL;
        }

        ctxt->cur_stmt = cr_statement_new_ruleset
                (ctxt->stylesheet, a_selector_list, NULL, NULL);
}