sp-root.cpp revision 2230ac0a2af6aefab16d3c711180325a97b4490c
/** \file
* SVG \<svg\> implementation.
*/
/*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 1999-2002 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string>
#include "attributes.h"
#include "print.h"
#include "document.h"
#include "inkscape-version.h"
#include "sp-defs.h"
#include "sp-root.h"
#include "display/drawing-group.h"
#include "svg/stringstream.h"
#include "sp-factory.h"
namespace {
{
return new SPRoot();
}
}
{
}
{
}
{
//XML Tree being used directly here while it shouldn't be.
}
this->readAttr("version");
this->readAttr("inkscape:version");
/* It is important to parse these here, so objects will have viewport build-time */
this->readAttr("x");
this->readAttr("y");
this->readAttr("width");
this->readAttr("height");
this->readAttr("viewBox");
this->readAttr("preserveAspectRatio");
this->readAttr("onload");
// Search for first <defs> node
if (SP_IS_DEFS(o)) {
break;
}
}
// clear transform, if any was read in - SVG does not allow transform= on <svg>
}
{
}
{
switch (key) {
case SP_ATTR_VERSION:
}
break;
case SP_ATTR_INKSCAPE_VERSION:
}
break;
case SP_ATTR_X:
/* Valid for non-root SVG elements; ex, em not handled correctly. */
}
/* fixme: I am almost sure these do not require viewport flag (Lauris) */
break;
case SP_ATTR_Y:
/* Valid for non-root SVG elements; ex, em not handled correctly. */
}
/* fixme: I am almost sure these do not require viewport flag (Lauris) */
break;
case SP_ATTR_WIDTH:
}
break;
case SP_ATTR_HEIGHT:
}
break;
case SP_ATTR_VIEWBOX:
set_viewBox( value );
break;
break;
case SP_ATTR_ONLOAD:
break;
default:
/* Pass the set event to the parent */
break;
}
}
{
// NOTE: some XML nodes do not have corresponding SP objects,
// for instance inkscape:clipboard used in the clipboard code.
// See LP bug #1227827
//g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object
// We search for first <defs> node - it is not beautiful, but works
if (SP_IS_DEFS(c)) {
break;
}
}
}
}
{
// We search for first remaining <defs> node - it is not beautiful, but works
break;
}
}
if (!iter) {
/* we should probably create a new <defs> here? */
}
}
}
{
if( !this->parent ) {
/*
* This is the root SVG element:
*
* x, y, width, and height apply to positioning the SVG element inside a parent.
* For the root SVG in Inkscape there is no parent, thus special rules apply:
* If width, height not set, width = 100%, height = 100% (as always).
* x, y are ignored.
* initial viewport = (0 0 width height)
*/
if( this->viewBox_set ) {
// Check if this is necessary
}
} else {
}
}
} else {
}
} else {
}
}
}
// Ignore x, y values for root element
}
}
}
}
}
// std::cout << "SPRoot::update: final:"
// << " x: " << x.computed
// << " y: " << y.computed
// << " width: " << width.computed
// << " height: " << height.computed << std::endl;
// Calculate new viewport
/* And invoke parent method */
/* As last step set additional transform of drawing group */
g->setChildTransform(this->c2p);
}
}
{
/* fixme: (Lauris) */
}
}
Inkscape::XML::Node *SPRoot::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
}
if (flags & SP_OBJECT_WRITE_EXT) {
}
}
}
}
/* 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).
*/
if (this->viewBox_set) {
}
return repr;
}
Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags)
{
if (ai) {
g->setChildTransform(this->c2p);
}
return ai;
}
{
}
const char *SPRoot::displayName() const {
return "SVG"; // Do not translate
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :