id-clash.cpp revision f5376aec383f80de56bd12894541ecd5f83222be
/*
* Routines for resolving ID clashes when importing or pasting.
*
* Authors:
* Stephen Silver <sasilver@users.sourceforge.net>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* 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"
#include "sp-paint-server.h"
#include "sp-root.h"
#include "sp-gradient.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",
"marker-end",
"marker-mid",
"marker-start"
};
/**
* 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 (!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 url(#...) references in markers */
for (unsigned i = SP_MARKER_LOC_START; i < SP_MARKER_LOC_QTY; i++) {
if (value) {
}
}
}
/* 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;
}
/*
* Change any references of svg:def from_obj into to_obj
*/
void
{
}
}
}
delete refmap;
}
/*
* Change the id of a SPObject to new_name
* If there is an id clash then rename to something similar
*/
{
g_message("Invalid Id, will not change.");
return;
}
g_message("Invalid Id, will not change.");
return;
}
// 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.
new_name2 += '-';
for (;;) {
break;
}
}
// Change to the new ID
// Make a note of this change, if we need to fix up refs to it
}
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 :