sp-root.cpp revision 9afeede0d946047f0421ae5f766568927eda11d6
/** \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 <cstring>
#include <string>
#include "display/nr-arena-group.h"
#include "attributes.h"
#include "print.h"
#include "document.h"
#include "sp-defs.h"
#include "sp-root.h"
#include <libnr/nr-matrix-fns.h>
#include <libnr/nr-matrix-ops.h>
#include <libnr/nr-matrix-translate-ops.h>
#include <libnr/nr-scale-ops.h>
#include <libnr/nr-translate-scale-ops.h>
#include "svg/stringstream.h"
#include "inkscape-version.h"
class SPDesktop;
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 NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static SPGroupClass *parent_class;
/**
* Returns the type info of sp_root, including its class sizes and initialization routines.
*/
sp_root_get_type(void)
{
if (!type) {
sizeof(SPRootClass),
sizeof(SPRoot),
16,
NULL, /* value_table */
};
}
return type;
}
/**
* 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.
*/
static void
{
}
/**
* Initializes an SPRoot object by setting its default parameter values.
*/
static void
{
/* root->viewbox.set_identity(); */
}
/**
* 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.
*/
static void
{
//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.
*/
static void
{
}
/**
* Sets the attribute given by key for SPRoot objects to the value specified by value.
*/
static void
{
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.
*/
static void
{
SPItemView *v;
/* 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(-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) */
} else {
}
}
/* And invoke parent method */
/* As last step set additional transform of arena 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.
*/
static void
{
/* 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) {
os << root->viewBox.x0 << " " << root->viewBox.y0 << " " << root->viewBox.x1 - root->viewBox.x0 << " " << root->viewBox.y1 - root->viewBox.y0;
}
return repr;
}
/**
* Displays the SPRoot item on the NRArena.
*/
static NRArenaItem *
{
if (ai) {
}
} else {
}
return ai;
}
/**
* Virtual print callback.
*/
static void
{
}
}
/*
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 :