summaryrefslogtreecommitdiff
path: root/desktop/source
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2024-06-25 19:07:25 +0900
committerMiklos Vajna <vmiklos@collabora.com>2024-07-10 11:47:49 +0200
commitbf972de2c193540c36f8d9fde0879da478c0ab8c (patch)
treed85a64b1ffb078f9e837681fcf39a0baebea2a65 /desktop/source
parent99fda8da4e0a1b24c9aaecacfeeba0fe593fe730 (diff)
lok: expose presentation info and slide render functions
This exposes the (impress only) function to get the current presentation info in JSON format and the slide rendering functions that enable rendering of slide layers to a bitmap. Change-Id: Id0591d5894f730eae48b3edc986ae5d804ce7c81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170263 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'desktop/source')
-rw-r--r--desktop/source/lib/init.cxx97
1 files changed, 97 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 03a5457edcc8..365947a43b9f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1274,6 +1274,19 @@ static void doc_setAccessibilityState(LibreOfficeKitDocument* pThis, int nId, bo
static char* doc_getA11yFocusedParagraph(LibreOfficeKitDocument* pThis);
static int doc_getA11yCaretPosition(LibreOfficeKitDocument* pThis);
+
+static char* doc_getPresentationInfo(LibreOfficeKitDocument* pThis);
+
+static bool doc_createSlideRenderer(
+ LibreOfficeKitDocument* pThis,
+ int nSlideNumber, unsigned* nViewWidth, unsigned* nViewHeight,
+ bool bRenderBackground, bool bRenderMasterPage);
+
+static void doc_postSlideshowCleanup(LibreOfficeKitDocument* pThis);
+
+static bool doc_renderNextSlideLayer(
+ LibreOfficeKitDocument* pThis, unsigned char* pBuffer, bool* bIsBitmapLayer, char** pJsonMsg);
+
} // extern "C"
namespace {
@@ -1471,6 +1484,11 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC
m_pDocumentClass->setAllowChangeComments = doc_setAllowChangeComments;
+ m_pDocumentClass->getPresentationInfo = doc_getPresentationInfo;
+ m_pDocumentClass->createSlideRenderer = doc_createSlideRenderer;
+ m_pDocumentClass->postSlideshowCleanup = doc_postSlideshowCleanup;
+ m_pDocumentClass->renderNextSlideLayer = doc_renderNextSlideLayer;
+
gDocumentClass = m_pDocumentClass;
}
pClass = m_pDocumentClass.get();
@@ -5499,6 +5517,85 @@ static void doc_setWindowTextSelection(LibreOfficeKitDocument* /*pThis*/, unsign
Application::PostMouseEvent(VclEventId::WindowMouseButtonUp, pWindow, &aCursorEvent);
}
+static char* doc_getPresentationInfo(LibreOfficeKitDocument* pThis)
+{
+ SolarMutexGuard aGuard;
+ SetLastExceptionMsg();
+
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ SetLastExceptionMsg(u"Document doesn't support tiled rendering"_ustr);
+ return nullptr;
+ }
+
+ return convertOString(pDoc->getPresentationInfo());
+}
+
+static bool doc_createSlideRenderer(
+ LibreOfficeKitDocument* pThis,
+ int nSlideNumber, unsigned* pViewWidth, unsigned* pViewHeight,
+ bool bRenderBackground, bool bRenderMasterPage)
+{
+ SolarMutexGuard aGuard;
+ SetLastExceptionMsg();
+
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ SetLastExceptionMsg(u"Document doesn't support tiled rendering"_ustr);
+ return false;
+ }
+
+ sal_Int32 nViewWidth = 0;
+ sal_Int32 nViewHeight = 0;
+ bool bReturn = pDoc->createSlideRenderer(
+ nSlideNumber, nViewWidth, nViewHeight,
+ bRenderBackground, bRenderMasterPage);
+
+ *pViewWidth = nViewWidth;
+ *pViewHeight = nViewHeight;
+
+ return bReturn;
+}
+
+static void doc_postSlideshowCleanup(LibreOfficeKitDocument* pThis)
+{
+ SolarMutexGuard aGuard;
+ SetLastExceptionMsg();
+
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ SetLastExceptionMsg(u"Document doesn't support tiled rendering"_ustr);
+ return;
+ }
+ pDoc->postSlideshowCleanup();
+}
+
+static bool doc_renderNextSlideLayer(
+ LibreOfficeKitDocument* pThis, unsigned char* pBuffer, bool* pIsBitmapLayer, char** pJsonMessage)
+{
+ SolarMutexGuard aGuard;
+ SetLastExceptionMsg();
+
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ SetLastExceptionMsg(u"Document doesn't support tiled rendering"_ustr);
+ return true;
+ }
+ OUString sJsonMesssage;
+ bool bIsBitmapLayer = false;
+ bool bDone = pDoc->renderNextSlideLayer(pBuffer, bIsBitmapLayer, sJsonMesssage);
+
+ if (pJsonMessage)
+ *pJsonMessage = convertOUString(sJsonMesssage);
+ *pIsBitmapLayer = bIsBitmapLayer;
+
+ return bDone;
+}
+
static bool getFromTransferable(
const css::uno::Reference<css::datatransfer::XTransferable> &xTransferable,
const OString &aInMimeType, OString &aRet);