sp-style-elem.cpp revision 34bbe9388eab58e6a7ab25d664595e0ed3b8dee8
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelenstatic void sp_style_elem_init(SPStyleElem *style_elem);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freestatic void sp_style_elem_class_init(SPStyleElemClass *klass);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freestatic void sp_style_elem_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freestatic void sp_style_elem_set(SPObject *object, unsigned const key, gchar const *const value);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freestatic void sp_style_elem_read_content(SPObject *);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freestatic Inkscape::XML::Node *sp_style_elem_write(SPObject *, Inkscape::XML::Node *, guint flags);
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen (GClassInitFunc) sp_style_elem_class_init,
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen type = g_type_register_static(SP_TYPE_OBJECT, "SPStyleElem", &info, (GTypeFlags) 0);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freesp_style_elem_class_init(SPStyleElemClass *klass)
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT);
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen klass->read_content = sp_style_elem_read_content;
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freesp_style_elem_set(SPObject *object, unsigned const key, gchar const *const value)
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen SPStyleElem &style_elem = *SP_STYLE_ELEM(object);
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen /* TODO: `type' attribute is required. Give error message as per
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. */
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free /* fixme: determine what whitespace is allowed. Will probably need to ask on SVG
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free * list; though the relevant RFC may give info on its lexer. */
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free style_elem.is_css = ( g_ascii_strncasecmp(value, "text/css", 8) == 0
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free#if 0 /* unfinished */
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free /* title is ignored. */
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelenchild_add_rm_cb(Inkscape::XML::Node *, Inkscape::XML::Node *, Inkscape::XML::Node *,
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free sp_style_elem_read_content(static_cast<SPObject *>(data));
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freecontent_changed_cb(Inkscape::XML::Node *, gchar const *, gchar const *,
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen sp_style_elem_read_content(static_cast<SPObject *>(data));
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freechild_order_changed_cb(Inkscape::XML::Node *, Inkscape::XML::Node *,
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free sp_style_elem_read_content(static_cast<SPObject *>(data));
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freesp_style_elem_write(SPObject *const object, Inkscape::XML::Node *repr, guint const flags)
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free SPStyleElem &style_elem = *SP_STYLE_ELEM(object);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_warning("nyi: Forming <style> content for SP_OBJECT_WRITE_BUILD.");
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free /* fixme: Consider having the CRStyleSheet be a member of SPStyleElem, and then
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free pretty-print to a string s, then repr->addChild(sp_repr_new_text(s), NULL). */
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free /* todo: media */
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen ((SPObjectClass *) parent_class)->write(object, repr, flags);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free/** Returns the concatenation of the content of the text children of the specified object. */
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freeconcat_children(Inkscape::XML::Node const &repr)
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free // effic: 0 is just to catch bugs. Increase to something reasonable.
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free for (Inkscape::XML::Node const *rch = repr.firstChild(); rch != NULL; rch = rch->next()) {
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free/* Callbacks for SAC-style libcroco parser. */
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-freeenum StmtType { NO_STMT, FONT_FACE_STMT, NORMAL_RULESET_STMT };
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free static unsigned const ParseTmp_magic = 0x23474397; // from /dev/urandom
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen ParseTmp(CRStyleSheet *const stylesheet) :
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free bool hasMagic() const {
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_return_if_fail(a_handler->app_data != NULL);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free ParseTmp &parse_tmp = *static_cast<ParseTmp *>(a_handler->app_data);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_warning("Expecting currStmt==NULL and stmtType==0 (NO_STMT) at start of ruleset, but found currStmt=%p, stmtType=%u",
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free static_cast<void *>(parse_tmp.currStmt), unsigned(parse_tmp.stmtType));
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free // fixme: Check whether we need to unref currStmt if non-NULL.
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free CRStatement *ruleset = cr_statement_new_ruleset(parse_tmp.stylesheet, a_sel_list, NULL, NULL);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_return_if_fail(ruleset && ruleset->type == RULESET_STMT);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_return_if_fail(a_handler->app_data != NULL);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free ParseTmp &parse_tmp = *static_cast<ParseTmp *>(a_handler->app_data);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free CRStatement *const ruleset = parse_tmp.currStmt;
94bd7adc978850d91de1a92a8b5c05d01162a74cJohan B. C. Engelen && ruleset->kind.ruleset->sel_list == a_sel_list)
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free parse_tmp.stylesheet->statements = cr_statement_append(parse_tmp.stylesheet->statements,
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_warning("Found stmtType=%u, stmt=%p, stmt.type=%u, ruleset.sel_list=%p, a_sel_list=%p.",
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_return_if_fail(a_handler->app_data != NULL);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free ParseTmp &parse_tmp = *static_cast<ParseTmp *>(a_handler->app_data);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free if (parse_tmp.stmtType != NO_STMT || parse_tmp.currStmt != NULL) {
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_warning("Expecting currStmt==NULL and stmtType==0 (NO_STMT) at start of @font-face, but found currStmt=%p, stmtType=%u",
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free static_cast<void *>(parse_tmp.currStmt), unsigned(parse_tmp.stmtType));
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free // fixme: Check whether we need to unref currStmt if non-NULL.
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_return_if_fail(a_handler->app_data != NULL);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free ParseTmp &parse_tmp = *static_cast<ParseTmp *>(a_handler->app_data);
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free if (parse_tmp.stmtType != FONT_FACE_STMT || parse_tmp.currStmt != NULL) {
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free g_warning("Expecting currStmt==NULL and stmtType==1 (FONT_FACE_STMT) at end of @font-face, but found currStmt=%p, stmtType=%u",
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free static_cast<void *>(parse_tmp.currStmt), unsigned(parse_tmp.stmtType));
895229950881e4c5be06fc7999ed0ef9aea62e92tavmjong-free // fixme: Check whether we need to unref currStmt if non-NULL.
* http://www.w3.org/TR/REC-CSS2/cascade.html#cascade says that "The author specifies style
errors/warnings/unsupported features of the current document. */