1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
11 #define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
16 #include <LibreOfficeKit/LibreOfficeKit.h>
20 #define LOK_TYPE_DOC_VIEW (lok_doc_view_get_type())
21 #define LOK_DOC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LOK_TYPE_DOC_VIEW, LOKDocView))
22 #define LOK_IS_DOC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LOK_TYPE_DOC_VIEW))
23 #define LOK_DOC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LOK_TYPE_DOC_VIEW, LOKDocViewClass))
24 #define LOK_IS_DOC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), LOK_TYPE_DOC_VIEW))
25 #define LOK_DOC_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LOK_TYPE_DOC_VIEW, LOKDocViewClass))
27 typedef struct _LOKDocView LOKDocView
;
28 typedef struct _LOKDocViewClass LOKDocViewClass
;
29 typedef struct _LOKDocViewPrivate LOKDocViewPrivate
;
33 GtkDrawingArea aDrawingArea
;
36 struct _LOKDocViewClass
38 GtkDrawingAreaClass parent_class
;
41 GType
lok_doc_view_get_type (void) G_GNUC_CONST
;
45 * @pPath: (nullable) (allow-none): LibreOffice install path. Pass null to set it to default
46 * path which in most cases would be $libdir/libreoffice/program
47 * @cancellable: The cancellable object that you can use to cancel this
49 * @error: The error that will be set if the object fails to initialize.
51 * Returns: (transfer none): The #LOKDocView widget instance.
53 GtkWidget
* lok_doc_view_new (const gchar
* pPath
,
54 GCancellable
*cancellable
,
58 * lok_doc_view_new_from_user_profile:
59 * @pPath: (nullable) (allow-none): LibreOffice install path. Pass null to set it to default
60 * path which in most cases would be $libdir/libreoffice/program
61 * @pUserProfile: (nullable) (allow-none): User profile URL. Must be either a file URL or a
62 * special vnd.sun.star.pathname URL. Pass non-null to be able to use this
63 * widget and LibreOffice itself in parallel.
64 * @cancellable: The cancellable object that you can use to cancel this
66 * @error: The error that will be set if the object fails to initialize.
68 * Returns: (transfer none): The #LOKDocView widget instance.
70 GtkWidget
* lok_doc_view_new_from_user_profile (const gchar
* pPath
,
71 const gchar
* pUserProfile
,
72 GCancellable
*cancellable
,
76 * lok_doc_view_new_from_widget:
77 * @pDocView: The #LOKDocView instance
78 * @pRenderingArguments: (nullable) (allow-none): lok::Document::initializeForRendering() arguments.
80 * Returns: (transfer none): The #LOKDocView widget instance.
82 GtkWidget
* lok_doc_view_new_from_widget (LOKDocView
* pDocView
,
83 const gchar
* pRenderingArguments
);
86 * lok_doc_view_open_document:
87 * @pDocView: The #LOKDocView instance
88 * @pPath: (transfer full): The path of the document that #LOKDocView widget should try to open
89 * @pRenderingArguments: (nullable) (allow-none): lok::Document::initializeForRendering() arguments.
94 void lok_doc_view_open_document (LOKDocView
* pDocView
,
96 const gchar
* pRenderingArguments
,
97 GCancellable
* cancellable
,
98 GAsyncReadyCallback callback
,
102 * lok_doc_view_open_document_finish:
103 * @pDocView: The #LOKDocView instance
107 * Returns: %TRUE if the document is loaded successfully, %FALSE otherwise
109 gboolean
lok_doc_view_open_document_finish (LOKDocView
* pDocView
,
114 * lok_doc_view_get_document:
115 * @pDocView: The #LOKDocView instance
117 * Gets the document the viewer displays.
119 * Returns: The #LibreOfficeKitDocument instance the widget is currently showing
121 LibreOfficeKitDocument
* lok_doc_view_get_document (LOKDocView
* pDocView
);
124 * lok_doc_view_set_zoom:
125 * @pDocView: The #LOKDocView instance
126 * @fZoom: The new zoom level that pDocView must set it into.
128 * Sets the new zoom level for the widget. Does nothing if fZoom is equal to
129 * existing zoom level. Values outside the range [0.25, 5.0] are clamped into
130 * the nearest allowed value in the interval.
132 void lok_doc_view_set_zoom (LOKDocView
* pDocView
,
135 * lok_doc_view_set_visible_area:
136 * @pDocView: The #LOKDocView instance
137 * @pVisibleArea: The new visible area of pDocView in twips.
139 * Sets the new visible area of the widget. This helps e.g. the page down key
140 * to jump the correct length, which depends on the amount of visible height of
143 void lok_doc_view_set_visible_area (LOKDocView
* pDocView
,
144 GdkRectangle
* pVisibleArea
);
147 * lok_doc_view_get_zoom:
148 * @pDocView: The #LOKDocView instance
150 * Returns: The current zoom factor value in float for pDocView
152 gfloat
lok_doc_view_get_zoom (LOKDocView
* pDocView
);
155 * lok_doc_view_get_parts:
156 * @pDocView: The #LOKDocView instance
158 * Returns: Part refers to either individual sheets in a Calc, or slides in Impress,
159 * and has no relevance for Writer. Returns -1 if no document is set currently.
161 gint
lok_doc_view_get_parts (LOKDocView
* pDocView
);
164 * lok_doc_view_get_part:
165 * @pDocView: The #LOKDocView instance
167 * Returns: Current part number of the document. Returns -1 if no document is set currently.
169 gint
lok_doc_view_get_part (LOKDocView
* pDocView
);
172 * lok_doc_view_set_part:
173 * @pDocView: The #LOKDocView instance
176 void lok_doc_view_set_part (LOKDocView
* pDocView
,
180 * lok_doc_view_get_part_name:
181 * @pDocView: The #LOKDocView instance
184 * Returns: Get current part name of loaded document. Returns null if no
185 * document is set, or document has been destroyed using lok_doc_view_destroy_document.
187 gchar
* lok_doc_view_get_part_name (LOKDocView
* pDocView
,
191 * lok_doc_view_set_partmode:
192 * @pDocView: The #LOKDocView instance
195 void lok_doc_view_set_partmode (LOKDocView
* pDocView
,
199 * lok_doc_view_reset_view:
200 * @pDocView: The #LOKDocView instance
202 void lok_doc_view_reset_view (LOKDocView
* pDocView
);
205 * lok_doc_view_set_edit:
206 * @pDocView: The #LOKDocView instance
207 * @bEdit: %TRUE if the pDocView should go in edit mode, %FALSE otherwise
209 * Sets if the viewer is actually an editor or not.
211 void lok_doc_view_set_edit (LOKDocView
* pDocView
,
215 * lok_doc_view_get_edit:
216 * @pDocView: The #LOKDocView instance
218 * Gets if the viewer is actually an editor or not.
220 * Returns: %TRUE if the given pDocView is in edit mode.
222 gboolean
lok_doc_view_get_edit (LOKDocView
* pDocView
);
225 * lok_doc_view_post_command:
226 * @pDocView: the #LOKDocView instance
227 * @pCommand: the command to issue to LO core
228 * @pArguments: the arguments to the given command
229 * @bNotifyWhenFinished: normally false, but it may be useful for eg. .uno:Save
231 * Posts the .uno: command to the LibreOfficeKit.
233 void lok_doc_view_post_command (LOKDocView
* pDocView
,
234 const gchar
* pCommand
,
235 const gchar
* pArguments
,
236 gboolean bNotifyWhenFinished
);
240 * lok_doc_view_find_next:
241 * @pDocView: The #LOKDocView instance
242 * @pText: text to search for
243 * @bHighlightAll: Whether all the matches should be highlighted or not
245 * Highlights the next matching text in the view. `search-not-found` signal will
246 * be emitted when no search is found
248 void lok_doc_view_find_next (LOKDocView
* pDocView
,
250 gboolean bHighlightAll
);
253 * lok_doc_view_find_prev:
254 * @pDocView: The #LOKDocView instance
255 * @pText: text to search for
256 * @bHighlightAll: Whether all the matches should be highlighted or not
258 * Highlights the previous matching text in the view. `search-not-found` signal
259 * will be emitted when no search is found
261 void lok_doc_view_find_prev (LOKDocView
* pDocView
,
263 gboolean bHighlightAll
);
266 * lok_doc_view_highlight_all:
267 * @pDocView: The #LOKDocView instance
268 * @pText: text to search for
270 * Highlights all matching texts in the view. `search-not-found` signal
271 * will be emitted when no search is found
273 void lok_doc_view_highlight_all (LOKDocView
* pDocView
,
277 * lok_doc_view_copy_selection:
278 * @pDocView: The #LOKDocView instance
279 * @pMimeType: suggests the return format, for example text/plain;charset=utf-8
280 * @pUsedMimeType: (out): output parameter to inform about the determined format
281 * (suggested or plain text).
283 * Returns: Selected text. The caller must free the returned buffer after
284 * use. Returns null if no document is set.
286 gchar
* lok_doc_view_copy_selection (LOKDocView
* pDocView
,
287 const gchar
* pMimeType
,
288 gchar
** pUsedMimeType
);
291 * lok_doc_view_paste:
292 * @pDocView: The #LOKDocView instance
293 * @pMimeType: format of pData, for example text/plain;charset=utf-8
294 * @pData: the data to be pasted
295 * @nSize: length of data to be pasted
297 * Pastes the content at the current cursor position
299 * Returns: if pData was pasted successfully.
301 gboolean
lok_doc_view_paste (LOKDocView
* pDocView
,
302 const gchar
* pMimeType
,
307 * lok_doc_view_set_document_password:
308 * @pDocView: The #LOKDocView instance
309 * @pURL: the URL of the document to set password for, as sent with signal `password-required`
310 * @pPassword: (nullable) (allow-none): the password, NULL for no password
312 * Set the password for password protected documents
314 void lok_doc_view_set_document_password (LOKDocView
* pDocView
,
316 const gchar
* pPassword
);
319 * lok_doc_view_get_version_info:
320 * @pDocView: The #LOKDocView instance
322 * Get version information of the LOKit process
324 * Returns: JSON string containing version information in format:
325 * {ProductName: <>, ProductVersion: <>, ProductExtension: <>, BuildId: <>}
327 * Eg: {"ProductName": "LibreOffice",
328 * "ProductVersion": "5.3",
329 * "ProductExtension": ".0.0.alpha0",
330 * "BuildId": "<full 40 char git hash>"}
332 gchar
* lok_doc_view_get_version_info (LOKDocView
* pDocView
);
335 * lok_doc_view_pixel_to_twip:
336 * @pDocView: The #LOKDocView instance
337 * @fInput: The value in pixels to convert to twips
339 * Converts the value in pixels to twips according to zoom level.
341 * Returns: The corresponding value in twips
343 gfloat
lok_doc_view_pixel_to_twip (LOKDocView
* pDocView
,
347 * lok_doc_view_twip_to_pixel:
348 * @pDocView: The #LOKDocView instance
349 * @fInput: The value in twips to convert to pixels
351 * Converts the value in twips to pixels according to zoom level.
353 * Returns: The corresponding value in pixels
355 gfloat
lok_doc_view_twip_to_pixel (LOKDocView
* pDocView
,
360 #endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */