2013-03-05 16:19:58 +00:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
2014-06-09 11:33:25 +01:00
|
|
|
#ifndef INCLUDED_DESKTOP_INC_LIBREOFFICEKIT_HXX
|
|
|
|
#define INCLUDED_DESKTOP_INC_LIBREOFFICEKIT_HXX
|
2013-03-05 16:19:58 +00:00
|
|
|
|
2014-06-09 11:33:25 +01:00
|
|
|
#include "LibreOfficeKit.h"
|
2013-11-15 12:09:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-06-10 11:42:13 +01:00
|
|
|
namespace lok
|
|
|
|
{
|
2013-11-15 12:09:10 +00:00
|
|
|
|
2014-06-10 11:42:13 +01:00
|
|
|
class Document
|
2013-07-26 18:21:45 +01:00
|
|
|
{
|
2014-04-06 12:05:13 +02:00
|
|
|
private:
|
2014-06-10 11:31:51 +01:00
|
|
|
LibreOfficeKitDocument* mpDoc;
|
2014-04-06 12:05:13 +02:00
|
|
|
|
2013-07-26 18:21:45 +01:00
|
|
|
public:
|
2014-06-10 11:42:13 +01:00
|
|
|
inline Document(LibreOfficeKitDocument* pDoc) :
|
2014-04-06 12:05:13 +02:00
|
|
|
mpDoc(pDoc)
|
|
|
|
{}
|
|
|
|
|
2014-06-10 11:42:13 +01:00
|
|
|
inline ~Document()
|
2014-04-06 12:05:13 +02:00
|
|
|
{
|
2014-06-17 15:13:33 +01:00
|
|
|
mpDoc->pClass->destroy(mpDoc);
|
2014-04-06 12:05:13 +02:00
|
|
|
}
|
2013-07-26 18:21:45 +01:00
|
|
|
|
2014-06-17 19:33:34 +01:00
|
|
|
inline bool saveAs(const char* pUrl, const char* pFormat = NULL, const char* pFilterOptions = NULL)
|
2013-11-15 12:09:10 +00:00
|
|
|
{
|
2014-06-17 19:33:34 +01:00
|
|
|
return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat, pFilterOptions);
|
2013-11-15 12:09:10 +00:00
|
|
|
}
|
2014-05-09 14:37:27 +01:00
|
|
|
|
2014-06-12 13:28:26 +01:00
|
|
|
inline LibreOfficeKitDocument *get() { return mpDoc; }
|
2014-05-09 14:37:27 +01:00
|
|
|
|
|
|
|
#ifdef LOK_USE_UNSTABLE_API
|
|
|
|
inline LibreOfficeKitDocumentType getDocumentType()
|
|
|
|
{
|
|
|
|
return mpDoc->pClass->getDocumentType(mpDoc);
|
|
|
|
}
|
|
|
|
|
2014-07-08 15:23:06 +02:00
|
|
|
inline int getParts()
|
2014-05-09 14:37:27 +01:00
|
|
|
{
|
2014-07-08 15:23:06 +02:00
|
|
|
return mpDoc->pClass->getParts(mpDoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int getPart()
|
|
|
|
{
|
|
|
|
return mpDoc->pClass->getPart(mpDoc);
|
2014-05-09 14:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void setPart(int nPart)
|
|
|
|
{
|
|
|
|
mpDoc->pClass->setPart(mpDoc, nPart);
|
|
|
|
}
|
|
|
|
|
2014-07-29 08:50:34 +02:00
|
|
|
inline char* getPartName(int nPart)
|
|
|
|
{
|
|
|
|
return mpDoc->pClass->getPartName(mpDoc, nPart);
|
|
|
|
}
|
|
|
|
|
2014-06-11 16:24:33 +01:00
|
|
|
inline void paintTile(
|
|
|
|
unsigned char* pBuffer,
|
|
|
|
const int nCanvasWidth,
|
2014-05-09 14:37:27 +01:00
|
|
|
const int nCanvasHeight,
|
2014-05-18 08:30:15 +01:00
|
|
|
int* pRowStride,
|
2014-05-09 14:37:27 +01:00
|
|
|
const int nTilePosX,
|
|
|
|
const int nTilePosY,
|
|
|
|
const int nTileWidth,
|
|
|
|
const int nTileHeight)
|
|
|
|
{
|
2014-06-11 16:24:33 +01:00
|
|
|
return mpDoc->pClass->paintTile(mpDoc, pBuffer, nCanvasWidth, nCanvasHeight, pRowStride,
|
2014-05-16 09:07:52 +01:00
|
|
|
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
2014-05-09 14:37:27 +01:00
|
|
|
}
|
2014-05-18 08:36:16 +01:00
|
|
|
|
|
|
|
inline void getDocumentSize(long* pWidth, long* pHeight)
|
|
|
|
{
|
2014-07-08 15:23:06 +02:00
|
|
|
mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
|
2014-05-18 08:36:16 +01:00
|
|
|
}
|
2014-05-09 14:37:27 +01:00
|
|
|
#endif // LOK_USE_UNSTABLE_API
|
2013-07-26 18:21:45 +01:00
|
|
|
};
|
2013-03-05 16:19:58 +00:00
|
|
|
|
2014-06-10 11:42:13 +01:00
|
|
|
class Office
|
2013-03-05 16:19:58 +00:00
|
|
|
{
|
2014-04-06 12:05:13 +02:00
|
|
|
private:
|
2014-06-10 11:31:51 +01:00
|
|
|
LibreOfficeKit* mpThis;
|
2014-04-06 12:05:13 +02:00
|
|
|
|
2013-03-05 16:19:58 +00:00
|
|
|
public:
|
2014-06-10 11:42:13 +01:00
|
|
|
inline Office(LibreOfficeKit* pThis) :
|
2014-04-06 12:05:13 +02:00
|
|
|
mpThis(pThis)
|
|
|
|
{}
|
2013-07-26 18:21:45 +01:00
|
|
|
|
2014-06-10 11:42:13 +01:00
|
|
|
inline ~Office()
|
2013-11-15 12:09:10 +00:00
|
|
|
{
|
2014-06-17 15:13:33 +01:00
|
|
|
mpThis->pClass->destroy(mpThis);
|
2013-11-15 12:09:10 +00:00
|
|
|
}
|
2013-03-05 16:19:58 +00:00
|
|
|
|
2014-06-10 11:42:13 +01:00
|
|
|
inline Document* documentLoad(const char* pUrl)
|
2014-04-06 12:05:13 +02:00
|
|
|
{
|
2014-06-17 15:13:33 +01:00
|
|
|
LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
|
2014-04-06 12:05:13 +02:00
|
|
|
if (pDoc == NULL)
|
2013-11-15 12:09:10 +00:00
|
|
|
return NULL;
|
2014-06-10 11:42:13 +01:00
|
|
|
return new Document(pDoc);
|
2013-11-15 12:09:10 +00:00
|
|
|
}
|
2013-03-05 16:19:58 +00:00
|
|
|
|
2013-07-26 18:21:45 +01:00
|
|
|
// return the last error as a string, free me.
|
2014-04-06 12:05:13 +02:00
|
|
|
inline char* getError()
|
|
|
|
{
|
2014-06-17 15:13:33 +01:00
|
|
|
return mpThis->pClass->getError(mpThis);
|
2014-04-06 12:05:13 +02:00
|
|
|
}
|
2013-03-05 16:19:58 +00:00
|
|
|
};
|
|
|
|
|
2014-06-11 15:37:17 +01:00
|
|
|
inline Office* lok_cpp_init(const char* pInstallPath)
|
2013-11-15 12:09:10 +00:00
|
|
|
{
|
2014-06-10 11:31:51 +01:00
|
|
|
LibreOfficeKit* pThis = lok_init(pInstallPath);
|
2014-06-17 15:13:33 +01:00
|
|
|
if (pThis == NULL || pThis->pClass->nSize == 0)
|
2013-11-15 12:09:10 +00:00
|
|
|
return NULL;
|
2014-06-10 11:42:13 +01:00
|
|
|
return new ::lok::Office(pThis);
|
2013-11-15 12:09:10 +00:00
|
|
|
}
|
2013-03-05 16:19:58 +00:00
|
|
|
|
2014-06-11 15:37:17 +01:00
|
|
|
}
|
2013-03-05 16:19:58 +00:00
|
|
|
#endif
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|