summaryrefslogtreecommitdiff
path: root/include/LibreOfficeKit
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-17 15:13:33 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-06-17 16:58:57 +0100
commit8ba3116a8f09650b47aa69cf3d828ca0b5f6b51e (patch)
tree3dc21143fe4ef2b23d550d53c813f5ea62a9e396 /include/LibreOfficeKit
parent5df0bfdddb65742e437d7bfe2df2979f445aea8f (diff)
LOK: Split into instance and class.
Change-Id: I2b6f33eaf12343c7da1328a932eb703bb4e4ef6f
Diffstat (limited to 'include/LibreOfficeKit')
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h17
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx20
2 files changed, 23 insertions, 14 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 4c32fd254bb8..6bc91e453456 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -18,17 +18,25 @@ extern "C"
#endif
typedef struct _LibreOfficeKit LibreOfficeKit;
+typedef struct _LibreOfficeKitClass LibreOfficeKitClass;
+
typedef struct _LibreOfficeKitDocument LibreOfficeKitDocument;
+typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass;
// Do we have an extended member in this struct ?
#define LIBREOFFICEKIT_HAS_MEMBER(strct,member,nSize) \
((((size_t)((unsigned char *)&((strct *) 0)->member) + \
sizeof ((strct *) 0)->member)) <= (nSize))
-#define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKit,member,(pKit)->nSize)
+#define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitClass,member,(pKit)->pClass->nSize)
struct _LibreOfficeKit
{
+ LibreOfficeKitClass* pClass;
+};
+
+struct _LibreOfficeKitClass
+{
size_t nSize;
void (*destroy) (LibreOfficeKit *pThis);
@@ -37,10 +45,15 @@ struct _LibreOfficeKit
char* (*getError) (LibreOfficeKit *pThis);
};
-#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocument,member,(pDoc)->nSize)
+#define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
struct _LibreOfficeKitDocument
{
+ LibreOfficeKitDocumentClass* pClass;
+};
+
+struct _LibreOfficeKitDocumentClass
+{
size_t nSize;
void (*destroy) (LibreOfficeKitDocument* pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index ec1131312280..4cd502addd97 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -33,22 +33,18 @@ public:
inline ~Document()
{
- mpDoc->destroy(mpDoc);
+ mpDoc->pClass->destroy(mpDoc);
}
// Save as the given format, if format is NULL sniff from ext'n
inline bool saveAs(const char* pUrl, const char* pFormat = NULL)
{
- return mpDoc->saveAs(mpDoc, pUrl, pFormat);
+ return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat);
}
inline bool saveAsWithOptions(const char* pUrl, const char* pFormat = NULL, const char* pFilterOptions = NULL)
{
- // available since LibreOffice 4.3
- if (!LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, saveAsWithOptions))
- return false;
-
- return mpDoc->saveAsWithOptions(mpDoc, pUrl, pFormat, pFilterOptions);
+ return mpDoc->pClass->saveAsWithOptions(mpDoc, pUrl, pFormat, pFilterOptions);
}
inline LibreOfficeKitDocument *get() { return mpDoc; }
};
@@ -65,17 +61,17 @@ public:
inline ~Office()
{
- mpThis->destroy(mpThis);
+ mpThis->pClass->destroy(mpThis);
}
inline bool initialize(const char* pInstallPath)
{
- return mpThis->initialize(mpThis, pInstallPath);
+ return mpThis->pClass->initialize(mpThis, pInstallPath);
}
inline Document* documentLoad(const char* pUrl)
{
- LibreOfficeKitDocument* pDoc = mpThis->documentLoad(mpThis, pUrl);
+ LibreOfficeKitDocument* pDoc = mpThis->pClass->documentLoad(mpThis, pUrl);
if (pDoc == NULL)
return NULL;
return new Document(pDoc);
@@ -84,14 +80,14 @@ public:
// return the last error as a string, free me.
inline char* getError()
{
- return mpThis->getError(mpThis);
+ return mpThis->pClass->getError(mpThis);
}
};
inline Office* lok_cpp_init(const char* pInstallPath)
{
LibreOfficeKit* pThis = lok_init(pInstallPath);
- if (pThis == NULL || pThis->nSize == 0)
+ if (pThis == NULL || pThis->pClass->nSize == 0)
return NULL;
return new ::lok::Office(pThis);
}