Code

Dockable dialogs patch applied
[inkscape.git] / src / dialogs / rdf.cpp
index df89ee6480a1c5841a7e7fff20c934241c066079..1e26a79c45d1c1e9507858345a39887e34bc7115 100644 (file)
@@ -28,7 +28,7 @@
 
    Example RDF XML from various places...
  
-<rdf:RDF xmlns="http://web.resource.org/cc/"
+<rdf:RDF xmlns="http://creativecommons.org/ns#"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 <Work rdf:about="">
@@ -48,7 +48,7 @@
 </Work>
 
 
-  <rdf:RDF xmlns="http://web.resource.org/cc/"
+  <rdf:RDF xmlns="http://creativecommons.org/ns#"
       xmlns:dc="http://purl.org/dc/elements/1.1/"
       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
   <Work rdf:about="">
         <dc:title>John Cliff</dc:title>
      </Agent></dc:rights>
      <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-     <license rdf:resource="http://web.resource.org/cc/PublicDomain" />
+     <license rdf:resource="http://creativecommons.org/ns#PublicDomain" />
   </Work>
   
-  <License rdf:about="http://web.resource.org/cc/PublicDomain">
-     <permits rdf:resource="http://web.resource.org/cc/Reproduction" />
-     <permits rdf:resource="http://web.resource.org/cc/Distribution" />
-     <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+  <License rdf:about="http://creativecommons.org/ns#PublicDomain">
+     <permits rdf:resource="http://creativecommons.org/ns#Reproduction" />
+     <permits rdf:resource="http://creativecommons.org/ns#Distribution" />
+     <permits rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
   </License>
   
 </rdf:RDF>
@@ -91,140 +91,138 @@ struct rdf_double_t rdf_license_empty [] = {
 };
 
 struct rdf_double_t rdf_license_cc_a [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_sa [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
+    { "cc:requires", "http://creativecommons.org/ns#ShareAlike", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nd [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nc [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:prohibits", "http://web.resource.org/cc/CommercialUse", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:prohibits", "http://creativecommons.org/ns#CommercialUse", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nc_sa [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:prohibits", "http://web.resource.org/cc/CommercialUse", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:prohibits", "http://creativecommons.org/ns#CommercialUse", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
+    { "cc:requires", "http://creativecommons.org/ns#ShareAlike", },
     { NULL, NULL }
 };
 
 struct rdf_double_t rdf_license_cc_a_nc_nd [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
-    { "cc:prohibits", "http://web.resource.org/cc/CommercialUse", },
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
+    { "cc:prohibits", "http://creativecommons.org/ns#CommercialUse", },
     { NULL, NULL }
 };
 
-struct rdf_double_t rdf_license_gpl [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
-    { "cc:requires", "http://web.resource.org/cc/SourceCode", },
+struct rdf_double_t rdf_license_pd [] = {
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
     { NULL, NULL }
 };
 
-struct rdf_double_t rdf_license_pd [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
+struct rdf_double_t rdf_license_freeart [] = {
+    { "cc:permits", "http://creativecommons.org/ns#Reproduction", },
+    { "cc:permits", "http://creativecommons.org/ns#Distribution", },
+    { "cc:permits", "http://creativecommons.org/ns#DerivativeWorks", },
+    { "cc:requires", "http://creativecommons.org/ns#ShareAlike", },
+    { "cc:requires", "http://creativecommons.org/ns#Notice", },
+    { "cc:requires", "http://creativecommons.org/ns#Attribution", },
     { NULL, NULL }
 };
 
-struct rdf_double_t rdf_license_freeart [] = {
-    { "cc:permits", "http://web.resource.org/cc/Reproduction", },
-    { "cc:permits", "http://web.resource.org/cc/Distribution", },
-    { "cc:permits", "http://web.resource.org/cc/DerivativeWorks", },
-    { "cc:requires", "http://web.resource.org/cc/ShareAlike", },
-    { "cc:requires", "http://web.resource.org/cc/Notice", },
-    { "cc:requires", "http://web.resource.org/cc/Attribution", },
+struct rdf_double_t rdf_license_ofl [] = {
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/Reproduction", },
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/Distribution", },
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/Embedding", },
+    { "cc:permits", "http://scripts.sil.org/pub/OFL/DerivativeWorks", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/Notice", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/Attribution", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/ShareAlike", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/DerivativeRenaming", },
+    { "cc:requires", "http://scripts.sil.org/pub/OFL/BundlingWhenSelling", },
     { NULL, NULL }
 };
 
 struct rdf_license_t rdf_licenses [] = {
-    { _("CC Attribution"), 
-      "http://creativecommons.org/licenses/by/2.5/",
+    { N_("CC Attribution"), 
+      "http://creativecommons.org/licenses/by/3.0/",
       rdf_license_cc_a,
     },
 
-    { _("CC Attribution-ShareAlike"), 
-      "http://creativecommons.org/licenses/by-sa/2.5/",
+    { N_("CC Attribution-ShareAlike"), 
+      "http://creativecommons.org/licenses/by-sa/3.0/",
       rdf_license_cc_a_sa,
     },
 
-    { _("CC Attribution-NoDerivs"), 
-      "http://creativecommons.org/licenses/by-nd/2.5/",
+    { N_("CC Attribution-NoDerivs"), 
+      "http://creativecommons.org/licenses/by-nd/3.0/",
       rdf_license_cc_a_nd,
     },
 
-    { _("CC Attribution-NonCommercial"), 
-      "http://creativecommons.org/licenses/by-nc/2.5/",
+    { N_("CC Attribution-NonCommercial"), 
+      "http://creativecommons.org/licenses/by-nc/3.0/",
       rdf_license_cc_a_nc,
     },
 
-    { _("CC Attribution-NonCommercial-ShareAlike"), 
-      "http://creativecommons.org/licenses/by-nc-sa/2.5/",
+    { N_("CC Attribution-NonCommercial-ShareAlike"), 
+      "http://creativecommons.org/licenses/by-nc-sa/3.0/",
       rdf_license_cc_a_nc_sa,
     },
 
-    { _("CC Attribution-NonCommercial-NoDerivs"), 
-      "http://creativecommons.org/licenses/by-nc-nd/2.5/",
+    { N_("CC Attribution-NonCommercial-NoDerivs"), 
+      "http://creativecommons.org/licenses/by-nc-nd/3.0/",
       rdf_license_cc_a_nc_nd,
     },
 
-    { _("GNU General Public License"), 
-      "http://creativecommons.org/licenses/GPL/2.0/",
-      rdf_license_gpl,
-    },
-
-    { _("GNU Lesser General Public License"), 
-      "http://creativecommons.org/licenses/LGPL/2.1/",
-      rdf_license_gpl,
-    },
-
-    { _("Public Domain"),
-      "http://web.resource.org/cc/PublicDomain",
+    { N_("Public Domain"),
+      "http://creativecommons.org/licenses/publicdomain/",
       rdf_license_pd,
     },
 
-    { _("FreeArt"),
+    { N_("FreeArt"),
       "http://artlibre.org/licence.php/lalgb.html",
       rdf_license_freeart,
     },
 
+    { N_("Open Font License"),
+      "http://scripts.sil.org/OFL",
+      rdf_license_ofl,
+    },
+
     { NULL, NULL, rdf_license_empty, }
 };
 
@@ -341,7 +339,7 @@ rdf_string(struct rdf_t * rdf)
     gchar *string=NULL;
 
     gchar *rdf_head="\
-<rdf:RDF xmlns=\"http://web.resource.org/cc/\"\
+<rdf:RDF xmlns=\"http://creativecommons.org/ns#\"\
     xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\
     xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\
 ";
@@ -536,12 +534,16 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
     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);
@@ -550,14 +552,14 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
             }
             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);
@@ -566,8 +568,8 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
 
             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);
@@ -576,8 +578,8 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
 
             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);
@@ -605,8 +607,8 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
                     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);
@@ -622,13 +624,13 @@ rdf_set_repr_text ( Inkscape::XML::Node * repr,
             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);
@@ -650,6 +652,9 @@ rdf_get_rdf_root_repr ( SPDocument * doc, bool build )
     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) {
@@ -661,14 +666,17 @@ rdf_get_rdf_root_repr ( SPDocument * doc, bool build )
 
         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);
@@ -682,7 +690,7 @@ rdf_get_rdf_root_repr ( SPDocument * doc, bool build )
     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 */
@@ -714,7 +722,10 @@ rdf_get_xml_repr( SPDocument * doc, gchar const * name, bool build )
         //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", "" );
@@ -741,7 +752,10 @@ rdf_get_work_repr( SPDocument * doc, gchar const * name, bool build )
         //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);
@@ -927,23 +941,26 @@ rdf_get_license(SPDocument * document)
  *  
  */
 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 );
@@ -963,17 +980,19 @@ struct rdf_entity_default_t rdf_defaults[] = {
 };
 
 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);
     }
@@ -985,8 +1004,8 @@ rdf_set_defaults ( SPDocument * document )
         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 );
         }
     }
 }