id-clash.cpp revision b06dd4be3139209b8660173fa02b6ef358711c2b
#define __ID_CLASH_C__
/** \file
* Routines for resolving ID clashes when importing or pasting.
*
* Authors:
* Stephen Silver <sasilver@users.sourceforge.net>
*
* Copyright (C) 2008 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <cstdlib>
#include <cstring>
#include <list>
#include <map>
#include <string>
#include <utility>
#include "extract-uri.h"
#include "id-clash.h"
#include "sp-object.h"
#include "style.h"
struct IdReference {
const char *attr; // property or href-like attribute
};
const char *href_like_attributes[] = {
"inkscape:connection-end",
"inkscape:connection-start",
"inkscape:href",
"inkscape:path-effect",
"inkscape:perspectiveID",
"inkscape:tiled-clone-of",
"xlink:href",
};
};
const char* SPIPaint_properties[] = {
"color",
"fill",
"stroke",
};
const char* other_url_properties[] = {
"clip-path",
"color-profile",
"cursor",
"marker-end",
"marker-mid",
"marker-start",
"mask",
};
const char* clipboard_properties[] = {
"color",
"fill",
"filter",
"stroke",
};
/**
* Build a table of places where IDs are referenced, for a given element.
* FIXME: There are some types of references not yet dealt with here
* (e.g., ID selectors in CSS stylesheets, and references in scripts).
*/
static void
{
if (SP_OBJECT_IS_CLONED(elem)) return;
if (!repr_elem) return;
/* check for references in inkscape:clipboard elements */
if (css) {
for (unsigned i = 0; i < NUM_CLIPBOARD_PROPERTIES; ++i) {
const char *attr = clipboard_properties[i];
if (value) {
}
}
}
}
return; // nothing more to do for inkscape:clipboard elements
}
/* check for xlink:href="#..." and similar */
for (unsigned i = 0; i < NUM_HREF_LIKE_ATTRIBUTES; ++i) {
const char *attr = href_like_attributes[i];
}
}
/* check for url(#...) references in 'fill' or 'stroke' */
for (unsigned i = 0; i < NUM_SPIPAINT_PROPERTIES; ++i) {
if (obj) {
}
}
}
/* check for url(#...) references in 'filter' */
if (obj) {
}
}
/* check for other url(#...) references */
for (unsigned i = 0; i < NUM_OTHER_URL_PROPERTIES; ++i) {
const char *attr = other_url_properties[i];
if (value) {
}
}
}
/* recurse */
{
}
}
/**
* Change any IDs that clash with IDs in the current document, and make
* a list of those changes that will require fixing up references.
*/
static void
{
// Choose a new ID.
// To try to preserve any meaningfulness that the original ID
// may have had, the new ID is the old ID followed by a hyphen
// and one or more digits.
for (;;) {
}
// Change to the new ID
// Make a note of this change, if we need to fix up refs to it
}
/* recurse */
{
}
}
/**
* Fix up references to changed IDs.
*/
static void
{
}
}
}
}
else g_assert(0); // shouldn't happen
}
}
}
/**
* This function resolves ID clashes between the document being imported
* and the current open document: IDs in the imported document that would
* clash with IDs in the existing document are changed, and references to
* those IDs are updated accordingly.
*/
void
{
&id_changes);
delete refmap;
}
/*
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 :