summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx22
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h5
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx5
3 files changed, 32 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8f32a54e0a57..252d79bc7faa 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -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);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index cf2bcb2a757e..f63f3a71ac91 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -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
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 09b4ae61b28f..ee310fec0f0e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -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
};