sp-root.cpp revision a2e796b608034e2c62290378d713058b8b58ef8f
/** \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"
/**
* Initializes an SPRootClass object by setting its class and parent class objects, and registering
* function pointers (i.e.\ gobject-style virtual functions) for various operations.
*/
{
}
}
}
root->aspect_set = 0;
root->aspect_align = 0;
root->aspect_clip = 0;
}
/**
* Initializes an SPRoot object by setting its default parameter values.
*/
{
}
//XML Tree being used directly here while it shouldn't be.
}
/* It is important to parse these here, so objects will have viewport build-time */
// 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:
/* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
}
/* fixme: I am almost sure these do not require viewport flag (Lauris) */
break;
case SP_ATTR_Y:
/* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
}
/* fixme: I am almost sure these do not require viewport flag (Lauris) */
break;
case SP_ATTR_WIDTH:
/* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
}
break;
case SP_ATTR_HEIGHT:
/* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */
}
break;
case SP_ATTR_VIEWBOX:
if (value) {
char *eptr;
/* fixme: We have to take original item affine into account */
/* fixme: Think (Lauris) */
/* Set viewbox */
} else {
}
} else {
}
break;
/* Do setup before, so we can use break to escape */
if (value) {
int len;
gchar c[256];
gchar const *p, *e;
p = value;
while (*p && *p == 32) p += 1;
if (!*p) break;
e = p;
while (*e && *e != 32) e += 1;
len = e - p;
if (len > 8) break;
c[len] = 0;
/* Now the actual part */
if (!strcmp(c, "none")) {
} else if (!strcmp(c, "xMinYMin")) {
} else if (!strcmp(c, "xMidYMin")) {
} else if (!strcmp(c, "xMaxYMin")) {
} else if (!strcmp(c, "xMinYMid")) {
} else if (!strcmp(c, "xMidYMid")) {
} else if (!strcmp(c, "xMaxYMid")) {
} else if (!strcmp(c, "xMinYMax")) {
} else if (!strcmp(c, "xMidYMax")) {
} else if (!strcmp(c, "xMaxYMax")) {
} else {
break;
}
while (*e && *e == 32) e += 1;
if (*e) {
if (!strcmp(e, "meet")) {
} else if (!strcmp(e, "slice")) {
} else {
break;
}
}
}
break;
case SP_ATTR_ONLOAD:
break;
default:
/* Pass the set event to the parent */
break;
}
}
// 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? */
}
}
}
/* fixme: This will be invoked too often (Lauris) */
/* fixme: We should calculate only if parent viewport has changed (Lauris) */
/* If position is specified as percentage, calculate actual values */
}
}
}
}
/* Create copy of item context */
/* Calculate child to parent transformation */
/*
* fixme: I am not sure whether setting x and y does or does not
* fixme: translate the content of inner SVG.
* fixme: Still applying translation and setting viewport to width and
* fixme: height seems natural, as this makes the inner svg element
* fixme: self-contained. The spec is vague here.
*/
}
if (root->viewBox_set) {
/* Determine actual viewbox in viewport coordinates */
x = 0.0;
y = 0.0;
} else {
/* Things are getting interesting */
/* Now place viewbox to requested position */
/* todo: Use an array lookup to find the 0.0/0.5/1.0 coefficients,
switch (root->aspect_align) {
case SP_ASPECT_XMIN_YMIN:
x = 0.0;
y = 0.0;
break;
case SP_ASPECT_XMID_YMIN:
y = 0.0;
break;
case SP_ASPECT_XMAX_YMIN:
y = 0.0;
break;
case SP_ASPECT_XMIN_YMID:
x = 0.0;
break;
case SP_ASPECT_XMID_YMID:
break;
case SP_ASPECT_XMAX_YMID:
break;
case SP_ASPECT_XMIN_YMAX:
x = 0.0;
break;
case SP_ASPECT_XMID_YMAX:
break;
case SP_ASPECT_XMAX_YMAX:
break;
default:
x = 0.0;
y = 0.0;
break;
}
}
/* Compose additional transformation from scale and position */
/* Append viewbox transformation */
/* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS
expression should have c2p at the beginning rather than at the end. Test it. */
root->c2p = Geom::Translate(-root->viewBox.min()) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p;
}
/* Initialize child viewport */
if (root->viewBox_set) {
} else {
/* fixme: I wonder whether this logic is correct (Lauris) */
}
rctx.viewport = Geom::Rect::from_xywh(minp[Geom::X], minp[Geom::Y], root->width.computed, root->height.computed);
}
/* And invoke parent method */
/* As last step set additional transform of drawing group */
}
}
/* fixme: (Lauris) */
}
}
Inkscape::XML::Node* CRoot::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 (root->viewBox_set) {
}
return repr;
}
Inkscape::DrawingItem* CRoot::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) {
if (ai) {
}
return ai;
}
}
/*
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 :