Implement document size retrieval for LibLO.

Change-Id: Ibd69f8e766fd421b05d2305f967179a969bc5b56
This commit is contained in:
Andrzej Hunt
2014-05-18 08:36:16 +01:00
parent 41911db36e
commit fd5f324b09
3 changed files with 32 additions and 0 deletions

View File

@@ -177,6 +177,9 @@ static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight);
static void doc_getDocumentSize(LibreOfficeDocument* pThis,
long* pWidth,
long* pHeight);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -198,6 +201,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->getNumberOfParts = doc_getNumberOfParts;
m_pDocumentClass->setPart = doc_setPart;
m_pDocumentClass->paintTile = doc_paintTile;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
gDocumentClass = m_pDocumentClass;
}
@@ -444,6 +448,24 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
return pRet;
}
static void doc_getDocumentSize(LibreOfficeDocument* pThis,
long* pWidth,
long* pHeight)
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
if (true) // TODO: test that we have a writer document here (vs calc/impress/etc.)
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
SwDocShell* pDocShell = pTxtDoc->GetDocShell();
SwDoc* pDoc = pDocShell->GetDoc();
SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
Size aDocumentSize = pViewShell->GetDocSize();
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
}
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);

View File

@@ -98,6 +98,11 @@ struct _LibreOfficeKitDocumentClass
const int nTilePosY,
const int nTileWidth,
const int nTileHeight);
// Get the document sizes in twips.
void (*getDocumentSize) (LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
#endif // LOK_USE_UNSTABLE_API
};

View File

@@ -70,6 +70,11 @@ public:
return mpDoc->pClass->paintTile(mpDoc, nCanvasWidth, nCanvasHeight, pRowStride,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
inline void getDocumentSize(long* pWidth, long* pHeight)
{
mpDoc->getDocumentSize(mpDoc, pWidth, pHeight);
}
#endif // LOK_USE_UNSTABLE_API
};