Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:client_coding:libreoffice_plugin_wire_protocol [2012/06/26 18:53] – [Word Processor Commands] simon | dev:client_coding:libreoffice_plugin_wire_protocol [2022/07/20 09:44] (current) – adomasven | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== LibreOffice | + | ====== LibreOffice Wire Protocol ====== |
- | The LibreOffice plugin uses a simple wire protocol to communicate with Zotero. (The Word for Mac and Word for Windows plugins both run in process, and use AppleEvents and COM respectively to communicate with the word processor.) The below documentation applies to Zotero | + | The LibreOffice plugin uses a simple wire protocol to communicate with Zotero. (The Word for Mac and Word for Windows plugins both run in process, and use AppleEvents and COM respectively to communicate with the word processor.) The below documentation applies to Zotero |
===== Basics ===== | ===== Basics ===== | ||
- | The Firefox or Zotero | + | The Zotero |
There are two types of commands: [[# | There are two types of commands: [[# | ||
Line 20: | Line 20: | ||
TRANS ID LENGTH | TRANS ID LENGTH | ||
HEXADECIMAL | HEXADECIMAL | ||
- | INTERPRETATION | + | INTERPRETATION |
</ | </ | ||
Line 35: | Line 35: | ||
< | < | ||
TRANS ID LENGTH | TRANS ID LENGTH | ||
- | HEXADECIMAL | + | HEXADECIMAL |
INTERPRETATION | INTERPRETATION | ||
</ | </ | ||
You can observe frame payloads sent between Zotero and LibreOffice in the Zotero [[/ | You can observe frame payloads sent between Zotero and LibreOffice in the Zotero [[/ | ||
+ | |||
===== Integration Commands ===== | ===== Integration Commands ===== | ||
- | These commands are sent from the word processor to Zotero, and do not receive a response. The command payload is always a quoted string. | + | These commands are sent from the word processor to Zotero, and do not receive a response. The command payload is always a JSON object with a `command` property, which is described below and a `templateVersion` property which is a number. The templateVersion number is used by Zotero to notify the integration user if the plugin installed in LibreOffice is outdated. The current up-to-date version is " |
^ Command ^ Description ^ | ^ Command ^ Description ^ | ||
- | | "addCitation" | Add a new citation | | + | | "addEditCitation" | Add a new or edit an existing citation | |
- | | " | + | | "addEditBibliography" | Add a new or edit an existing |
- | | "addBibliography" | Add a new bibliography | | + | | "addNote" | Insert a Zotero note into the document |
- | | "editBibliography" | Edit an existing bibliography | + | |
| " | | " | ||
| " | | " | ||
| " | | " | ||
+ | | " | ||
+ | |||
+ | An up-to-date command list is always available by looking at the methods of [[https:// | ||
===== Word Processor Commands ==== | ===== Word Processor Commands ==== | ||
Line 61: | Line 64: | ||
</ | </ | ||
- | If the request is successful, the client must send a response with a JSON-encoded payload. This response is often code>null</ | + | If the request is successful, the client must send a response with a JSON-encoded payload. This response is often null if the command returns no output, but may also be an array, an integer, a string, or a boolean value depending on the command. |
If the request is unsuccessful, | If the request is unsuccessful, | ||
Line 70: | Line 73: | ||
Zotero will cancel the current operation, log this error, and present it to the user using the [[# | Zotero will cancel the current operation, log this error, and present it to the user using the [[# | ||
+ | |||
+ | A full and up-to-date API of commands is available as part of [[https:// | ||
==== Application_getActiveDocument ==== | ==== Application_getActiveDocument ==== | ||
Line 157: | Line 162: | ||
==== Document_getDocumentData ==== | ==== Document_getDocumentData ==== | ||
- | Retrieves data string set by [# | + | Retrieves data string set by [[# |
=== Parameters === | === Parameters === | ||
Line 165: | Line 170: | ||
=== Returns === | === Returns === | ||
- | (String) The document data string. | + | (String) The document data string |
==== Document_cursorInField ==== | ==== Document_cursorInField ==== | ||
Line 205: | Line 210: | ||
| 1 | fieldCode | %%Integer|String%% | The code stored within this field. Since no data has been set, this should be empty. | | | 1 | fieldCode | %%Integer|String%% | The code stored within this field. Since no data has been set, this should be empty. | | ||
| 2 | noteIndex | %%Integer%% | The number of the footnote in which this field resides, or 0 if the field is not in a footnote. | | | 2 | noteIndex | %%Integer%% | The number of the footnote in which this field resides, or 0 if the field is not in a footnote. | | ||
+ | |||
+ | ==== Document_insertText ==== | ||
+ | |||
+ | Inserts rich text (HTML) at cursor position. The rich text may contain citation placeholder hyperlinks (to https:// | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | 0 | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | 1 | text | %%String%% | The text | | ||
+ | |||
+ | |||
+ | === Returns === | ||
+ | |||
+ | null | ||
+ | |||
==== Document_getFields ==== | ==== Document_getFields ==== | ||
- | Get all fields present in the document. | + | Get all fields present in the document, in document order. |
=== Parameters === | === Parameters === | ||
Line 225: | Line 245: | ||
==== Document_convert ==== | ==== Document_convert ==== | ||
- | TODO | + | Converts all fields in a document to a different fieldType or noteType. Called upon style change from a an in-text to note type or vice-versa |
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | 0 | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | 1 | fields | %%Array(String)%% | Array of field IDs to be converted | | ||
+ | | 2 | toFieldType | %%Array(String)%% | Array of field types to be converted to. Each entry is either " | ||
+ | | 3 | toNoteType | %%Array(Number)%% | Array of note types to be converted to. Each array entry corresponds to a field in the '' | ||
+ | NOTE_IN_TEXT = 0 | ||
+ | NOTE_FOOTNOTE = 1 | ||
+ | NOTE_ENDNOTE = 2 | ||
+ | </ | ||
+ | | count | %%Number%% | Size of the above arrays | | ||
+ | |||
+ | === Returns === | ||
+ | |||
+ | null | ||
+ | |||
+ | ==== Document_convertPlaceholdersToFields ==== | ||
+ | |||
+ | Converts placeholders (which are text with links to https:// | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | 0 | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | 1 | placeholderIDs | %%Array(String)%% | An array of placeholderID strings which are to be converted to citation fields in the document. | | ||
+ | | 2 | noteType | Number | Note type to convert citation placeholders to. Is one of< | ||
+ | NOTE_IN_TEXT = 0 | ||
+ | NOTE_FOOTNOTE = 1 | ||
+ | NOTE_ENDNOTE = 2 | ||
+ | </ | ||
+ | | 3 | fieldType | Number | Field type to convert to. Either `ReferenceMark` or `Bookmark` | ||
+ | | count | %%Number%% | Size of the above arrays | | ||
+ | |||
+ | === Returns === | ||
+ | |||
+ | Array of fields after conversion | ||
+ | |||
+ | (Array) | ||
+ | |||
+ | | 0 | fieldID | %%Array(Integer|String)%% | Unique identifiers for each field | | ||
+ | | 1 | fieldCode | %%Array(Integer|String)%% | The code stored in each field | | ||
+ | | 2 | noteIndex | %%Array(Integer)%% | The number of the footnote in which each field resides, or 0 if the field is not in a footnote | | ||
+ | |||
+ | |||
+ | ==== Document_importDocument ==== | ||
+ | |||
+ | Called to convert Zotero document transfer format links to fields after Document_getDocumentData returns " | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | 0 | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | 1 | fieldType | %%String%% | Specifies to what field type the import links should be converted. Should always be " | ||
+ | |||
+ | === Returns === | ||
+ | |||
+ | `true` if field links and document data were found and imported, `false` otherwise | ||
+ | |||
+ | |||
+ | ==== Document_exportDocument ==== | ||
+ | |||
+ | Converts the document to the Zotero transfer document format. The format is: | ||
+ | 1. Insert 4 paragraphs at the beginning of the document, where first one reads " | ||
+ | 2. Convert all citations to links that point to " | ||
+ | 3. At the end of the document insert a link that points to " | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | 0 | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | 1 | fieldType | %%String%% | The field type that the document stores Zotero citations in. Either " | ||
+ | | 2 | transferDocumentInstructions | %%String%% | A text string to be inserted at the start of the document explaining the document format | | ||
+ | |||
+ | === Returns === | ||
+ | |||
+ | null | ||
==== Document_setBibliographyStyle ==== | ==== Document_setBibliographyStyle ==== | ||
- | TODO | + | Provides parameters for the dedicated bibliography formatting style (usually called " |
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | 0 | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | 1 | firstLineIndent | %%Integer%% | First line indent in twips | | ||
+ | | 2 | bodyIndent | %%Integer%% | Bibliography body indent in twips. Applies to first line too. First line indent is calculated by < | ||
+ | | 3 | lineSpacing | %%Integer%% | Line spacing in twips | | ||
+ | | 4 | entrySpacing | %%Integer%% | Bibliography entry spacing in twips | | ||
+ | | 5 | tabStops | %%Array(Integer)%% | Tabulator indents | | ||
+ | | 6 | numTabStops | %%Integer%% | Length of tabStops array | | ||
+ | |||
+ | == Example Parameters == | ||
+ | |||
+ | < | ||
+ | [1, -720, 720, 240, 0, [], 0] | ||
+ | [1, -720, 720, 240, 0, [1], 720] | ||
+ | </ | ||
+ | |||
+ | |||
+ | === Returns === | ||
+ | |||
+ | null | ||
==== Document_complete ==== | ==== Document_complete ==== | ||
Line 291: | Line 407: | ||
| fieldID | %%Integer|String%% | The fieldID, as originally returned by [[# | | fieldID | %%Integer|String%% | The fieldID, as originally returned by [[# | ||
| text | %%String%% | The text | | | text | %%String%% | The text | | ||
+ | | isRich | %%Boolean%% | Whether the text should be interpreted as RTF || | ||
=== Returns === | === Returns === | ||
Line 298: | Line 415: | ||
==== Field_getText ==== | ==== Field_getText ==== | ||
- | Gets the text of a field. | + | Gets the (visible) |
=== Parameters === | === Parameters === | ||
Line 307: | Line 424: | ||
=== Returns === | === Returns === | ||
- | (String) The text | + | (String) The (visible) |
==== Field_setCode ==== | ==== Field_setCode ==== | ||
Line 318: | Line 435: | ||
| fieldID | %%Integer|String%% | The fieldID, as originally returned by [[# | | fieldID | %%Integer|String%% | The fieldID, as originally returned by [[# | ||
| code | %%String%% | The field code| | | code | %%String%% | The field code| | ||
+ | |||
+ | === Returns === | ||
+ | |||
+ | null | ||
+ | |||
+ | ==== Field_convert ==== | ||
+ | |||
+ | Converts a field from one type to another. | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | | documentID | %%Integer|String%% | The documentID, as originally returned by [[# | ||
+ | | fieldID | %%Integer|String%% | The fieldID, as originally returned by [[# | ||
+ | | fieldType | %%String%% | The type of field used by the document, either ReferenceMark or Bookmark | | ||
+ | | noteType | %%Integer%% | The type of note specified by the style:< | ||
+ | NOTE_IN_TEXT = 0 | ||
+ | NOTE_FOOTNOTE = 1 | ||
+ | NOTE_ENDNOTE = 2 | ||
+ | </ | ||
=== Returns === | === Returns === | ||
null | null |