Kaydet (Commit) e50699e6 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

liblo: clean-up liblibreoffice.h(xx)

Change-Id: I596fc3afde94e095ecf97c23617158f3d49afcc1
üst 4aec6c9e
...@@ -11,32 +11,34 @@ ...@@ -11,32 +11,34 @@
#define INCLUDED_DESKTOP_INC_LIBLIBREOFFICE_H #define INCLUDED_DESKTOP_INC_LIBLIBREOFFICE_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C"
{
#endif #endif
typedef struct _LibreOffice LibreOffice; typedef struct _LibreOffice LibreOffice;
typedef struct _LibreOfficeDocument LibreOfficeDocument; typedef struct _LibreOfficeDocument LibreOfficeDocument;
struct _LibreOffice { struct _LibreOffice
{
int nSize; int nSize;
void (*destroy) (LibreOffice *pThis); void (*destroy) (LibreOffice *pThis);
int (*initialize) (LibreOffice *pThis, int (*initialize) (LibreOffice *pThis, const char *pInstallPath);
const char *pInstallPath); LibreOfficeDocument* (*documentLoad) (LibreOffice *pThis, const char *pURL);
LibreOfficeDocument *(*documentLoad) (LibreOffice *pThis, char* (*getError) (LibreOffice *pThis);
const char *pURL);
char * (*getError) (LibreOffice *pThis);
}; };
struct _LibreOfficeDocument { struct _LibreOfficeDocument
{
int nSize; int nSize;
void (*destroy) (LibreOfficeDocument *pThis); void (*destroy) (LibreOfficeDocument* pThis);
int (*saveAs) (LibreOfficeDocument *pThis, int (*saveAs) (LibreOfficeDocument* pThis,
const char *pUrl, const char *pFormat); const char *pUrl,
const char *pFormat);
}; };
LibreOffice *lo_init (const char *install_path); LibreOffice* lo_init (const char* pInstallPath);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -21,48 +21,67 @@ ...@@ -21,48 +21,67 @@
class LODocument class LODocument
{ {
LibreOfficeDocument *mpDoc; private:
LibreOfficeDocument* mpDoc;
public: public:
inline LODocument( LibreOfficeDocument *pDoc ) : mpDoc( pDoc ) {} inline LODocument(LibreOfficeDocument* pDoc) :
inline ~LODocument() { mpDoc->destroy( mpDoc ); } mpDoc(pDoc)
{}
inline ~LODocument()
{
mpDoc->destroy(mpDoc);
}
// Save as the given format, if format is NULL sniff from ext'n // Save as the given format, if format is NULL sniff from ext'n
inline bool saveAs( const char *url, const char *format = NULL ) inline bool saveAs(const char* pUrl, const char* pFormat = NULL)
{ {
return mpDoc->saveAs( mpDoc, url, format ); return mpDoc->saveAs(mpDoc, pUrl, pFormat);
} }
}; };
class LibLibreOffice class LibLibreOffice
{ {
LibreOffice *mpThis; private:
LibreOffice* mpThis;
public: public:
inline LibLibreOffice( LibreOffice *pThis ) : mpThis( pThis ) {} inline LibLibreOffice(LibreOffice* pThis) :
inline ~LibLibreOffice() { mpThis->destroy( mpThis ); }; mpThis(pThis)
{}
inline bool initialize( const char *installPath ) inline ~LibLibreOffice()
{ {
return mpThis->initialize( mpThis, installPath ); mpThis->destroy(mpThis);
} }
inline LODocument *documentLoad( const char *url ) inline bool initialize(const char* pInstallPath)
{ {
LibreOfficeDocument *pDoc = mpThis->documentLoad( mpThis, url ); return mpThis->initialize(mpThis, pInstallPath);
if( !pDoc ) }
inline LODocument* documentLoad(const char* pUrl)
{
LibreOfficeDocument* pDoc = mpThis->documentLoad(mpThis, pUrl);
if (pDoc == NULL)
return NULL; return NULL;
return new LODocument( pDoc ); return new LODocument(pDoc);
} }
// return the last error as a string, free me. // return the last error as a string, free me.
inline char *getError() { return mpThis->getError( mpThis ); } inline char* getError()
{
return mpThis->getError(mpThis);
}
}; };
inline LibLibreOffice *lo_cpp_init( const char *install_path ) inline LibLibreOffice* lo_cpp_init(const char* pInstallPath)
{ {
LibreOffice *pThis = lo_init( install_path ); LibreOffice* pThis = lo_init(pInstallPath);
if( !pThis || pThis->nSize == 0 ) if (pThis == NULL || pThis->nSize == 0)
return NULL; return NULL;
return new LibLibreOffice( pThis ); return new LibLibreOffice(pThis);
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment