Upgrade LibreOfficeKit C++ API.
Change-Id: If263b8fc748f67a1ed423c0f3f7cd465cf533993
This commit is contained in:
committed by
Michael Meeks
parent
cd76b9996c
commit
a533f986f9
@@ -18,18 +18,20 @@
|
||||
* b) allow ABI stability - C++ vtables are not good for that.
|
||||
* c) avoid C++ types as part of the API.
|
||||
*/
|
||||
namespace lok
|
||||
{
|
||||
|
||||
class LODocument
|
||||
class Document
|
||||
{
|
||||
private:
|
||||
LibreOfficeKitDocument* mpDoc;
|
||||
|
||||
public:
|
||||
inline LODocument(LibreOfficeKitDocument* pDoc) :
|
||||
inline Document(LibreOfficeKitDocument* pDoc) :
|
||||
mpDoc(pDoc)
|
||||
{}
|
||||
|
||||
inline ~LODocument()
|
||||
inline ~Document()
|
||||
{
|
||||
mpDoc->destroy(mpDoc);
|
||||
}
|
||||
@@ -50,17 +52,17 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LibLibreOffice
|
||||
class Office
|
||||
{
|
||||
private:
|
||||
LibreOfficeKit* mpThis;
|
||||
|
||||
public:
|
||||
inline LibLibreOffice(LibreOfficeKit* pThis) :
|
||||
inline Office(LibreOfficeKit* pThis) :
|
||||
mpThis(pThis)
|
||||
{}
|
||||
|
||||
inline ~LibLibreOffice()
|
||||
inline ~Office()
|
||||
{
|
||||
mpThis->destroy(mpThis);
|
||||
}
|
||||
@@ -70,12 +72,12 @@ public:
|
||||
return mpThis->initialize(mpThis, pInstallPath);
|
||||
}
|
||||
|
||||
inline LODocument* documentLoad(const char* pUrl)
|
||||
inline Document* documentLoad(const char* pUrl)
|
||||
{
|
||||
LibreOfficeKitDocument* pDoc = mpThis->documentLoad(mpThis, pUrl);
|
||||
if (pDoc == NULL)
|
||||
return NULL;
|
||||
return new LODocument(pDoc);
|
||||
return new Document(pDoc);
|
||||
}
|
||||
|
||||
// return the last error as a string, free me.
|
||||
@@ -85,12 +87,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline LibLibreOffice* lo_cpp_init(const char* pInstallPath)
|
||||
}
|
||||
|
||||
inline ::lok::Office* lo_cpp_init(const char* pInstallPath)
|
||||
{
|
||||
LibreOfficeKit* pThis = lok_init(pInstallPath);
|
||||
if (pThis == NULL || pThis->nSize == 0)
|
||||
return NULL;
|
||||
return new LibLibreOffice(pThis);
|
||||
return new ::lok::Office(pThis);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include <sys/time.h>
|
||||
#include <LibreOfficeKit/LibreOfficeKit.hxx>
|
||||
|
||||
using namespace ::lok;
|
||||
|
||||
long getTimeMS()
|
||||
{
|
||||
struct timeval t;
|
||||
@@ -44,7 +46,7 @@ int main (int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
LibLibreOffice *pOffice = lo_cpp_init( argv[1] );
|
||||
Office *pOffice = lo_cpp_init( argv[1] );
|
||||
if( !pOffice )
|
||||
{
|
||||
fprintf( stderr, "Failed to initialize\n" );
|
||||
@@ -63,7 +65,7 @@ int main (int argc, char **argv)
|
||||
start = end;
|
||||
|
||||
fprintf( stderr, "start to load document '%s'\n", argv[2] );
|
||||
LODocument *pDocument = pOffice->documentLoad( argv[2] );
|
||||
Document *pDocument = pOffice->documentLoad( argv[2] );
|
||||
if( !pDocument )
|
||||
{
|
||||
char *pError = pOffice->getError();
|
||||
|
Reference in New Issue
Block a user