Logo Search packages:      
Sourcecode: inkscape version File versions

static Inkscape::XML::Node * sp_object_private_write ( SPObject object,
Inkscape::XML::Document doc,
Inkscape::XML::Node repr,
guint  flags 
) [static]

Callback for write event.

Todo:
I'm not sure what to do in this case. Bug #1165868 suggests that it can arise, but the submitter doesn't know how to do so reliably. The main two options are either leave repr's style attribute unchanged, or explicitly clear it. Must also consider what to do with property attributes for the element; see below.

Note:
We treat object->style as authoritative. Its effects have been written to the style attribute above; any properties that are unset we take to be deliberately unset (e.g. so that clones can override the property).
Note that the below has an undesirable consequence of changing the appearance on renderers that lack CSS support (e.g. SVG tiny); possibly we should write property attributes instead of a style attribute.

Definition at line 1125 of file sp-object.cpp.

References Inkscape::XML::Node::attribute(), SPObject::collectionPolicy(), SPObject::id, SPIXmlSpace::set, Inkscape::XML::Node::setAttribute(), sp_style_unset_property_attrs(), sp_style_write_string(), sp_xml_get_space_string(), SPIXmlSpace::value, and SPObject::xml_space.

Referenced by sp_object_class_init().

{
    if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) {
        repr = SP_OBJECT_REPR(object)->duplicate(doc);
        if (!( flags & SP_OBJECT_WRITE_EXT )) {
            repr->setAttribute("inkscape:collect", NULL);
        }
    } else {
        repr->setAttribute("id", object->id);

        if (object->xml_space.set) {
            char const *xml_space;
            xml_space = sp_xml_get_space_string(object->xml_space.value);
            repr->setAttribute("xml:space", xml_space);
        }

        if ( flags & SP_OBJECT_WRITE_EXT &&
             object->collectionPolicy() == SPObject::ALWAYS_COLLECT )
        {
            repr->setAttribute("inkscape:collect", "always");
        } else {
            repr->setAttribute("inkscape:collect", NULL);
        }
 
        SPStyle const *const obj_style = SP_OBJECT_STYLE(object);
        if (obj_style) {
            gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET);
            repr->setAttribute("style", ( *s ? s : NULL ));
            g_free(s);
        } else {
            /** \todo I'm not sure what to do in this case.  Bug #1165868
             * suggests that it can arise, but the submitter doesn't know
             * how to do so reliably.  The main two options are either
             * leave repr's style attribute unchanged, or explicitly clear it.
             * Must also consider what to do with property attributes for
             * the element; see below.
             */
            char const *style_str = repr->attribute("style");
            if (!style_str) {
                style_str = "NULL";
            }
            g_warning("Item's style is NULL; repr style attribute is %s", style_str);
        }

        /** \note We treat object->style as authoritative.  Its effects have
         * been written to the style attribute above; any properties that are
         * unset we take to be deliberately unset (e.g. so that clones can
         * override the property).
         *
         * Note that the below has an undesirable consequence of changing the
         * appearance on renderers that lack CSS support (e.g. SVG tiny);
         * possibly we should write property attributes instead of a style
         * attribute.
         */
        sp_style_unset_property_attrs (object);
    }

    return repr;
}


Generated by  Doxygen 1.6.0   Back to index