Logo Search packages:      
Sourcecode: inkscape version File versions

static void sp_object_private_set ( SPObject object,
unsigned int  key,
gchar const *  value 
) [static]

Callback for set event.

Definition at line 933 of file sp-object.cpp.

References SPObject::_default_label, SPObject::_label, SPDocument::bindObjectToId(), SPDocument::getObjectById(), SPObject::id, SPObject::parent, SPObject::repr, SP_ATTR_INVALID, sp_object_ref(), sp_object_unref(), Inkscape::XML::Node::type(), SPIXmlSpace::value, and SPObject::xml_space.

Referenced by sp_object_class_init().

{
    g_assert(key != SP_ATTR_INVALID);

    switch (key) {
        case SP_ATTR_ID:
            if ( !SP_OBJECT_IS_CLONED(object) && object->repr->type() == Inkscape::XML::ELEMENT_NODE ) {
                SPDocument *document=object->document;
                SPObject *conflict=NULL;

                if (value) {
                    conflict = document->getObjectById((char const *)value);
                }
                if ( conflict && conflict != object ) {
                    sp_object_ref(conflict, NULL);
                    // give the conflicting object a new ID
                    gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL);
                    SP_OBJECT_REPR(conflict)->setAttribute("id", new_conflict_id);
                    g_free(new_conflict_id);
                    sp_object_unref(conflict, NULL);
                }

                if (object->id) {
                    document->bindObjectToId(object->id, NULL);
                    g_free(object->id);
                }

                if (value) {
                    object->id = g_strdup((char const*)value);
                    document->bindObjectToId(object->id, object);
                } else {
                    object->id = NULL;
                }

                g_free(object->_default_label);
                object->_default_label = NULL;
            }
            break;
        case SP_ATTR_INKSCAPE_LABEL:
            g_free(object->_label);
            if (value) {
                object->_label = g_strdup(value);
            } else {
                object->_label = NULL;
            }
            g_free(object->_default_label);
            object->_default_label = NULL;
            break;
        case SP_ATTR_INKSCAPE_COLLECT:
            if ( value && !strcmp(value, "always") ) {
                object->setCollectionPolicy(SPObject::ALWAYS_COLLECT);
            } else {
                object->setCollectionPolicy(SPObject::COLLECT_WITH_PARENT);
            }
            break;
        case SP_ATTR_XML_SPACE:
            if (value && !strcmp(value, "preserve")) {
                object->xml_space.value = SP_XML_SPACE_PRESERVE;
                object->xml_space.set = TRUE;
            } else if (value && !strcmp(value, "default")) {
                object->xml_space.value = SP_XML_SPACE_DEFAULT;
                object->xml_space.set = TRUE;
            } else if (object->parent) {
                SPObject *parent;
                parent = object->parent;
                object->xml_space.value = parent->xml_space.value;
            }
            object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
            break;
        default:
            break;
    }
}


Generated by  Doxygen 1.6.0   Back to index