Kaydet (Commit) d2382e3f authored tarafından Andrzej Hunt's avatar Andrzej Hunt

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
üst 9e4f2369
...@@ -14,6 +14,7 @@ $(eval $(call gb_Library_set_include,sofficeapp,\ ...@@ -14,6 +14,7 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
-I$(SRCDIR)/desktop/inc \ -I$(SRCDIR)/desktop/inc \
-I$(SRCDIR)/desktop/source/inc \ -I$(SRCDIR)/desktop/source/inc \
-I$(SRCDIR)/desktop/source/deployment/inc \ -I$(SRCDIR)/desktop/source/deployment/inc \
-I$(SRCDIR)/sw/inc \
)) ))
$(eval $(call gb_Library_use_external,sofficeapp,boost_headers)) $(eval $(call gb_Library_use_external,sofficeapp,boost_headers))
...@@ -45,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\ ...@@ -45,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
sfx \ sfx \
svl \ svl \
svt \ svt \
sw \
tk \ tk \
tl \ tl \
ucbhelper \ ucbhelper \
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.hxx> #include <LibreOfficeKit/LibreOfficeKit.hxx>
static int help() static int help()
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp> #include <boost/weak_ptr.hpp>
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.h> #include <LibreOfficeKit/LibreOfficeKit.h>
#include <tools/errinf.hxx> #include <tools/errinf.hxx>
...@@ -39,10 +40,19 @@ ...@@ -39,10 +40,19 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <tools/resmgr.hxx> #include <tools/resmgr.hxx>
#include <vcl/graphicfilter.hxx> #include <vcl/graphicfilter.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
#include <unotools/syslocaleoptions.hxx> #include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx> #include <unotools/mediadescriptor.hxx>
#include <osl/module.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 css;
using namespace utl; using namespace utl;
...@@ -154,6 +164,13 @@ extern "C" ...@@ -154,6 +164,13 @@ extern "C"
static void doc_destroy(LibreOfficeKitDocument* pThis); static void doc_destroy(LibreOfficeKitDocument* pThis);
static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const char* pFormat, const char* pFilterOptions); 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 struct LibLODocument_Impl : public _LibreOfficeKitDocument
{ {
...@@ -171,6 +188,10 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument ...@@ -171,6 +188,10 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->destroy = doc_destroy; m_pDocumentClass->destroy = doc_destroy;
m_pDocumentClass->saveAs = doc_saveAs; 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; gDocumentClass = m_pDocumentClass;
} }
...@@ -338,6 +359,61 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha ...@@ -338,6 +359,61 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
return false; 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) static char* lo_getError (LibreOfficeKit *pThis)
{ {
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis); LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
......
...@@ -30,6 +30,17 @@ typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass; ...@@ -30,6 +30,17 @@ typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass;
#define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitClass,member,(pKit)->pClass->nSize) #define LIBREOFFICEKIT_HAS(pKit,member) LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitClass,member,(pKit)->pClass->nSize)
#ifdef LOK_USE_UNSTABLE_API
typedef enum
{
WRITER,
SPREADSHEET,
PRESENTATION,
OTHER
}
LibreOfficeKitDocumentType;
#endif // LOK_USE_UNSTABLE_API
struct _LibreOfficeKit struct _LibreOfficeKit
{ {
LibreOfficeKitClass* pClass; LibreOfficeKitClass* pClass;
...@@ -60,6 +71,37 @@ struct _LibreOfficeKitDocumentClass ...@@ -60,6 +71,37 @@ struct _LibreOfficeKitDocumentClass
const char *pUrl, const char *pUrl,
const char *pFormat, const char *pFormat,
const char *pFilterOptions); const char *pFilterOptions);
int (*saveAsWithOptions) (LibreOfficeKitDocument* pThis,
const char *pUrl,
const char *pFormat,
const char *pFilterOptions);
#ifdef LOK_USE_UNSTABLE_API
LibreOfficeKitDocumentType (*getDocumentType) (LibreOfficeKitDocument* pThis);
// Part refers to either indivual sheets in a Spreadsheet, or slides
// in a Slideshow, and has no relevance for wrtier documents.
int (*getNumberOfParts) (LibreOfficeKitDocument* pThis);
void (*setPart) (LibreOfficeKitDocument* 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) (LibreOfficeKitDocument* pThis,
void* Canvas,
const int nCanvasWidth,
const int nCanvasHeight,
const int nTilePosX,
const int nTilePosY,
const int nTileWidth,
const int nTileHeight);
#endif // LOK_USE_UNSTABLE_API
}; };
LibreOfficeKit* lok_init (const char* pInstallPath); LibreOfficeKit* lok_init (const char* pInstallPath);
......
...@@ -40,7 +40,37 @@ public: ...@@ -40,7 +40,37 @@ public:
{ {
return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat, pFilterOptions); return mpDoc->pClass->saveAs(mpDoc, pUrl, pFormat, pFilterOptions);
} }
inline LibreOfficeKitDocument *get() { return mpDoc; } inline LibreOfficeKitDocument *get() { return mpDoc; }
#ifdef LOK_USE_UNSTABLE_API
inline LibreOfficeKitDocumentType getDocumentType()
{
return mpDoc->pClass->getDocumentType(mpDoc);
}
inline int getNumberOfParts()
{
return mpDoc->pClass->getNumberOfParts(mpDoc);
}
inline void setPart(int nPart)
{
mpDoc->pClass->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->pClass->paintTile(mpDoc, pHandle, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
#endif // LOK_USE_UNSTABLE_API
}; };
class Office class Office
......
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