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>
18 // Avoid "error C2375: 'foo': redefinition; different linkage" on MSVC
19 #if defined LOK_DOC_VIEW_IMPLEMENTATION
20 #define LOK_DOC_VIEW_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
22 #define LOK_DOC_VIEW_DLLPUBLIC
27 #define LOK_TYPE_DOC_VIEW (lok_doc_view_get_type())
28 #define LOK_DOC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LOK_TYPE_DOC_VIEW, LOKDocView))
29 #define LOK_IS_DOC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LOK_TYPE_DOC_VIEW))
30 #define LOK_DOC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LOK_TYPE_DOC_VIEW, LOKDocViewClass))
31 #define LOK_IS_DOC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), LOK_TYPE_DOC_VIEW))
32 #define LOK_DOC_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LOK_TYPE_DOC_VIEW, LOKDocViewClass))
34 typedef struct _LOKDocView LOKDocView
;
35 typedef struct _LOKDocViewClass LOKDocViewClass
;
36 typedef struct _LOKDocViewPrivate LOKDocViewPrivate
;
40 GtkDrawingArea aDrawingArea
;
43 struct _LOKDocViewClass
45 GtkDrawingAreaClass parent_class
;
48 LOK_DOC_VIEW_DLLPUBLIC GType
lok_doc_view_get_type (void) G_GNUC_CONST
;
52 * @pPath: (nullable) (allow-none): LibreOffice install path. Pass null to set it to default
53 * path which in most cases would be $libdir/libreoffice/program
54 * @cancellable: The cancellable object that you can use to cancel this
56 * @error: The error that will be set if the object fails to initialize.
58 * Returns: (transfer none): The #LOKDocView widget instance.
60 LOK_DOC_VIEW_DLLPUBLIC GtkWidget
* lok_doc_view_new (const gchar
* pPath
,
61 GCancellable
*cancellable
,
65 * lok_doc_view_new_from_user_profile:
66 * @pPath: (nullable) (allow-none): LibreOffice install path. Pass null to set it to default
67 * path which in most cases would be $libdir/libreoffice/program
68 * @pUserProfile: (nullable) (allow-none): User profile URL. Must be either a file URL or a
69 * special vnd.sun.star.pathname URL. Pass non-null to be able to use this
70 * widget and LibreOffice itself in parallel.
71 * @cancellable: The cancellable object that you can use to cancel this
73 * @error: The error that will be set if the object fails to initialize.
75 * Returns: (transfer none): The #LOKDocView widget instance.
77 LOK_DOC_VIEW_DLLPUBLIC GtkWidget
* lok_doc_view_new_from_user_profile (const gchar
* pPath
,
78 const gchar
* pUserProfile
,
79 GCancellable
*cancellable
,
83 * lok_doc_view_new_from_widget:
84 * @pDocView: The #LOKDocView instance
85 * @pRenderingArguments: (nullable) (allow-none): lok::Document::initializeForRendering() arguments.
87 * Returns: (transfer none): The #LOKDocView widget instance.
89 LOK_DOC_VIEW_DLLPUBLIC GtkWidget
* lok_doc_view_new_from_widget (LOKDocView
* pDocView
,
90 const gchar
* pRenderingArguments
);
93 * lok_doc_view_open_document:
94 * @pDocView: The #LOKDocView instance
95 * @pPath: (transfer full): The path of the document that #LOKDocView widget should try to open
96 * @pRenderingArguments: (nullable) (allow-none): lok::Document::initializeForRendering() arguments.
101 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_open_document (LOKDocView
* pDocView
,
103 const gchar
* pRenderingArguments
,
104 GCancellable
* cancellable
,
105 GAsyncReadyCallback callback
,
109 * lok_doc_view_open_document_finish:
110 * @pDocView: The #LOKDocView instance
114 * Returns: %TRUE if the document is loaded successfully, %FALSE otherwise
116 LOK_DOC_VIEW_DLLPUBLIC gboolean
lok_doc_view_open_document_finish (LOKDocView
* pDocView
,
121 * lok_doc_view_get_document:
122 * @pDocView: The #LOKDocView instance
124 * Gets the document the viewer displays.
126 * Returns: The #LibreOfficeKitDocument instance the widget is currently showing
128 LOK_DOC_VIEW_DLLPUBLIC LibreOfficeKitDocument
* lok_doc_view_get_document (LOKDocView
* pDocView
);
131 * lok_doc_view_set_zoom:
132 * @pDocView: The #LOKDocView instance
133 * @fZoom: The new zoom level that pDocView must set it into.
135 * Sets the new zoom level for the widget. Does nothing if fZoom is equal to
136 * existing zoom level. Values outside the range [0.25, 5.0] are clamped into
137 * the nearest allowed value in the interval.
139 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_set_zoom (LOKDocView
* pDocView
,
142 * lok_doc_view_set_visible_area:
143 * @pDocView: The #LOKDocView instance
144 * @pVisibleArea: The new visible area of pDocView in twips.
146 * Sets the new visible area of the widget. This helps e.g. the page down key
147 * to jump the correct length, which depends on the amount of visible height of
150 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_set_visible_area (LOKDocView
* pDocView
,
151 GdkRectangle
* pVisibleArea
);
154 * lok_doc_view_get_zoom:
155 * @pDocView: The #LOKDocView instance
157 * Returns: The current zoom factor value in float for pDocView
159 LOK_DOC_VIEW_DLLPUBLIC gfloat
lok_doc_view_get_zoom (LOKDocView
* pDocView
);
162 * lok_doc_view_get_parts:
163 * @pDocView: The #LOKDocView instance
165 * Returns: Part refers to either individual sheets in a Calc, or slides in Impress,
166 * and has no relevance for Writer. Returns -1 if no document is set currently.
168 LOK_DOC_VIEW_DLLPUBLIC gint
lok_doc_view_get_parts (LOKDocView
* pDocView
);
171 * lok_doc_view_get_part:
172 * @pDocView: The #LOKDocView instance
174 * Returns: Current part number of the document. Returns -1 if no document is set currently.
176 LOK_DOC_VIEW_DLLPUBLIC gint
lok_doc_view_get_part (LOKDocView
* pDocView
);
179 * lok_doc_view_set_part:
180 * @pDocView: The #LOKDocView instance
183 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_set_part (LOKDocView
* pDocView
,
187 * lok_doc_view_get_part_name:
188 * @pDocView: The #LOKDocView instance
191 * Returns: Get current part name of loaded document. Returns null if no
192 * document is set, or document has been destroyed using lok_doc_view_destroy_document.
194 LOK_DOC_VIEW_DLLPUBLIC gchar
* lok_doc_view_get_part_name (LOKDocView
* pDocView
,
198 * lok_doc_view_set_partmode:
199 * @pDocView: The #LOKDocView instance
202 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_set_partmode (LOKDocView
* pDocView
,
206 * lok_doc_view_reset_view:
207 * @pDocView: The #LOKDocView instance
209 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_reset_view (LOKDocView
* pDocView
);
212 * lok_doc_view_set_edit:
213 * @pDocView: The #LOKDocView instance
214 * @bEdit: %TRUE if the pDocView should go in edit mode, %FALSE otherwise
216 * Sets if the viewer is actually an editor or not.
218 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_set_edit (LOKDocView
* pDocView
,
222 * lok_doc_view_get_edit:
223 * @pDocView: The #LOKDocView instance
225 * Gets if the viewer is actually an editor or not.
227 * Returns: %TRUE if the given pDocView is in edit mode.
229 LOK_DOC_VIEW_DLLPUBLIC gboolean
lok_doc_view_get_edit (LOKDocView
* pDocView
);
232 * lok_doc_view_post_command:
233 * @pDocView: the #LOKDocView instance
234 * @pCommand: the command to issue to LO core
235 * @pArguments: the arguments to the given command
236 * @bNotifyWhenFinished: normally false, but it may be useful for eg. .uno:Save
238 * Posts the .uno: command to the LibreOfficeKit.
240 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_post_command (LOKDocView
* pDocView
,
241 const gchar
* pCommand
,
242 const gchar
* pArguments
,
243 gboolean bNotifyWhenFinished
);
246 * lok_doc_view_get_command_values:
247 * @pDocView: the #LOKDocView instance
248 * @pCommand: the command to issue to LO core
250 * Get a json mapping of the possible values for the given command.
251 * In the form of: {commandName: unoCmd, commandValues: {possible_values}}
253 * Returns: A json mapping of the possible values for the given command
255 LOK_DOC_VIEW_DLLPUBLIC gchar
* lok_doc_view_get_command_values (LOKDocView
* pDocView
,
256 const gchar
* pCommand
);
259 * lok_doc_view_find_next:
260 * @pDocView: The #LOKDocView instance
261 * @pText: text to search for
262 * @bHighlightAll: Whether all the matches should be highlighted or not
264 * Highlights the next matching text in the view. `search-not-found` signal will
265 * be emitted when no search is found
267 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_find_next (LOKDocView
* pDocView
,
269 gboolean bHighlightAll
);
272 * lok_doc_view_find_prev:
273 * @pDocView: The #LOKDocView instance
274 * @pText: text to search for
275 * @bHighlightAll: Whether all the matches should be highlighted or not
277 * Highlights the previous matching text in the view. `search-not-found` signal
278 * will be emitted when no search is found
280 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_find_prev (LOKDocView
* pDocView
,
282 gboolean bHighlightAll
);
285 * lok_doc_view_highlight_all:
286 * @pDocView: The #LOKDocView instance
287 * @pText: text to search for
289 * Highlights all matching texts in the view. `search-not-found` signal
290 * will be emitted when no search is found
292 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_highlight_all (LOKDocView
* pDocView
,
296 * lok_doc_view_copy_selection:
297 * @pDocView: The #LOKDocView instance
298 * @pMimeType: suggests the return format, for example text/plain;charset=utf-8
299 * @pUsedMimeType: (out): output parameter to inform about the determined format
300 * (suggested or plain text).
302 * Returns: Selected text. The caller must free the returned buffer after
303 * use. Returns null if no document is set.
305 LOK_DOC_VIEW_DLLPUBLIC gchar
* lok_doc_view_copy_selection (LOKDocView
* pDocView
,
306 const gchar
* pMimeType
,
307 gchar
** pUsedMimeType
);
310 * lok_doc_view_paste:
311 * @pDocView: The #LOKDocView instance
312 * @pMimeType: format of pData, for example text/plain;charset=utf-8
313 * @pData: the data to be pasted
314 * @nSize: length of data to be pasted
316 * Pastes the content at the current cursor position
318 * Returns: if pData was pasted successfully.
320 LOK_DOC_VIEW_DLLPUBLIC gboolean
lok_doc_view_paste (LOKDocView
* pDocView
,
321 const gchar
* pMimeType
,
326 * lok_doc_view_set_document_password:
327 * @pDocView: The #LOKDocView instance
328 * @pURL: the URL of the document to set password for, as sent with signal `password-required`
329 * @pPassword: (nullable) (allow-none): the password, NULL for no password
331 * Set the password for password protected documents
333 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_set_document_password (LOKDocView
* pDocView
,
335 const gchar
* pPassword
);
338 * lok_doc_view_get_version_info:
339 * @pDocView: The #LOKDocView instance
341 * Get version information of the LOKit process
343 * Returns: JSON string containing version information in format:
344 * {ProductName: <>, ProductVersion: <>, ProductExtension: <>, BuildId: <>}
346 * Eg: {"ProductName": "LibreOffice",
347 * "ProductVersion": "5.3",
348 * "ProductExtension": ".0.0.alpha0",
349 * "BuildId": "<full 40 char git hash>"}
351 LOK_DOC_VIEW_DLLPUBLIC gchar
* lok_doc_view_get_version_info (LOKDocView
* pDocView
);
354 * lok_doc_view_pixel_to_twip:
355 * @pDocView: The #LOKDocView instance
356 * @fInput: The value in pixels to convert to twips
358 * Converts the value in pixels to twips according to zoom level.
360 * Returns: The corresponding value in twips
362 LOK_DOC_VIEW_DLLPUBLIC gfloat
lok_doc_view_pixel_to_twip (LOKDocView
* pDocView
,
366 * lok_doc_view_twip_to_pixel:
367 * @pDocView: The #LOKDocView instance
368 * @fInput: The value in twips to convert to pixels
370 * Converts the value in twips to pixels according to zoom level.
372 * Returns: The corresponding value in pixels
374 LOK_DOC_VIEW_DLLPUBLIC gfloat
lok_doc_view_twip_to_pixel (LOKDocView
* pDocView
,
378 * lok_doc_view_send_content_control_event:
379 * @pDocView: The #LOKDocView instance
380 * @pArguments: (nullable) (allow-none): see lok::Document::sendContentControlEvent() for the details.
382 LOK_DOC_VIEW_DLLPUBLIC
void lok_doc_view_send_content_control_event(LOKDocView
* pDocView
, const gchar
* pArguments
);
386 #endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
388 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */