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 @@
#define INCLUDED_DESKTOP_INC_LIBLIBREOFFICE_H
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
typedef struct _LibreOffice LibreOffice;
typedef struct _LibreOfficeDocument LibreOfficeDocument;
struct _LibreOffice {
struct _LibreOffice
{
int nSize;
void (*destroy) (LibreOffice *pThis);
int (*initialize) (LibreOffice *pThis,
const char *pInstallPath);
LibreOfficeDocument *(*documentLoad) (LibreOffice *pThis,
const char *pURL);
char * (*getError) (LibreOffice *pThis);
int (*initialize) (LibreOffice *pThis, const char *pInstallPath);
LibreOfficeDocument* (*documentLoad) (LibreOffice *pThis, const char *pURL);
char* (*getError) (LibreOffice *pThis);
};
struct _LibreOfficeDocument {
struct _LibreOfficeDocument
{
int nSize;
void (*destroy) (LibreOfficeDocument *pThis);
int (*saveAs) (LibreOfficeDocument *pThis,
const char *pUrl, const char *pFormat);
void (*destroy) (LibreOfficeDocument* pThis);
int (*saveAs) (LibreOfficeDocument* pThis,
const char *pUrl,
const char *pFormat);
};
LibreOffice *lo_init (const char *install_path);
LibreOffice* lo_init (const char* pInstallPath);
#ifdef __cplusplus
}
......
......@@ -21,48 +21,67 @@
class LODocument
{
LibreOfficeDocument *mpDoc;
private:
LibreOfficeDocument* mpDoc;
public:
inline LODocument( LibreOfficeDocument *pDoc ) : mpDoc( pDoc ) {}
inline ~LODocument() { mpDoc->destroy( mpDoc ); }
inline LODocument(LibreOfficeDocument* pDoc) :
mpDoc(pDoc)
{}
inline ~LODocument()
{
mpDoc->destroy(mpDoc);
}
// 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
{
LibreOffice *mpThis;
private:
LibreOffice* mpThis;
public:
inline LibLibreOffice( LibreOffice *pThis ) : mpThis( pThis ) {}
inline ~LibLibreOffice() { mpThis->destroy( mpThis ); };
inline LibLibreOffice(LibreOffice* pThis) :
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 );
if( !pDoc )
return mpThis->initialize(mpThis, pInstallPath);
}
inline LODocument* documentLoad(const char* pUrl)
{
LibreOfficeDocument* pDoc = mpThis->documentLoad(mpThis, pUrl);
if (pDoc == NULL)
return NULL;
return new LODocument( pDoc );
return new LODocument(pDoc);
}
// 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 );
if( !pThis || pThis->nSize == 0 )
LibreOffice* pThis = lo_init(pInstallPath);
if (pThis == NULL || pThis->nSize == 0)
return NULL;
return new LibLibreOffice( pThis );
return new LibLibreOffice(pThis);
}
#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