93 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
94 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
95 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
96 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
97 {
"cc:permits",
"http://creativecommons.org/ns#DerivativeWorks", },
102 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
103 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
104 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
105 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
106 {
"cc:permits",
"http://creativecommons.org/ns#DerivativeWorks", },
107 {
"cc:requires",
"http://creativecommons.org/ns#ShareAlike", },
112 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
113 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
114 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
115 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
120 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
121 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
122 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
123 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
124 {
"cc:prohibits",
"http://creativecommons.org/ns#CommercialUse", },
125 {
"cc:permits",
"http://creativecommons.org/ns#DerivativeWorks", },
130 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
131 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
132 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
133 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
134 {
"cc:prohibits",
"http://creativecommons.org/ns#CommercialUse", },
135 {
"cc:permits",
"http://creativecommons.org/ns#DerivativeWorks", },
136 {
"cc:requires",
"http://creativecommons.org/ns#ShareAlike", },
141 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
142 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
143 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
144 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
145 {
"cc:prohibits",
"http://creativecommons.org/ns#CommercialUse", },
150 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
151 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
152 {
"cc:permits",
"http://creativecommons.org/ns#DerivativeWorks", },
157 {
"cc:permits",
"http://creativecommons.org/ns#Reproduction", },
158 {
"cc:permits",
"http://creativecommons.org/ns#Distribution", },
159 {
"cc:permits",
"http://creativecommons.org/ns#DerivativeWorks", },
160 {
"cc:requires",
"http://creativecommons.org/ns#ShareAlike", },
161 {
"cc:requires",
"http://creativecommons.org/ns#Notice", },
162 {
"cc:requires",
"http://creativecommons.org/ns#Attribution", },
167 {
"cc:permits",
"http://scripts.sil.org/pub/OFL/Reproduction", },
168 {
"cc:permits",
"http://scripts.sil.org/pub/OFL/Distribution", },
169 {
"cc:permits",
"http://scripts.sil.org/pub/OFL/Embedding", },
170 {
"cc:permits",
"http://scripts.sil.org/pub/OFL/DerivativeWorks", },
171 {
"cc:requires",
"http://scripts.sil.org/pub/OFL/Notice", },
172 {
"cc:requires",
"http://scripts.sil.org/pub/OFL/Attribution", },
173 {
"cc:requires",
"http://scripts.sil.org/pub/OFL/ShareAlike", },
174 {
"cc:requires",
"http://scripts.sil.org/pub/OFL/DerivativeRenaming", },
175 {
"cc:requires",
"http://scripts.sil.org/pub/OFL/BundlingWhenSelling", },
180 { N_(
"CC Attribution"),
181 "http://creativecommons.org/licenses/by/4.0/",
185 { N_(
"CC Attribution-ShareAlike"),
186 "http://creativecommons.org/licenses/by-sa/4.0/",
190 { N_(
"CC Attribution-NoDerivs"),
191 "http://creativecommons.org/licenses/by-nd/4.0/",
195 { N_(
"CC Attribution-NonCommercial"),
196 "http://creativecommons.org/licenses/by-nc/4.0/",
200 { N_(
"CC Attribution-NonCommercial-ShareAlike"),
201 "http://creativecommons.org/licenses/by-nc-sa/4.0/",
205 { N_(
"CC Attribution-NonCommercial-NoDerivs"),
206 "http://creativecommons.org/licenses/by-nc-nd/4.0/",
210 { N_(
"CC0 Public Domain Dedication"),
211 "http://creativecommons.org/publicdomain/zero/1.0/",
216 "http://artlibre.org/licence/lal",
220 { N_(
"Open Font License"),
221 "http://scripts.sil.org/OFL",
229#define XML_TAG_NAME_SVG "svg:svg"
230#define XML_TAG_NAME_METADATA "svg:metadata"
231#define XML_TAG_NAME_RDF "rdf:RDF"
232#define XML_TAG_NAME_WORK "cc:Work"
233#define XML_TAG_NAME_LICENSE "cc:License"
235#define XML_TAG_NAME_LICENSE_PROP "cc:license"
248 {
"format", N_(
"Format:"),
"dc:format",
RDF_CONTENT,
255 {
"creator", N_(
"Creator:"),
"dc:creator",
RDF_AGENT,
258 {
"rights", N_(
"Rights:"),
"dc:rights",
RDF_AGENT,
261 {
"publisher", N_(
"Publisher:"),
"dc:publisher",
RDF_AGENT,
265 {
"identifier", N_(
"Identifier:"),
"dc:identifier",
RDF_CONTENT,
268 {
"source", N_(
"Source:"),
"dc:source",
RDF_CONTENT,
271 {
"relation", N_(
"Relation:"),
"dc:relation",
RDF_CONTENT,
274 {
"language", N_(
"Language:"),
"dc:language",
RDF_CONTENT,
277 {
"subject", N_(
"Keywords:"),
"dc:subject",
RDF_BAG,
282 {
"coverage", N_(
"Coverage:"),
"dc:coverage",
RDF_CONTENT,
283 N_(
"The spatial or temporal topic of the resource, the spatial applicability of the resource, or the jurisdiction under which the resource is relevant"),
RDF_FORMAT_LINE,
RDF_EDIT_GENERIC,
286 {
"description", N_(
"Description:"),
"dc:description",
RDF_CONTENT,
291 {
"contributor", N_(
"Contributors:"),
"dc:contributor",
RDF_AGENT,
296 {
"license_uri", N_(
"URI:"),
"cc:license",
RDF_RESOURCE,
302 {
"license_fragment", N_(
"Fragment:"),
"License",
RDF_XML,
350 gchar
const * text );
368 if (strcmp(entity->
name,
name)==0)
break;
370 if (entity->
name)
return entity;
495 g_return_val_if_fail (repr !=
nullptr, NULL);
496 static gchar * bag =
nullptr;
497 gchar * holder =
nullptr;
503 if ( temp ==
nullptr )
return nullptr;
509 if ( temp ==
nullptr )
return nullptr;
512 if ( temp ==
nullptr )
return nullptr;
515 if ( temp ==
nullptr )
return nullptr;
523 return "xml goes here";
527 if (bag) g_free(bag);
531 if ( temp ==
nullptr ) {
534 if ( temp ==
nullptr )
return nullptr;
541 temp = temp->
next() ) {
542 if (!strcmp(temp->
name(),
"rdf:li") &&
547 bag = g_strconcat(holder,
", ", str,
nullptr);
567 g_return_val_if_fail ( repr !=
nullptr, 0);
568 g_return_val_if_fail ( text !=
nullptr, 0);
569 gchar * str =
nullptr;
570 gchar** strlist =
nullptr;
577 g_return_val_if_fail (xmldoc !=
nullptr, FALSE);
580 if (!strcmp(entity.
name,
"title")) {
590 if ( temp ==
nullptr ) {
592 g_return_val_if_fail (temp !=
nullptr, FALSE);
594 parent->appendChild(temp);
606 if ( temp ==
nullptr ) {
608 g_return_val_if_fail (temp !=
nullptr, FALSE);
610 parent->appendChild(temp);
616 if ( temp ==
nullptr ) {
618 g_return_val_if_fail (temp !=
nullptr, FALSE);
620 parent->appendChild(temp);
626 if ( temp ==
nullptr ) {
628 g_return_val_if_fail (temp !=
nullptr, FALSE);
630 parent->appendChild(temp);
641 parent->setAttribute(
"rdf:resource", text );
650 if ( temp ==
nullptr ) {
652 while ( (temp =
parent->firstChild()) ) {
653 parent->removeChild(temp);
657 g_return_val_if_fail (temp !=
nullptr, FALSE);
659 parent->appendChild(temp);
665 while ( (temp =
parent->firstChild()) ) {
670 strlist = g_strsplit( text,
",", 0);
672 for (i = 0; (str = strlist[i]); i++) {
674 g_return_val_if_fail (temp !=
nullptr, 0);
676 parent->appendChild(temp);
680 g_return_val_if_fail (
child !=
nullptr, 0);
685 g_strfreev( strlist );
698 g_critical(
"Null node passed to ensureParentIsMetadata().");
700 g_critical(
"No parent node when verifying <metadata> placement." );
703 if ( strcmp( currentParent->
name(), XML_TAG_NAME_METADATA ) != 0 ) {
706 g_critical(
"Unable to create metadata element.");
726 g_critical(
"Null doc passed to getRdfRootRepr()");
728 g_critical(
"XML doc is null.");
740 g_critical(
"Null doc passed to ensureRdfRootRepr()");
742 g_critical(
"XML doc is null.");
748 g_critical(
"Unable to locate svg element.");
751 if (
parent ==
nullptr ) {
754 g_critical(
"Unable to create metadata element");
762 g_critical(
"Parent has no document");
766 g_critical(
"Unable to create root RDF element.");
777 ensureParentIsMetadata( doc, rdf );
787 g_critical(
"Null doc passed to getXmlRepr()");
789 g_critical(
"XML doc is null.");
791 g_critical(
"Null name passed to getXmlRepr()");
812 g_critical(
"Null doc passed to ensureXmlRepr()");
814 g_critical(
"XML doc is null.");
816 g_critical(
"Null name passed to ensureXmlRepr()");
824 g_critical(
"Unable to create xml element <%s>.",
name);
841 g_critical(
"Null doc passed to getWorkRepr()");
843 g_critical(
"XML doc is null.");
845 g_critical(
"Null name passed to getWorkRepr()");
859 g_critical(
"Null doc passed to ensureWorkRepr()");
861 g_critical(
"XML doc is null.");
863 g_critical(
"Null name passed to ensureWorkRepr()");
872 g_critical(
"Unable to create xml element <%s>",
name);
887 const gchar *
result =
nullptr;
889 g_critical(
"Null doc passed to rdf_get_work_entity()");
890 }
else if ( entity ) {
893 result = RDFImpl::getWorkEntity(doc, *entity);
902 gchar
const *
result =
nullptr;
919 g_critical(
"Null doc passed to rdf_set_work_entity()");
920 }
else if ( entity ) {
921 result = RDFImpl::setWorkEntity( doc, *entity, text );
930 if (!text || !text[0]) {
934 if (!strcmp(entity.
name,
"title")) {
950 g_critical(
"Unable to get work element");
963 g_assert ( repr !=
nullptr );
964 g_assert ( license !=
nullptr );
968 printf(
"checking against '%s'\n",license->
name);
973 details->name; details++ ) {
976 bool * matched = (
bool*)calloc(count,
sizeof(
bool));
982 gchar
const * attr =
current->attribute(
"rdf:resource");
983 if ( attr ==
nullptr )
continue;
986 printf(
"\texamining '%s' => '%s'\n",
current->name(), attr);
989 bool found_match=FALSE;
990 for (
int i=0; i<count; i++) {
992 if (matched[i])
continue;
1006 printf(
"\t\tgood!\n");
1016 printf(
"\t\tno '%s' element matched XML (bong)!\n",license->
name);
1022 if (
result) printf(
"\t\tall XML found matching elements!\n");
1024 for (
int i=0;
result && i<count; i++) {
1026 if (matched[i]==0) {
1029 printf(
"\t\tnot all '%s' elements used to match (bong)!\n", license->
name);
1035 printf(
"\t\tall '%s' elements used to match!\n",license->
name);
1041 if (
result) printf(
"matched '%s'\n",license->
name);
1049 return RDFImpl::getLicense(document, read_only);
1059 if (entity ==
nullptr) {
1060 g_critical(
"Can't find internal entity structure for 'license_uri'");
1064 const gchar *uri = getWorkEntity(document, *entity);
1067 if (
uri !=
nullptr) {
1069 if (g_strcmp0(
uri, license->uri) == 0) {
1070 license_by_uri = license;
1089 license_by_properties = license;
1095 if (license_by_uri !=
nullptr && license_by_properties !=
nullptr) {
1097 if (license_by_uri != license_by_properties) {
1099 g_warning(
"Mismatch between %s and %s metadata:\n"
1100 "%s value URI: %s (using this one!)\n"
1101 "%s derived URI: %s",
1102 XML_TAG_NAME_LICENSE_PROP,
1103 XML_TAG_NAME_LICENSE,
1104 XML_TAG_NAME_LICENSE_PROP,
1105 license_by_uri->
uri,
1106 XML_TAG_NAME_LICENSE,
1107 license_by_properties->
uri);
1113 setLicense(document, license_by_uri);
1116 return license_by_uri;
1118 else if (license_by_uri !=
nullptr) {
1121 setLicense(document, license_by_uri);
1124 return license_by_uri;
1126 else if (license_by_properties !=
nullptr) {
1130 g_warning(
"No %s metadata found, derived license URI from %s: %s",
1131 XML_TAG_NAME_LICENSE_PROP, XML_TAG_NAME_LICENSE,
1132 license_by_properties->
uri);
1135 setWorkEntity(document, *entity, license_by_properties->
uri);
1138 return license_by_properties;
1148 RDFImpl::setLicense( doc, license );
1167 g_critical(
"XML doc is null.");
1170 repr = ensureXmlRepr( doc, XML_TAG_NAME_LICENSE );
1177 g_assert (
child !=
nullptr );
1179 child->setAttribute(
"rdf:resource", detail->resource );
1189 RDFImpl::setDefaults( doc );
1195 g_assert( doc !=
nullptr );
1208 if (!prefs->
getBool(
"/metadata/addToNewFile")) {
1224 if (text.length() > 0) {
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &def="")
Retrieve an UTF-8 string.
static Preferences * get()
Access the singleton Preferences object.
Interface for refcounted XML nodes.
virtual Node * parent()=0
Get the parent of this node.
virtual Node * next()=0
Get the next sibling of this node.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
virtual char const * name() const =0
Get the name of the element node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * firstChild()=0
Get the first child of this node.
virtual void setContent(char const *value)=0
Set the content of a text or comment node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual char const * content() const =0
Get the content of a text or comment node.
virtual Document * document()=0
Get the node's associated document.
virtual void removeChild(Node *child)=0
Remove a child of this node.
Typed SVG document implementation.
SPRoot * getRoot()
Returns our SPRoot.
Inkscape::XML::Node * getReprRoot()
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
bool setTitle(char const *title, bool verbatim=false)
Sets the title of this object.
static char const *const current
static char const *const parent
Inkscape::XML::Node * node
static R & anchor(R &r)
Increments the reference count of a anchored object.
static R & release(R &r)
Decrements the reference count of a anchored object.
Singleton class to access the preferences file in a convenient way.
struct rdf_license_t rdf_licenses[]
struct rdf_work_entity_t rdf_work_entities[]
unsigned int rdf_set_work_entity(SPDocument *doc, struct rdf_work_entity_t *entity, const gchar *text)
struct rdf_work_entity_t * rdf_find_entity(gchar const *name)
Retrieves a known RDF/Work entity by name.
struct rdf_double_t rdf_license_cc_a_nc[]
struct rdf_double_t rdf_license_cc_a_nc_sa[]
struct rdf_license_t * rdf_get_license(SPDocument *document, bool read_only)
Attempts to match and retrieve a known RDF/License from the document XML.
void rdf_add_from_preferences(SPDocument *doc)
struct rdf_double_t rdf_license_cc_a_nd[]
static bool rdf_match_license(Inkscape::XML::Node const *repr, struct rdf_license_t const *license)
struct rdf_double_t rdf_license_cc_a_sa[]
struct rdf_double_t rdf_license_cc_a_nc_nd[]
void rdf_set_license(SPDocument *doc, struct rdf_license_t const *license)
Stores an RDF/License XML in the document XML.
struct rdf_double_t rdf_license_freeart[]
struct rdf_double_t rdf_license_cc_a[]
void rdf_set_defaults(SPDocument *doc)
struct rdf_double_t rdf_license_ofl[]
struct rdf_double_t rdf_license_pd[]
struct rdf_double_t rdf_license_empty[]
const gchar * rdf_get_work_entity(SPDocument const *doc, struct rdf_work_entity_t *entity)
Retrieves a known RDF/Work entity's contents from the document XML by name.
constexpr auto PREFS_METADATA
Inkscape::XML::Node const * sp_repr_lookup_name(Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth)
C facade to Inkscape::XML::Node.
void sp_repr_unparent(Inkscape::XML::Node *repr)
Remove repr from children of its parent node.
SPRoot: SVG <svg> implementation.
Interface for XML documents.
virtual Node * createTextNode(char const *content)=0
virtual Node * createElement(char const *name)=0
Holds license name/resource doubles for rdf_license_t entries.
Holds license name and RDF information.
struct rdf_double_t * details
Holds known RDF/Work tags.