Documentation
¶
Index ¶
- type Callback
- type CallbackType
- type ClipboardData
- type Document
- func (d Document) AddCertificate(cert []byte) bool
- func (d Document) CompleteFunction(functionName string)
- func (d Document) CreateView() int
- func (d Document) CreateViewWithOptions(options string) int
- func (d Document) Destroy()
- func (d Document) DestroyView(id int)
- func (d Document) Doc() *capi.LibreOfficeKitDocument
- func (d Document) GetClipboard(requested []string) ([]ClipboardData, bool)
- func (d Document) GetCommandValues(command string) string
- func (d Document) GetDocumentSize() (w, h int)
- func (d Document) GetDocumentType() DocumentType
- func (d Document) GetPart() int
- func (d Document) GetPartHash(part int) string
- func (d Document) GetPartInfo(part int) string
- func (d Document) GetPartName(part int) string
- func (d Document) GetPartPageRectangles() string
- func (d Document) GetParts() int
- func (d Document) GetSelectionType() SelectionType
- func (d Document) GetSignatureState() SignatureState
- func (d Document) GetTextSelection(mimeType string) (text, usedMimeType string, ok bool)
- func (d Document) GetTileMode() TileMode
- func (d Document) GetView() int
- func (d Document) GetViewIds() []int
- func (d Document) GetViewsCount() int
- func (d Document) InitializeForRendering(arguments string)
- func (d Document) InsertCertificate(cert, key []byte) bool
- func (d Document) MoveSelectedParts(position int, duplicate bool)
- func (d Document) PaintPartTile(buffer []byte, ...)
- func (d Document) PaintTile(buffer []byte, ...)
- func (d Document) PaintWindow(windowID uint, buffer []byte, x, y, width, height int)
- func (d Document) PaintWindowDPI(windowID uint, buffer []byte, x, y, width, height int, dpiScale float64)
- func (d Document) PaintWindowForView(windowID uint, buffer []byte, x, y, width, height int, dpiScale float64, ...)
- func (d Document) Paste(mimeType string, data []byte) bool
- func (d Document) PostKeyEvent(typ KeyEventType, charCode, keyCode int)
- func (d Document) PostMouseEvent(typ MouseEventType, x, y, count, buttons, modifier int)
- func (d Document) PostUnoCommand(command, arguments string, notify bool)
- func (d Document) PostWindow(windowID uint, action WindowAction, data string)
- func (d Document) PostWindowExtTextInputEvent(windowID uint, typ ExtTextInputType, text string)
- func (d Document) PostWindowGestureEvent(windowID uint, typ string, x, y, offset int)
- func (d Document) PostWindowKeyEvent(windowID uint, typ KeyEventType, charCode, keyCode int)
- func (d Document) PostWindowMouseEvent(windowID uint, typ MouseEventType, x, y, count, buttons, modifier int)
- func (d Document) RegisterCallback(callback Callback)
- func (d Document) RemoveTextContext(windowID uint, before, after int)
- func (d Document) RenderFont(fontName, ch string) (bitmap []byte, width, height int)
- func (d Document) RenderFontOrientation(fontName, ch string, orientation int) (bitmap []byte, width, height int)
- func (d Document) RenderSearchResult(searchResult string) (bitmap []byte, width, height int, ok bool)
- func (d Document) RenderShapeSelection() (data []byte, ok bool)
- func (d Document) ResetSelection()
- func (d Document) ResizeWindow(windowID uint, width, height int)
- func (d Document) SaveAs(url, format, filterOptions string) bool
- func (d Document) SelectPart(part, selectMode int)
- func (d Document) SendDialogEvent(windowID uint64, args string)
- func (d Document) SendFormFieldEvent(args string)
- func (d Document) SetBlockedCommandList(viewID int, blockedCommandList string)
- func (d Document) SetClientVisibleArea(x, y, width, height int)
- func (d Document) SetClientZoom(tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight int)
- func (d Document) SetClipboard(data []ClipboardData) bool
- func (d Document) SetGraphicSelection(typ SetGraphicSelectionType, x, y int)
- func (d Document) SetOutlineState(column bool, level, index int, hidden bool)
- func (d Document) SetPart(part int)
- func (d Document) SetPartMode(mode PartMode)
- func (d Document) SetTextSelection(typ SetTextSelectionType, x, y int)
- func (d Document) SetView(id int)
- func (d Document) SetViewLanguage(id int, language string)
- func (d Document) SetWindowTextSelection(windowID uint, swap bool, x, y int)
- type DocumentType
- type ExtTextInputType
- type KeyEventType
- type MouseEventType
- type Office
- func (o Office) Destroy()
- func (o Office) DocumentLoad(url string) (d Document, err error)
- func (o Office) DocumentLoadWithOptions(url, options string) (d Document, err error)
- func (o Office) GetError() error
- func (o Office) GetFilterTypes() string
- func (o Office) GetVersionInfo() string
- func (o Office) Lok() *capi.LibreOfficeKit
- func (o Office) RegisterCallback(callback Callback)
- func (o Office) RunLoop(poll PollCallback, wake WakeCallback)
- func (o Office) RunMacro(url string) int
- func (o Office) SendDialogEvent(windowID uint64, args string)
- func (o Office) SetDocumentPassword(url, password string)
- func (o Office) SetOption(option, value string)
- func (o Office) SetOptionalFeatures(features OptionalFeatures)
- func (o Office) SignDocument(url string, cert, key []byte) bool
- type OptionalFeatures
- type PartMode
- type PollCallback
- type SelectionType
- type SetGraphicSelectionType
- type SetTextSelectionType
- type SignatureState
- type TileMode
- type WakeCallback
- type WindowAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback func(typ CallbackType, payload string)
type CallbackType ¶
type CallbackType int
CallbackType enumerates the types of callbacks emitted to a LibreOfficeKit object's callback function or to a LibreOfficeKitDocument object's callback function. No callback type will be emitted to both. It is a bit unfortunate that the same enum contains both kinds of callbacks.
const ( // Any tiles which are over the rectangle described in the payload are no // longer valid. // // Rectangle format: "x, y, width, height", where all numbers are document // coordinates, in twips. When all tiles are supposed to be dropped, the // format is the "EMPTY" string. CALLBACK_INVALIDATE_TILES CallbackType = 0 // The size and/or the position of the visible cursor changed. // // Old format is the same as CALLBACK_INVALIDATE_TILES. // New format is a JSON with 3 elements the 'viewId' element represented by // an integer value, a 'rectangle' element in the format "x, y, width, height", // and a 'misspelledWord' element represented by an integer value: '1' when // a misspelled word is at the cursor position, '0' when the word is // not misspelled. CALLBACK_INVALIDATE_VISIBLE_CURSOR CallbackType = 1 // The list of rectangles representing the current text selection changed. // // List format is "rectangle1[; rectangle2[; ...]]" (without quotes and // brackets), where rectangleN has the same format as // CALLBACK_INVALIDATE_TILES. When there is no selection, an empty // string is provided. CALLBACK_TEXT_SELECTION CallbackType = 2 // The position and size of the cursor rectangle at the text // selection start. It is used to draw the selection handles. // // This callback must be called prior to CALLBACK_TEXT_SELECTION every // time the selection is updated. // // Rectangle format is the same as CALLBACK_INVALIDATE_TILES. CALLBACK_TEXT_SELECTION_START CallbackType = 3 // The position and size of the cursor rectangle at the text // selection end. It is used to draw the selection handles. // // This callback must be called prior to CALLBACK_TEXT_SELECTION every // time the selection is updated. // // Rectangle format is the same as CALLBACK_INVALIDATE_TILES. CALLBACK_TEXT_SELECTION_END CallbackType = 4 // The blinking text cursor is now visible or not. // // Clients should assume that this is true initially and are expected to // hide the blinking cursor at the rectangle described by // CALLBACK_INVALIDATE_VISIBLE_CURSOR once it becomes false. Payload is // either the "true" or the "false" string. CALLBACK_CURSOR_VISIBLE CallbackType = 5 // The size and/or the position of the graphic selection changed, // the rotation angle of the embedded graphic object, and a property list // which can be used for informing the client about several properties. // // Format is "x, y, width, height, angle, { list of properties }", // where angle is in 100th of degree, and the property list is optional. // // The "{ list of properties }" part is in JSON format. // Follow some examples of the property list part: // // 1) when the selected object is an image inserted in Writer: // // { "isWriterGraphic": true } // // 2) when the selected object is a chart legend: // // { "isDraggable": true, "isResizable": true, "isRotatable": false } // // 3) when the selected object is a pie segment in a chart: // // { // "isDraggable": true, // "isResizable": false, // "isRotatable": false, // "dragInfo": { // "dragMethod": "PieSegmentDragging", // "initialOffset": 50, // "dragDirection": [x, y], // "svg": "<svg ..." // } // } // // where the "svg" property is a string containing an svg document // which is a representation of the pie segment. CALLBACK_GRAPHIC_SELECTION CallbackType = 6 // User clicked on a hyperlink that should be handled by other // applications accordingly. CALLBACK_HYPERLINK_CLICKED CallbackType = 7 // Emit state update to the client. // For example, when cursor is on bold text, this callback is triggered // with payload: ".uno:Bold=true" CALLBACK_STATE_CHANGED CallbackType = 8 // Start a "status indicator" (here restricted to a progress bar type // indicator). The payload is the descriptive text (or empty). Even if // there is no documentation that would promise so, we assume that de facto // for a document being viewed or edited, there will be at most one status // indicator, and its descriptive text will not change. // // Note that for the case of the progress indication during loading of a // document, the status indicator callbacks will arrive to the callback // registered for the LibreOfficeKit (singleton) object, not a // LibreOfficeKitDocument one, because we are in the very progress of // loading a document and then constructing a LibreOfficeKitDocument // object. CALLBACK_STATUS_INDICATOR_START CallbackType = 9 // Sets the numeric value of the status indicator. // The payload should be a percentage, an integer between 0 and 100. CALLBACK_STATUS_INDICATOR_SET_VALUE CallbackType = 10 // Ends the status indicator. // // Not necessarily ever emitted. CALLBACK_STATUS_INDICATOR_FINISH CallbackType = 11 // No match was found for the search input CALLBACK_SEARCH_NOT_FOUND CallbackType = 12 // Size of the document changed. // // Payload format is "width, height", i.e. clients get the new size without // having to do an explicit lok::Document::getDocumentSize() call. // // A size change is always preceded by a series of // CALLBACK_INVALIDATE_TILES events invalidating any areas // need re-rendering to adapt. CALLBACK_DOCUMENT_SIZE_CHANGED CallbackType = 13 // The current part number is changed. // // Payload is a single 0-based integer. CALLBACK_SET_PART CallbackType = 14 // Selection rectangles of the search result when find all is performed. // // Payload format example, in case of two matches: // // { // "searchString": "...", // "highlightAll": true|false, // this is a result of 'search all' // "searchResultSelection": [ // { // "part": "...", // "rectangles": "..." // }, // { // "part": "...", // "rectangles": "..." // } // ] // } // // - searchString is the search query // - searchResultSelection is an array of part-number and rectangle list // pairs, in CALLBACK_SET_PART / CALLBACK_TEXT_SELECTION format. CALLBACK_SEARCH_RESULT_SELECTION CallbackType = 15 // Result of the UNO command execution when bNotifyWhenFinished was set // to 'true' during the postUnoCommand() call. // // The result returns a success / failure state, and potentially // additional data: // // { // "commandName": "...", // the command for which this is the result // "success": true/false, // when the result is "don't know", this is missing // // TODO "result": "..." // UNO Any converted to JSON (not implemented yet) // } CALLBACK_UNO_COMMAND_RESULT CallbackType = 16 // The size and/or the position of the cell cursor changed. // // Payload format: "x, y, width, height, column, row", where the first // 4 numbers are document coordinates, in twips, and the last 2 are table // coordinates starting from 0. // When the cursor is not shown the payload format is the "EMPTY" string. // // Rectangle format is the same as CALLBACK_INVALIDATE_TILES. CALLBACK_CELL_CURSOR CallbackType = 17 // The current mouse pointer style. // // Payload is a css mouse pointer style. CALLBACK_MOUSE_POINTER CallbackType = 18 // The text content of the formula bar in Calc. CALLBACK_CELL_FORMULA CallbackType = 19 // Loading a document requires a password. // // Loading the document is blocked until the password is provided via // lok::Office::setDocumentPassword(). The document cannot be loaded // without the password. CALLBACK_DOCUMENT_PASSWORD CallbackType = 20 // Editing a document requires a password. // // Loading the document is blocked until the password is provided via // lok::Office::setDocumentPassword(). CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY CallbackType = 21 // An error happened. // // The payload returns information further identifying the error, like: // // { // "classification": "error" | "warning" | "info" // "kind": "network" etc. // "code": a structured 32-bit error code, the ErrCode from LibreOffice's <tools/errcode.hxx> // "message": freeform description // } CALLBACK_ERROR CallbackType = 22 // Context menu structure // // Returns the structure of context menu. Contains all the separators & // submenus, example of the returned structure: // // { // "menu": [ // { "text": "label text1", "type": "command", "command": ".uno:Something1", "enabled": "true" }, // { "text": "label text2", "type": "command", "command": ".uno:Something2", "enabled": "false" }, // { "type": "separator" }, // { "text": "label text2", "type": "menu", "menu": [ { ... }, { ... }, ... ] }, // ... // ] // } // // The 'command' can additionally have a checkable status, like: // // {"text": "label text3", "type": "command", "command": ".uno:Something3", "checktype": "checkmark|radio|auto", "checked": "true|false"} CALLBACK_CONTEXT_MENU CallbackType = 23 // The size and/or the position of the view cursor changed. A view cursor // is a cursor of another view, the current view can't change it. // // The payload format: // // { // "viewId": "..." // "rectangle": "..." // } // // - viewId is a value returned earlier by lok::Document::createView() // - rectangle uses the format of CALLBACK_INVALIDATE_VISIBLE_CURSOR CALLBACK_INVALIDATE_VIEW_CURSOR CallbackType = 24 // The text selection in one of the other views has changed. // // The payload format: // // { // "viewId": "..." // "selection": "..." // } // // - viewId is a value returned earlier by lok::Document::createView() // - selection uses the format of CALLBACK_TEXT_SELECTION. CALLBACK_TEXT_VIEW_SELECTION CallbackType = 25 // The cell cursor in one of the other views has changed. // // The payload format: // // { // "viewId": "..." // "rectangle": "..." // } // // - viewId is a value returned earlier by lok::Document::createView() // - rectangle uses the format of CALLBACK_CELL_CURSOR. CALLBACK_CELL_VIEW_CURSOR CallbackType = 26 // The size and/or the position of a graphic selection in one of the other // views has changed. // // The payload format: // // { // "viewId": "..." // "selection": "..." // } // // - viewId is a value returned earlier by lok::Document::createView() // - selection uses the format of CALLBACK_INVALIDATE_TILES. CALLBACK_GRAPHIC_VIEW_SELECTION CallbackType = 27 // The blinking text cursor in one of the other views is now visible or // not. // // The payload format: // // { // "viewId": "..." // "visible": "..." // } // // - viewId is a value returned earlier by lok::Document::createView() // - visible uses the format of CALLBACK_CURSOR_VISIBLE. CALLBACK_VIEW_CURSOR_VISIBLE CallbackType = 28 // The size and/or the position of a lock rectangle in one of the other // views has changed. // // The payload format: // // { // "viewId": "..." // "rectangle": "..." // } // // - viewId is a value returned earlier by lok::Document::createView() // - rectangle uses the format of CALLBACK_INVALIDATE_TILES. CALLBACK_VIEW_LOCK CallbackType = 29 // The size of the change tracking table has changed. // // The payload example: // { // "redline": { // "action": "Remove", // "index": "1", // "author": "Unknown Author", // "type": "Delete", // "comment": "", // "description": "Delete 'abc'", // "dateTime": "2016-08-18T12:14:00" // } // } // // The format is the same as an entry of // lok::Document::getCommandValues('.uno:AcceptTrackedChanges'), extra // fields: // // - 'action' is either 'Add' or 'Remove', depending on if this is an // insertion into the table or a removal. CALLBACK_REDLINE_TABLE_SIZE_CHANGED CallbackType = 30 // An entry in the change tracking table has been modified. // // The payload example: // { // "redline": { // "action": "Modify", // "index": "1", // "author": "Unknown Author", // "type": "Insert", // "comment": "", // "description": "Insert 'abcd'", // "dateTime": "2016-08-18T13:13:00" // } // } // // The format is the same as an entry of // lok::Document::getCommandValues('.uno:AcceptTrackedChanges'), extra // fields: // // - 'action' is 'Modify'. CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED CallbackType = 31 // There is some change in comments in the document // // The payload example: // { // "comment": { // "action": "Add", // "id": "11", // "parent": "4", // "author": "Unknown Author", // "text": "", // "dateTime": "2016-08-18T13:13:00", // "anchorPos": "4529, 3906", // "textRange": "1418, 3906, 3111, 919" // } // } // // The format is the same as an entry of // lok::Document::getCommandValues('.uno:ViewAnnotations'), extra // fields: // // - 'action' can be 'Add', 'Remove' or 'Modify' depending on whether // comment has been added, removed or modified. CALLBACK_COMMENT CallbackType = 32 // The column/row header is no more valid because of a column/row insertion // or a similar event. Clients must query a new column/row header set. // // The payload says if we are invalidating a row or column header. So, // payload values can be: "row", "column", "all". CALLBACK_INVALIDATE_HEADER CallbackType = 33 // The text content of the address field in Calc. Eg: "A7" CALLBACK_CELL_ADDRESS CallbackType = 34 // The key ruler related properties on change are reported by this. // // The payload format is: // // { // "margin1": "...", // "margin2": "...", // "leftOffset": "...", // "pageOffset": "...", // "pageWidth": "...", // "unit": "..." // } // // Here all aproperties are same as described in svxruler. CALLBACK_RULER_UPDATE CallbackType = 35 // Window related callbacks are emitted under this category. It includes // external windows like dialogs, autopopups for now. // // The payload format is: // // { // "id": "unique integer id of the dialog", // "action": "<see below>", // "type": "<see below>" // "rectangle": "x, y, width, height" // } // // "type" tells the type of the window the action is associated with // - "dialog" - window is a dialog // - "child" - window is a floating window (combo boxes, etc.) // - "deck" - window is a docked/floating deck (i.e. the sidebar) // - "tooltip" - window is a tooltip popup // // "action" can take following values: // - "created" - window is created in the backend, client can render it now // - "title_changed" - window's title is changed // - "size_changed" - window's size is changed // - "invalidate" - the area as described by "rectangle" is invalidated // Clients must request the new area // - "cursor_invalidate" - cursor is invalidated. New position is in "rectangle" // - "cursor_visible" - cursor visible status is changed. Status is available // in "visible" field // - "close" - window is closed // - "show" - show the window // - "hide" - hide the window CALLBACK_WINDOW CallbackType = 36 // When for the current cell is defined a validity list we need to show // a drop down button in the form of a marker. // // The payload format is: "x, y, visible" where x, y are the current // cell cursor coordinates and visible is set to 0 or 1. CALLBACK_VALIDITY_LIST_BUTTON CallbackType = 37 // Notification that the clipboard contents have changed. // Typically fired in response to copying to clipboard. // // Payload is optional. When payload is empty, Online gets string from selected text. // Payload format is JSON. // Example: { "mimeType": "text/plain", "content": "some content" } CALLBACK_CLIPBOARD_CHANGED CallbackType = 38 // When the (editing) context changes - like the user switches from // editing textbox in Impress to editing a shape there. // // Payload is the application ID and context, delimited by space. // Eg. com.sun.star.presentation.PresentationDocument TextObject CALLBACK_CONTEXT_CHANGED CallbackType = 39 // On-load notification of the document signature status. CALLBACK_SIGNATURE_STATUS CallbackType = 40 // Profiling tracing information single string of multiple lines // containing <pid> <timestamp> and zone start/stop information CALLBACK_PROFILE_FRAME CallbackType = 41 // The position and size of the cell selection area. It is used to // draw the selection handles for cells in Calc documents. // // Rectangle format is the same as CALLBACK_INVALIDATE_TILES. CALLBACK_CELL_SELECTION_AREA CallbackType = 42 // The position and size of the cell auto fill area. It is used to // trigger auto fill functionality if that area is hit. // // Rectangle format is the same as CALLBACK_INVALIDATE_TILES. CALLBACK_CELL_AUTO_FILL_AREA CallbackType = 43 // When the cursor is in a table or a table is selected in the // document, this sends the table's column and row border positions // to the client. If the payload is empty (empty JSON object), then // no table is currently selected or the cursor is not inside a table // cell. CALLBACK_TABLE_SELECTED CallbackType = 44 // Show reference marks from payload. // // Example payload: // { // "marks": [ // { "rectangle": "3825, 3315, 1245, 2010", "color": "0000ff", "part": "0" }, // { "rectangle": "8925, 4335, 2520, 735", "color": "ff0000", "part": "0" }, // ... // ] // } CALLBACK_REFERENCE_MARKS CallbackType = 45 // Callback related to native dialogs generated in JavaScript from // the description. CALLBACK_JSDIALOG CallbackType = 46 // Send the list of functions whose name starts with the characters entered // by the user in the formula input bar. CALLBACK_CALC_FUNCTION_LIST CallbackType = 47 // Sends the tab stop list for the current of the current cursor position. CALLBACK_TAB_STOP_LIST CallbackType = 48 // Sends all information for displaying form field button for a text based field. // // It contains the position where the frame with the button should be displayed and // also contains all information that the popup window needs. // // The payload example: // { // "action": "show", // "type": "drop-down", // "textArea": "1418, 3906, 3111, 919", // "params": { // "items": ["January", "February", "July"], // "selected": "2", // "placeholder": "No items specified" // } // } // // or // { // "action": "hide", // "type": "drop-down" // } CALLBACK_FORM_FIELD_BUTTON CallbackType = 49 // This is Calc specific. Indicates that some or all of the current sheet's // geometry data has changed. Clients must request a full or partial sheet // geometry data set. // // The payload specifies what part of the sheet geometry data has changed. // The payload format is: // 'all|rows|columns [sizes [hidden [filtered [groups]]]]' // // For example, the payload 'rows sizes groups' indicates that the row heights // and row-groups data have changed. CALLBACK_INVALIDATE_SHEET_GEOMETRY CallbackType = 50 // When for the current cell is defined an input help text. // // The payload format is JSON: { "title": "title text", "content": "content text" } CALLBACK_VALIDITY_INPUT_HELP CallbackType = 51 // This is currently Calc only. Indicates the document background // color in the payload as a RGB hex string (RRGGBB). CALLBACK_DOCUMENT_BACKGROUND_COLOR CallbackType = 52 // When a user tries to use command which is restricted for that user COMMAND_BLOCKED CallbackType = 53 // The position of the cell cursor jumped to. // // Payload format: "x, y, width, height, column, row", where the first // 4 numbers are document coordinates, in twips, and the last 2 are table // coordinates starting from 0. // When the cursor is not shown the payload format is the "EMPTY" string. // // Rectangle format is the same as CALLBACK_INVALIDATE_TILES. CALLBACK_SC_FOLLOW_JUMP CallbackType = 54 )
func (CallbackType) String ¶
func (t CallbackType) String() string
String returns the string representation of a CallbackType enumeration element, mirroring lokCallbackTypeToString() in LibreOfficeKitEnums.h.
type ClipboardData ¶
ClipboardData is a single clipboard item: a MIME type and its content.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents one loaded document instance. A Document is typically created by Office.DocumentLoad.
func (Document) AddCertificate ¶
AddCertificate adds the certificate (in binary form) to the certificate store.
func (Document) CompleteFunction ¶
CompleteFunction selects the Calc function to be pasted into the formula input box.
func (Document) CreateView ¶
CreateView creates a new view for the existing document. By default a loaded document has 1 view; it returns the ID of the new view.
func (Document) CreateViewWithOptions ¶
CreateViewWithOptions creates a new view for the existing document with options similar to DocumentLoadWithOptions. By default a loaded document has 1 view; it returns the ID of the new view.
func (Document) Destroy ¶
func (d Document) Destroy()
Destroy releases the underlying LibreOfficeKit document.
func (Document) DestroyView ¶
DestroyView destroys a view of the existing document. id is a view ID returned by CreateView or CreateViewWithOptions.
func (Document) Doc ¶
func (d Document) Doc() *capi.LibreOfficeKitDocument
Doc returns the underlying LibreOfficeKitDocument handle for low-level access.
func (Document) GetClipboard ¶
func (d Document) GetClipboard(requested []string) ([]ClipboardData, bool)
GetClipboard returns the content on the clipboard for the current view as a series of binary streams. requested is a list of mime types to fetch; an empty (or nil) list fetches the complete set of available types.
func (Document) GetCommandValues ¶
GetCommandValues returns a JSON mapping of the possible values for the given command, e.g. {commandName: ".uno:StyleApply", commandValues: {...}}.
func (Document) GetDocumentSize ¶
GetDocumentSize returns the size of the document in twips.
func (Document) GetDocumentType ¶
func (d Document) GetDocumentType() DocumentType
GetDocumentType returns the document type, an element of the DocumentType enum.
func (Document) GetPartHash ¶
GetPartHash returns the current part's hash.
func (Document) GetPartInfo ¶
GetPartInfo returns information about the given part, e.g. the hidden state of Calc sheets, in JSON format.
func (Document) GetPartName ¶
GetPartName returns the current part's name.
func (Document) GetPartPageRectangles ¶
GetPartPageRectangles returns the logical rectangle of each part. A part refers to an individual page in Writer and has no relevance for Calc or Impress. The rectangle list uses the same format as CALLBACK_TEXT_SELECTION.
func (Document) GetParts ¶
GetParts returns the number of parts in the document. A part refers to either individual sheets in Calc, or slides in Impress, and has no relevance for Writer.
func (Document) GetSelectionType ¶
func (d Document) GetSelectionType() SelectionType
GetSelectionType returns the type of the selected content, an element of the SelectionType enum.
func (Document) GetSignatureState ¶
func (d Document) GetSignatureState() SignatureState
GetSignatureState verifies the signature of the document and returns an element of the SignatureState enum.
func (Document) GetTextSelection ¶
GetTextSelection returns the currently selected text. mimeType suggests the return format, e.g. "text/plain;charset=utf-8". usedMimeType reports the determined format (the suggested one or plain text).
func (Document) GetTileMode ¶
GetTileMode returns the tile mode: the pixel format used for the buffer of PaintTile, an element of the TileMode enum.
func (Document) GetViewIds ¶
GetViewIds returns the view ID for each existing view. Since view IDs are not reused, they are not the same as the index of the view in the view array over time. Use GetViewsCount to size the result.
func (Document) GetViewsCount ¶
GetViewsCount returns the number of views of this document.
func (Document) InitializeForRendering ¶
InitializeForRendering sets the rendering and document parameters to default values needed for tiled rendering. It must be called right after DocumentLoad if any of the tiled rendering methods are used later. arguments is a JSON string, e.g. for text documents:
{
".uno:HideWhitespace":
{
"type": "boolean",
"value": "true"
}
}
func (Document) InsertCertificate ¶
InsertCertificate inserts a certificate (in binary form) into the certificate store.
func (Document) MoveSelectedParts ¶
MoveSelectedParts moves the selected pages/slides to a new position. duplicate, when true, copies instead of moving.
func (Document) PaintPartTile ¶
func (d Document) PaintPartTile(buffer []byte, part, canvasWidth, canvasHeight, tilePosX, tilePosY, tileWidth, tileHeight int)
PaintPartTile renders a subset of the document's part to a pre-allocated buffer. part is the part number of the document whose tile is painted; see PaintTile for the coordinate semantics.
func (Document) PaintTile ¶
func (d Document) PaintTile(buffer []byte, canvasWidth, canvasHeight, tilePosX, tilePosY, tileWidth, tileHeight int)
PaintTile renders a subset of the document to a pre-allocated buffer. The buffer size and the tile size are independent, so different zoom levels are supported implicitly (number of rendered pixels vs. the rendered rectangle of the document are independent).
- buffer: pre-allocated pixel buffer; its size is determined by canvasWidth and canvasHeight (RGBA, 4 bytes per pixel).
- tilePosX/Y: logical position of the top left corner of the rendered rectangle, in twips.
- tileWidth/Height: logical size of the rendered rectangle, in twips.
func (Document) PaintWindow ¶
PaintWindow renders a window (dialog, popup, etc.) with the given id into buffer. x, y, width, height are the window image rect to paint.
func (Document) PaintWindowDPI ¶
func (d Document) PaintWindowDPI(windowID uint, buffer []byte, x, y, width, height int, dpiScale float64)
PaintWindowDPI renders a window with the given id into buffer, with a dpi scale value applied by the client.
func (Document) PaintWindowForView ¶
func (d Document) PaintWindowForView(windowID uint, buffer []byte, x, y, width, height int, dpiScale float64, viewID int)
PaintWindowForView renders a window with the given id for a specific view, with a dpi scale applied. viewID -1 uses the current view.
func (Document) Paste ¶
Paste pastes content at the current cursor position. mimeType is the format of data, e.g. "text/plain;charset=utf-8". It reports whether the supplied data was pasted successfully.
func (Document) PostKeyEvent ¶
func (d Document) PostKeyEvent(typ KeyEventType, charCode, keyCode int)
PostKeyEvent posts a keyboard event to the focused frame.
- typ: event type, like press or release.
- charCode: the Unicode character generated by this event, or 0.
- keyCode: the integer code representing the key (non-zero for control keys).
func (Document) PostMouseEvent ¶
func (d Document) PostMouseEvent(typ MouseEventType, x, y, count, buttons, modifier int)
PostMouseEvent posts a mouse event to the document.
- typ: event type, like down, move or up.
- x, y: position in document coordinates.
- count: number of clicks: 1 for single click, 2 for double click.
- buttons: which mouse buttons: 1 for left, 2 for middle, 4 for right.
- modifier: which keyboard modifier (see VCL key modifiers).
func (Document) PostUnoCommand ¶
PostUnoCommand posts a UNO command to the document, e.g. ".uno:Bold". arguments is a JSON string of command arguments, e.g.:
{
"SearchItem.SearchString":
{
"type": "string",
"value": "foobar"
},
"SearchItem.Backward":
{
"type": "boolean",
"value": "false"
}
}
notify, when true, requests a notification when the command has finished.
func (Document) PostWindow ¶
func (d Document) PostWindow(windowID uint, action WindowAction, data string)
PostWindow posts a command to the window (dialog, popup, etc.) with the given id. action is a WindowAction; data is optional command data.
func (Document) PostWindowExtTextInputEvent ¶
func (d Document) PostWindowExtTextInputEvent(windowID uint, typ ExtTextInputType, text string)
PostWindowExtTextInputEvent posts text input from an external input window, like IME, to the given window id. If windowID is 0, the event is posted into the document. typ is an ExtTextInputType.
func (Document) PostWindowGestureEvent ¶
PostWindowGestureEvent posts a gesture event to the window with the given id. typ is the event type, like "panStart", "panEnd" or "panUpdate"; offset is the difference value from when the gesture started to the current value.
func (Document) PostWindowKeyEvent ¶
func (d Document) PostWindowKeyEvent(windowID uint, typ KeyEventType, charCode, keyCode int)
PostWindowKeyEvent posts a keyboard event to the dialog with the given id. See PostKeyEvent for the event parameters.
func (Document) PostWindowMouseEvent ¶
func (d Document) PostWindowMouseEvent(windowID uint, typ MouseEventType, x, y, count, buttons, modifier int)
PostWindowMouseEvent posts a mouse event to the window with the given id. See PostMouseEvent for the event parameters.
func (Document) RegisterCallback ¶
RegisterCallback registers a callback for this document. LOK invokes it whenever it wants to inform the client about document events.
func (Document) RemoveTextContext ¶
RemoveTextContext deletes many characters all at once. windowID is the window to post the input event to (0 posts into the document); before and after are the numbers of characters to delete before/after the cursor.
func (Document) RenderFont ¶
RenderFont paints a font name or character, as displayed in the font list. It returns the bitmap plus its width and height in pixels.
func (Document) RenderFontOrientation ¶
func (d Document) RenderFontOrientation(fontName, ch string, orientation int) (bitmap []byte, width, height int)
RenderFontOrientation paints a font name or character with the given orientation (in degrees), returning the bitmap plus its size.
func (Document) RenderSearchResult ¶
func (d Document) RenderSearchResult(searchResult string) (bitmap []byte, width, height int, ok bool)
RenderSearchResult renders an input search result to a bitmap buffer.
func (Document) RenderShapeSelection ¶
RenderShapeSelection returns an image of the selected shapes (PNG data, to be freed by the caller).
func (Document) ResetSelection ¶
func (d Document) ResetSelection()
ResetSelection gets rid of any text or graphic selection.
func (Document) ResizeWindow ¶
ResizeWindow resizes a window (dialog, popup, etc.) with the given id.
func (Document) SaveAs ¶
SaveAs stores the document's persistent data to a URL and continues to be a representation of the old URL.
- url: the location where to store the document.
- format: the export format; when omitted, deducted from the URL's extension.
- filterOptions: options for the export filter, e.g. "SkipImages". Another useful option is "TakeOwnership": the document identity changes to url and '.uno:ModifiedStatus' is triggered like "Save As..." in the UI. "TakeOwnership" must not be used when saving to PNG or PDF.
func (Document) SelectPart ¶
SelectPart sets a part's selection mode. selectMode is 0 to deselect, 1 to select, and 2 to toggle.
func (Document) SendDialogEvent ¶
SendDialogEvent posts a dialog event for the window with the given id. args are the arguments of the event.
func (Document) SendFormFieldEvent ¶
SendFormFieldEvent posts an event for the form field at the cursor position. args are the arguments of the event.
func (Document) SetBlockedCommandList ¶
SetBlockedCommandList sets a list of commands that are blocked for the given view.
func (Document) SetClientVisibleArea ¶
SetClientVisibleArea informs core about the currently visible area of the document on the client, so that it can perform e.g. page down (which depends on the visible height) in a sane way.
func (Document) SetClientZoom ¶
SetClientZoom saves the client's view so that the right zoom level can be computed for mouse events. This only affects Calc.
func (Document) SetClipboard ¶
func (d Document) SetClipboard(data []ClipboardData) bool
SetClipboard populates the clipboard for this view with multiple types of content. It reports whether the supplied data was populated successfully.
func (Document) SetGraphicSelection ¶
func (d Document) SetGraphicSelection(typ SetGraphicSelectionType, x, y int)
SetGraphicSelection adjusts the graphic selection. typ is an element of SetGraphicSelectionType; x, y are in document coordinates.
func (Document) SetOutlineState ¶
SetOutlineState shows or hides a single row/column header outline for Calc documents (collapsed/expanded groups).
func (Document) SetPartMode ¶
SetPartMode sets the part's selection mode (body, header or footer).
func (Document) SetTextSelection ¶
func (d Document) SetTextSelection(typ SetTextSelectionType, x, y int)
SetTextSelection sets the start or end of a text selection. typ is an element of SetTextSelectionType; x, y are in document coordinates.
func (Document) SetView ¶
SetView sets an existing view of the existing document as current. id is a view ID returned by CreateView or CreateViewWithOptions.
func (Document) SetViewLanguage ¶
SetViewLanguage sets the language tag of the view with the specified id. language is a BCP47 language tag, like "en-US".
type DocumentType ¶
type DocumentType int
const ( DOCTYPE_TEXT DocumentType = iota DOCTYPE_SPREADSHEET DOCTYPE_PRESENTATION DOCTYPE_DRAWING DOCTYPE_OTHER )
type ExtTextInputType ¶
type ExtTextInputType int
const ( // cf. SalEvent::ExtTextInput EXT_TEXTINPUT ExtTextInputType = iota // cf. SalEvent::ExtTextInputPos EXT_TEXTINPUT_POS // cf. SalEvent::EndExtTextInput EXT_TEXTINPUT_END )
type KeyEventType ¶
type KeyEventType int
const ( // A key on the keyboard is pressed. KEYEVENT_KEYINPUT KeyEventType = iota // A key on the keyboard is released. KEYEVENT_KEYUP )
type MouseEventType ¶
type MouseEventType int
const ( // A pressed gesture has started. MOUSEEVENT_MOUSEBUTTONDOWN MouseEventType = iota // A pressed gesture has finished. MOUSEEVENT_MOUSEBUTTONUP // A change has happened during a press gesture. MOUSEEVENT_MOUSEMOVE )
type Office ¶
type Office struct {
// contains filtered or unexported fields
}
Office represents one started LibreOfficeKit instance. An Office is typically created by NewOffice.
func NewOffice ¶
NewOffice initializes a LibreOfficeKit instance from the given LibreOffice install path and starts the office. Use the standard path "/usr/lib/libreoffice/program" for a default installation. Only one Office instance may exist per process.
func (Office) DocumentLoad ¶
DocumentLoad loads a document from a URL.
- url: the URL of the document to load.
- filterOptions: options for the import filter, e.g. "SkipImages" or "Language=..." (switches LibreOfficeKit's language accordingly first).
func (Office) DocumentLoadWithOptions ¶
DocumentLoadWithOptions loads a document from a URL with explicit import filter options. See DocumentLoad for the parameters.
func (Office) GetError ¶
GetError returns the last error raised by the underlying LibreOfficeKit instance, or nil if there is none.
func (Office) GetFilterTypes ¶
GetFilterTypes returns details of the filter types as a JSON string, e.g.:
{
"writer8": {
"MediaType": "application/vnd.oasis.opendocument.text"
},
"calc8": {
"MediaType": "application/vnd.oasis.opendocument.spreadsheet"
}
}
func (Office) GetVersionInfo ¶
GetVersionInfo returns version information of the LOKit process as a JSON string: {ProductName: <>, ProductVersion: <>, ProductExtension: <>, BuildId: <>}.
func (Office) Lok ¶
func (o Office) Lok() *capi.LibreOfficeKit
Lok returns the underlying LibreOfficeKit handle for low-level access.
func (Office) RegisterCallback ¶
RegisterCallback registers a callback for the office. LOK invokes it when it wants to inform the client about office-level events.
func (Office) RunLoop ¶
func (o Office) RunLoop(poll PollCallback, wake WakeCallback)
RunLoop runs the main loop in the current thread. To trigger this mode, set SAL_LOK_OPTIONS to contain 'unipoll'. poll is called to poll for events from the kit client, and wake may be called by internal LibreOfficeKit threads to wake the caller of RunLoop. RunLoop is expected not to return until kit exit.
func (Office) RunMacro ¶
RunMacro runs a macro. The same syntax as on the command line is permissible (i.e. the macro:// URI forms).
func (Office) SendDialogEvent ¶
SendDialogEvent posts a dialog event for the window with the given id. args are the arguments of the event.
func (Office) SetDocumentPassword ¶
SetDocumentPassword sets the password required for loading or editing a document. Loading is blocked until the password is provided. In response to CALLBACK_DOCUMENT_PASSWORD, a valid password continues loading, an invalid password triggers another password request, and a nil password aborts loading. In response to CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY, a nil password continues loading the document in read-only mode.
func (Office) SetOption ¶
SetOption toggles and tweaks various things in the core LO, e.g. "profilezonerecording" ("start"/"stop") or "sallogoverride" (a string overriding the SAL_LOG environment variable).
func (Office) SetOptionalFeatures ¶
func (o Office) SetOptionalFeatures(features OptionalFeatures)
SetOptionalFeatures sets the bitmask of optional features supported by the client, an element of the OptionalFeatures flags.
type OptionalFeatures ¶
type OptionalFeatures uint64
Optional features of LibreOfficeKit, in particular callbacks that block LibreOfficeKit until the corresponding reply is received, which would deadlock if the client does not support the feature.
const ( // Handle CALLBACK_DOCUMENT_PASSWORD by prompting the user // for a password. FEATURE_DOCUMENT_PASSWORD OptionalFeatures = 1 << iota // Handle CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY by prompting the user // for a password. FEATURE_DOCUMENT_PASSWORD_TO_MODIFY // Request to have the part number as an 5th value in the // CALLBACK_INVALIDATE_TILES payload. FEATURE_PART_IN_INVALIDATION_CALLBACK // Turn off tile rendering for annotations FEATURE_NO_TILED_ANNOTATIONS // Enable range based header data FEATURE_RANGE_HEADERS // Request to have the active view's Id as the 1st value in the // CALLBACK_INVALIDATE_VISIBLE_CURSOR payload. FEATURE_VIEWID_IN_VISCURSOR_INVALIDATION_CALLBACK )
type PollCallback ¶
type SelectionType ¶
type SelectionType int
const ( SELTYPE_NONE SelectionType = iota SELTYPE_TEXT SELTYPE_LARGE_TEXT SELTYPE_COMPLEX )
type SetGraphicSelectionType ¶
type SetGraphicSelectionType int
const ( // A move or a resize action starts. It is assumed that there is a valid // graphic selection (see CALLBACK_GRAPHIC_SELECTION) and the supplied // coordinates are the ones the user tapped on. // // The type of the action is move by default, unless the coordinates are // the position of a handle (see below), in which case it's a resize. // // There are 8 handles for a graphic selection: // - top-left, top-center, top-right // - middle-left, middle-right // - bottom-left, bottom-center, bottom-right SETGRAPHICSELECTION_START SetGraphicSelectionType = iota // A move or resize action stops. It is assumed that this is always used // only after a SETTEXTSELECTION_START. The supplied coordinates are // the ones where the user released the screen. SETGRAPHICSELECTION_END )
type SetTextSelectionType ¶
type SetTextSelectionType int
const ( // The start of selection is to be adjusted. SETTEXTSELECTION_START SetTextSelectionType = iota // The end of selection is to be adjusted. SETTEXTSELECTION_END // Both the start and the end of selection is to be adjusted. SETTEXTSELECTION_RESET )
type SignatureState ¶
type SignatureState int
SignatureState is the signing state of a document, as returned by Document.GetSignatureState.
const ( // The document is not signed. SIGNATURE_NONE SignatureState = iota // The document is signed and the signature is valid. SIGNATURE_OK // The document is signed but the signature is invalid. SIGNATURE_INVALID // The document has a partial set of signatures. SIGNATURE_PARTIAL )
type WakeCallback ¶
type WakeCallback func()