sp-root.cpp revision 4ad85b8b269b23f4e2124ef7bdaca7181e185950
/** \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"
static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static Inkscape::DrawingItem *sp_root_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
/**
* 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.
*/
{
}
/**
* Initializes an SPRoot object by setting its default parameter values.
*/
{
}
/**
* Fills in the data for an SPObject from its Inkscape::XML::Node object.
* It fills in data such as version, x, y, width, height, etc.
* It then calls the object's parent class object's build function.
*/
{
//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>
}
/**
* This is a destructor routine for SPRoot objects. It de-references any \<def\> items and calls
* the parent class destructor.
*/
{
}
/**
* Sets the attribute given by key for SPRoot objects to the value specified by value.
*/
{
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;
}
}
/**
* This routine is for adding a child SVG object to an SPRoot object.
* The SPRoot object is taken to be an SPGroup.
*/
static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
}
// We search for first <defs> node - it is not beautiful, but works
if (SP_IS_DEFS(c)) {
break;
}
}
}
}
/**
* Removes the given child from this SPRoot object.
*/
{
// We search for first remaining <defs> node - it is not beautiful, but works
break;
}
}
if (!iter) {
/* we should probably create a new <defs> here? */
}
}
}
}
/**
* This callback routine updates the SPRoot object when its attributes have been changed.
*/
{
/* 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 */
}
}
/**
* Calls the <tt>modified</tt> routine of the SPRoot object's parent class.
* Also, if the viewport has been modified, it sets the document size to the new
* height and width.
*/
{
/* fixme: (Lauris) */
}
}
/**
* Writes the object into the repr object, then calls the parent's write routine.
*/
sp_root_write(SPObject *object, 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;
}
/**
* Displays the SPRoot item on the drawing.
*/
static Inkscape::DrawingItem *
{
if (ai) {
}
} else {
}
return ai;
}
/**
* Virtual print callback.
*/
{
}
}
/*
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 :