- Show an error when a document was created with an incompatible field type.
- Move duplicate detection resolution code to Zotero.Integration.URIMap interface, so it will apply to uncited items in the bibliography as well.
This commit is contained in:
parent
a6da9fa061
commit
45b5421941
2 changed files with 54 additions and 38 deletions
|
@ -476,7 +476,9 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
|
|||
} else {
|
||||
var data = new Zotero.Integration.DocumentData(dataString);
|
||||
if(data.dataVersion < DATA_VERSION) {
|
||||
if(data.dataVersion == 1 && data.prefs.fieldType == "Field" && this._app.primaryFieldType == "ReferenceMark") {
|
||||
if(data.dataVersion == 1
|
||||
&& data.prefs.fieldType == "Field"
|
||||
&& this._app.primaryFieldType == "ReferenceMark") {
|
||||
// Converted OOo docs use ReferenceMarks, not fields
|
||||
data.prefs.fieldType = "ReferenceMark";
|
||||
}
|
||||
|
@ -488,6 +490,12 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
|
|||
} else if(data.dataVersion > DATA_VERSION) {
|
||||
throw new Zotero.Integration.DisplayException("newerDocumentVersion", [data.zoteroVersion, Zotero.version]);
|
||||
}
|
||||
|
||||
if(data.prefs.fieldType !== this._app.primaryFieldType
|
||||
&& data.prefs.fieldType !== this._app.secondaryFieldType) {
|
||||
throw new Zotero.Integration.DisplayException("fieldTypeMismatch");
|
||||
}
|
||||
|
||||
if(Zotero.Integration.sessions[data.sessionID]) {
|
||||
this._session = Zotero.Integration.sessions[data.sessionID];
|
||||
} else {
|
||||
|
@ -1213,40 +1221,7 @@ Zotero.Integration.Session.prototype.addCitation = function(index, noteIndex, ar
|
|||
var zoteroItem = false;
|
||||
if(citationItem.uri) {
|
||||
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(citationItem.uri);
|
||||
if(zoteroItem) {
|
||||
if(needUpdate) this.updateIndices[index] = true;
|
||||
} else {
|
||||
// Try merged item mappings
|
||||
for each(var uri in citationItem.uri) {
|
||||
var seen = [];
|
||||
|
||||
// Follow merged item relations until we find an item
|
||||
// or hit a dead end
|
||||
while (!zoteroItem) {
|
||||
var relations = Zotero.Relations.getByURIs(uri, Zotero.Relations.deletedItemPredicate);
|
||||
// No merged items found
|
||||
if(!relations.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
uri = relations[0].object;
|
||||
|
||||
// Keep track of mapped URIs in case there's a circular relation
|
||||
if(seen.indexOf(uri) != -1) {
|
||||
var msg = "Circular relation for '" + uri + "' in merged item mapping resolution";
|
||||
Zotero.debug(msg, 2);
|
||||
Components.utils.reportError(msg);
|
||||
break;
|
||||
}
|
||||
seen.push(uri);
|
||||
|
||||
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs([uri]);
|
||||
}
|
||||
}
|
||||
|
||||
if(zoteroItem && needUpdate) this.updateIndices[index] = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(citationItem.key) {
|
||||
zoteroItem = Zotero.Items.getByKey(citationItem.key);
|
||||
|
@ -1662,7 +1637,7 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
|||
// new style array of arrays with URIs
|
||||
let zoteroItem, needUpdate;
|
||||
for each(var uris in documentData.uncited) {
|
||||
[zoteroItem, update] = this.uriMap.getZoteroItemForURIs(uris);
|
||||
[zoteroItem, needUpdate] = this.uriMap.getZoteroItemForURIs(uris);
|
||||
if(zoteroItem && !this.citationsByItemID[zoteroItem.id]) {
|
||||
this.uncitedItems[zoteroItem.id] = true;
|
||||
} else {
|
||||
|
@ -2089,16 +2064,56 @@ Zotero.Integration.URIMap.prototype.getZoteroItemForURIs = function(uris) {
|
|||
var zoteroItem = false;
|
||||
var needUpdate = false;
|
||||
|
||||
for(var i in uris) {
|
||||
for(var i=0, n=uris.length; i<n; i++) {
|
||||
// Try getting URI directly
|
||||
var uri = uris[i];
|
||||
try {
|
||||
zoteroItem = Zotero.URI.getURIItem(uris[i]);
|
||||
zoteroItem = Zotero.URI.getURIItem(uri);
|
||||
if(zoteroItem) {
|
||||
// Ignore items in the trash
|
||||
if(zoteroItem.deleted) {
|
||||
zoteroItem = false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// Try merged item mappings
|
||||
var seen = [];
|
||||
|
||||
// Follow merged item relations until we find an item or hit a dead end
|
||||
while (!zoteroItem) {
|
||||
var relations = Zotero.Relations.getByURIs(uri, Zotero.Relations.deletedItemPredicate);
|
||||
// No merged items found
|
||||
if(!relations.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
uri = relations[0].object;
|
||||
|
||||
// Keep track of mapped URIs in case there's a circular relation
|
||||
if(seen.indexOf(uri) != -1) {
|
||||
var msg = "Circular relation for '" + uri + "' in merged item mapping resolution";
|
||||
Zotero.debug(msg, 2);
|
||||
Components.utils.reportError(msg);
|
||||
break;
|
||||
}
|
||||
seen.push(uri);
|
||||
|
||||
try {
|
||||
zoteroItem = Zotero.URI.getURIItem(uri);
|
||||
if(zoteroItem) {
|
||||
// Ignore items in the trash
|
||||
if(zoteroItem.deleted) {
|
||||
zoteroItem = false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
if(zoteroItem) break;
|
||||
}
|
||||
|
||||
if(zoteroItem) {
|
||||
|
|
|
@ -589,6 +589,7 @@ integration.error.notInCitation = You must place the cursor in a Zotero citati
|
|||
integration.error.noBibliography = The current bibliographic style does not define a bibliography. If you wish to add a bibliography, please choose another style.
|
||||
integration.error.deletePipe = The pipe that Zotero uses to communicate with the word processor could not be initialized. Would you like Zotero to attempt to correct this error? You will be prompted for your password.
|
||||
integration.error.invalidStyle = The style you have selected does not appear to be valid. If you have created this style yourself, please ensure that it passes validation as described at http://zotero.org/support/dev/citation_styles. Alternatively, try selecting another style.
|
||||
integration.error.fieldTypeMismatch = Zotero cannot update this document because it was created by a different word processing application with an encompatible field encoding. In order to make a document compatible with both Word and OpenOffice.org/LibreOffice/NeoOffice, open the document in the word processor with which it was originally created, and switch the field type to bookmarks in the Zotero Document Preferences.
|
||||
|
||||
integration.replace = Replace this Zotero field?
|
||||
integration.missingItem.single = This item no longer exists in your Zotero database. Do you want to select a substitute item?
|
||||
|
|
Loading…
Reference in a new issue