From 944188fa63f66bae5b547a66911a458b8dde6a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Thu, 30 Aug 2018 10:55:54 +0300 Subject: [PATCH] Fix RTF dontUpdate=true citations updating on LO. Closes #1561 --- chrome/content/zotero/xpcom/integration.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index f006a9c052..31c4acb865 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -755,7 +755,7 @@ Zotero.Integration.Interface.prototype.setDocPrefs = Zotero.Promise.coroutine(fu this._session.fields = new Zotero.Integration.Fields(this._session, this._doc); this._session.fields.ignoreEmptyBibliography = false; - if (this._session.data.prefs.delayCitationUpdates) return; + if (this._session.data.prefs.delayCitationUpdates && !fieldsToConvert.length) return; yield this._session.fields.updateSession(FORCE_CITATIONS_RESET_TEXT); return this._session.fields.updateDocument(FORCE_CITATIONS_RESET_TEXT, true, true); @@ -1038,11 +1038,17 @@ Zotero.Integration.Fields.prototype._updateDocument = async function(forceCitati DIALOG_ICON_CAUTION, DIALOG_BUTTONS_YES_NO); if (result) { citation.properties.dontUpdate = true; + // Sigh. This hurts. setCode in LO forces a text reset. If the formattedText is rtf + // it is reinserted, however that breaks what properties.dontUpdate should do + if (this._session.primaryFieldType == "ReferenceMark" + && citation.properties.formattedCitation.includes('\\')) { + citation.properties.formattedCitation = citation.properties.plainCitation; + } } } // Update citation text: - // If we're looking to reset the text even if it matches previous text + // If we're looking to reset the text even if it matches previous text (i.e. style change) if (forceCitations == FORCE_CITATIONS_RESET_TEXT // Or metadata has changed thus changing the formatted citation || ((citation.properties.formattedCitation !== formattedCitation