summaryrefslogtreecommitdiff
path: root/desktop/source
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-05-09 14:37:27 +0100
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-25 13:04:28 +0100
commitd2382e3f3d9a53c6197edc9c64665f718538c92b (patch)
treef9642a8712adaeec6feee6a1c330ef7923286379 /desktop/source
parent9e4f23698af8079edc114d7006ef6a7fc229c1c9 (diff)
Add tiled rendering via liblibreoffice.
We still need to add functions for getting dimensions of documents etc. for this to be truly useful, this is also only usable for writer documents for now. Change-Id: I07812c9b72caca71dfd509705af48c1d355cb2f8
Diffstat (limited to 'desktop/source')
-rw-r--r--desktop/source/lib/init.cxx76
1 files changed, 76 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 710b4741bca6..5580a038a375 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -16,6 +16,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
+#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.h>
#include <tools/errinf.hxx>
@@ -39,10 +40,19 @@
#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>
#include <osl/module.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;
@@ -154,6 +164,13 @@ extern "C"
static void doc_destroy(LibreOfficeKitDocument* pThis);
static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const char* pFormat, const char* pFilterOptions);
+static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
+static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
+static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
+static void doc_paintTile(LibreOfficeKitDocument* 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 _LibreOfficeKitDocument
{
@@ -171,6 +188,10 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->destroy = doc_destroy;
m_pDocumentClass->saveAs = doc_saveAs;
+ m_pDocumentClass->getDocumentType = doc_getDocumentType;
+ m_pDocumentClass->getNumberOfParts = doc_getNumberOfParts;
+ m_pDocumentClass->setPart = doc_setPart;
+ m_pDocumentClass->paintTile = doc_paintTile;
gDocumentClass = m_pDocumentClass;
}
@@ -338,6 +359,61 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
return false;
}
+static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* pThis)
+{
+ (void) pThis;
+ return WRITER;
+}
+
+static int doc_getNumberOfParts (LibreOfficeKitDocument* pThis)
+{
+ (void) pThis;
+ // Assume writer document for now.
+ return 1;
+}
+
+static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
+{
+ (void) pThis;
+ (void) nPart;
+}
+
+static void doc_paintTile (LibreOfficeKitDocument* 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 (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);