/** \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>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2007 Gail Banaszkiewicz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "attributes.h"
#include "document.h"
#include "sp-factory.h"
#include "sp-text.h"
#include "sp-tspan.h"
#include "sp-tref.h"
#include "style.h"
#include "text-editing.h"
#include "uri.h"
//#define DEBUG_TREF
#ifdef DEBUG_TREF
g_message(f, ## a); \
g_message("\n"); \
}
#else
#endif
/* TRef base class */
this->stringChild = NULL;
this->uriOriginalRef = new SPTRefReference(this);
this->_changed_connection =
this->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), this));
}
delete this->uriOriginalRef;
}
this->readAttr( "xlink:href" );
this->readAttr( "x" );
this->readAttr( "y" );
this->readAttr( "dx" );
this->readAttr( "dy" );
this->readAttr( "rotate" );
}
//this->attributes.~TextTagAttributes();
this->_delete_connection.disconnect();
this->_changed_connection.disconnect();
this->uriOriginalRef->detach();
}
debug("0x%p %s(%u): '%s'",this,
if ( !value ) {
// No value
this->uriOriginalRef->detach();
// Value has changed
if ( this->href ) {
}
try {
this->uriOriginalRef->updateObserver();
} catch ( Inkscape::BadURIException &e ) {
this->uriOriginalRef->detach();
}
// No matter what happened, an update should be in order
}
} else { // default
}
}
debug("0x%p",this);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
if (child) {
}
}
}
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
if (child) {
}
}
}
Inkscape::XML::Node* SPTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
debug("0x%p",this);
}
if (this->uriOriginalRef->getURI()) {
}
return repr;
}
// find out the ancestor text which holds our layout
}
if (parent_text == NULL) {
return bbox;
}
// get the bbox of our portion of the layout
// Add stroke width
// FIXME this code is incorrect
}
return bbox;
}
return _("Cloned Character Data");
}
if (referred) {
char *child_desc;
if (SP_IS_ITEM(referred)) {
} else {
}
return ret;
}
return g_strdup(_("[orphaned]"));
}
/* 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 = refRoot->connectDelete(sigc::bind(sigc::ptr_fun(&sp_tref_delete_self), tref));
}
}
}
/**
* Delete the tref object
*/
static void
{
self->deleteObject();
}
/**
* Return the object referred to via the URI reference
*/
{
if (uriOriginalRef) {
}
return referredObject;
}
/**
* 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;
}
{
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
new_tspan->updateRepr();
// 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.
tref->deleteObject(false);
// 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 {
l = g_slist_prepend (l, child);
}
l = g_slist_reverse (l);
while (l) {
SPObject *child = reinterpret_cast<SPObject *>(l->data); // We just built this list, so cast is safe.
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:fileencoding=utf-8:textwidth=99 :