remove bundled LOKit headers
It was a source of confusion that these bundled headers had to be synced with core all the time, and when it did not happen, the builds broke. Change-Id: Id9d0a8a496b293d20c39e855176a00bcb85df640 Reviewed-on: https://gerrit.libreoffice.org/84358 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>distro/collabora/code-4.2.0-3
parent
eff3aa96a2
commit
b83610704b
12
Makefile.am
12
Makefile.am
|
@ -230,11 +230,6 @@ kit_headers = kit/ChildSession.hpp \
|
|||
kit/Watermark.hpp
|
||||
|
||||
noinst_HEADERS = $(wsd_headers) $(shared_headers) $(kit_headers) \
|
||||
bundled/include/LibreOfficeKit/LibreOfficeKit.h \
|
||||
bundled/include/LibreOfficeKit/LibreOfficeKit.hxx \
|
||||
bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h \
|
||||
bundled/include/LibreOfficeKit/LibreOfficeKitInit.h \
|
||||
bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h \
|
||||
test/WopiTestServer.hpp \
|
||||
test/countloolkits.hpp \
|
||||
test/test.hpp \
|
||||
|
@ -242,6 +237,13 @@ noinst_HEADERS = $(wsd_headers) $(shared_headers) $(kit_headers) \
|
|||
|
||||
dist-hook:
|
||||
git log -1 --format=%h > $(distdir)/dist_git_hash 2> /dev/null || rm $(distdir)/dist_git_hash
|
||||
mkdir -p $(distdir)/bundled/include/LibreOfficeKit/
|
||||
cp @LOKIT_PATH@/LibreOfficeKit/LibreOfficeKit.h \
|
||||
@LOKIT_PATH@/LibreOfficeKit/LibreOfficeKit.hxx \
|
||||
@LOKIT_PATH@/LibreOfficeKit/LibreOfficeKitEnums.h \
|
||||
@LOKIT_PATH@/LibreOfficeKit/LibreOfficeKitInit.h \
|
||||
@LOKIT_PATH@/LibreOfficeKit/LibreOfficeKitTypes.h \
|
||||
$(distdir)/bundled/include/LibreOfficeKit/
|
||||
|
||||
EXTRA_DIST = discovery.xml \
|
||||
favicon.ico \
|
||||
|
|
|
@ -1,452 +0,0 @@
|
|||
/* -*- 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>
|
||||
|
||||
// the unstable API needs C99's bool
|
||||
// TODO remove the C99 types from the API before making stable
|
||||
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
# ifndef _WIN32
|
||||
# include <stdbool.h>
|
||||
# endif
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#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);
|
||||
|
||||
/// @since LibreOffice 5.0
|
||||
LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis,
|
||||
const char* pURL,
|
||||
const char* pOptions);
|
||||
/// @since LibreOffice 5.2
|
||||
void (*freeError) (char* pFree);
|
||||
|
||||
/// @since LibreOffice 6.0
|
||||
void (*registerCallback) (LibreOfficeKit* pThis,
|
||||
LibreOfficeKitCallback pCallback,
|
||||
void* pData);
|
||||
|
||||
/** @see lok::Office::getFilterTypes().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
char* (*getFilterTypes) (LibreOfficeKit* pThis);
|
||||
|
||||
/** @see lok::Office::setOptionalFeatures().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
void (*setOptionalFeatures)(LibreOfficeKit* pThis, unsigned long long features);
|
||||
|
||||
/** @see lok::Office::setDocumentPassword().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
void (*setDocumentPassword) (LibreOfficeKit* pThis,
|
||||
char const* pURL,
|
||||
char const* pPassword);
|
||||
|
||||
/** @see lok::Office::getVersionInfo().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
char* (*getVersionInfo) (LibreOfficeKit* pThis);
|
||||
|
||||
/** @see lok::Office::runMacro().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
int (*runMacro) (LibreOfficeKit *pThis, const char* pURL);
|
||||
|
||||
/** @see lok::Office::signDocument().
|
||||
@since LibreOffice 6.2
|
||||
*/
|
||||
bool (*signDocument) (LibreOfficeKit* pThis,
|
||||
const char* pUrl,
|
||||
const unsigned char* pCertificateBinary,
|
||||
const int nCertificateBinarySize,
|
||||
const unsigned char* pPrivateKeyBinary,
|
||||
const int nPrivateKeyBinarySize);
|
||||
|
||||
/// @see lok::Office::runLoop()
|
||||
void (*runLoop) (LibreOfficeKit* pThis,
|
||||
LibreOfficeKitPollCallback pPollCallback,
|
||||
LibreOfficeKitWakeCallback pWakeCallback,
|
||||
void* pData);
|
||||
};
|
||||
|
||||
#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);
|
||||
|
||||
/** @see lok::Document::getDocumentType().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
int (*getDocumentType) (LibreOfficeKitDocument* pThis);
|
||||
|
||||
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
/// @see lok::Document::getParts().
|
||||
int (*getParts) (LibreOfficeKitDocument* pThis);
|
||||
|
||||
/// @see lok::Document::getPartPageRectangles().
|
||||
char* (*getPartPageRectangles) (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);
|
||||
|
||||
/// @see lok::Document::setPartMode().
|
||||
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::getTileMode().
|
||||
int (*getTileMode) (LibreOfficeKitDocument* pThis);
|
||||
|
||||
/// @see lok::Document::getDocumentSize().
|
||||
void (*getDocumentSize) (LibreOfficeKitDocument* pThis,
|
||||
long* pWidth,
|
||||
long* pHeight);
|
||||
|
||||
/// @see lok::Document::initializeForRendering().
|
||||
void (*initializeForRendering) (LibreOfficeKitDocument* pThis,
|
||||
const char* pArguments);
|
||||
|
||||
/// @see lok::Document::registerCallback().
|
||||
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,
|
||||
int nButtons,
|
||||
int nModifier);
|
||||
|
||||
/// @see lok::Document::postUnoCommand
|
||||
void (*postUnoCommand) (LibreOfficeKitDocument* pThis,
|
||||
const char* pCommand,
|
||||
const char* pArguments,
|
||||
bool bNotifyWhenFinished);
|
||||
|
||||
/// @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::paste().
|
||||
bool (*paste) (LibreOfficeKitDocument* pThis,
|
||||
const char* pMimeType,
|
||||
const char* pData,
|
||||
size_t nSize);
|
||||
|
||||
/// @see lok::Document::setGraphicSelection
|
||||
void (*setGraphicSelection) (LibreOfficeKitDocument* pThis,
|
||||
int nType,
|
||||
int nX,
|
||||
int nY);
|
||||
|
||||
/// @see lok::Document::resetSelection
|
||||
void (*resetSelection) (LibreOfficeKitDocument* pThis);
|
||||
|
||||
/// @see lok::Document::getCommandValues().
|
||||
char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
|
||||
|
||||
/// @see lok::Document::setClientZoom().
|
||||
void (*setClientZoom) (LibreOfficeKitDocument* pThis,
|
||||
int nTilePixelWidth,
|
||||
int nTilePixelHeight,
|
||||
int nTileTwipWidth,
|
||||
int nTileTwipHeight);
|
||||
|
||||
/// @see lok::Document::setVisibleArea).
|
||||
void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
|
||||
|
||||
/// @see lok::Document::createView().
|
||||
int (*createView) (LibreOfficeKitDocument* pThis);
|
||||
/// @see lok::Document::destroyView().
|
||||
void (*destroyView) (LibreOfficeKitDocument* pThis, int nId);
|
||||
/// @see lok::Document::setView().
|
||||
void (*setView) (LibreOfficeKitDocument* pThis, int nId);
|
||||
/// @see lok::Document::getView().
|
||||
int (*getView) (LibreOfficeKitDocument* pThis);
|
||||
/// @see lok::Document::getViewsCount().
|
||||
int (*getViewsCount) (LibreOfficeKitDocument* pThis);
|
||||
|
||||
/// @see lok::Document::renderFont().
|
||||
unsigned char* (*renderFont) (LibreOfficeKitDocument* pThis,
|
||||
const char* pFontName,
|
||||
const char* pChar,
|
||||
int* pFontWidth,
|
||||
int* pFontHeight);
|
||||
|
||||
/// @see lok::Document::getPartHash().
|
||||
char* (*getPartHash) (LibreOfficeKitDocument* pThis,
|
||||
int nPart);
|
||||
|
||||
/// Paints a tile from a specific part.
|
||||
/// @see lok::Document::paintTile().
|
||||
void (*paintPartTile) (LibreOfficeKitDocument* pThis,
|
||||
unsigned char* pBuffer,
|
||||
const int nPart,
|
||||
const int nCanvasWidth,
|
||||
const int nCanvasHeight,
|
||||
const int nTilePosX,
|
||||
const int nTilePosY,
|
||||
const int nTileWidth,
|
||||
const int nTileHeight);
|
||||
|
||||
/// @see lok::Document::getViewIds().
|
||||
bool (*getViewIds) (LibreOfficeKitDocument* pThis,
|
||||
int* pArray,
|
||||
size_t nSize);
|
||||
|
||||
/// @see lok::Document::setOutlineState).
|
||||
void (*setOutlineState) (LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden);
|
||||
|
||||
/// Paints window with given id to the buffer
|
||||
/// @see lok::Document::paintWindow().
|
||||
void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
|
||||
unsigned char* pBuffer,
|
||||
const int x, const int y,
|
||||
const int width, const int height);
|
||||
|
||||
/// @see lok::Document::postWindow().
|
||||
void (*postWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, int nAction, const char* pData);
|
||||
|
||||
/// @see lok::Document::postWindowKeyEvent().
|
||||
void (*postWindowKeyEvent) (LibreOfficeKitDocument* pThis,
|
||||
unsigned nWindowId,
|
||||
int nType,
|
||||
int nCharCode,
|
||||
int nKeyCode);
|
||||
|
||||
/// @see lok::Document::postWindowMouseEvent().
|
||||
void (*postWindowMouseEvent) (LibreOfficeKitDocument* pThis,
|
||||
unsigned nWindowId,
|
||||
int nType,
|
||||
int nX,
|
||||
int nY,
|
||||
int nCount,
|
||||
int nButtons,
|
||||
int nModifier);
|
||||
|
||||
/// @see lok::Document::setViewLanguage().
|
||||
void (*setViewLanguage) (LibreOfficeKitDocument* pThis, int nId, const char* language);
|
||||
|
||||
/// @see lok::Document::postWindowExtTextInputEvent
|
||||
void (*postWindowExtTextInputEvent) (LibreOfficeKitDocument* pThis,
|
||||
unsigned nWindowId,
|
||||
int nType,
|
||||
const char* pText);
|
||||
|
||||
/// @see lok::Document::getPartInfo().
|
||||
char* (*getPartInfo) (LibreOfficeKitDocument* pThis, int nPart);
|
||||
|
||||
/// Paints window with given id to the buffer with the give DPI scale
|
||||
/// (every pixel is dpiscale-times larger).
|
||||
/// @see lok::Document::paintWindow().
|
||||
void (*paintWindowDPI) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
|
||||
unsigned char* pBuffer,
|
||||
const int x, const int y,
|
||||
const int width, const int height,
|
||||
const double dpiscale);
|
||||
|
||||
#ifdef IOS
|
||||
/// @see lok::Document::paintTileToCGContext().
|
||||
void (*paintTileToCGContext) (LibreOfficeKitDocument* pThis,
|
||||
void* rCGContext,
|
||||
const int nCanvasWidth,
|
||||
const int nCanvasHeight,
|
||||
const int nTilePosX,
|
||||
const int nTilePosY,
|
||||
const int nTileWidth,
|
||||
const int nTileHeight);
|
||||
#endif // IOS
|
||||
|
||||
// CERTIFICATE AND SIGNING
|
||||
|
||||
/// @see lok::Document::insertCertificate().
|
||||
bool (*insertCertificate) (LibreOfficeKitDocument* pThis,
|
||||
const unsigned char* pCertificateBinary,
|
||||
const int nCertificateBinarySize,
|
||||
const unsigned char* pPrivateKeyBinary,
|
||||
const int nPrivateKeyBinarySize);
|
||||
|
||||
/// @see lok::Document::addCertificate().
|
||||
bool (*addCertificate) (LibreOfficeKitDocument* pThis,
|
||||
const unsigned char* pCertificateBinary,
|
||||
const int nCertificateBinarySize);
|
||||
|
||||
/// @see lok::Document::getSignatureState().
|
||||
int (*getSignatureState) (LibreOfficeKitDocument* pThis);
|
||||
// END CERTIFICATE AND SIGNING
|
||||
|
||||
/// @see lok::Document::renderShapeSelection
|
||||
size_t (*renderShapeSelection)(LibreOfficeKitDocument* pThis, char** pOutput);
|
||||
|
||||
/// @see lok::Document::postWindowGestureEvent().
|
||||
void (*postWindowGestureEvent) (LibreOfficeKitDocument* pThis,
|
||||
unsigned nWindowId,
|
||||
const char* pType,
|
||||
int nX,
|
||||
int nY,
|
||||
int nOffset);
|
||||
|
||||
/// @see lok::Document::createViewWithOptions().
|
||||
int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions);
|
||||
|
||||
/// @see lok::Document::selectPart().
|
||||
void (*selectPart) (LibreOfficeKitDocument* pThis, int nPart, int nSelect);
|
||||
|
||||
/// @see lok::Document::moveSelectedParts().
|
||||
void (*moveSelectedParts) (LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate);
|
||||
|
||||
/// Resize window with given id.
|
||||
/// @see lok::Document::resizeWindow().
|
||||
void (*resizeWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
|
||||
const int width, const int height);
|
||||
|
||||
/// Pass a nullptr terminated array of mime-type strings
|
||||
/// @see lok::Document::getClipboard for more details
|
||||
int (*getClipboard) (LibreOfficeKitDocument* pThis,
|
||||
const char **pMimeTypes,
|
||||
size_t *pOutCount,
|
||||
char ***pOutMimeTypes,
|
||||
size_t **pOutSizes,
|
||||
char ***pOutStreams);
|
||||
|
||||
/// @see lok::Document::setClipboard
|
||||
int (*setClipboard) (LibreOfficeKitDocument* pThis,
|
||||
const size_t nInCount,
|
||||
const char **pInMimeTypes,
|
||||
const size_t *pInSizes,
|
||||
const char **pInStreams);
|
||||
|
||||
/// @see lok::Document::getSelectionType
|
||||
int (*getSelectionType) (LibreOfficeKitDocument* pThis);
|
||||
|
||||
/// @see lok::Document::removeTextContext
|
||||
void (*removeTextContext) (LibreOfficeKitDocument* pThis,
|
||||
unsigned nWindowId,
|
||||
int nBefore,
|
||||
int nAfter);
|
||||
|
||||
/// @see lok::Document::sendDialogEvent
|
||||
void (*sendDialogEvent) (LibreOfficeKitDocument* pThis,
|
||||
unsigned nLOKWindowId,
|
||||
const char* pArguments);
|
||||
|
||||
/// @see lok::Document::renderFontOrientation().
|
||||
unsigned char* (*renderFontOrientation) (LibreOfficeKitDocument* pThis,
|
||||
const char* pFontName,
|
||||
const char* pChar,
|
||||
int* pFontWidth,
|
||||
int* pFontHeight,
|
||||
int pOrientation);
|
||||
|
||||
/// Switches view to viewId if viewId >= 0, and paints window
|
||||
/// @see lok::Document::paintWindowDPI().
|
||||
void (*paintWindowForView) (LibreOfficeKitDocument* pThis, unsigned nWindowId,
|
||||
unsigned char* pBuffer,
|
||||
const int x, const int y,
|
||||
const int width, const int height,
|
||||
const double dpiscale,
|
||||
int viewId);
|
||||
|
||||
/// @see lok::Document::completeFunction
|
||||
void (*completeFunction) (LibreOfficeKitDocument* pThis,
|
||||
int nIndex);
|
||||
|
||||
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,977 +0,0 @@
|
|||
/* -*- 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 <cstddef>
|
||||
|
||||
#include <LibreOfficeKit/LibreOfficeKit.h>
|
||||
#include <LibreOfficeKit/LibreOfficeKitInit.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.
|
||||
Document(LibreOfficeKitDocument* pDoc) :
|
||||
mpDoc(pDoc)
|
||||
{}
|
||||
|
||||
~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.
|
||||
* Another useful FilterOption is "TakeOwnership". It is consumed
|
||||
* by the saveAs() itself, and when provided, the document identity
|
||||
* changes to the provided pUrl - meaning that '.uno:ModifiedStatus'
|
||||
* is triggered as with the "Save As..." in the UI.
|
||||
* "TakeOwnership" mode must not be used when saving to PNG or PDF.
|
||||
*/
|
||||
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.
|
||||
LibreOfficeKitDocument *get() { return mpDoc; }
|
||||
|
||||
/**
|
||||
* Get document type.
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
* @return an element of the LibreOfficeKitDocumentType enum.
|
||||
*/
|
||||
int getDocumentType()
|
||||
{
|
||||
return mpDoc->pClass->getDocumentType(mpDoc);
|
||||
}
|
||||
|
||||
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
/**
|
||||
* Get number of part that the document contains.
|
||||
*
|
||||
* Part refers to either individual sheets in a Calc, or slides in Impress,
|
||||
* and has no relevance for Writer.
|
||||
*/
|
||||
int getParts()
|
||||
{
|
||||
return mpDoc->pClass->getParts(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the logical rectangle of each part in the document.
|
||||
*
|
||||
* A part refers to an individual page in Writer and has no relevant for
|
||||
* Calc or Impress.
|
||||
*
|
||||
* @return a rectangle list, using the same format as
|
||||
* LOK_CALLBACK_TEXT_SELECTION.
|
||||
*/
|
||||
char* getPartPageRectangles()
|
||||
{
|
||||
return mpDoc->pClass->getPartPageRectangles(mpDoc);
|
||||
}
|
||||
|
||||
/// Get the current part of the document.
|
||||
int getPart()
|
||||
{
|
||||
return mpDoc->pClass->getPart(mpDoc);
|
||||
}
|
||||
|
||||
/// Set the current part of the document.
|
||||
void setPart(int nPart)
|
||||
{
|
||||
mpDoc->pClass->setPart(mpDoc, nPart);
|
||||
}
|
||||
|
||||
/// Get the current part's name.
|
||||
char* getPartName(int nPart)
|
||||
{
|
||||
return mpDoc->pClass->getPartName(mpDoc, nPart);
|
||||
}
|
||||
|
||||
/// Get the current part's hash.
|
||||
char* getPartHash(int nPart)
|
||||
{
|
||||
return mpDoc->pClass->getPartHash(mpDoc, nPart);
|
||||
}
|
||||
|
||||
void setPartMode(int nMode)
|
||||
{
|
||||
mpDoc->pClass->setPartMode(mpDoc, nMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a window (dialog, popup, etc.) with give id
|
||||
*
|
||||
* @param nWindowId
|
||||
* @param pBuffer Buffer with enough memory allocated to render any dialog
|
||||
* @param x x-coordinate from where the dialog should start painting
|
||||
* @param y y-coordinate from where the dialog should start painting
|
||||
* @param width The width of the dialog image to be painted
|
||||
* @param height The height of the dialog image to be painted
|
||||
* @param dpiscale The dpi scale value used by the client. Please note
|
||||
* that the x, y, width, height are supposed to be the
|
||||
* values with dpiscale applied (ie. dialog covering
|
||||
* 100x100 "normal" pixels with dpiscale '2' will have
|
||||
* 200x200 width x height), so that it is easy to compute
|
||||
* the buffer sizes etc.
|
||||
*/
|
||||
void paintWindow(unsigned nWindowId,
|
||||
unsigned char* pBuffer,
|
||||
const int x,
|
||||
const int y,
|
||||
const int width,
|
||||
const int height,
|
||||
const double dpiscale = 1.0,
|
||||
const int viewId = -1)
|
||||
{
|
||||
return mpDoc->pClass->paintWindowForView(mpDoc, nWindowId, pBuffer, x, y,
|
||||
width, height, dpiscale, viewId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a command to the window (dialog, popup, etc.) with given id
|
||||
*
|
||||
* @param nWindowid
|
||||
*/
|
||||
void postWindow(unsigned nWindowId, int nAction, const char* pData = nullptr)
|
||||
{
|
||||
return mpDoc->pClass->postWindow(mpDoc, nWindowId, nAction, pData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tile mode: the pixel format used for the pBuffer of paintTile().
|
||||
*
|
||||
* @return an element of the LibreOfficeKitTileMode enum.
|
||||
*/
|
||||
int getTileMode()
|
||||
{
|
||||
return mpDoc->pClass->getTileMode(mpDoc);
|
||||
}
|
||||
|
||||
/// Get the document sizes in TWIPs.
|
||||
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.
|
||||
*
|
||||
* Example argument string for text documents:
|
||||
*
|
||||
* {
|
||||
* ".uno:HideWhitespace":
|
||||
* {
|
||||
* "type": "boolean",
|
||||
* "value": "true"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param pArguments arguments of the rendering
|
||||
*/
|
||||
void initializeForRendering(const char* pArguments = NULL)
|
||||
{
|
||||
mpDoc->pClass->initializeForRendering(mpDoc, pArguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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)
|
||||
*/
|
||||
void postKeyEvent(int nType, int nCharCode, int nKeyCode)
|
||||
{
|
||||
mpDoc->pClass->postKeyEvent(mpDoc, nType, nCharCode, nKeyCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a keyboard event to the dialog
|
||||
*
|
||||
* @param nWindowId
|
||||
* @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)
|
||||
*/
|
||||
void postWindowKeyEvent(unsigned nWindowId, int nType, int nCharCode, int nKeyCode)
|
||||
{
|
||||
mpDoc->pClass->postWindowKeyEvent(mpDoc, nWindowId, 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
|
||||
* @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
|
||||
* @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
|
||||
*/
|
||||
void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
mpDoc->pClass->postMouseEvent(mpDoc, nType, nX, nY, nCount, nButtons, nModifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a mouse event to the window with given id.
|
||||
*
|
||||
* @param nWindowId
|
||||
* @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
|
||||
* @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
|
||||
* @param nModifier: which keyboard modifier: (see include/vcl/vclenum.hxx for possible values)
|
||||
*/
|
||||
void postWindowMouseEvent(unsigned nWindowId, int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
|
||||
{
|
||||
mpDoc->pClass->postWindowMouseEvent(mpDoc, nWindowId, nType, nX, nY, nCount, nButtons, nModifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a dialog event for the window with given id
|
||||
*
|
||||
* @param nWindowId id of the window to notify
|
||||
* @param pArguments arguments of the event.
|
||||
*/
|
||||
void sendDialogEvent(unsigned nWindowId, const char* pArguments = NULL)
|
||||
{
|
||||
mpDoc->pClass->sendDialogEvent(mpDoc, nWindowId, pArguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void postUnoCommand(const char* pCommand, const char* pArguments = NULL, bool bNotifyWhenFinished = false)
|
||||
{
|
||||
mpDoc->pClass->postUnoCommand(mpDoc, pCommand, pArguments, bNotifyWhenFinished);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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).
|
||||
*/
|
||||
char* getTextSelection(const char* pMimeType, char** pUsedMimeType = NULL)
|
||||
{
|
||||
return mpDoc->pClass->getTextSelection(mpDoc, pMimeType, pUsedMimeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the selected content.
|
||||
*
|
||||
* @return an element of the LibreOfficeKitSelectionType enum.
|
||||
*/
|
||||
int getSelectionType()
|
||||
{
|
||||
return mpDoc->pClass->getSelectionType(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content on the clipboard for the current view as a series of binary streams.
|
||||
*
|
||||
* NB. returns a complete set of possible selection types if nullptr is passed for pMimeTypes.
|
||||
*
|
||||
* @param pMimeTypes passes in a nullptr terminated list of mime types to fetch
|
||||
* @param pOutCount returns the size of the other @pOut arrays
|
||||
* @param pOutMimeTypes returns an array of mime types
|
||||
* @param pOutSizes returns the size of each pOutStream
|
||||
* @param pOutStreams the content of each mime-type, of length in @pOutSizes
|
||||
*
|
||||
* @returns: true on success, false on error.
|
||||
*/
|
||||
bool getClipboard(const char **pMimeTypes,
|
||||
size_t *pOutCount,
|
||||
char ***pOutMimeTypes,
|
||||
size_t **pOutSizes,
|
||||
char ***pOutStreams)
|
||||
{
|
||||
return mpDoc->pClass->getClipboard(mpDoc, pMimeTypes, pOutCount, pOutMimeTypes, pOutSizes, pOutStreams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the clipboard for this view with multiple types of content.
|
||||
*
|
||||
* @param nInCount the number of types to paste
|
||||
* @param pInMimeTypes array of mime type strings
|
||||
* @param pInSizes array of sizes of the data to paste
|
||||
* @param pInStreams array containing the data of the various types
|
||||
*
|
||||
* @return if the supplied data was populated successfully.
|
||||
*/
|
||||
bool setClipboard(const size_t nInCount,
|
||||
const char **pInMimeTypes,
|
||||
const size_t *pInSizes,
|
||||
const char **pInStreams)
|
||||
{
|
||||
return mpDoc->pClass->setClipboard(mpDoc, nInCount, pInMimeTypes, pInSizes, pInStreams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pastes content at the current cursor position.
|
||||
*
|
||||
* @param pMimeType format of pData, for example text/plain;charset=utf-8.
|
||||
* @param pData the actual data to be pasted.
|
||||
* @return if the supplied data was pasted successfully.
|
||||
*/
|
||||
bool paste(const char* pMimeType, const char* pData, size_t nSize)
|
||||
{
|
||||
return mpDoc->pClass->paste(mpDoc, pMimeType, pData, nSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the graphic selection.
|
||||
*
|
||||
* @param nType @see LibreOfficeKitSetGraphicSelectionType
|
||||
* @param nX horizontal position in document coordinates
|
||||
* @param nY vertical position in document coordinates
|
||||
*/
|
||||
void setGraphicSelection(int nType, int nX, int nY)
|
||||
{
|
||||
mpDoc->pClass->setGraphicSelection(mpDoc, nType, nX, nY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets rid of any text or graphic selection.
|
||||
*/
|
||||
void resetSelection()
|
||||
{
|
||||
mpDoc->pClass->resetSelection(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a json mapping of the possible values for the given command
|
||||
* e.g. {commandName: ".uno:StyleApply", commandValues: {"familyName1" : ["list of style names in the family1"], etc.}}
|
||||
* @param pCommand a UNO command for which the possible values are requested
|
||||
* @return {commandName: unoCmd, commandValues: {possible_values}}
|
||||
*/
|
||||
char* getCommandValues(const char* pCommand)
|
||||
{
|
||||
return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the client's view so that we can compute the right zoom level
|
||||
* for the mouse events. This only affects CALC.
|
||||
* @param nTilePixelWidth - tile width in pixels
|
||||
* @param nTilePixelHeight - tile height in pixels
|
||||
* @param nTileTwipWidth - tile width in twips
|
||||
* @param nTileTwipHeight - tile height in twips
|
||||
*/
|
||||
void setClientZoom(
|
||||
int nTilePixelWidth,
|
||||
int nTilePixelHeight,
|
||||
int nTileTwipWidth,
|
||||
int nTileTwipHeight)
|
||||
{
|
||||
mpDoc->pClass->setClientZoom(mpDoc, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform 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.
|
||||
*
|
||||
* @param nX - top left corner horizontal position
|
||||
* @param nY - top left corner vertical position
|
||||
* @param nWidth - area width
|
||||
* @param nHeight - area height
|
||||
*/
|
||||
void setClientVisibleArea(int nX, int nY, int nWidth, int nHeight)
|
||||
{
|
||||
mpDoc->pClass->setClientVisibleArea(mpDoc, nX, nY, nWidth, nHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show/Hide a single row/column header outline for Calc documents.
|
||||
*
|
||||
* @param bColumn - if we are dealing with a column or row group
|
||||
* @param nLevel - the level to which the group belongs
|
||||
* @param nIndex - the group entry index
|
||||
* @param bHidden - the new group state (collapsed/expanded)
|
||||
*/
|
||||
void setOutlineState(bool bColumn, int nLevel, int nIndex, bool bHidden)
|
||||
{
|
||||
mpDoc->pClass->setOutlineState(mpDoc, bColumn, nLevel, nIndex, bHidden);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new view for an existing document with
|
||||
* options similar to documentLoadWithOptions.
|
||||
* By default a loaded document has 1 view.
|
||||
* @return the ID of the new view.
|
||||
*/
|
||||
int createView(const char* pOptions = nullptr)
|
||||
{
|
||||
if (LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, createViewWithOptions))
|
||||
return mpDoc->pClass->createViewWithOptions(mpDoc, pOptions);
|
||||
else
|
||||
return mpDoc->pClass->createView(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a view of an existing document.
|
||||
* @param nId a view ID, returned by createView().
|
||||
*/
|
||||
void destroyView(int nId)
|
||||
{
|
||||
mpDoc->pClass->destroyView(mpDoc, nId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an existing view of an existing document as current.
|
||||
* @param nId a view ID, returned by createView().
|
||||
*/
|
||||
void setView(int nId)
|
||||
{
|
||||
mpDoc->pClass->setView(mpDoc, nId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current view.
|
||||
* @return a view ID, previously returned by createView().
|
||||
*/
|
||||
int getView()
|
||||
{
|
||||
return mpDoc->pClass->getView(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of views of this document.
|
||||
*/
|
||||
int getViewsCount()
|
||||
{
|
||||
return mpDoc->pClass->getViewsCount(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a font name or character if provided to be displayed in the font list
|
||||
* @param pFontName the font to be painted
|
||||
*/
|
||||
unsigned char* renderFont(const char *pFontName,
|
||||
const char *pChar,
|
||||
int *pFontWidth,
|
||||
int *pFontHeight,
|
||||
int pOrientation = 0)
|
||||
{
|
||||
if (LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, renderFontOrientation))
|
||||
return mpDoc->pClass->renderFontOrientation(mpDoc, pFontName, pChar, pFontWidth, pFontHeight, pOrientation);
|
||||
else
|
||||
return mpDoc->pClass->renderFont(mpDoc, pFontName, pChar, pFontWidth, pFontHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a subset of the document's part to a pre-allocated buffer.
|
||||
*
|
||||
* @param nPart the part number of the document of which the tile is painted.
|
||||
* @see paintTile.
|
||||
*/
|
||||
void paintPartTile(unsigned char* pBuffer,
|
||||
const int nPart,
|
||||
const int nCanvasWidth,
|
||||
const int nCanvasHeight,
|
||||
const int nTilePosX,
|
||||
const int nTilePosY,
|
||||
const int nTileWidth,
|
||||
const int nTileHeight)
|
||||
{
|
||||
return mpDoc->pClass->paintPartTile(mpDoc, pBuffer, nPart,
|
||||
nCanvasWidth, nCanvasHeight,
|
||||
nTilePosX, nTilePosY,
|
||||
nTileWidth, nTileHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the viewID for each existing view. Since viewIDs are not reused,
|
||||
* viewIDs are not the same as the index of the view in the view array over
|
||||
* time. Use getViewsCount() to know the minimal nSize that's large enough.
|
||||
*
|
||||
* @param pArray the array to write the viewIDs into
|
||||
* @param nSize the size of pArray
|
||||
* @returns true if pArray was large enough and result is written, false
|
||||
* otherwise.
|
||||
*/
|
||||
bool getViewIds(int* pArray,
|
||||
size_t nSize)
|
||||
{
|
||||
return mpDoc->pClass->getViewIds(mpDoc, pArray, nSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the language tag of the window with the specified nId.
|
||||
*
|
||||
* @param nId a view ID, returned by createView().
|
||||
* @param language Bcp47 languageTag, like en-US or so.
|
||||
*/
|
||||
void setViewLanguage(int nId, const char* language)
|
||||
{
|
||||
mpDoc->pClass->setViewLanguage(mpDoc, nId, language);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post the text input from external input window, like IME, to given windowId
|
||||
*
|
||||
* @param nWindowId Specify the window id to post the input event to. If
|
||||
* nWindow is 0, the event is posted into the document
|
||||
* @param nType see LibreOfficeKitExtTextInputType
|
||||
* @param pText Text for LOK_EXT_TEXTINPUT
|
||||
*/
|
||||
void postWindowExtTextInputEvent(unsigned nWindowId, int nType, const char* pText)
|
||||
{
|
||||
mpDoc->pClass->postWindowExtTextInputEvent(mpDoc, nWindowId, nType, pText);
|
||||
}
|
||||
|
||||
#ifdef IOS
|
||||
/**
|
||||
* Renders a subset of the document to a Core Graphics context.
|
||||
*
|
||||
* 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 rCGContext the CGContextRef, cast to a void*.
|
||||
* @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.
|
||||
*/
|
||||
void paintTileToCGContext(void* rCGContext,
|
||||
const int nCanvasWidth,
|
||||
const int nCanvasHeight,
|
||||
const int nTilePosX,
|
||||
const int nTilePosY,
|
||||
const int nTileWidth,
|
||||
const int nTileHeight)
|
||||
{
|
||||
return mpDoc->pClass->paintTileToCGContext(mpDoc, rCGContext, nCanvasWidth, nCanvasHeight,
|
||||
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
||||
}
|
||||
#endif // IOS
|
||||
|
||||
/**
|
||||
* Insert certificate (in binary form) to the certificate store.
|
||||
*/
|
||||
bool insertCertificate(const unsigned char* pCertificateBinary,
|
||||
const int pCertificateBinarySize,
|
||||
const unsigned char* pPrivateKeyBinary,
|
||||
const int nPrivateKeyBinarySize)
|
||||
{
|
||||
return mpDoc->pClass->insertCertificate(mpDoc,
|
||||
pCertificateBinary, pCertificateBinarySize,
|
||||
pPrivateKeyBinary, nPrivateKeyBinarySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the certificate (in binary form) to the certificate store.
|
||||
*
|
||||
*/
|
||||
bool addCertificate(const unsigned char* pCertificateBinary,
|
||||
const int pCertificateBinarySize)
|
||||
{
|
||||
return mpDoc->pClass->addCertificate(mpDoc,
|
||||
pCertificateBinary, pCertificateBinarySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify signature of the document.
|
||||
*
|
||||
* Check possible values in include/sfx2/signaturestate.hxx
|
||||
*/
|
||||
int getSignatureState()
|
||||
{
|
||||
return mpDoc->pClass->getSignatureState(mpDoc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an image of the selected shapes.
|
||||
* @param pOutput contains the result; use free to deallocate.
|
||||
* @return the size of *pOutput in bytes.
|
||||
*/
|
||||
size_t renderShapeSelection(char** pOutput)
|
||||
{
|
||||
return mpDoc->pClass->renderShapeSelection(mpDoc, pOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts a gesture event to the window with given id.
|
||||
*
|
||||
* @param nWindowId
|
||||
* @param pType Event type, like panStart, panEnd, panUpdate.
|
||||
* @param nX horizontal position in document coordinates
|
||||
* @param nY vertical position in document coordinates
|
||||
* @param nOffset difference value from when the gesture started to current value
|
||||
*/
|
||||
void postWindowGestureEvent(unsigned nWindowId,
|
||||
const char* pType,
|
||||
int nX, int nY, int nOffset)
|
||||
{
|
||||
return mpDoc->pClass->postWindowGestureEvent(mpDoc, nWindowId, pType, nX, nY, nOffset);
|
||||
}
|
||||
|
||||
/// Set a part's selection mode.
|
||||
/// nSelect is 0 to deselect, 1 to select, and 2 to toggle.
|
||||
void selectPart(int nPart, int nSelect)
|
||||
{
|
||||
mpDoc->pClass->selectPart(mpDoc, nPart, nSelect);
|
||||
}
|
||||
|
||||
/// Moves the selected pages/slides to a new position.
|
||||
/// nPosition is the new position where the selection
|
||||
/// should go. bDuplicate when true will copy instead of move.
|
||||
void moveSelectedParts(int nPosition, bool bDuplicate)
|
||||
{
|
||||
mpDoc->pClass->moveSelectedParts(mpDoc, nPosition, bDuplicate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize a window (dialog, popup, etc.) with give id.
|
||||
*
|
||||
* @param nWindowId
|
||||
* @param width The width of the window.
|
||||
* @param height The height of the window.
|
||||
*/
|
||||
void resizeWindow(unsigned nWindowId,
|
||||
const int width,
|
||||
const int height)
|
||||
{
|
||||
return mpDoc->pClass->resizeWindow(mpDoc, nWindowId, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* For deleting many characters all at once
|
||||
*
|
||||
* @param nWindowId Specify the window id to post the input event to. If
|
||||
* nWindow is 0, the event is posted into the document
|
||||
* @param nBefore The characters to be deleted before the cursor position
|
||||
* @param nAfter The characters to be deleted after the cursor position
|
||||
*/
|
||||
void removeTextContext(unsigned nWindowId, int nBefore, int nAfter)
|
||||
{
|
||||
mpDoc->pClass->removeTextContext(mpDoc, nWindowId, nBefore, nAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the Calc function to be pasted into the formula input box
|
||||
*
|
||||
* @param nIndex is the index of the selected function
|
||||
*/
|
||||
void completeFunction(int nIndex)
|
||||
{
|
||||
mpDoc->pClass->completeFunction(mpDoc, nIndex);
|
||||
}
|
||||
|
||||
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
};
|
||||
|
||||
/// 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.
|
||||
Office(LibreOfficeKit* pThis) :
|
||||
mpThis(pThis)
|
||||
{}
|
||||
|
||||
~Office()
|
||||
{
|
||||
mpThis->pClass->destroy(mpThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a document from a URL.
|
||||
*
|
||||
* @param pUrl the URL of the document to load
|
||||
* @param pFilterOptions options for the import filter, e.g. SkipImages.
|
||||
* Another useful FilterOption is "Language=...". It is consumed
|
||||
* by the documentLoad() itself, and when provided, LibreOfficeKit
|
||||
* switches the language accordingly first.
|
||||
* @since pFilterOptions argument added in LibreOffice 5.0
|
||||
*/
|
||||
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.
|
||||
char* getError()
|
||||
{
|
||||
return mpThis->pClass->getError(mpThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the memory pointed to by pFree.
|
||||
*
|
||||
* @since LibreOffice 5.2
|
||||
*/
|
||||
void freeError(char* pFree)
|
||||
{
|
||||
mpThis->pClass->freeError(pFree);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback. LOK will invoke this function when it wants to
|
||||
* inform the client about events.
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
* @param pCallback the callback to invoke
|
||||
* @param pData the user data, will be passed to the callback on invocation
|
||||
*/
|
||||
void registerCallback(LibreOfficeKitCallback pCallback, void* pData)
|
||||
{
|
||||
mpThis->pClass->registerCallback(mpThis, pCallback, pData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns details of filter types.
|
||||
*
|
||||
* Example returned string:
|
||||
*
|
||||
* {
|
||||
* "writer8": {
|
||||
* "MediaType": "application/vnd.oasis.opendocument.text"
|
||||
* },
|
||||
* "calc8": {
|
||||
* "MediaType": "application/vnd.oasis.opendocument.spreadsheet"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
*/
|
||||
char* getFilterTypes()
|
||||
{
|
||||
return mpThis->pClass->getFilterTypes(mpThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bitmask of optional features supported by the client.
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
* @see LibreOfficeKitOptionalFeatures
|
||||
*/
|
||||
void setOptionalFeatures(unsigned long long features)
|
||||
{
|
||||
return mpThis->pClass->setOptionalFeatures(mpThis, features);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set password required for loading or editing a document.
|
||||
*
|
||||
* Loading the document is blocked until the password is provided.
|
||||
*
|
||||
* @param pURL the URL of the document, as sent to the callback
|
||||
* @param pPassword the password, nullptr indicates no password
|
||||
*
|
||||
* In response to LOK_CALLBACK_DOCUMENT_PASSWORD, a valid password
|
||||
* will continue loading the document, an invalid password will
|
||||
* result in another LOK_CALLBACK_DOCUMENT_PASSWORD request,
|
||||
* and a NULL password will abort loading the document.
|
||||
*
|
||||
* In response to LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY, a valid
|
||||
* password will continue loading the document, an invalid password will
|
||||
* result in another LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY request,
|
||||
* and a NULL password will continue loading the document in read-only
|
||||
* mode.
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
*/
|
||||
void setDocumentPassword(char const* pURL, char const* pPassword)
|
||||
{
|
||||
mpThis->pClass->setDocumentPassword(mpThis, pURL, pPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version information of the LOKit process
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
* @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 char git hash>"}
|
||||
*/
|
||||
char* getVersionInfo()
|
||||
{
|
||||
return mpThis->pClass->getVersionInfo(mpThis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a macro.
|
||||
*
|
||||
* Same syntax as on command line is permissible (ie. the macro:// URI forms)
|
||||
*
|
||||
* @since LibreOffice 6.0
|
||||
* @param pURL macro url to run
|
||||
*/
|
||||
|
||||
bool runMacro( const char* pURL)
|
||||
{
|
||||
return mpThis->pClass->runMacro( mpThis, pURL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the document and signes its content.
|
||||
*/
|
||||
bool signDocument(const char* pURL,
|
||||
const unsigned char* pCertificateBinary, const int nCertificateBinarySize,
|
||||
const unsigned char* pPrivateKeyBinary, const int nPrivateKeyBinarySize)
|
||||
{
|
||||
return mpThis->pClass->signDocument(mpThis, pURL,
|
||||
pCertificateBinary, nCertificateBinarySize,
|
||||
pPrivateKeyBinary, nPrivateKeyBinarySize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the main-loop in the current thread. To trigger this
|
||||
* mode you need to putenv a SAL_LOK_OPTIONS containing 'unipoll'.
|
||||
* The @pPollCallback is called to poll for events from the Kit client
|
||||
* and the @pWakeCallback can be called by internal LibreOfficeKit threads
|
||||
* to wake the caller of 'runLoop' ie. the main thread.
|
||||
*
|
||||
* it is expected that runLoop does not return until Kit exit.
|
||||
*
|
||||
* @pData is a context/closure passed to both methods.
|
||||
*/
|
||||
void runLoop(LibreOfficeKitPollCallback pPollCallback,
|
||||
LibreOfficeKitWakeCallback pWakeCallback,
|
||||
void* pData)
|
||||
{
|
||||
mpThis->pClass->runLoop(mpThis, pPollCallback, pWakeCallback, pData);
|
||||
}
|
||||
};
|
||||
|
||||
/// Factory method to create a lok::Office instance.
|
||||
inline Office* lok_cpp_init(const char* pInstallPath, const char* pUserProfileUrl = NULL)
|
||||
{
|
||||
LibreOfficeKit* pThis = lok_init_2(pInstallPath, pUserProfileUrl);
|
||||
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: */
|
|
@ -1,908 +0,0 @@
|
|||
/* -*- 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
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
typedef enum
|
||||
{
|
||||
LOK_DOCTYPE_TEXT,
|
||||
LOK_DOCTYPE_SPREADSHEET,
|
||||
LOK_DOCTYPE_PRESENTATION,
|
||||
LOK_DOCTYPE_DRAWING,
|
||||
LOK_DOCTYPE_OTHER
|
||||
}
|
||||
LibreOfficeKitDocumentType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LOK_PARTMODE_SLIDES,
|
||||
LOK_PARTMODE_NOTES
|
||||
}
|
||||
LibreOfficeKitPartMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LOK_TILEMODE_RGBA,
|
||||
LOK_TILEMODE_BGRA
|
||||
}
|
||||
LibreOfficeKitTileMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LOK_WINDOW_CLOSE,
|
||||
LOK_WINDOW_PASTE
|
||||
}
|
||||
LibreOfficeKitWindowAction;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LOK_SELTYPE_NONE,
|
||||
LOK_SELTYPE_TEXT,
|
||||
LOK_SELTYPE_LARGE_TEXT,
|
||||
LOK_SELTYPE_COMPLEX
|
||||
}
|
||||
LibreOfficeKitSelectionType;
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* @see lok::Office::setOptionalFeatures().
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* Handle LOK_CALLBACK_DOCUMENT_PASSWORD by prompting the user
|
||||
* for a password.
|
||||
*
|
||||
* @see lok::Office::setDocumentPassword().
|
||||
*/
|
||||
LOK_FEATURE_DOCUMENT_PASSWORD = (1ULL << 0),
|
||||
|
||||
/**
|
||||
* Handle LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY by prompting the user
|
||||
* for a password.
|
||||
*
|
||||
* @see lok::Office::setDocumentPassword().
|
||||
*/
|
||||
LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY = (1ULL << 1),
|
||||
|
||||
/**
|
||||
* Request to have the part number as an 5th value in the
|
||||
* LOK_CALLBACK_INVALIDATE_TILES payload.
|
||||
*/
|
||||
LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK = (1ULL << 2),
|
||||
|
||||
/**
|
||||
* Turn off tile rendering for annotations
|
||||
*/
|
||||
LOK_FEATURE_NO_TILED_ANNOTATIONS = (1ULL << 3),
|
||||
|
||||
/**
|
||||
* Enable range based header data
|
||||
*/
|
||||
LOK_FEATURE_RANGE_HEADERS = (1ULL << 4),
|
||||
|
||||
/**
|
||||
* Request to have the active view's Id as the 1st value in the
|
||||
* LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR payload.
|
||||
*/
|
||||
LOK_FEATURE_VIEWID_IN_VISCURSOR_INVALIDATION_CALLBACK = (1ULL << 5)
|
||||
}
|
||||
LibreOfficeKitOptionalFeatures;
|
||||
|
||||
// This 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.
|
||||
|
||||
// TODO: We should really add some indication at the documentation for
|
||||
// each enum value telling which type of callback it is.
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @see LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK.
|
||||
*/
|
||||
LOK_CALLBACK_INVALIDATE_TILES = 0,
|
||||
/**
|
||||
* The size and/or the position of the visible cursor changed.
|
||||
*
|
||||
* Old format is the same as LOK_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 'mispelledWord' element represented by an integer value: '1' when
|
||||
* a mispelled word is at the cursor position, '0' when the word is
|
||||
* not mispelled.
|
||||
*/
|
||||
LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR = 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
|
||||
* LOK_CALLBACK_INVALIDATE_TILES. When there is no selection, an empty
|
||||
* string is provided.
|
||||
*/
|
||||
LOK_CALLBACK_TEXT_SELECTION = 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 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 = 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 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 = 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
|
||||
* LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR once it becomes false. Payload is
|
||||
* either the "true" or the "false" string.
|
||||
*/
|
||||
LOK_CALLBACK_CURSOR_VISIBLE = 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.
|
||||
*/
|
||||
LOK_CALLBACK_GRAPHIC_SELECTION = 6,
|
||||
|
||||
/**
|
||||
* User clicked on an hyperlink that should be handled by other
|
||||
* applications accordingly.
|
||||
*/
|
||||
LOK_CALLBACK_HYPERLINK_CLICKED = 7,
|
||||
|
||||
/**
|
||||
* 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 = 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.
|
||||
*/
|
||||
LOK_CALLBACK_STATUS_INDICATOR_START = 9,
|
||||
|
||||
/**
|
||||
* 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 = 10,
|
||||
|
||||
/**
|
||||
* Ends the status indicator.
|
||||
*
|
||||
* Not necessarily ever emitted.
|
||||
*/
|
||||
LOK_CALLBACK_STATUS_INDICATOR_FINISH = 11,
|
||||
|
||||
/**
|
||||
* No match was found for the search input
|
||||
*/
|
||||
LOK_CALLBACK_SEARCH_NOT_FOUND = 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 preceeded by a series of
|
||||
* LOK_CALLBACK_INVALIDATE_TILES events invalidating any areas
|
||||
* need re-rendering to adapt.
|
||||
*/
|
||||
LOK_CALLBACK_DOCUMENT_SIZE_CHANGED = 13,
|
||||
|
||||
/**
|
||||
* The current part number is changed.
|
||||
*
|
||||
* Payload is a single 0-based integer.
|
||||
*/
|
||||
LOK_CALLBACK_SET_PART = 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 LOK_CALLBACK_SET_PART / LOK_CALLBACK_TEXT_SELECTION format.
|
||||
*/
|
||||
LOK_CALLBACK_SEARCH_RESULT_SELECTION = 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)
|
||||
* }
|
||||
*/
|
||||
LOK_CALLBACK_UNO_COMMAND_RESULT = 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 LOK_CALLBACK_INVALIDATE_TILES.
|
||||
*/
|
||||
LOK_CALLBACK_CELL_CURSOR = 17,
|
||||
|
||||
/**
|
||||
* The current mouse pointer style.
|
||||
*
|
||||
* Payload is a css mouse pointer style.
|
||||
*/
|
||||
LOK_CALLBACK_MOUSE_POINTER = 18,
|
||||
|
||||
/**
|
||||
* The text content of the formula bar in Calc.
|
||||
*/
|
||||
LOK_CALLBACK_CELL_FORMULA = 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.
|
||||
*/
|
||||
LOK_CALLBACK_DOCUMENT_PASSWORD = 20,
|
||||
|
||||
/**
|
||||
* Editing a document requires a password.
|
||||
*
|
||||
* Loading the document is blocked until the password is provided via
|
||||
* lok::Office::setDocumentPassword().
|
||||
*/
|
||||
LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY = 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
|
||||
* }
|
||||
*/
|
||||
LOK_CALLBACK_ERROR = 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"}
|
||||
*/
|
||||
LOK_CALLBACK_CONTEXT_MENU = 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 LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR
|
||||
*/
|
||||
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR = 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 LOK_CALLBACK_TEXT_SELECTION.
|
||||
*/
|
||||
LOK_CALLBACK_TEXT_VIEW_SELECTION = 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 LOK_CALLBACK_CELL_CURSOR.
|
||||
*/
|
||||
LOK_CALLBACK_CELL_VIEW_CURSOR = 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 LOK_CALLBACK_INVALIDATE_TILES.
|
||||
*/
|
||||
LOK_CALLBACK_GRAPHIC_VIEW_SELECTION = 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 LOK_CALLBACK_CURSOR_VISIBLE.
|
||||
*/
|
||||
LOK_CALLBACK_VIEW_CURSOR_VISIBLE = 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 LOK_CALLBACK_INVALIDATE_TILES.
|
||||
*/
|
||||
LOK_CALLBACK_VIEW_LOCK = 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.
|
||||
*/
|
||||
LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED = 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'.
|
||||
*/
|
||||
LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED = 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.
|
||||
*/
|
||||
LOK_CALLBACK_COMMENT = 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".
|
||||
*/
|
||||
LOK_CALLBACK_INVALIDATE_HEADER = 33,
|
||||
/**
|
||||
* The text content of the address field in Calc. Eg: "A7"
|
||||
*/
|
||||
LOK_CALLBACK_CELL_ADDRESS = 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.
|
||||
*/
|
||||
LOK_CALLBACK_RULER_UPDATE = 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)
|
||||
*
|
||||
* "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
|
||||
*/
|
||||
LOK_CALLBACK_WINDOW = 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.
|
||||
*/
|
||||
LOK_CALLBACK_VALIDITY_LIST_BUTTON = 37,
|
||||
|
||||
/**
|
||||
* Notification that the clipboard contents have changed.
|
||||
* Typically fired in response to copying to clipboard.
|
||||
*
|
||||
* The payload currently is empty and it's up to the
|
||||
* client to get the contents, if necessary. However,
|
||||
* in the future the contents might be included for
|
||||
* convenience.
|
||||
*/
|
||||
LOK_CALLBACK_CLIPBOARD_CHANGED = 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
|
||||
*/
|
||||
LOK_CALLBACK_CONTEXT_CHANGED = 39,
|
||||
|
||||
/**
|
||||
* On-load notification of the document signature status.
|
||||
*/
|
||||
LOK_CALLBACK_SIGNATURE_STATUS = 40,
|
||||
|
||||
/**
|
||||
* Profiling tracing information single string of multiple lines
|
||||
* containing <pid> <timestamp> and zone start/stop information
|
||||
*/
|
||||
LOK_CALLBACK_PROFILE_FRAME = 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 LOK_CALLBACK_INVALIDATE_TILES.
|
||||
*/
|
||||
LOK_CALLBACK_CELL_SELECTION_AREA = 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 LOK_CALLBACK_INVALIDATE_TILES.
|
||||
*/
|
||||
LOK_CALLBACK_CELL_AUTO_FILL_AREA = 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.
|
||||
*/
|
||||
LOK_CALLBACK_TABLE_SELECTED = 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" },
|
||||
* ...
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
LOK_CALLBACK_REFERENCE_MARKS = 45,
|
||||
|
||||
/**
|
||||
* Callback related to native dialogs generated in JavaScript from
|
||||
* the description.
|
||||
*/
|
||||
LOK_CALLBACK_JSDIALOG = 46,
|
||||
|
||||
/**
|
||||
* Send the list of functions whose name starts with the characters entered
|
||||
* by the user in the formula input bar.
|
||||
*/
|
||||
LOK_CALLBACK_CALC_FUNCTION_LIST = 47
|
||||
}
|
||||
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
|
||||
{
|
||||
/// cf. SalEvent::ExtTextInput
|
||||
LOK_EXT_TEXTINPUT,
|
||||
/// cf. SalEvent::ExtTextInputPos
|
||||
LOK_EXT_TEXTINPUT_POS,
|
||||
/// cf. SalEvent::EndExtTextInput
|
||||
LOK_EXT_TEXTINPUT_END
|
||||
}
|
||||
LibreOfficeKitExtTextInputType;
|
||||
|
||||
/// Returns the string representation of a LibreOfficeKitCallbackType enumeration element.
|
||||
static inline const char* lokCallbackTypeToString(int nType)
|
||||
{
|
||||
switch (static_cast<LibreOfficeKitCallbackType>(nType))
|
||||
{
|
||||
case LOK_CALLBACK_INVALIDATE_TILES:
|
||||
return "LOK_CALLBACK_INVALIDATE_TILES";
|
||||
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
|
||||
return "LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR";
|
||||
case LOK_CALLBACK_TEXT_SELECTION:
|
||||
return "LOK_CALLBACK_TEXT_SELECTION";
|
||||
case LOK_CALLBACK_TEXT_SELECTION_START:
|
||||
return "LOK_CALLBACK_TEXT_SELECTION_START";
|
||||
case LOK_CALLBACK_TEXT_SELECTION_END:
|
||||
return "LOK_CALLBACK_TEXT_SELECTION_END";
|
||||
case LOK_CALLBACK_CURSOR_VISIBLE:
|
||||
return "LOK_CALLBACK_CURSOR_VISIBLE";
|
||||
case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
|
||||
return "LOK_CALLBACK_VIEW_CURSOR_VISIBLE";
|
||||
case LOK_CALLBACK_GRAPHIC_SELECTION:
|
||||
return "LOK_CALLBACK_GRAPHIC_SELECTION";
|
||||
case LOK_CALLBACK_GRAPHIC_VIEW_SELECTION:
|
||||
return "LOK_CALLBACK_GRAPHIC_VIEW_SELECTION";
|
||||
case LOK_CALLBACK_CELL_CURSOR:
|
||||
return "LOK_CALLBACK_CELL_CURSOR";
|
||||
case LOK_CALLBACK_HYPERLINK_CLICKED:
|
||||
return "LOK_CALLBACK_HYPERLINK_CLICKED";
|
||||
case LOK_CALLBACK_MOUSE_POINTER:
|
||||
return "LOK_CALLBACK_MOUSE_POINTER";
|
||||
case LOK_CALLBACK_STATE_CHANGED:
|
||||
return "LOK_CALLBACK_STATE_CHANGED";
|
||||
case LOK_CALLBACK_STATUS_INDICATOR_START:
|
||||
return "LOK_CALLBACK_STATUS_INDICATOR_START";
|
||||
case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
|
||||
return "LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE";
|
||||
case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
|
||||
return "LOK_CALLBACK_STATUS_INDICATOR_FINISH";
|
||||
case LOK_CALLBACK_SEARCH_NOT_FOUND:
|
||||
return "LOK_CALLBACK_SEARCH_NOT_FOUND";
|
||||
case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
|
||||
return "LOK_CALLBACK_DOCUMENT_SIZE_CHANGED";
|
||||
case LOK_CALLBACK_SET_PART:
|
||||
return "LOK_CALLBACK_SET_PART";
|
||||
case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
|
||||
return "LOK_CALLBACK_SEARCH_RESULT_SELECTION";
|
||||
case LOK_CALLBACK_DOCUMENT_PASSWORD:
|
||||
return "LOK_CALLBACK_DOCUMENT_PASSWORD";
|
||||
case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
|
||||
return "LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY";
|
||||
case LOK_CALLBACK_CONTEXT_MENU:
|
||||
return "LOK_CALLBACK_CONTEXT_MENU";
|
||||
case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
|
||||
return "LOK_CALLBACK_INVALIDATE_VIEW_CURSOR";
|
||||
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
|
||||
return "LOK_CALLBACK_TEXT_VIEW_SELECTION";
|
||||
case LOK_CALLBACK_CELL_VIEW_CURSOR:
|
||||
return "LOK_CALLBACK_CELL_VIEW_CURSOR";
|
||||
case LOK_CALLBACK_CELL_ADDRESS:
|
||||
return "LOK_CALLBACK_CELL_ADDRESS";
|
||||
case LOK_CALLBACK_CELL_FORMULA:
|
||||
return "LOK_CALLBACK_CELL_FORMULA";
|
||||
case LOK_CALLBACK_UNO_COMMAND_RESULT:
|
||||
return "LOK_CALLBACK_UNO_COMMAND_RESULT";
|
||||
case LOK_CALLBACK_ERROR:
|
||||
return "LOK_CALLBACK_ERROR";
|
||||
case LOK_CALLBACK_VIEW_LOCK:
|
||||
return "LOK_CALLBACK_VIEW_LOCK";
|
||||
case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED:
|
||||
return "LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED";
|
||||
case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED:
|
||||
return "LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED";
|
||||
case LOK_CALLBACK_INVALIDATE_HEADER:
|
||||
return "LOK_CALLBACK_INVALIDATE_HEADER";
|
||||
case LOK_CALLBACK_COMMENT:
|
||||
return "LOK_CALLBACK_COMMENT";
|
||||
case LOK_CALLBACK_RULER_UPDATE:
|
||||
return "LOK_CALLBACK_RULER_UPDATE";
|
||||
case LOK_CALLBACK_WINDOW:
|
||||
return "LOK_CALLBACK_WINDOW";
|
||||
case LOK_CALLBACK_VALIDITY_LIST_BUTTON:
|
||||
return "LOK_CALLBACK_VALIDITY_LIST_BUTTON";
|
||||
case LOK_CALLBACK_CLIPBOARD_CHANGED:
|
||||
return "LOK_CALLBACK_CLIPBOARD_CHANGED";
|
||||
case LOK_CALLBACK_CONTEXT_CHANGED:
|
||||
return "LOK_CALLBACK_CONTEXT_CHANGED";
|
||||
case LOK_CALLBACK_SIGNATURE_STATUS:
|
||||
return "LOK_CALLBACK_SIGNATURE_STATUS";
|
||||
case LOK_CALLBACK_PROFILE_FRAME:
|
||||
return "LOK_CALLBACK_PROFILE_FRAME";
|
||||
case LOK_CALLBACK_CELL_SELECTION_AREA:
|
||||
return "LOK_CALLBACK_CELL_SELECTION_AREA";
|
||||
case LOK_CALLBACK_CELL_AUTO_FILL_AREA:
|
||||
return "LOK_CALLBACK_CELL_AUTO_FILL_AREA";
|
||||
case LOK_CALLBACK_TABLE_SELECTED:
|
||||
return "LOK_CALLBACK_TABLE_SELECTED";
|
||||
case LOK_CALLBACK_REFERENCE_MARKS:
|
||||
return "LOK_CALLBACK_REFERENCE_MARKS";
|
||||
case LOK_CALLBACK_JSDIALOG:
|
||||
return "LOK_CALLBACK_JSDIALOG";
|
||||
case LOK_CALLBACK_CALC_FUNCTION_LIST:
|
||||
return "LOK_CALLBACK_CALC_FUNCTION_LIST";
|
||||
}
|
||||
|
||||
assert(!"Unknown LibreOfficeKitCallbackType type.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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 // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITENUMS_H
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,356 +0,0 @@
|
|||
/* -*- 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/LibreOfficeKit.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
# define LOK_TOLERATE_UNUSED __attribute__((used))
|
||||
#else
|
||||
# define LOK_TOLERATE_UNUSED
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined (__FreeBSD_kernel__) || defined(_AIX) ||\
|
||||
defined(_WIN32) || defined(__APPLE__) || defined (__NetBSD__) ||\
|
||||
defined (__sun) || defined(__OpenBSD__)
|
||||
|
||||
#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 '/'
|
||||
|
||||
#if !defined(IOS)
|
||||
static void *lok_loadlib(const char *pFN)
|
||||
{
|
||||
return dlopen(pFN, RTLD_LAZY
|
||||
#if defined LOK_LOADLIB_GLOBAL
|
||||
| RTLD_GLOBAL
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
static char *lok_dlerror(void)
|
||||
{
|
||||
return dlerror();
|
||||
}
|
||||
|
||||
// This function must be called to release memory allocated by lok_dlerror()
|
||||
static void lok_dlerror_free(char *pErrMessage)
|
||||
{
|
||||
(void)pErrMessage;
|
||||
// Do nothing for return of dlerror()
|
||||
}
|
||||
|
||||
static void extendUnoPath(const char *pPath)
|
||||
{
|
||||
(void)pPath;
|
||||
}
|
||||
|
||||
static void *lok_dlsym(void *Hnd, const char *pName)
|
||||
{
|
||||
return dlsym(Hnd, pName);
|
||||
}
|
||||
|
||||
static int lok_dlclose(void *Hnd)
|
||||
{
|
||||
return dlclose(Hnd);
|
||||
}
|
||||
#endif // IOS
|
||||
|
||||
|
||||
#else
|
||||
#if !defined WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#define TARGET_LIB "sofficeapp" ".dll"
|
||||
#define TARGET_MERGED_LIB "mergedlo" ".dll"
|
||||
#define SEPARATOR '\\'
|
||||
#define UNOPATH "\\..\\URE\\bin"
|
||||
|
||||
static void *lok_loadlib(const char *pFN)
|
||||
{
|
||||
return (void *) LoadLibraryA(pFN);
|
||||
}
|
||||
|
||||
static char *lok_dlerror(void)
|
||||
{
|
||||
LPSTR buf = NULL;
|
||||
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(), 0, reinterpret_cast<LPSTR>(&buf), 0, NULL);
|
||||
return buf;
|
||||
}
|
||||
|
||||
// This function must be called to release memory allocated by lok_dlerror()
|
||||
static void lok_dlerror_free(char *pErrMessage)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, pErrMessage);
|
||||
}
|
||||
|
||||
static void *lok_dlsym(void *Hnd, const char *pName)
|
||||
{
|
||||
return reinterpret_cast<void *>(GetProcAddress((HINSTANCE) Hnd, pName));
|
||||
}
|
||||
|
||||
static int lok_dlclose(void *Hnd)
|
||||
{
|
||||
return FreeLibrary((HINSTANCE) Hnd);
|
||||
}
|
||||
|
||||
static void extendUnoPath(const char *pPath)
|
||||
{
|
||||
char *sNewPath = NULL, *sEnvPath = NULL;
|
||||
size_t size_sEnvPath = 0, buffer_size = 0;
|
||||
DWORD cChars;
|
||||
|
||||
if (!pPath)
|
||||
return;
|
||||
|
||||
cChars = GetEnvironmentVariableA("PATH", sEnvPath, 0);
|
||||
if (cChars > 0)
|
||||
{
|
||||
sEnvPath = (char *) malloc(cChars);
|
||||
cChars = GetEnvironmentVariableA("PATH", sEnvPath, cChars);
|
||||
//If PATH is not set then it is no error
|
||||
if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND)
|
||||
{
|
||||
free(sEnvPath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//prepare the new PATH. Add the Ure/bin directory at the front.
|
||||
//note also adding ';'
|
||||
if(sEnvPath)
|
||||
size_sEnvPath = strlen(sEnvPath);
|
||||
buffer_size = size_sEnvPath + 2*strlen(pPath) + strlen(UNOPATH) + 4;
|
||||
sNewPath = (char *) malloc(buffer_size);
|
||||
sNewPath[0] = L'\0';
|
||||
strcat_s(sNewPath, buffer_size, pPath); // program to PATH
|
||||
strcat_s(sNewPath, buffer_size, ";");
|
||||
strcat_s(sNewPath, buffer_size, UNOPATH); // UNO to PATH
|
||||
if (size_sEnvPath > 0)
|
||||
{
|
||||
strcat_s(sNewPath, buffer_size, ";");
|
||||
strcat_s(sNewPath, buffer_size, sEnvPath);
|
||||
}
|
||||
|
||||
SetEnvironmentVariableA("PATH", sNewPath);
|
||||
|
||||
free(sNewPath);
|
||||
free(sEnvPath);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(IOS)
|
||||
static void *lok_dlopen( const char *install_path, char ** _imp_lib )
|
||||
{
|
||||
char *imp_lib;
|
||||
void *dlhandle;
|
||||
|
||||
size_t partial_length, imp_lib_size;
|
||||
struct stat dir_st;
|
||||
|
||||
*_imp_lib = NULL;
|
||||
|
||||
if (!install_path)
|
||||
return NULL;
|
||||
|
||||
if (stat(install_path, &dir_st) != 0)
|
||||
{
|
||||
fprintf(stderr, "installation path \"%s\" does not exist\n", install_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// allocate large enough buffer
|
||||
partial_length = strlen(install_path);
|
||||
imp_lib_size = partial_length + sizeof(TARGET_LIB) + sizeof(TARGET_MERGED_LIB) + 2;
|
||||
imp_lib = (char *) malloc(imp_lib_size);
|
||||
if (!imp_lib)
|
||||
{
|
||||
fprintf( stderr, "failed to open library : not enough memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(imp_lib, install_path, partial_length);
|
||||
|
||||
extendUnoPath(install_path);
|
||||
|
||||
imp_lib[partial_length++] = SEPARATOR;
|
||||
strncpy(imp_lib + partial_length, TARGET_LIB, imp_lib_size - partial_length);
|
||||
|
||||
dlhandle = lok_loadlib(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)
|
||||
{
|
||||
char *pErrMessage = lok_dlerror();
|
||||
fprintf(stderr, "failed to open library '%s': %s\n",
|
||||
imp_lib, pErrMessage);
|
||||
lok_dlerror_free(pErrMessage);
|
||||
free(imp_lib);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy(imp_lib + partial_length, TARGET_MERGED_LIB, imp_lib_size - partial_length);
|
||||
|
||||
dlhandle = lok_loadlib(imp_lib);
|
||||
if (!dlhandle)
|
||||
{
|
||||
char *pErrMessage = lok_dlerror();
|
||||
fprintf(stderr, "failed to open library '%s': %s\n",
|
||||
imp_lib, pErrMessage);
|
||||
lok_dlerror_free(pErrMessage);
|
||||
free(imp_lib);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
*_imp_lib = imp_lib;
|
||||
return dlhandle;
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef LibreOfficeKit *(LokHookFunction)( const char *install_path);
|
||||
|
||||
typedef LibreOfficeKit *(LokHookFunction2)( const char *install_path, const char *user_profile_url );
|
||||
|
||||
typedef int (LokHookPreInit) ( const char *install_path, const char *user_profile_url );
|
||||
|
||||
#if defined(IOS) || defined(ANDROID)
|
||||
LibreOfficeKit *libreofficekit_hook_2(const char* install_path, const char* user_profile_path);
|
||||
#endif
|
||||
|
||||
static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_profile_url )
|
||||
{
|
||||
#if !defined(IOS) && !defined(ANDROID)
|
||||
void *dlhandle;
|
||||
char *imp_lib;
|
||||
LokHookFunction *pSym;
|
||||
LokHookFunction2 *pSym2;
|
||||
|
||||
dlhandle = lok_dlopen(install_path, &imp_lib);
|
||||
if (!dlhandle)
|
||||
return NULL;
|
||||
|
||||
pSym2 = (LokHookFunction2 *) lok_dlsym(dlhandle, "libreofficekit_hook_2");
|
||||
if (!pSym2)
|
||||
{
|
||||
if (user_profile_url != NULL)
|
||||
{
|
||||
fprintf( stderr, "the LibreOffice version in '%s' does not support passing a user profile to the hook function\n",
|
||||
imp_lib );
|
||||
lok_dlclose( dlhandle );
|
||||
free( imp_lib );
|
||||
return NULL;
|
||||
}
|
||||
pSym = (LokHookFunction *) lok_dlsym( dlhandle, "libreofficekit_hook" );
|
||||
if (!pSym)
|
||||
{
|
||||
fprintf( stderr, "failed to find hook in library '%s'\n", imp_lib );
|
||||
lok_dlclose( dlhandle );
|
||||
free( imp_lib );
|
||||
return NULL;
|
||||
}
|
||||
free( imp_lib );
|
||||
// dlhandle is "leaked"
|
||||
// coverity[leaked_storage] - on purpose
|
||||
return pSym( install_path );
|
||||
}
|
||||
|
||||
if (user_profile_url != NULL && user_profile_url[0] == '/')
|
||||
{
|
||||
// It should be either a file: URL or a vnd.sun.star.pathname: URL.
|
||||
fprintf( stderr, "second parameter to lok_init_2 '%s' should be a URL, not a pathname\n", user_profile_url );
|
||||
lok_dlclose( dlhandle );
|
||||
free( imp_lib );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
free( imp_lib );
|
||||
// dlhandle is "leaked"
|
||||
// coverity[leaked_storage] - on purpose
|
||||
return pSym2( install_path, user_profile_url );
|
||||
#else
|
||||
return libreofficekit_hook_2( install_path, user_profile_url );
|
||||
#endif
|
||||
}
|
||||
|
||||
static LOK_TOLERATE_UNUSED
|
||||
LibreOfficeKit *lok_init( const char *install_path )
|
||||
{
|
||||
return lok_init_2( install_path, NULL );
|
||||
}
|
||||
|
||||
#if !defined(IOS)
|
||||
static LOK_TOLERATE_UNUSED
|
||||
int lok_preinit( const char *install_path, const char *user_profile_url )
|
||||
{
|
||||
void *dlhandle;
|
||||
char *imp_lib;
|
||||
LokHookPreInit *pSym;
|
||||
|
||||
dlhandle = lok_dlopen(install_path, &imp_lib);
|
||||
if (!dlhandle)
|
||||
return -1;
|
||||
|
||||
pSym = (LokHookPreInit *) lok_dlsym(dlhandle, "lok_preinit");
|
||||
if (!pSym)
|
||||
{
|
||||
fprintf( stderr, "failed to find pre-init hook in library '%s'\n", imp_lib );
|
||||
lok_dlclose( dlhandle );
|
||||
free( imp_lib );
|
||||
return -1;
|
||||
}
|
||||
|
||||
free( imp_lib );
|
||||
|
||||
// dlhandle is "leaked"
|
||||
// coverity[leaked_storage] - on purpose
|
||||
return pSym( install_path, user_profile_url );
|
||||
}
|
||||
#endif
|
||||
|
||||
#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: */
|
|
@ -1,37 +0,0 @@
|
|||
/* -*- 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
|
||||
|
||||
/** @see lok::Office::registerCallback().
|
||||
@since LibreOffice 6.0
|
||||
*/
|
||||
typedef void (*LibreOfficeKitCallback)(int nType, const char* pPayload, void* pData);
|
||||
|
||||
/** @see lok::Office::runLoop().
|
||||
@since LibreOffice 6.3
|
||||
*/
|
||||
typedef int (*LibreOfficeKitPollCallback)(void* pData, int timeoutUs);
|
||||
typedef void (*LibreOfficeKitWakeCallback)(void* pData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_TYPES_H
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Loading…
Reference in New Issue