summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 89c06dc)
raw | patch | inline | side by side (parent: 89c06dc)
author | keescook <keescook@users.sourceforge.net> | |
Sun, 21 Jan 2007 22:08:49 +0000 (22:08 +0000) | ||
committer | keescook <keescook@users.sourceforge.net> | |
Sun, 21 Jan 2007 22:08:49 +0000 (22:08 +0000) |
src/dialogs/rdf.cpp | patch | blob | history | |
src/dialogs/rdf.h | patch | blob | history |
diff --git a/src/dialogs/rdf.cpp b/src/dialogs/rdf.cpp
index a0bb04ad17adfda1bd41ccada84292b852054947..d3faa260aeb32bc14dbf251a05d38f98a530c2ad 100644 (file)
--- a/src/dialogs/rdf.cpp
+++ b/src/dialogs/rdf.cpp
Inkscape::XML::Node * temp=NULL;
Inkscape::XML::Node * child=NULL;
Inkscape::XML::Node * parent=repr;
+
+ Inkscape::XML::Document * xmldoc = parent->document();
+ g_return_val_if_fail (xmldoc != NULL, FALSE);
+
switch (entity->datatype) {
case RDF_CONTENT:
temp = sp_repr_children(parent);
if ( temp == NULL ) {
- temp = sp_repr_new_text( text );
- g_return_val_if_fail (temp != NULL, 0);
+ temp = xmldoc->createTextNode( text );
+ g_return_val_if_fail (temp != NULL, FALSE);
parent->appendChild(temp);
Inkscape::GC::release(temp);
}
else {
temp->setContent(text);
- return TRUE;
+ return TRUE;
}
case RDF_AGENT:
temp = sp_repr_lookup_name ( parent, "cc:Agent", 1 );
if ( temp == NULL ) {
- temp = sp_repr_new ( "cc:Agent" );
- g_return_val_if_fail (temp != NULL, 0);
+ temp = xmldoc->createElement ( "cc:Agent" );
+ g_return_val_if_fail (temp != NULL, FALSE);
parent->appendChild(temp);
Inkscape::GC::release(temp);
temp = sp_repr_lookup_name ( parent, "dc:title", 1 );
if ( temp == NULL ) {
- temp = sp_repr_new ( "dc:title" );
- g_return_val_if_fail (temp != NULL, 0);
+ temp = xmldoc->createElement ( "dc:title" );
+ g_return_val_if_fail (temp != NULL, FALSE);
parent->appendChild(temp);
Inkscape::GC::release(temp);
temp = sp_repr_children(parent);
if ( temp == NULL ) {
- temp = sp_repr_new_text( text );
- g_return_val_if_fail (temp != NULL, 0);
+ temp = xmldoc->createTextNode( text );
+ g_return_val_if_fail (temp != NULL, FALSE);
parent->appendChild(temp);
Inkscape::GC::release(temp);
parent->removeChild(temp);
}
- temp = sp_repr_new ( "rdf:Bag" );
- g_return_val_if_fail (temp != NULL, 0);
+ temp = xmldoc->createElement ( "rdf:Bag" );
+ g_return_val_if_fail (temp != NULL, FALSE);
parent->appendChild(temp);
Inkscape::GC::release(temp);
strlist = g_strsplit( text, ",", 0);
for (i = 0; (str = strlist[i]); i++) {
- temp = sp_repr_new ( "rdf:li" );
+ temp = xmldoc->createElement ( "rdf:li" );
g_return_val_if_fail (temp != NULL, 0);
parent->appendChild(temp);
Inkscape::GC::release(temp);
- child = sp_repr_new_text( g_strstrip(str) );
+ child = xmldoc->createTextNode( g_strstrip(str) );
g_return_val_if_fail (child != NULL, 0);
temp->appendChild(child);
g_return_val_if_fail (doc != NULL, NULL);
g_return_val_if_fail (doc->rroot != NULL, NULL);
+ Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+ g_return_val_if_fail (xmldoc != NULL, NULL);
+
Inkscape::XML::Node * rdf = sp_repr_lookup_name ( doc->rroot, XML_TAG_NAME_RDF );
if (rdf == NULL) {
Inkscape::XML::Node * parent = sp_repr_lookup_name ( svg, XML_TAG_NAME_METADATA );
if ( parent == NULL ) {
- parent = sp_repr_new( XML_TAG_NAME_METADATA );
+ parent = xmldoc->createElement( XML_TAG_NAME_METADATA );
g_return_val_if_fail ( parent != NULL, NULL);
svg->appendChild(parent);
Inkscape::GC::release(parent);
}
- rdf = sp_repr_new( XML_TAG_NAME_RDF );
+ Inkscape::XML::Document * xmldoc = parent->document();
+ g_return_val_if_fail (xmldoc != NULL, FALSE);
+
+ rdf = xmldoc->createElement( XML_TAG_NAME_RDF );
g_return_val_if_fail (rdf != NULL, NULL);
parent->appendChild(rdf);
Inkscape::XML::Node * want_metadata = sp_repr_parent ( rdf );
g_return_val_if_fail (want_metadata != NULL, NULL);
if (strcmp( want_metadata->name(), XML_TAG_NAME_METADATA )) {
- Inkscape::XML::Node * metadata = sp_repr_new( XML_TAG_NAME_METADATA );
+ Inkscape::XML::Node * metadata = xmldoc->createElement( XML_TAG_NAME_METADATA );
g_return_val_if_fail (metadata != NULL, NULL);
/* attach the metadata node */
//printf("missing XML '%s'\n",name);
if (!build) return NULL;
- xml = sp_repr_new( name );
+ Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+ g_return_val_if_fail (xmldoc != NULL, NULL);
+
+ xml = xmldoc->createElement( name );
g_return_val_if_fail (xml != NULL, NULL);
xml->setAttribute("rdf:about", "" );
//printf("missing XML '%s'\n",name);
if (!build) return NULL;
- item = sp_repr_new( name );
+ Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+ g_return_val_if_fail (xmldoc != NULL, NULL);
+
+ item = xmldoc->createElement( name );
g_return_val_if_fail (item != NULL, NULL);
work->appendChild(item);
*
*/
void
-rdf_set_license(SPDocument * document, struct rdf_license_t const * license)
+rdf_set_license(SPDocument * doc, struct rdf_license_t const * license)
{
// drop old license section
- Inkscape::XML::Node * repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, FALSE );
+ Inkscape::XML::Node * repr = rdf_get_xml_repr ( doc, XML_TAG_NAME_LICENSE, FALSE );
if (repr) sp_repr_unparent(repr);
if (!license) return;
// build new license section
- repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, TRUE );
+ repr = rdf_get_xml_repr ( doc, XML_TAG_NAME_LICENSE, TRUE );
g_assert ( repr );
repr->setAttribute("rdf:about", license->uri );
+ Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+ g_return_if_fail (xmldoc != NULL);
+
for (struct rdf_double_t * detail = license->details;
detail->name; detail++) {
- Inkscape::XML::Node * child = sp_repr_new( detail->name );
+ Inkscape::XML::Node * child = xmldoc->createElement( detail->name );
g_assert ( child != NULL );
child->setAttribute("rdf:resource", detail->resource );
};
void
-rdf_set_defaults ( SPDocument * document )
+rdf_set_defaults ( SPDocument * doc )
{
- g_assert ( document != NULL );
+ g_assert ( doc != NULL );
// Create metadata node if it doesn't already exist
- if (!sp_item_group_get_child_by_name ((SPGroup *) document->root, NULL,
+ if (!sp_item_group_get_child_by_name ((SPGroup *) doc->root, NULL,
XML_TAG_NAME_METADATA)) {
// create repr
- Inkscape::XML::Node * rnew = sp_repr_new (XML_TAG_NAME_METADATA);
+ Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc);
+ g_return_if_fail (xmldoc != NULL);
+ Inkscape::XML::Node * rnew = xmldoc->createElement (XML_TAG_NAME_METADATA);
// insert into the document
- document->rroot->addChild(rnew, NULL);
+ doc->rroot->addChild(rnew, NULL);
// clean up
Inkscape::GC::release(rnew);
}
struct rdf_work_entity_t * entity = rdf_find_entity ( rdf_default->name );
g_assert ( entity != NULL );
- if ( rdf_get_work_entity ( document, entity ) == NULL ) {
- rdf_set_work_entity ( document, entity, rdf_default->text );
+ if ( rdf_get_work_entity ( doc, entity ) == NULL ) {
+ rdf_set_work_entity ( doc, entity, rdf_default->text );
}
}
}
diff --git a/src/dialogs/rdf.h b/src/dialogs/rdf.h
index 29da859c26f595911873a04876702ea8078ef664..f4eec5a0c684bd2e0f3ac6e8700a24d2e90cfc5c 100644 (file)
--- a/src/dialogs/rdf.h
+++ b/src/dialogs/rdf.h
void rdf_set_license(SPDocument * doc,
struct rdf_license_t const * license);
-void rdf_set_defaults ( SPDocument * document );
+void rdf_set_defaults ( SPDocument * doc );
#endif // _RDF_H_