commit 303f980954ad9bf24c7adcfbc68e0a1a620faabe
parent 3d70456938c008e3f32d865672535fa40c63fbe1
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 20 Jun 2010 10:48:38 +0000
Fix for "The command is not available because no document is open" error (part 2)
Diffstat:
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -156,7 +156,7 @@ Zotero.Integration = new function() {
/**
* Executes an integration command.
*/
- this.execCommand = function execCommand(agent, command) {
+ this.execCommand = function execCommand(agent, command, docId) {
if(_inProgress) {
Zotero.Integration.activate();
Zotero.debug("Integration: Request already in progress; not executing "+agent+" "+command);
@@ -183,7 +183,10 @@ Zotero.Integration = new function() {
// Try to create a new document; otherwise display an error using the alert service
try {
- var integration = new Zotero.Integration.Document(application);
+ Zotero.debug(application.getDocument);
+ Zotero.debug(docId);
+ var document = (application.getDocument && docId ? application.getDocument(docId) : application.getActiveDocument());
+ var integration = new Zotero.Integration.Document(application, document);
} catch(e) {
_inProgress = false;
Zotero.Integration.activate();
@@ -330,9 +333,9 @@ const BIBLIOGRAPHY_PLACEHOLDER = "{Bibliography}";
/**
*
*/
-Zotero.Integration.Document = function(app) {
+Zotero.Integration.Document = function(app, doc) {
this._app = app;
- this._doc = app.getActiveDocument();
+ this._doc = doc;
}
/**
diff --git a/components/zotero-integration-service.js b/components/zotero-integration-service.js
@@ -35,13 +35,14 @@ const ZoteroIntegrationCommandLineHandler = {
handle : function(cmdLine) {
var agent = cmdLine.handleFlagWithParam("ZoteroIntegrationAgent", false);
var command = cmdLine.handleFlagWithParam("ZoteroIntegrationCommand", false);
+ var docId = cmdLine.handleFlagWithParam("ZoteroIntegrationDocument", false);
if(agent && command) {
if(!this.Zotero) this.Zotero = Components.classes["@zotero.org/Zotero;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
var Zotero = this.Zotero;
// Not quite sure why this is necessary to get the appropriate scoping
var timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
- timer.initWithCallback({notify:function() { Zotero.Integration.execCommand(agent, command) }}, 0,
+ timer.initWithCallback({notify:function() { Zotero.Integration.execCommand(agent, command, docId) }}, 0,
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}
},
diff --git a/idl/zoteroIntegration.idl b/idl/zoteroIntegration.idl
@@ -146,6 +146,11 @@ interface zoteroIntegrationApplication : nsISupports
* The active document.
*/
zoteroIntegrationDocument getActiveDocument();
+
+ /**
+ * A document by some app-specific identifier.
+ */
+ zoteroIntegrationDocument getDocument(in wstring documentIdentifier);
};
///////////////////////////////////////////////////////////////////////////////