1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 */ 9 10 #ifndef INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H 11 #define INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H 12 13 #include <stddef.h> 14 15 // the unstable API needs C99's bool 16 // TODO remove the C99 types from the API before making stable 17 #if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY 18 # ifndef _WIN32 19 # include <stdbool.h> 20 # endif 21 # include <stdint.h> 22 #endif 23 24 #include <LibreOfficeKit/LibreOfficeKitTypes.h> 25 26 #ifdef __cplusplus 27 extern "C" 28 { 29 #endif 30 31 typedef struct _LibreOfficeKit LibreOfficeKit; 32 typedef struct _LibreOfficeKitClass LibreOfficeKitClass; 33 34 typedef struct _LibreOfficeKitDocument LibreOfficeKitDocument; 35 typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass; 36 37 // Do we have an extended member in this struct ? 38 #define LIBREOFFICEKIT_HAS_MEMBER(strct,member,nSize) \ 39 (offsetof(strct, member) < (nSize)) 40 41 #define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitClass,member,(pKit)->pClass->nSize) 42 43 struct _LibreOfficeKit 44 { 45 LibreOfficeKitClass* pClass; 46 }; 47 48 struct _LibreOfficeKitClass 49 { 50 size_t nSize; 51 52 void (*destroy) (LibreOfficeKit* pThis); 53 54 LibreOfficeKitDocument* (*documentLoad) (LibreOfficeKit* pThis, 55 const char* pURL); 56 57 char* (*getError) (LibreOfficeKit* pThis); 58 59 /// @since LibreOffice 5.0 60 LibreOfficeKitDocument* (*documentLoadWithOptions) (LibreOfficeKit* pThis, 61 const char* pURL, 62 const char* pOptions); 63 /// @since LibreOffice 5.2 64 void (*freeError) (char* pFree); 65 66 /// @since LibreOffice 6.0 67 void (*registerCallback) (LibreOfficeKit* pThis, 68 LibreOfficeKitCallback pCallback, 69 void* pData); 70 71 /** @see lok::Office::getFilterTypes(). 72 @since LibreOffice 6.0 73 */ 74 char* (*getFilterTypes) (LibreOfficeKit* pThis); 75 76 /** @see lok::Office::setOptionalFeatures(). 77 @since LibreOffice 6.0 78 */ 79 void (*setOptionalFeatures)(LibreOfficeKit* pThis, unsigned long long features); 80 81 /** @see lok::Office::setDocumentPassword(). 82 @since LibreOffice 6.0 83 */ 84 void (*setDocumentPassword) (LibreOfficeKit* pThis, 85 char const* pURL, 86 char const* pPassword); 87 88 /** @see lok::Office::getVersionInfo(). 89 @since LibreOffice 6.0 90 */ 91 char* (*getVersionInfo) (LibreOfficeKit* pThis); 92 93 /** @see lok::Office::runMacro(). 94 @since LibreOffice 6.0 95 */ 96 int (*runMacro) (LibreOfficeKit *pThis, const char* pURL); 97 98 /** @see lok::Office::signDocument(). 99 @since LibreOffice 6.2 100 */ 101 bool (*signDocument) (LibreOfficeKit* pThis, 102 const char* pUrl, 103 const unsigned char* pCertificateBinary, 104 const int nCertificateBinarySize, 105 const unsigned char* pPrivateKeyBinary, 106 const int nPrivateKeyBinarySize); 107 108 /// @see lok::Office::runLoop() 109 void (*runLoop) (LibreOfficeKit* pThis, 110 LibreOfficeKitPollCallback pPollCallback, 111 LibreOfficeKitWakeCallback pWakeCallback, 112 void* pData); 113 }; 114 115 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize) 116 117 struct _LibreOfficeKitDocument 118 { 119 LibreOfficeKitDocumentClass* pClass; 120 }; 121 122 struct _LibreOfficeKitDocumentClass 123 { 124 size_t nSize; 125 126 void (*destroy) (LibreOfficeKitDocument* pThis); 127 128 int (*saveAs) (LibreOfficeKitDocument* pThis, 129 const char* pUrl, 130 const char* pFormat, 131 const char* pFilterOptions); 132 133 /** @see lok::Document::getDocumentType(). 134 @since LibreOffice 6.0 135 */ 136 int (*getDocumentType) (LibreOfficeKitDocument* pThis); 137 138 #if defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY 139 /// @see lok::Document::getParts(). 140 int (*getParts) (LibreOfficeKitDocument* pThis); 141 142 /// @see lok::Document::getPartPageRectangles(). 143 char* (*getPartPageRectangles) (LibreOfficeKitDocument* pThis); 144 145 /// @see lok::Document::getPart(). 146 int (*getPart) (LibreOfficeKitDocument* pThis); 147 148 /// @see lok::Document::setPart(). 149 void (*setPart) (LibreOfficeKitDocument* pThis, 150 int nPart); 151 152 /// @see lok::Document::getPartName(). 153 char* (*getPartName) (LibreOfficeKitDocument* pThis, 154 int nPart); 155 156 /// @see lok::Document::setPartMode(). 157 void (*setPartMode) (LibreOfficeKitDocument* pThis, 158 int nMode); 159 160 /// @see lok::Document::paintTile(). 161 void (*paintTile) (LibreOfficeKitDocument* pThis, 162 unsigned char* pBuffer, 163 const int nCanvasWidth, 164 const int nCanvasHeight, 165 const int nTilePosX, 166 const int nTilePosY, 167 const int nTileWidth, 168 const int nTileHeight); 169 170 /// @see lok::Document::getTileMode(). 171 int (*getTileMode) (LibreOfficeKitDocument* pThis); 172 173 /// @see lok::Document::getDocumentSize(). 174 void (*getDocumentSize) (LibreOfficeKitDocument* pThis, 175 long* pWidth, 176 long* pHeight); 177 178 /// @see lok::Document::initializeForRendering(). 179 void (*initializeForRendering) (LibreOfficeKitDocument* pThis, 180 const char* pArguments); 181 182 /// @see lok::Document::registerCallback(). 183 void (*registerCallback) (LibreOfficeKitDocument* pThis, 184 LibreOfficeKitCallback pCallback, 185 void* pData); 186 187 /// @see lok::Document::postKeyEvent 188 void (*postKeyEvent) (LibreOfficeKitDocument* pThis, 189 int nType, 190 int nCharCode, 191 int nKeyCode); 192 193 /// @see lok::Document::postMouseEvent 194 void (*postMouseEvent) (LibreOfficeKitDocument* pThis, 195 int nType, 196 int nX, 197 int nY, 198 int nCount, 199 int nButtons, 200 int nModifier); 201 202 /// @see lok::Document::postUnoCommand 203 void (*postUnoCommand) (LibreOfficeKitDocument* pThis, 204 const char* pCommand, 205 const char* pArguments, 206 bool bNotifyWhenFinished); 207 208 /// @see lok::Document::setTextSelection 209 void (*setTextSelection) (LibreOfficeKitDocument* pThis, 210 int nType, 211 int nX, 212 int nY); 213 214 /// @see lok::Document::getTextSelection 215 char* (*getTextSelection) (LibreOfficeKitDocument* pThis, 216 const char* pMimeType, 217 char** pUsedMimeType); 218 219 /// @see lok::Document::paste(). 220 bool (*paste) (LibreOfficeKitDocument* pThis, 221 const char* pMimeType, 222 const char* pData, 223 size_t nSize); 224 225 /// @see lok::Document::setGraphicSelection 226 void (*setGraphicSelection) (LibreOfficeKitDocument* pThis, 227 int nType, 228 int nX, 229 int nY); 230 231 /// @see lok::Document::resetSelection 232 void (*resetSelection) (LibreOfficeKitDocument* pThis); 233 234 /// @see lok::Document::getCommandValues(). 235 char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand); 236 237 /// @see lok::Document::setClientZoom(). 238 void (*setClientZoom) (LibreOfficeKitDocument* pThis, 239 int nTilePixelWidth, 240 int nTilePixelHeight, 241 int nTileTwipWidth, 242 int nTileTwipHeight); 243 244 /// @see lok::Document::setVisibleArea). 245 void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); 246 247 /// @see lok::Document::createView(). 248 int (*createView) (LibreOfficeKitDocument* pThis); 249 /// @see lok::Document::destroyView(). 250 void (*destroyView) (LibreOfficeKitDocument* pThis, int nId); 251 /// @see lok::Document::setView(). 252 void (*setView) (LibreOfficeKitDocument* pThis, int nId); 253 /// @see lok::Document::getView(). 254 int (*getView) (LibreOfficeKitDocument* pThis); 255 /// @see lok::Document::getViewsCount(). 256 int (*getViewsCount) (LibreOfficeKitDocument* pThis); 257 258 /// @see lok::Document::renderFont(). 259 unsigned char* (*renderFont) (LibreOfficeKitDocument* pThis, 260 const char* pFontName, 261 const char* pChar, 262 int* pFontWidth, 263 int* pFontHeight); 264 265 /// @see lok::Document::getPartHash(). 266 char* (*getPartHash) (LibreOfficeKitDocument* pThis, 267 int nPart); 268 269 /// Paints a tile from a specific part. 270 /// @see lok::Document::paintTile(). 271 void (*paintPartTile) (LibreOfficeKitDocument* pThis, 272 unsigned char* pBuffer, 273 const int nPart, 274 const int nCanvasWidth, 275 const int nCanvasHeight, 276 const int nTilePosX, 277 const int nTilePosY, 278 const int nTileWidth, 279 const int nTileHeight); 280 281 /// @see lok::Document::getViewIds(). 282 bool (*getViewIds) (LibreOfficeKitDocument* pThis, 283 int* pArray, 284 size_t nSize); 285 286 /// @see lok::Document::setOutlineState). 287 void (*setOutlineState) (LibreOfficeKitDocument* pThis, bool bColumn, int nLevel, int nIndex, bool bHidden); 288 289 /// Paints window with given id to the buffer 290 /// @see lok::Document::paintWindow(). 291 void (*paintWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, 292 unsigned char* pBuffer, 293 const int x, const int y, 294 const int width, const int height); 295 296 /// @see lok::Document::postWindow(). 297 void (*postWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, int nAction, const char* pData); 298 299 /// @see lok::Document::postWindowKeyEvent(). 300 void (*postWindowKeyEvent) (LibreOfficeKitDocument* pThis, 301 unsigned nWindowId, 302 int nType, 303 int nCharCode, 304 int nKeyCode); 305 306 /// @see lok::Document::postWindowMouseEvent(). 307 void (*postWindowMouseEvent) (LibreOfficeKitDocument* pThis, 308 unsigned nWindowId, 309 int nType, 310 int nX, 311 int nY, 312 int nCount, 313 int nButtons, 314 int nModifier); 315 316 /// @see lok::Document::setViewLanguage(). 317 void (*setViewLanguage) (LibreOfficeKitDocument* pThis, int nId, const char* language); 318 319 /// @see lok::Document::postWindowExtTextInputEvent 320 void (*postWindowExtTextInputEvent) (LibreOfficeKitDocument* pThis, 321 unsigned nWindowId, 322 int nType, 323 const char* pText); 324 325 /// @see lok::Document::getPartInfo(). 326 char* (*getPartInfo) (LibreOfficeKitDocument* pThis, int nPart); 327 328 /// Paints window with given id to the buffer with the give DPI scale 329 /// (every pixel is dpiscale-times larger). 330 /// @see lok::Document::paintWindow(). 331 void (*paintWindowDPI) (LibreOfficeKitDocument* pThis, unsigned nWindowId, 332 unsigned char* pBuffer, 333 const int x, const int y, 334 const int width, const int height, 335 const double dpiscale); 336 337 #ifdef IOS 338 /// @see lok::Document::paintTileToCGContext(). 339 void (*paintTileToCGContext) (LibreOfficeKitDocument* pThis, 340 void* rCGContext, 341 const int nCanvasWidth, 342 const int nCanvasHeight, 343 const int nTilePosX, 344 const int nTilePosY, 345 const int nTileWidth, 346 const int nTileHeight); 347 #endif // IOS 348 349 // CERTIFICATE AND SIGNING 350 351 /// @see lok::Document::insertCertificate(). 352 bool (*insertCertificate) (LibreOfficeKitDocument* pThis, 353 const unsigned char* pCertificateBinary, 354 const int nCertificateBinarySize, 355 const unsigned char* pPrivateKeyBinary, 356 const int nPrivateKeyBinarySize); 357 358 /// @see lok::Document::addCertificate(). 359 bool (*addCertificate) (LibreOfficeKitDocument* pThis, 360 const unsigned char* pCertificateBinary, 361 const int nCertificateBinarySize); 362 363 /// @see lok::Document::getSignatureState(). 364 int (*getSignatureState) (LibreOfficeKitDocument* pThis); 365 // END CERTIFICATE AND SIGNING 366 367 /// @see lok::Document::renderShapeSelection 368 size_t (*renderShapeSelection)(LibreOfficeKitDocument* pThis, char** pOutput); 369 370 /// @see lok::Document::postWindowGestureEvent(). 371 void (*postWindowGestureEvent) (LibreOfficeKitDocument* pThis, 372 unsigned nWindowId, 373 const char* pType, 374 int nX, 375 int nY, 376 int nOffset); 377 378 /// @see lok::Document::createViewWithOptions(). 379 int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions); 380 381 /// @see lok::Document::selectPart(). 382 void (*selectPart) (LibreOfficeKitDocument* pThis, int nPart, int nSelect); 383 384 /// @see lok::Document::moveSelectedParts(). 385 void (*moveSelectedParts) (LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate); 386 387 /// Resize window with given id. 388 /// @see lok::Document::resizeWindow(). 389 void (*resizeWindow) (LibreOfficeKitDocument* pThis, unsigned nWindowId, 390 const int width, const int height); 391 392 /// Pass a nullptr terminated array of mime-type strings 393 /// @see lok::Document::getClipboard for more details 394 int (*getClipboard) (LibreOfficeKitDocument* pThis, 395 const char **pMimeTypes, 396 size_t *pOutCount, 397 char ***pOutMimeTypes, 398 size_t **pOutSizes, 399 char ***pOutStreams); 400 401 /// @see lok::Document::setClipboard 402 int (*setClipboard) (LibreOfficeKitDocument* pThis, 403 const size_t nInCount, 404 const char **pInMimeTypes, 405 const size_t *pInSizes, 406 const char **pInStreams); 407 408 /// @see lok::Document::getSelectionType 409 int (*getSelectionType) (LibreOfficeKitDocument* pThis); 410 411 /// @see lok::Document::removeTextContext 412 void (*removeTextContext) (LibreOfficeKitDocument* pThis, 413 unsigned nWindowId, 414 int nBefore, 415 int nAfter); 416 417 /// @see lok::Document::sendDialogEvent 418 void (*sendDialogEvent) (LibreOfficeKitDocument* pThis, 419 unsigned nLOKWindowId, 420 const char* pArguments); 421 422 /// @see lok::Document::renderFontOrientation(). 423 unsigned char* (*renderFontOrientation) (LibreOfficeKitDocument* pThis, 424 const char* pFontName, 425 const char* pChar, 426 int* pFontWidth, 427 int* pFontHeight, 428 int pOrientation); 429 430 /// Switches view to viewId if viewId >= 0, and paints window 431 /// @see lok::Document::paintWindowDPI(). 432 void (*paintWindowForView) (LibreOfficeKitDocument* pThis, unsigned nWindowId, 433 unsigned char* pBuffer, 434 const int x, const int y, 435 const int width, const int height, 436 const double dpiscale, 437 int viewId); 438 439 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY 440 }; 441 442 #ifdef __cplusplus 443 } 444 #endif 445 446 #endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKIT_H 447 448 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 449