Skip to content

Commit

Permalink
Reverts 2deea6b. Handles additional required setText() calls.
Browse files Browse the repository at this point in the history
Previously integration.js used to handle additional RTF setText() calls for
setCode() invocations
  • Loading branch information
adomasven committed Feb 2, 2018
1 parent 7df8f78 commit 1c2612a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
16 changes: 1 addition & 15 deletions build/source/org/zotero/integration/ooo/comp/ReferenceMark.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,6 @@ public void setCode(String code) throws Exception {
String oldRawCode = rawCode;
rawCode = Document.PREFIXES[0] + code + " RND" + Document.getRandomString(Document.REFMARK_ADD_CHARS);
doc.mMarkManager.renameMark(oldRawCode, rawCode);
// Setting the ReferenceMark name resets the style to the document default, so
// we store the previous style.
XPropertySet rangeProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, range);
Object[] oldPropertyValues = new Object[PROPERTIES_CHANGE_TO_DEFAULT.length];
for(int i=0; i<PROPERTIES_CHANGE_TO_DEFAULT.length; i++) {
Object result = rangeProps.getPropertyValue(PROPERTIES_CHANGE_TO_DEFAULT[i]);
oldPropertyValues[i] = result instanceof Any ? ((Any) result).getObject() : result;
}

// Set the actual referenceMark code.
if(isTextSection) {
Expand All @@ -307,13 +299,7 @@ public void setCode(String code) throws Exception {
removeCode();
reattachMark();
}

// And restore the style here
for(int i=0; i<PROPERTIES_CHANGE_TO_DEFAULT.length; i++) {
if(oldPropertyValues[i] != null) {
rangeProps.setPropertyValue(PROPERTIES_CHANGE_TO_DEFAULT[i], oldPropertyValues[i]);
}
}

getOutOfField();
}

Expand Down
14 changes: 14 additions & 0 deletions components/zoteroOpenOfficeIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ var Field = function(documentID, index, code, noteIndex) {
this._index = index;
this._code = code;
this._noteIndex = noteIndex;
this._formattedText = null;
};
Field.prototype = {};

Expand All @@ -488,6 +489,13 @@ for (let method of ["delete", "select", "removeCode", "setText", "getText"]) {
[this._documentID, this._index].concat(Array.prototype.slice.call(arguments)));
};
}
Field.prototype.setText = function(text, isRich) {
if (isRich) {
this._formattedText = text;
}
return Comm.sendCommand("Field_setText",
[this._documentID, this._index, text, isRich]);
}
Field.prototype.getCode = function() {
Zotero.debug(`LibreOfficePlugin: Field(${this._index}).getCode: ${this._code}`);
return this._code;
Expand All @@ -496,6 +504,12 @@ Field.prototype.setCode = function(code) {
this._code = code;
Zotero.debug(`LibreOfficePlugin: Field(${this._index}).setCode: ${this._code}`);
Comm.sendCommand("Field_setCode", [this._documentID, this._index, code]);
// Setting field codes removes formatting, so we have to do reapply the text again
// (Doing this within the LO plugin is not viable)
if (this._formattedText) {
this.setText(this._formattedText, true);
this._formattedText = null;
}
}
Field.prototype.getNoteIndex = function() {
Zotero.debug(`LibreOfficePlugin: Field(${this._index}).getNoteIndex: ${this._noteIndex}`);
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>zoteroOpenOfficeIntegration@zotero.org</em:id>
<em:name>Zotero LibreOffice Integration</em:name>
<em:version>5.0.9.SOURCE</em:version>
<em:version>5.0.10.SOURCE</em:version>
<em:creator>Center for History and New Media<br/>George Mason University</em:creator>
<em:developer>Simon Kornblith</em:developer>
<em:homepageURL>https://www.zotero.org</em:homepageURL>
Expand Down
Binary file modified install/Zotero_OpenOffice_Integration.oxt
Binary file not shown.
2 changes: 1 addition & 1 deletion resource/installer.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ var Plugin = new function() {
}];

// Bump if you want to trigger auto-update
this.LAST_INSTALLED_FILE_UPDATE = "5.0.9pre";
this.LAST_INSTALLED_FILE_UPDATE = "5.0.10pre";
this.DISABLE_PROGRESS_WINDOW = true;

var zoteroPluginInstaller, pathToAddon, installing, prefBranch, wizardWindow;
Expand Down

0 comments on commit 1c2612a

Please sign in to comment.