sp-tref.cpp revision 980f39d0ea2b51d4b46d2ea552d9b8e02dbea8c2
/** \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
*/
#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 "sp-factory.h"
namespace {
SPObject* createTRef() {
return new SPTRef();
}
}
//#define DEBUG_TREF
#ifdef DEBUG_TREF
g_message(f, ## a); \
g_message("\n"); \
}
#else
# define debug(f, a...) /**/
#endif
/* TRef base class */
static void
{
}
}
}
tref->uriOriginalRef->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_tref_href_changed), tref));
}
static void
{
}
static void
{
delete tref->uriOriginalRef;
}
}
}
if ( !value ) {
// No value
// Value has changed
}
try {
} catch ( Inkscape::BadURIException &e ) {
}
// No matter what happened, an update should be in order
}
} else { // default
}
}
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
if (child) {
}
}
}
if (flags & SP_OBJECT_MODIFIED_FLAG) {
}
if (child) {
}
}
}
Inkscape::XML::Node* CTRef::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
}
}
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;
}
if (tref)
{
if (tref->getObjectReferredTo()) {
char *child_desc;
if (SP_IS_ITEM(referred)) {
} else {
}
char *ret = g_strdup_printf(
_("<b>Cloned character data</b>%s%s"),
return ret;
}
}
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 = 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;
}
/**
* 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 :