sp-tref.cpp revision d5ad05ac17abfd7d2eae333a8c1233971e1c1a8f
#define __SP_TREF_CPP__
/** \file
* SVG <tref> implementation - All character data within the referenced
* element, including character data enclosed within additional markup,
* will be rendered.
*
* This file was created based on skeleton.cpp
*/
/*
* Authors:
* Gail Banaszkiewicz <Gail.Banaszkiewicz@gmail.com>
*
* Copyright (C) 2007 Gail Banaszkiewicz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "attributes.h"
#include "document.h"
#include "sp-object-repr.h"
#include "sp-text.h"
#include "sp-tspan.h"
#include "sp-tref.h"
#include "style.h"
#include "text-editing.h"
#include "uri.h"
#include "display/nr-arena-group.h"
#include "libnr/nr-matrix-fns.h"
//#define DEBUG_TREF
#ifdef DEBUG_TREF
g_message(f, ## a); \
g_message("\n"); \
}
#else
# define debug(f, a...) /**/
#endif
/* TRef base class */
static Inkscape::XML::Node *sp_tref_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static SPObjectClass *tref_parent_class;
{
if (!tref_type) {
sizeof(SPTRefClass),
sizeof(SPTRef),
16,
NULL, /* value_table */
};
}
return tref_type;
}
static void
{
}
static void
{
tref->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), tref));
}
static void
{
delete tref->uriOriginalRef;
}
/**
* Reads the Inkscape::XML::Node, and initializes SPTRef variables.
*/
static void
{
}
}
/**
* Drops any allocated memory.
*/
static void
{
}
/**
* Sets a specific value in the SPTRef.
*/
static void
{
if ( !value ) {
// No value
// Value has changed
}
try {
} catch ( Inkscape::BadURIException &e ) {
}
// No matter what happened, an update should be in order
}
} else { // default
}
}
}
/**
* Receives update notifications. Code based on sp_use_update and sp_tspan_update.
*/
static void
{
}
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
if (child) {
}
}
}
static void
{
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
if (child) {
}
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
}
}
}
return repr;
}
/**
* The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way
*/
static void
sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
// find out the ancestor text which holds our layout
for (; parent_text != NULL && !SP_IS_TEXT(parent_text); parent_text = SP_OBJECT_PARENT (parent_text)){};
if (parent_text == NULL) return;
// get the bbox of our portion of the layout
bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1);
// Add stroke width
}
}
}
}
static gchar *
{
char *child_desc;
if (SP_IS_ITEM(referred)) {
} else {
}
char *ret = g_strdup_printf(
_("<b>Cloned character data</b>%s%s"),
return ret;
} else {
return g_strdup(_("<b>Orphaned cloned character data</b>"));
}
}
/* For the sigc::connection changes (i.e. when the object being refered to changes) */
static void
{
if (tref)
{
// Save a pointer to the original object being referred to
if (tref->stringChild) {
}
// Ensure that we are referring to a legitimate object
// Update the text being referred to (will create a new string child)
// Restore the delete connection now that we're done messing with stuff
tref->_delete_connection = SP_OBJECT(refRoot)->connectDelete(sigc::bind(sigc::ptr_fun(&sp_tref_delete_self), tref));
}
}
}
/**
* Delete the tref object
*/
static void
{
}
/**
* Return the object referred to via the URI reference
*/
{
if (uriOriginalRef) {
}
return referredObject;
}
/**
* Returns true when the given tref is allowed to refer to a particular object
*/
bool
{
bool allowed = false;
if (tref && possible_ref) {
if (tref != possible_ref) {
bool ancestor = false;
if (possible_ref == obj) {
ancestor = true;
break;
}
}
}
}
return allowed;
}
/**
* Returns true if a tref is fully contained in the confines of the given
* iterators and layout (or if there is no tref).
*/
bool
{
bool fully_contained = false;
if (start_item && end_item) {
// If neither the beginning or the end is a tref then we return true (whether there
// is a tref in the innards or not, because if there is one then it must be totally
// contained)
fully_contained = true;
}
// Both the beginning and end are trefs; but in this case, the string iterators
// must be at the right places
fully_contained = true;
}
}
// If the beginning is a string that is a child of a tref, the iterator has to be
// at the beginning of the item
fully_contained = true;
}
}
// Same, but the for the end
fully_contained = true;
}
}
}
return fully_contained;
}
void
{
if (tref) {
// Get the character data that will be used with this tref
if (tref->stringChild) {
}
// Create the node and SPString to be the tref's child
// Add this SPString as a child of the tref
}
}
/**
* Using depth-first search, build up a string by concatenating all SPStrings
* found in the tree starting at the root
*/
static void
{
// Stop and concatenate when a SPString is found
// Otherwise, continue searching down the tree (with the assumption that no children nodes
// of a SPString are actually legal)
} else {
}
}
}
}
/**
* This function will create a new tspan element with the same attributes as
* the tref had and add the same text as a child. The tref is replaced in the
* tree with the new tspan.
* The code is based partially on sp_use_unlink
*/
SPObject *
{
////////////////////
// BASE CASE
////////////////////
if (SP_IS_TREF(obj)) {
// Add the new tspan element just after the current tref
// Create a new string child for the tspan
//SPObject * new_string_child = document->getObjectByRepr(new_string_repr);
// Merge style from the tref
// Hold onto our SPObject and repr for now.
// Remove ourselves, not propagating delete events to avoid a
// chain-reaction with other elements that might reference us.
// Give the copy our old id and let go of our old repr.
// Establish the succession and let go of our object.
}
}
////////////////////
// RECURSIVE CASE
////////////////////
else {
for (SPObject *child = sp_object_first_child(obj) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
l = g_slist_prepend (l, child);
}
l = g_slist_reverse (l);
while (l) {
l = g_slist_remove (l, child);
// Note that there may be more than one conversion happening here, so if it's not a
// tref being passed into this function, the returned value can't be specifically known
}
}
return new_tspan;
}
/*
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:encoding=utf-8:textwidth=99 :