ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #04579
[Merge] lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-headers into lp:ubuntu-docviewer-app/reboot
Stefano Verzegnassi has proposed merging lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-headers into lp:ubuntu-docviewer-app/reboot.
Commit message:
Added LibreOfficeKit headers
Requested reviews:
Ubuntu Document Viewer Developers (ubuntu-docviewer-dev)
For more details, see:
https://code.launchpad.net/~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-headers/+merge/269125
Added LibreOfficeKit headers
--
Your team Ubuntu Document Viewer Developers is requested to review the proposed merge of lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-lok-headers into lp:ubuntu-docviewer-app/reboot.
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/CMakeLists.txt'
--- src/plugin/libreofficetoolkit-qml-plugin/CMakeLists.txt 2015-07-22 16:44:39 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/CMakeLists.txt 2015-08-25 22:36:41 +0000
@@ -4,7 +4,7 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
- /usr/include/LibreOfficeKit/
+ ${CMAKE_CURRENT_SOURCE_DIR}/LibreOfficeKit/
)
#add the sources to compile
=== added directory 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit'
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKit.h'
--- src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKit.h 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKit.h 2015-08-25 22:36:41 +0000
@@ -0,0 +1,171 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H
+#define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H
+
+#include <stddef.h>
+
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct _LibreOfficeKit LibreOfficeKit;
+typedef struct _LibreOfficeKitClass LibreOfficeKitClass;
+
+typedef struct _LibreOfficeKitDocument LibreOfficeKitDocument;
+typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass;
+
+// Do we have an extended member in this struct ?
+#define LIBREOFFICEKIT_HAS_MEMBER(strct,member,nSize) \
+ (offsetof(strct, member) < (nSize))
+
+#define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitClass,member,(pKit)->pClass->nSize)
+
+struct _LibreOfficeKit
+{
+ LibreOfficeKitClass* pClass;
+};
+
+struct _LibreOfficeKitClass
+{
+ size_t nSize;
+
+ void (*destroy) (LibreOfficeKit* pThis);
+
+ LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit* pThis,
+ const char* pURL);
+
+ char* (*getError) (LibreOfficeKit* pThis);
+
+ LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
+ const char* pURL,
+ const char* pOptions);
+#ifdef LOK_USE_UNSTABLE_API
+ void (*registerCallback) (LibreOfficeKit* pThis,
+ LibreOfficeKitCallback pCallback,
+ void* pData);
+#endif
+};
+
+#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
+
+struct _LibreOfficeKitDocument
+{
+ LibreOfficeKitDocumentClass* pClass;
+};
+
+struct _LibreOfficeKitDocumentClass
+{
+ size_t nSize;
+
+ void (*destroy) (LibreOfficeKitDocument* pThis);
+
+ int (*saveAs) (LibreOfficeKitDocument* pThis,
+ const char* pUrl,
+ const char* pFormat,
+ const char* pFilterOptions);
+
+#ifdef LOK_USE_UNSTABLE_API
+ /// @see lok::Document::getDocumentType().
+ int (*getDocumentType) (LibreOfficeKitDocument* pThis);
+
+ /// @see lok::Document::getParts().
+ int (*getParts) (LibreOfficeKitDocument* pThis);
+
+ /// @see lok::Document::getPart().
+ int (*getPart) (LibreOfficeKitDocument* pThis);
+
+ /// @see lok::Document::setPart().
+ void (*setPart) (LibreOfficeKitDocument* pThis,
+ int nPart);
+
+ /// @see lok::Document::getPartName().
+ char* (*getPartName) (LibreOfficeKitDocument* pThis,
+ int nPart);
+
+ /** Sets mode of the current part.
+ *
+ * @param nMode - element from the LibreOfficeKitPartMode enum.
+ */
+ void (*setPartMode) (LibreOfficeKitDocument* pThis,
+ int nMode);
+
+ /// @see lok::Document::paintTile().
+ void (*paintTile) (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
+ const int nCanvasWidth,
+ const int nCanvasHeight,
+ const int nTilePosX,
+ const int nTilePosY,
+ const int nTileWidth,
+ const int nTileHeight);
+
+ /// @see lok::Document::getDocumentSize().
+ void (*getDocumentSize) (LibreOfficeKitDocument* pThis,
+ long* pWidth,
+ long* pHeight);
+
+ /// @see lok::Document::initializeForRendering().
+ void (*initializeForRendering) (LibreOfficeKitDocument* pThis);
+
+ void (*registerCallback) (LibreOfficeKitDocument* pThis,
+ LibreOfficeKitCallback pCallback,
+ void* pData);
+
+ /// @see lok::Document::postKeyEvent
+ void (*postKeyEvent) (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nCharCode,
+ int nKeyCode);
+
+ /// @see lok::Document::postMouseEvent
+ void (*postMouseEvent) (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY,
+ int nCount);
+
+ /// @see lok::Document::postUnoCommand
+ void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
+ const char* pCommand,
+ const char* pArguments);
+
+ /// @see lok::Document::setTextSelection
+ void (*setTextSelection) (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY);
+
+ /// @see lok::Document::getTextSelection
+ char* (*getTextSelection) (LibreOfficeKitDocument* pThis,
+ const char* pMimeType,
+ char** pUsedMimeType);
+
+ /// @see lok::Document::setGraphicSelection
+ void (*setGraphicSelection) (LibreOfficeKitDocument* pThis,
+ int nType,
+ int nX,
+ int nY);
+
+ /// @see lok::Document::resetSelection
+ void (*resetSelection) (LibreOfficeKitDocument* pThis);
+#endif // LOK_USE_UNSTABLE_API
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKit.hxx'
--- src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKit.hxx 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKit.hxx 2015-08-25 22:36:41 +0000
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_HXX
+#define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_HXX
+
+#include "LibreOfficeKit.h"
+
+/*
+ * The reasons this C++ code is not as pretty as it could be are:
+ * a) provide a pure C API - that's useful for some people
+ * b) allow ABI stability - C++ vtables are not good for that.
+ * c) avoid C++ types as part of the API.
+ */
+namespace lok
+{
+
+/// The lok::Document class represents one loaded document instance.
+class Document
+{
+private:
+ LibreOfficeKitDocument* mpDoc;
+
+public:
+ /// A lok::Document is typically created by the lok::Office::documentLoad() method.
+ inline Document(LibreOfficeKitDocument* pDoc) :
+ mpDoc(pDoc)
+ {}
+
+ inline ~Document()
+ {
+ mpDoc->pClass->destroy(mpDoc);
+ }
+
+ /**
+ * Stores the document's persistent data to a URL and
+ * continues to be a representation of the old URL.
+ *
+ * @param pUrl the location where to store the document
+ * @param pFormat the format to use while exporting, when omitted, then deducted from pURL's extension
+ * @param pFilterOptions options for the export filter, e.g. SkipImages.
+ */
+ inline bool saveAs(const char* pUrl, const char* pFormat = NULL, const char* pFilterOptions = NULL)
+ {
+ return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat, pFilterOptions) != 0;
+ }
+
+ /// Gives access to the underlying C pointer.
+ inline LibreOfficeKitDocument *get() { return mpDoc; }
+
+#ifdef LOK_USE_UNSTABLE_API
+ /**
+ * Get document type.
+ *
+ * @return an element of the LibreOfficeKitDocumentType enum.
+ */
+ inline int getDocumentType()
+ {
+ return mpDoc->pClass->getDocumentType(mpDoc);
+ }
+
+ /**
+ * Get number of part that the document contains.
+ *
+ * Part refers to either indivual sheets in a Calc, or slides in Impress,
+ * and has no relevance for Writer.
+ */
+ inline int getParts()
+ {
+ return mpDoc->pClass->getParts(mpDoc);
+ }
+
+ /// Get the current part of the document.
+ inline int getPart()
+ {
+ return mpDoc->pClass->getPart(mpDoc);
+ }
+
+ /// Set the current part of the document.
+ inline void setPart(int nPart)
+ {
+ mpDoc->pClass->setPart(mpDoc, nPart);
+ }
+
+ /// Get the current part's name.
+ inline char* getPartName(int nPart)
+ {
+ return mpDoc->pClass->getPartName(mpDoc, nPart);
+ }
+
+ /**
+ * Renders a subset of the document to a pre-allocated buffer.
+ *
+ * Note that the buffer size and the tile size implicitly supports
+ * rendering at different zoom levels, as the number of rendered pixels and
+ * the rendered rectangle of the document are independent.
+ *
+ * @param pBuffer pointer to the buffer, its size is determined by nCanvasWidth and nCanvasHeight.
+ * @param nCanvasWidth number of pixels in a row of pBuffer.
+ * @param nCanvasHeight number of pixels in a column of pBuffer.
+ * @param nTilePosX logical X position of the top left corner of the rendered rectangle, in TWIPs.
+ * @param nTilePosY logical Y position of the top left corner of the rendered rectangle, in TWIPs.
+ * @param nTileWidth logical width of the rendered rectangle, in TWIPs.
+ * @param nTileHeight logical height of the rendered rectangle, in TWIPs.
+ */
+ inline void paintTile(
+ unsigned char* pBuffer,
+ const int nCanvasWidth,
+ const int nCanvasHeight,
+ const int nTilePosX,
+ const int nTilePosY,
+ const int nTileWidth,
+ const int nTileHeight)
+ {
+ return mpDoc->pClass->paintTile(mpDoc, pBuffer, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ }
+
+ /// Get the document sizes in TWIPs.
+ inline void getDocumentSize(long* pWidth, long* pHeight)
+ {
+ mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
+ }
+
+ /**
+ * Initialize document for rendering.
+ *
+ * Sets the rendering and document parameters to default values that are
+ * needed to render the document correctly using tiled rendering. This
+ * method has to be called right after documentLoad() in case any of the
+ * tiled rendering methods are to be used later.
+ */
+ inline void initializeForRendering()
+ {
+ mpDoc->pClass->initializeForRendering(mpDoc);
+ }
+
+ /**
+ * Registers a callback. LOK will invoke this function when it wants to
+ * inform the client about events.
+ *
+ * @param pCallback the callback to invoke
+ * @param pData the user data, will be passed to the callback on invocation
+ */
+ inline void registerCallback(LibreOfficeKitCallback pCallback, void* pData)
+ {
+ mpDoc->pClass->registerCallback(mpDoc, pCallback, pData);
+ }
+
+ /**
+ * Posts a keyboard event to the focused frame.
+ *
+ * @param nType Event type, like press or release.
+ * @param nCharCode contains the Unicode character generated by this event or 0
+ * @param nKeyCode contains the integer code representing the key of the event (non-zero for control keys)
+ */
+ inline void postKeyEvent(int nType, int nCharCode, int nKeyCode)
+ {
+ mpDoc->pClass->postKeyEvent(mpDoc, nType, nCharCode, nKeyCode);
+ }
+
+ /**
+ * Posts a mouse event to the document.
+ *
+ * @param nType Event type, like down, move or up.
+ * @param nX horizontal position in document coordinates
+ * @param nY vertical position in document coordinates
+ * @param nCount number of clicks: 1 for single click, 2 for double click
+ */
+ inline void postMouseEvent(int nType, int nX, int nY, int nCount)
+ {
+ mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount);
+ }
+
+ /**
+ * Posts an UNO command to the document.
+ *
+ * Example argument string:
+ *
+ * {
+ * "SearchItem.SearchString":
+ * {
+ * "type": "string",
+ * "value": "foobar"
+ * },
+ * "SearchItem.Backward":
+ * {
+ * "type": "boolean",
+ * "value": "false"
+ * }
+ * }
+ *
+ * @param pCommand uno command to be posted to the document, like ".uno:Bold"
+ * @param pArguments arguments of the uno command.
+ */
+ inline void postUnoCommand(const char* pCommand, const char* pArguments = 0)
+ {
+ mpDoc->pClass->postUnoCommand(mpDoc, pCommand, pArguments);
+ }
+
+ /**
+ * Sets the start or end of a text selection.
+ *
+ * @param nType @see LibreOfficeKitSetTextSelectionType
+ * @param nX horizontal position in document coordinates
+ * @param nY vertical position in document coordinates
+ */
+ inline void setTextSelection(int nType, int nX, int nY)
+ {
+ mpDoc->pClass->setTextSelection(mpDoc, nType, nX, nY);
+ }
+
+ /**
+ * Gets the currently selected text.
+ *
+ * @param pMimeType suggests the return format, for example text/plain;charset=utf-8.
+ * @param pUsedMimeType output parameter to inform about the determined format (suggested one or plain text).
+ */
+ inline char* getTextSelection(const char* pMimeType, char** pUsedMimeType = 0)
+ {
+ return mpDoc->pClass->getTextSelection(mpDoc, pMimeType, pUsedMimeType);
+ }
+
+ /**
+ * Adjusts the graphic selection.
+ *
+ * @param nType @see LibreOfficeKitSetGraphicSelectionType
+ * @param nX horizontal position in document coordinates
+ * @param nY vertical position in document coordinates
+ */
+ inline void setGraphicSelection(int nType, int nX, int nY)
+ {
+ mpDoc->pClass->setGraphicSelection(mpDoc, nType, nX, nY);
+ }
+
+ /**
+ * Gets rid of any text or graphic selection.
+ */
+ inline void resetSelection()
+ {
+ mpDoc->pClass->resetSelection(mpDoc);
+ }
+#endif // LOK_USE_UNSTABLE_API
+};
+
+/// The lok::Office class represents one started LibreOfficeKit instance.
+class Office
+{
+private:
+ LibreOfficeKit* mpThis;
+
+public:
+ /// A lok::Office is typically created by the lok_cpp_init() function.
+ inline Office(LibreOfficeKit* pThis) :
+ mpThis(pThis)
+ {}
+
+ inline ~Office()
+ {
+ mpThis->pClass->destroy(mpThis);
+ }
+
+ /**
+ * Loads a document from an URL.
+ *
+ * @param pUrl the URL of the document to load
+ * @param pFilterOptions options for the import filter, e.g. SkipImages.
+ */
+ inline Document* documentLoad(const char* pUrl, const char* pFilterOptions = NULL)
+ {
+ LibreOfficeKitDocument* pDoc = NULL;
+
+ if (LIBREOFFICEKIT_HAS(mpThis, documentLoadWithOptions))
+ pDoc = mpThis->pClass->documentLoadWithOptions(mpThis, pUrl, pFilterOptions);
+ else
+ pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
+
+ if (pDoc == NULL)
+ return NULL;
+
+ return new Document(pDoc);
+ }
+
+ /// Returns the last error as a string, the returned pointer has to be freed by the caller.
+ inline char* getError()
+ {
+ return mpThis->pClass->getError(mpThis);
+ }
+};
+
+/// Factory method to create a lok::Office instance.
+inline Office* lok_cpp_init(const char* pInstallPath, const char* pUserProfilePath = NULL)
+{
+ LibreOfficeKit* pThis = lok_init_2(pInstallPath, pUserProfilePath);
+ if (pThis == NULL || pThis->pClass->nSize == 0)
+ return NULL;
+ return new ::lok::Office(pThis);
+}
+
+}
+
+#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitEnums.h'
--- src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitEnums.h 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitEnums.h 2015-08-25 22:36:41 +0000
@@ -0,0 +1,229 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITENUMS_H
+#define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITENUMS_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef LOK_USE_UNSTABLE_API
+typedef enum
+{
+ LOK_DOCTYPE_TEXT,
+ LOK_DOCTYPE_SPREADSHEET,
+ LOK_DOCTYPE_PRESENTATION,
+ LOK_DOCTYPE_DRAWING,
+ LOK_DOCTYPE_OTHER
+}
+LibreOfficeKitDocumentType;
+
+typedef enum
+{
+ LOK_PARTMODE_DEFAULT,
+ LOK_PARTMODE_SLIDE,
+ LOK_PARTMODE_NOTES,
+ LOK_PARTMODE_SLIDENOTES,
+ LOK_PARTMODE_EMBEDDEDOBJ
+}
+LibreOfficeKitPartMode;
+
+typedef enum
+{
+ /**
+ * Any tiles which are over the rectangle described in the payload are no
+ * longer valid.
+ *
+ * Rectangle format: "width, height, x, y", where all numbers are document
+ * coordinates, in twips. When all tiles are supposed to be dropped, the
+ * format is the "EMPTY" string.
+ */
+ LOK_CALLBACK_INVALIDATE_TILES,
+ /**
+ * The size and/or the position of the visible cursor changed.
+ *
+ * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
+ */
+ LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
+ /**
+ * 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
+ * LOK_CALLBACK_INVALIDATE_TILES. When there is no selection, an empty
+ * string is provided.
+ */
+ LOK_CALLBACK_TEXT_SELECTION,
+ /**
+ * 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 LOK_CALLBACK_TEXT_SELECTION every
+ * time the selection is updated.
+ *
+ * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
+ */
+ LOK_CALLBACK_TEXT_SELECTION_START,
+ /**
+ * 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 LOK_CALLBACK_TEXT_SELECTION every
+ * time the selection is updated.
+ *
+ * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
+ */
+ LOK_CALLBACK_TEXT_SELECTION_END,
+ /**
+ * 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
+ * LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR once it becomes false. Payload is
+ * either the "true" or the "false" string.
+ */
+ LOK_CALLBACK_CURSOR_VISIBLE,
+ /**
+ * The size and/or the position of the graphic selection changed.
+ *
+ * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
+ */
+ LOK_CALLBACK_GRAPHIC_SELECTION,
+
+ /**
+ * User clicked on an hyperlink that should be handled by other
+ * applications accordingly.
+ */
+ LOK_CALLBACK_HYPERLINK_CLICKED,
+
+ /**
+ * Emit state update to the client.
+ * For example, when cursor is on bold text, this callback is triggered
+ * with payload: ".uno:Bold=true"
+ */
+ LOK_CALLBACK_STATE_CHANGED,
+
+ /**
+ * 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 docuemnt and then constructing a LibreOfficeKitDocument
+ * object.
+ */
+ LOK_CALLBACK_STATUS_INDICATOR_START,
+
+ /**
+ * Sets the numeric value of the status indicator.
+ * The payload should be a percentage, an integer between 0 and 100.
+ */
+ LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE,
+
+ /**
+ * Ends the status indicator.
+ *
+ * Not necessarily ever emitted.
+ */
+ LOK_CALLBACK_STATUS_INDICATOR_FINISH,
+
+ /**
+ * No match was found for the search input
+ */
+ LOK_CALLBACK_SEARCH_NOT_FOUND,
+
+ /**
+ * 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.
+ */
+ LOK_CALLBACK_DOCUMENT_SIZE_CHANGED,
+
+ /**
+ * The current part number is changed.
+ *
+ * Payload is a single 0-based integer.
+ */
+ LOK_CALLBACK_SET_PART
+}
+LibreOfficeKitCallbackType;
+
+typedef enum
+{
+ /// A key on the keyboard is pressed.
+ LOK_KEYEVENT_KEYINPUT,
+ /// A key on the keyboard is released.
+ LOK_KEYEVENT_KEYUP
+}
+LibreOfficeKitKeyEventType;
+
+typedef enum
+{
+ /// A pressed gesture has started.
+ LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+ /// A pressed gesture has finished.
+ LOK_MOUSEEVENT_MOUSEBUTTONUP,
+ /// A change has happened during a press gesture.
+ LOK_MOUSEEVENT_MOUSEMOVE
+}
+LibreOfficeKitMouseEventType;
+
+typedef enum
+{
+ /// The start of selection is to be adjusted.
+ LOK_SETTEXTSELECTION_START,
+ /// The end of selection is to be adjusted.
+ LOK_SETTEXTSELECTION_END,
+ /// Both the start and the end of selection is to be adjusted.
+ LOK_SETTEXTSELECTION_RESET
+}
+LibreOfficeKitSetTextSelectionType;
+
+typedef enum
+{
+ /**
+ * A move or a resize action starts. It is assumed that there is a valid
+ * graphic selection (see LOK_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
+ */
+ LOK_SETGRAPHICSELECTION_START,
+ /**
+ * A move or resize action stops. It is assumed that this is always used
+ * only after a LOK_SETTEXTSELECTION_START. The supplied coordinates are
+ * the ones where the user released the screen.
+ */
+ LOK_SETGRAPHICSELECTION_END
+}
+LibreOfficeKitSetGraphicSelectionType;
+
+#endif // LOK_USE_UNSTABLE_API
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITENUMS_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitGtk.h'
--- src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitGtk.h 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitGtk.h 2015-08-25 22:36:41 +0000
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
+#define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define LOK_DOCVIEW(obj) GTK_CHECK_CAST (obj, lok_docview_get_type(), LOKDocView)
+#define LOK_DOCVIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_get_type(), LOKDocViewClass)
+#define IS_LOK_DOCVIEW(obj) GTK_CHECK_TYPE (obj, lok_docview_get_type())
+
+typedef struct _LOKDocView LOKDocView;
+typedef struct _LOKDocViewClass LOKDocViewClass;
+
+struct _LOKDocView
+{
+ GtkScrolledWindow aScrollWindow;
+ struct LOKDocView_Impl* m_pImpl;
+};
+
+struct _LOKDocViewClass
+{
+ GtkScrolledWindowClass parent_class;
+ void (* edit_changed) (LOKDocView* pView, gboolean was_edit);
+ void (* command_changed) (LOKDocView* pView, char* new_state);
+ void (* search_not_found) (LOKDocView* pView, char* new_state);
+ void (* part_changed) (LOKDocView* pView, int new_part);
+};
+
+guint lok_docview_get_type (void);
+GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
+gboolean lok_docview_open_document (LOKDocView* pDocView,
+ char* pPath);
+
+/// Gets the document the viewer displays.
+LibreOfficeKitDocument* lok_docview_get_document(LOKDocView* pDocView);
+
+void lok_docview_set_zoom (LOKDocView* pDocView,
+ float fZoom);
+float lok_docview_get_zoom (LOKDocView* pDocView);
+
+int lok_docview_get_parts (LOKDocView* pDocView);
+int lok_docview_get_part (LOKDocView* pDocView);
+void lok_docview_set_part (LOKDocView* pDocView,
+ int nPart);
+char* lok_docview_get_part_name (LOKDocView* pDocView,
+ int nPart);
+void lok_docview_set_partmode (LOKDocView* pDocView,
+ int nPartMode);
+/// Sets if the viewer is actually an editor or not.
+void lok_docview_set_edit (LOKDocView* pDocView,
+ gboolean bEdit);
+/// Gets if the viewer is actually an editor or not.
+gboolean lok_docview_get_edit (LOKDocView* pDocView);
+
+/// Posts the .uno: command to the LibreOfficeKit.
+void lok_docview_post_command (LOKDocView* pDocView, const char* pCommand, const char* pArguments);
+
+/// Posts a keyboard event to LibreOfficeKit.
+void lok_docview_post_key (GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData);
+
+/// Get the visible area of the document (in twips).
+void lok_docview_get_visarea(LOKDocView* pThis, GdkRectangle* pArea);
+#ifdef __cplusplus
+}
+#endif
+
+#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitInit.h'
--- src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitInit.h 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitInit.h 2015-08-25 22:36:41 +0000
@@ -0,0 +1,257 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITINIT_H
+#define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITINIT_H
+
+#include "LibreOfficeKit.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || defined(_WIN32) || defined(__APPLE__)
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#ifndef _WIN32
+
+ #include "dlfcn.h"
+
+ #ifdef _AIX
+ # include <sys/ldr.h>
+ #endif
+ #ifdef __APPLE__
+ #define TARGET_LIB "lib" "sofficeapp" ".dylib"
+ #define TARGET_MERGED_LIB "lib" "mergedlo" ".dylib"
+ #else
+ #define TARGET_LIB "lib" "sofficeapp" ".so"
+ #define TARGET_MERGED_LIB "lib" "mergedlo" ".so"
+ #endif
+ #define SEPARATOR '/'
+
+ void *_dlopen(const char *pFN)
+ {
+ return dlopen(pFN, RTLD_LAZY
+#if defined __clang__ && defined __linux__ \
+ && defined ENABLE_RUNTIME_OPTIMIZATIONS
+#if !ENABLE_RUNTIME_OPTIMIZATIONS
+ | RTLD_GLOBAL
+#endif
+#endif
+ );
+ }
+
+ char *_dlerror(void)
+ {
+ return dlerror();
+ }
+
+ void *_dlsym(void *Hnd, const char *pName)
+ {
+ return dlsym(Hnd, pName);
+ }
+
+ int _dlclose(void *Hnd)
+ {
+ return dlclose(Hnd);
+ }
+
+ void extendUnoPath(const char *pPath)
+ {
+ (void)pPath;
+ }
+
+#else
+
+ #include <windows.h>
+ #define TARGET_LIB "sofficeapp" ".dll"
+ #define TARGET_MERGED_LIB "mergedlo" ".dll"
+ #define SEPARATOR '\\'
+ #define UNOPATH "\\..\\URE\\bin"
+
+ void *_dlopen(const char *pFN)
+ {
+ return (void *) LoadLibrary(pFN);
+ }
+
+ char *_dlerror(void)
+ {
+ LPSTR buf = NULL;
+ FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, reinterpret_cast<LPSTR>(&buf), 0, NULL);
+ return buf;
+ }
+
+ void *_dlsym(void *Hnd, const char *pName)
+ {
+ return GetProcAddress((HINSTANCE) Hnd, pName);
+ }
+
+ int _dlclose(void *Hnd)
+ {
+ return FreeLibrary((HINSTANCE) Hnd);
+ }
+
+ void extendUnoPath(const char *pPath)
+ {
+ if (!pPath)
+ return;
+
+ char* sEnvPath = NULL;
+ DWORD cChars = GetEnvironmentVariable("PATH", sEnvPath, 0);
+ if (cChars > 0)
+ {
+ sEnvPath = new char[cChars];
+ cChars = GetEnvironmentVariable("PATH", sEnvPath, cChars);
+ //If PATH is not set then it is no error
+ if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND)
+ {
+ delete[] sEnvPath;
+ return;
+ }
+ }
+ //prepare the new PATH. Add the Ure/bin directory at the front.
+ //note also adding ';'
+ char * sNewPath = new char[strlen(sEnvPath) + strlen(pPath) + strlen(UNOPATH) + 2];
+ sNewPath[0] = L'\0';
+ strcat(sNewPath, pPath);
+ strcat(sNewPath, UNOPATH);
+ if (strlen(sEnvPath))
+ {
+ strcat(sNewPath, ";");
+ strcat(sNewPath, sEnvPath);
+ }
+
+ SetEnvironmentVariable("PATH", sNewPath);
+
+ delete[] sEnvPath;
+ delete[] sNewPath;
+ }
+#endif
+
+typedef LibreOfficeKit *(HookFunction)( const char *install_path);
+
+typedef LibreOfficeKit *(HookFunction2)( const char *install_path, const char *user_profile_path );
+
+static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_profile_path )
+{
+ char *imp_lib;
+ void *dlhandle;
+ HookFunction *pSym;
+ HookFunction2 *pSym2;
+
+#if !(defined(__APPLE__) && defined(__arm__))
+ size_t partial_length;
+
+ if (!install_path)
+ return NULL;
+
+ // allocate large enough buffer
+ partial_length = strlen(install_path);
+ imp_lib = (char *) malloc(partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2);
+ if (!imp_lib)
+ {
+ fprintf( stderr, "failed to open library : not enough memory\n");
+ return NULL;
+ }
+
+ strcpy(imp_lib, install_path);
+
+ extendUnoPath(install_path);
+
+ imp_lib[partial_length++] = SEPARATOR;
+ strcpy(imp_lib + partial_length, TARGET_LIB);
+
+ dlhandle = _dlopen(imp_lib);
+ if (!dlhandle)
+ {
+ // If TARGET_LIB exists, and likely is a real library (not a
+ // small one-line text stub as in the --enable-mergedlib
+ // case), but dlopen failed for some reason, don't try
+ // TARGET_MERGED_LIB.
+ struct stat st;
+ if (stat(imp_lib, &st) == 0 && st.st_size > 100)
+ {
+ fprintf(stderr, "failed to open library '%s': %s\n",
+ imp_lib, _dlerror());
+ free(imp_lib);
+ return NULL;
+ }
+
+ strcpy(imp_lib + partial_length, TARGET_MERGED_LIB);
+
+ dlhandle = _dlopen(imp_lib);
+ if (!dlhandle)
+ {
+ fprintf(stderr, "failed to open library '%s': %s\n",
+ imp_lib, _dlerror());
+ free(imp_lib);
+ return NULL;
+ }
+ }
+#else
+ imp_lib = strdup("the app executable");
+ dlhandle = RTLD_MAIN_ONLY;
+#endif
+
+ pSym2 = (HookFunction2 *) _dlsym( dlhandle, "libreofficekit_hook_2" );
+ if (!pSym2)
+ {
+ if (user_profile_path != NULL)
+ {
+ fprintf( stderr, "the LibreOffice version in '%s' does not support passing a user profile to the hook function\n",
+ imp_lib );
+ _dlclose( dlhandle );
+ free( imp_lib );
+ return NULL;
+ }
+ pSym = (HookFunction *) _dlsym( dlhandle, "libreofficekit_hook" );
+ if (!pSym)
+ {
+ fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
+ _dlclose( dlhandle );
+ free( imp_lib );
+ return NULL;
+ }
+ free( imp_lib );
+ // dlhandle is "leaked"
+ // coverity[leaked_storage]
+ return pSym( install_path );
+ }
+
+ free( imp_lib );
+ // dlhandle is "leaked"
+ // coverity[leaked_storage]
+ return pSym2( install_path, user_profile_path );
+}
+
+static
+#ifdef __GNUC__
+__attribute__((used))
+#endif
+LibreOfficeKit *lok_init( const char *install_path )
+{
+ return lok_init_2( install_path, NULL );
+}
+
+#undef SEPARATOR // It is used at least in enum class MenuItemType
+
+#endif // defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) || defined(_WIN32) || defined(__APPLE__)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITINIT_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
=== added file 'src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitTypes.h'
--- src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitTypes.h 1970-01-01 00:00:00 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/LibreOfficeKit/LibreOfficeKitTypes.h 2015-08-25 22:36:41 +0000
@@ -0,0 +1,30 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_TYPES_H
+#define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_TYPES_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef LOK_USE_UNSTABLE_API
+typedef void (*LibreOfficeKitCallback)(int nType, const char* pPayload, void* pData);
+#endif // LOK_USE_UNSTABLE_API
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_TYPES_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Follow ups