Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

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

Writes the object into the repr object, then calls the parent's write routine.

Definition at line 580 of file sp-root.cpp.

References SPRoot::height, Inkscape::XML::Node::setAttribute(), sp_repr_set_svg_double(), SPRoot::viewBox, SPRoot::viewBox_set, SPRoot::width, SPRoot::x, and SPRoot::y.

Referenced by sp_root_class_init().

{
    SPRoot *root = SP_ROOT(object);

    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
        repr = xml_doc->createElement("svg:svg");
    }

    if (flags & SP_OBJECT_WRITE_EXT) {
        repr->setAttribute("sodipodi:version", SODIPODI_VERSION);
        repr->setAttribute("inkscape:version", INKSCAPE_VERSION);
    }

    repr->setAttribute("version", SVG_VERSION);

    if (fabs(root->x.computed) > 1e-9)
        sp_repr_set_svg_double(repr, "x", root->x.computed);
    if (fabs(root->y.computed) > 1e-9)
        sp_repr_set_svg_double(repr, "y", root->y.computed);

    /* Unlike all other SPObject, here we want to preserve absolute units too (and only here,
     * according to the recommendation in http://www.w3.org/TR/SVG11/coords.html#Units).
     */
    repr->setAttribute("width", sp_svg_length_write_with_units(root->width).c_str());
    repr->setAttribute("height", sp_svg_length_write_with_units(root->height).c_str());

    if (root->viewBox_set) {
        Inkscape::SVGOStringStream os;
        os << root->viewBox.x0 << " " << root->viewBox.y0 << " " << root->viewBox.x1 - root->viewBox.x0 << " " << root->viewBox.y1 - root->viewBox.y0;
        repr->setAttribute("viewBox", os.str().c_str());
    }

    if (((SPObjectClass *) (parent_class))->write)
        ((SPObjectClass *) (parent_class))->write(object, repr, flags);

    return repr;
}


Generated by  Doxygen 1.6.0   Back to index