LOKDocView.View

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned LOKDocView.View LOKDocView.View Gio.Initable->LOKDocView.View Gtk.Buildable->Gtk.Widget Gtk.DrawingArea Gtk.DrawingArea Gtk.DrawingArea->LOKDocView.View Gtk.Widget->Gtk.DrawingArea

Subclasses:

None

Methods

Inherited:

Gtk.DrawingArea (1), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gio.Initable (2)

Structs:

Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new (pPath, cancellable)

class

new_from_user_profile (pPath, pUserProfile, cancellable)

copy_selection (pMimeType)

find_next (pText, bHighlightAll)

find_prev (pText, bHighlightAll)

get_command_values (pCommand)

get_edit ()

get_part ()

get_part_name (nPart)

get_parts ()

get_version_info ()

get_zoom ()

highlight_all (pText)

new_from_widget (pRenderingArguments)

open_document (pPath, pRenderingArguments, cancellable, callback, *userdata)

open_document_finish (res)

paste (pMimeType, pData, nSize)

pixel_to_twip (fInput)

post_command (pCommand, pArguments, bNotifyWhenFinished)

reset_view ()

send_content_control_event (pArguments)

set_document_password (pURL, pPassword)

set_edit (bEdit)

set_part (nPart)

set_partmode (nPartMode)

set_visible_area (pVisibleArea)

set_zoom (fZoom)

twip_to_pixel (fInput)

Virtual Methods

Inherited:

Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gio.Initable (1)

Properties

Inherited:

Gtk.Widget (39)

Name

Type

Flags

Short Description

can-zoom-in

bool

r

Whether the view can be zoomed in further

can-zoom-out

bool

r

Whether the view can be zoomed out further

doc-height

r/w

Height of the document in twips

doc-password

bool

r/w

Whether client supports providing document passwords

doc-password-to-modify

bool

r/w

Whether the client supports providing passwords to edit documents

doc-width

r/w

Width of the document in twips

docpath

str

r/w

The URI of the document to open

docpointer

int

r/w

A LibreOfficeKitDocument* from documentLoad()

editable

bool

r/w

Whether the content is in edit mode or not

is-initialized

bool

r

Whether the view has completely initialized

is-loading

bool

r

Whether the view is loading a document

load-progress

float

r

Shows the progress of the document load operation

lopath

str

r/w/co

LibreOffice Install Path

lopointer

int

r/w/co

A LibreOfficeKit* from lok_init()

tiled-annotations

bool

r/w

Whether the client wants in tile comment rendering

unipoll

bool

r/w/co

Whether we use a custom unified polling loop

userprofileurl

str

r/w/co

LibreOffice user profile path

zoom-level

float

r/w

The current zoom level of the content

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Widget (69), GObject.Object (1)

Name

Short Description

address-changed

command-changed

command-result

comment

content-control

cursor-changed

edit-changed

formula-changed

hyperlink-clicked

invalidate-header

The column/row header is no more valid because of a column/row insertion or a similar event.

load-changed

part-changed

password-required

Password must be provided by calling LOKDocView.View.set_document_password function with pUrl as provided by the callback.

ruler

The payload format is: { “margin1”: “…”, “margin2”: “…”, “leftOffset”: “…”, “pageOffset”: “…”, “pageWidth”: “…”, “unit”: “…” }

search-not-found

search-result-count

size-changed

text-selection

window

This signal emits information about external windows like dialogs, autopopups for now.

Fields

Inherited:

Gtk.Widget (69), GObject.Object (1)

Name

Type

Access

Description

aDrawingArea

Gtk.DrawingArea

r

Class Details

class LOKDocView.View(**kwargs)
Bases:

Gtk.DrawingArea, Gio.Initable

Abstract:

No

Structure:

LOKDocView.ViewClass

classmethod new(pPath, cancellable)
Parameters:
  • pPath (str or None) – LibreOffice install path. Pass null to set it to default path which in most cases would be $libdir/libreoffice/program

  • cancellable (Gio.Cancellable or None) – The cancellable object that you can use to cancel this operation.

Raises:

GLib.Error

Returns:

The LOKDocView.View widget instance.

Return type:

Gtk.Widget

classmethod new_from_user_profile(pPath, pUserProfile, cancellable)
Parameters:
  • pPath (str or None) – LibreOffice install path. Pass null to set it to default path which in most cases would be $libdir/libreoffice/program

  • pUserProfile (str or None) – User profile URL. Must be either a file URL or a special vnd.sun.star.pathname URL. Pass non-null to be able to use this widget and LibreOffice itself in parallel.

  • cancellable (Gio.Cancellable or None) – The cancellable object that you can use to cancel this operation.

Raises:

GLib.Error

Returns:

The LOKDocView.View widget instance.

Return type:

Gtk.Widget

copy_selection(pMimeType)
Parameters:

pMimeType (str) – suggests the return format, for example text/plain;charset=utf-8

Returns:

Selected text. The caller must free the returned buffer after use. Returns null if no document is set.

pUsedMimeType:

output parameter to inform about the determined format (suggested or plain text).

Return type:

(str, pUsedMimeType: str)

find_next(pText, bHighlightAll)
Parameters:
  • pText (str) – text to search for

  • bHighlightAll (bool) – Whether all the matches should be highlighted or not

Highlights the next matching text in the view. search-not-found signal will be emitted when no search is found

find_prev(pText, bHighlightAll)
Parameters:
  • pText (str) – text to search for

  • bHighlightAll (bool) – Whether all the matches should be highlighted or not

Highlights the previous matching text in the view. search-not-found signal will be emitted when no search is found

get_command_values(pCommand)
Parameters:

pCommand (str) – the command to issue to LO core

Returns:

A json mapping of the possible values for the given command

Return type:

str

Get a json mapping of the possible values for the given command. In the form of: {commandName: unoCmd, commandValues: {possible_values}}

get_edit()
Returns:

True if the given pDocView is in edit mode.

Return type:

bool

Gets if the viewer is actually an editor or not.

get_part()
Returns:

Current part number of the document. Returns -1 if no document is set currently.

Return type:

int

get_part_name(nPart)
Parameters:

nPart (int) –

Returns:

Get current part name of loaded document. Returns null if no document is set, or document has been destroyed using lok_doc_view_destroy_document.

Return type:

str

get_parts()
Returns:

Part refers to either individual sheets in a Calc, or slides in Impress, and has no relevance for Writer. Returns -1 if no document is set currently.

Return type:

int

get_version_info()
Returns:

JSON string containing version information in format: {ProductName: <>, ProductVersion: <>, ProductExtension: <>, BuildId: <>}

Eg: {“ProductName”: “LibreOffice”, “ProductVersion”: “5.3”, “ProductExtension”: “.0.0.alpha0”, “BuildId”: “<full 40 str git hash>”}

Return type:

str

Get version information of the LOKit process

get_zoom()
Returns:

The current zoom factor value in float for pDocView

Return type:

float

highlight_all(pText)
Parameters:

pText (str) – text to search for

Highlights all matching texts in the view. search-not-found signal will be emitted when no search is found

new_from_widget(pRenderingArguments)
Parameters:

pRenderingArguments (str or None) – lok::Document:py:func:::initializeForRendering<LOKDocView.View.signals.initializeForRendering>() arguments.

Returns:

The LOKDocView.View widget instance.

Return type:

Gtk.Widget

open_document(pPath, pRenderingArguments, cancellable, callback, *userdata)
Parameters:
open_document_finish(res)
Parameters:

res (Gio.AsyncResult) –

Raises:

GLib.Error

Returns:

True if the document is loaded successfully, False otherwise

Return type:

bool

paste(pMimeType, pData, nSize)
Parameters:
  • pMimeType (str) – format of pData, for example text/plain;charset=utf-8

  • pData (str) – the data to be pasted

  • nSize (int) – length of data to be pasted

Returns:

if pData was pasted successfully.

Return type:

bool

Pastes the content at the current cursor position

pixel_to_twip(fInput)
Parameters:

fInput (float) – The value in pixels to convert to twips

Returns:

The corresponding value in twips

Return type:

float

Converts the value in pixels to twips according to zoom level.

post_command(pCommand, pArguments, bNotifyWhenFinished)
Parameters:
  • pCommand (str) – the command to issue to LO core

  • pArguments (str) – the arguments to the given command

  • bNotifyWhenFinished (bool) – normally false, but it may be useful for eg. .uno:Save

Posts the .uno: command to the LibreOfficeKit.

reset_view()
send_content_control_event(pArguments)
Parameters:

pArguments (str or None) – see lok::Document:py:func:::sendContentControlEvent<LOKDocView.View.signals.sendContentControlEvent>() for the details.

set_document_password(pURL, pPassword)
Parameters:
  • pURL (str) – the URL of the document to set password for, as sent with signal password-required

  • pPassword (str or None) – the password, None for no password

Set the password for password protected documents

set_edit(bEdit)
Parameters:

bEdit (bool) – True if the pDocView should go in edit mode, False otherwise

Sets if the viewer is actually an editor or not.

set_part(nPart)
Parameters:

nPart (int) –

set_partmode(nPartMode)
Parameters:

nPartMode (int) –

set_visible_area(pVisibleArea)
Parameters:

pVisibleArea (Gdk.Rectangle) – The new visible area of pDocView in twips.

Sets the new visible area of the widget. This helps e.g. the page down key to jump the correct length, which depends on the amount of visible height of the document.

set_zoom(fZoom)
Parameters:

fZoom (float) – The new zoom level that pDocView must set it into.

Sets the new zoom level for the widget. Does nothing if fZoom is equal to existing zoom level. Values outside the range [0.25, 5.0] are clamped into the nearest allowed value in the interval.

twip_to_pixel(fInput)
Parameters:

fInput (float) – The value in twips to convert to pixels

Returns:

The corresponding value in pixels

Return type:

float

Converts the value in twips to pixels according to zoom level.

Signal Details

LOKDocView.View.signals.address_changed(view, aCommand)
Signal Name:

address-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (str) – formula text content

LOKDocView.View.signals.command_changed(view, aCommand)
Signal Name:

command-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (str) – the command that was changed

LOKDocView.View.signals.command_result(view, aCommand)
Signal Name:

command-result

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (str) – JSON containing the info about the command that finished, and its success status.

LOKDocView.View.signals.comment(view, pComment)
Signal Name:

comment

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • pComment (str) – the JSON string containing comment notification The has following structure containing the information telling whether the comment has been added, deleted or modified. The example: { “comment”: { “action”: “Add”, “id”: “11”, “parent”: “4”, “author”: “Unknown Author”, “text”: “This is a comment”, “dateTime”: “2016-08-18T13:13:00”, “anchorPos”: “4529, 3906”, “textRange”: “1418, 3906, 3111, 919” } } ‘action’ can be ‘Add’, ‘Remove’ or ‘Modify’ depending on whether comment has been added, removed or modified. ‘parent’ is a non-zero comment id if this comment is a reply comment, otherwise it’s a root comment.

LOKDocView.View.signals.content_control(view, pPayload)
Signal Name:

content-control

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • pPayload (str) – the JSON string containing the information about ruler properties

LOKDocView.View.signals.cursor_changed(view, nX, nY, nWidth, nHeight)
Signal Name:

cursor-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • nX (int) – The new cursor position (X coordinate) in pixels

  • nY (int) – The new cursor position (Y coordinate) in pixels

  • nWidth (int) – The width of new cursor

  • nHeight (int) – The height of new cursor

LOKDocView.View.signals.edit_changed(view, bEdit)
Signal Name:

edit-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • bEdit (bool) – the new edit value of the view

LOKDocView.View.signals.formula_changed(view, aCommand)
Signal Name:

formula-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (str) – formula text content

Signal Name:

hyperlink-clicked

Flags:

RUN_FIRST

Parameters:
LOKDocView.View.signals.invalidate_header(view, pPayload)
Signal Name:

invalidate-header

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • pPayload (str) – can be either “row”, “column”, or “all”.

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

LOKDocView.View.signals.load_changed(view, fLoadProgress)
Signal Name:

load-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • fLoadProgress (float) – the new progress value

LOKDocView.View.signals.part_changed(view, aCommand)
Signal Name:

part-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (int) – the part number which the view changed to

LOKDocView.View.signals.password_required(view, pUrl, bModify)
Signal Name:

password-required

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • pUrl (str) – URL of the document for which password is required

  • bModify (bool) – whether password id required to modify the document This is true when password is required to edit the document, while it can still be viewed without password. In such cases, provide a None password for read-only access to the document. If false, password is required for opening the document, and document cannot be opened without providing a valid password.

Password must be provided by calling LOKDocView.View.set_document_password function with pUrl as provided by the callback.

Upon entering an invalid password, another password-required signal is emitted. Upon entering a valid password, document starts to load. Upon entering a None password: if bModify is True, document starts to open in view-only mode, else loading of document is aborted.

LOKDocView.View.signals.ruler(view, pPayload)
Signal Name:

ruler

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • pPayload (str) – the JSON string containing the information about ruler properties

The payload format is:

{ “margin1”: “…”, “margin2”: “…”, “leftOffset”: “…”, “pageOffset”: “…”, “pageWidth”: “…”, “unit”: “…” }

LOKDocView.View.signals.search_not_found(view, aCommand)
Signal Name:

search-not-found

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (str) – the string for which the search was not found.

LOKDocView.View.signals.search_result_count(view, aCommand)
Signal Name:

search-result-count

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (str) – number of matches.

LOKDocView.View.signals.size_changed(view, aCommand)
Signal Name:

size-changed

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • aCommand (int) – None, we just notify that want to notify the UI elements that are interested.

LOKDocView.View.signals.text_selection(view, bIsTextSelected)
Signal Name:

text-selection

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • bIsTextSelected (bool) – whether text selected is non-null

LOKDocView.View.signals.window(view, pPayload)
Signal Name:

window

Flags:

RUN_FIRST

Parameters:
  • view (LOKDocView.View) – The object which received the signal

  • pPayload (str) – the JSON string containing the information about the window

This signal emits information about external windows like dialogs, autopopups for now.

The payload format of pPayload 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.)

“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

Property Details

LOKDocView.View.props.can_zoom_in
Name:

can-zoom-in

Type:

bool

Default Value:

True

Flags:

READABLE

It tells whether the view can further be zoomed in or not.

LOKDocView.View.props.can_zoom_out
Name:

can-zoom-out

Type:

bool

Default Value:

True

Flags:

READABLE

It tells whether the view can further be zoomed out or not.

LOKDocView.View.props.doc_height
Name:

doc-height

Type:

Default Value:

0

Flags:

READABLE, WRITABLE

The height of the currently loaded document in LOKDocView.View in twips.

LOKDocView.View.props.doc_password
Name:

doc-password

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Set it to true if client supports providing password for viewing password protected documents

LOKDocView.View.props.doc_password_to_modify
Name:

doc-password-to-modify

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Set it to true if client supports providing password for edit-protected documents

LOKDocView.View.props.doc_width
Name:

doc-width

Type:

Default Value:

0

Flags:

READABLE, WRITABLE

The width of the currently loaded document in LOKDocView.View in twips.

LOKDocView.View.props.docpath
Name:

docpath

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The path of the document that is currently being viewed.

LOKDocView.View.props.docpointer
Name:

docpointer

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE

A LibreOfficeKitDocument* in case documentLoad() is already called previously.

LOKDocView.View.props.editable
Name:

editable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Whether the document loaded inside of LOKDocView.View is editable or not.

LOKDocView.View.props.is_initialized
Name:

is-initialized

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the requested document has completely loaded or not.

LOKDocView.View.props.is_loading
Name:

is-loading

Type:

bool

Default Value:

False

Flags:

READABLE

Whether the requested document is being loaded or not. True if it is being loaded, otherwise False.

LOKDocView.View.props.load_progress
Name:

load-progress

Type:

float

Default Value:

0.0

Flags:

READABLE

The percent completion of the current loading operation of the document. This can be used for progress bars. Note that this is not a very accurate progress indicator, and its value might reset it couple of times to 0 and start again. You should not rely on its numbers.

LOKDocView.View.props.lopath
Name:

lopath

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The absolute path of the LibreOffice install.

LOKDocView.View.props.lopointer
Name:

lopointer

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A LibreOfficeKit* in case lok_init() is already called previously.

LOKDocView.View.props.tiled_annotations
Name:

tiled-annotations

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Whether the client wants in tile comment rendering

LOKDocView.View.props.unipoll
Name:

unipoll

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether we use our own unified polling mainloop in place of glib’s

LOKDocView.View.props.userprofileurl
Name:

userprofileurl

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The absolute path of the LibreOffice user profile.

LOKDocView.View.props.zoom_level
Name:

zoom-level

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE

The current zoom level of the document loaded inside LOKDocView.View. The default value is 1.0.