summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/Library_sofficeapp.mk1
-rw-r--r--desktop/inc/liblibreoffice.h39
-rw-r--r--desktop/inc/liblibreoffice.hxx29
-rw-r--r--desktop/source/lib/init.cxx78
4 files changed, 147 insertions, 0 deletions
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 0c6c3e71f0ba..f2fe076daf0f 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
-I$(SRCDIR)/desktop/inc \
-I$(SRCDIR)/desktop/source/inc \
-I$(SRCDIR)/desktop/source/deployment/inc \
+ -I$(SRCDIR)/sw/inc \
))
$(eval $(call gb_Library_use_external,sofficeapp,boost_headers))
diff --git a/desktop/inc/liblibreoffice.h b/desktop/inc/liblibreoffice.h
index 87111c43bc67..e79b36dfa243 100644
--- a/desktop/inc/liblibreoffice.h
+++ b/desktop/inc/liblibreoffice.h
@@ -28,6 +28,17 @@ struct _LibreOffice
char* (*getError) (LibreOffice *pThis);
};
+#ifdef LLO_USE_UNSTABLE_API
+typedef enum
+{
+ WRITER,
+ SPREADSHEET,
+ PRESENTATION,
+ OTHER
+}
+LibreOfficeDocumentType;
+#endif // LLO_USE_UNSTABLE_API
+
struct _LibreOfficeDocument
{
int nSize;
@@ -40,6 +51,34 @@ struct _LibreOfficeDocument
const char *pUrl,
const char *pFormat,
const char *pFilterOptions);
+
+#ifdef LLO_USE_UNSTABLE_API
+ LibreOfficeDocumentType (*getDocumentType) (LibreOfficeDocument* pThis);
+
+ // Part refers to either indivual sheets in a Spreadsheet, or slides
+ // in a Slideshow, and has no relevance for wrtier documents.
+ int (*getNumberOfParts) (LibreOfficeDocument* pThis);
+
+ void (*setPart) (LibreOfficeDocument* pThis,
+ int nPart);
+
+ // pCanvas is a pointer to the appropriate type of graphics object:
+ // Windows: HDC
+ // iOS/OSX: CGContextRef
+ // Unx: A full SystemGraphicsData
+ // (This is as we need multiple pieces of data on Unx -- in the future
+ // it would potentially be best to define our own simple equivalent
+ // structure here which can then be copied into a SystemGraphicsData
+ // within the paintTile implementation.)
+ void (*paintTile) (LibreOfficeDocument* pThis,
+ void* Canvas,
+ const int nCanvasWidth,
+ const int nCanvasHeight,
+ const int nTilePosX,
+ const int nTilePosY,
+ const int nTileWidth,
+ const int nTileHeight);
+#endif // LLO_USE_UNSTABLE_API
};
LibreOffice* lo_init (const char* pInstallPath);
diff --git a/desktop/inc/liblibreoffice.hxx b/desktop/inc/liblibreoffice.hxx
index 3afdc4be2675..9cfe465091f7 100644
--- a/desktop/inc/liblibreoffice.hxx
+++ b/desktop/inc/liblibreoffice.hxx
@@ -48,6 +48,35 @@ public:
return mpDoc->saveAsWithOptions(mpDoc, pUrl, pFormat, pFilterOptions);
}
+
+#ifdef LLO_USE_UNSTABLE_API
+ inline LibreOfficeDocumentType getDocumentType()
+ {
+ return mpDoc->getDocumentType(mpDoc);
+ }
+
+ inline int getNumberOfParts()
+ {
+ return mpDoc->getNumberOfParts(mpDoc);
+ }
+
+ inline void setPart(int nPart)
+ {
+ mpDoc->setPart(mpDoc, nPart);
+ }
+
+ inline void paintTile(void* pHandle,
+ const int nCanvasWidth,
+ const int nCanvasHeight,
+ const int nTilePosX,
+ const int nTilePosY,
+ const int nTileWidth,
+ const int nTileHeight)
+ {
+ mpDoc->paintTile(mpDoc, pHandle, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ }
+#endif // LLO_USE_UNSTABLE_API
};
class LibLibreOffice
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3b045590e0f1..fb223e7fcbde 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -13,6 +13,7 @@
#include <string.h>
#include <stdlib.h>
+#define LLO_USE_UNSTABLE_API
#include "liblibreoffice.h"
#include <tools/errinf.hxx>
@@ -36,9 +37,18 @@
#include <vcl/svapp.hxx>
#include <tools/resmgr.hxx>
#include <vcl/graphicfilter.hxx>
+#include <vcl/sysdata.hxx>
+#include <vcl/virdev.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx>
+// Dirty hack -- we go directly into sw -- ideally we need some sort of
+// layer to get the writer shell for tiled rendering
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <unotxdoc.hxx>
+#include <viewsh.hxx>
+
using namespace css;
using namespace utl;
@@ -147,6 +157,13 @@ extern "C"
static void doc_destroy(LibreOfficeDocument* pThis);
static int doc_saveAs(LibreOfficeDocument* pThis, const char* pUrl, const char* pFormat);
static int doc_saveAsWithOptions(LibreOfficeDocument* pThis, const char* pUrl, const char* pFormat, const char* pFilterOptions);
+static LibreOfficeDocumentType doc_getDocumentType(LibreOfficeDocument* pThis);
+static int doc_getNumberOfParts(LibreOfficeDocument* pThis);
+static void doc_setPart(LibreOfficeDocument* pThis, int nPart);
+static void doc_paintTile(LibreOfficeDocument* pThis, void* pCanvas,
+ const int nCanvasWidth, const int nCanvasHeight,
+ const int nTilePosX, const int nTilePosY,
+ const int nTileWidth, const int nTileHeight);
struct LibLODocument_Impl : public _LibreOfficeDocument
{
@@ -160,6 +177,10 @@ struct LibLODocument_Impl : public _LibreOfficeDocument
destroy = doc_destroy;
saveAs = doc_saveAs;
saveAsWithOptions = doc_saveAsWithOptions;
+ getDocumentType = doc_getDocumentType;
+ getNumberOfParts = doc_getNumberOfParts;
+ setPart = doc_setPart;
+ paintTile = doc_paintTile;
}
};
@@ -316,6 +337,63 @@ static int doc_saveAsWithOptions(LibreOfficeDocument* pThis, const char* sUrl, c
return false;
}
+static LibreOfficeDocumentType doc_getDocumentType (LibreOfficeDocument* pThis)
+{
+ (void) pThis;
+ return WRITER;
+}
+
+static int doc_getNumberOfParts (LibreOfficeDocument* pThis)
+{
+ (void) pThis;
+ // Assume writer document for now.
+ return 1;
+}
+
+static void doc_setPart(LibreOfficeDocument* pThis, int nPart)
+{
+ (void) pThis;
+ (void) nPart;
+}
+
+static void doc_paintTile (LibreOfficeDocument* pThis, void* pCanvas,
+ const int nCanvasWidth, const int nCanvasHeight,
+ const int nTilePosX, const int nTilePosY,
+ const int nTileWidth, const int nTileHeight)
+{
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ // We can't use this on anything but Linux for now, so the following is
+ // likely unusable for now.
+ SystemGraphicsData aSystemGraphicsData;
+#if defined( WNT )
+ aSystemGraphicsData.hDC = *static_cast< HDC* >(pCanvas);
+#elif defined( MACOSX )
+ aSystemGraphicsData.rCGContext = *static_cast< CGContextRef* >(pCanvas);
+#elif defined( ANDROID )
+ assert(false); // We can't use tiled rendering on Android in any case yet...
+#elif defined( IOS )
+ aSystemGraphicsData.rCGContext = *static_cast< CGContextRef* >(pCanvas);
+#elif defined( UNX )
+ aSystemGraphicsData = *static_cast< SystemGraphicsData*> (pCanvas);
+#endif
+
+ Application::AcquireSolarMutex(1);
+ {
+ SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
+ SwDocShell* pDocShell = pTxtDoc->GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+
+ VirtualDevice aDevice(&aSystemGraphicsData, (sal_uInt16)0);
+ pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ }
+ Application::ReleaseSolarMutex();
+}
+
+
+
static char* lo_getError (LibreOffice *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);