diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2024-06-25 19:07:25 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-06-25 17:11:48 +0200 |
commit | 70552902d13d319584d1b2b96993f23fca057800 (patch) | |
tree | 1338ee4e82285472f479a3119c71986b134615f9 | |
parent | 0d959d483555307c363f5bfa5b83eaf5bd98d357 (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/+/169452
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 6 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 97 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 16 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 27 |
4 files changed, 145 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 4a09b10931f6..1b780caaede0 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3680,9 +3680,13 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(71), offsetof(struct _LibreOfficeKitDocumentClass, getA11yCaretPosition)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), offsetof(struct _LibreOfficeKitDocumentClass, setViewReadOnly)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(73), offsetof(struct _LibreOfficeKitDocumentClass, setAllowChangeComments)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(74), offsetof(struct _LibreOfficeKitDocumentClass, getPresentationInfo)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(75), offsetof(struct _LibreOfficeKitDocumentClass, createSlideRenderer)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(76), offsetof(struct _LibreOfficeKitDocumentClass, postSlideshowCleanup)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(77), offsetof(struct _LibreOfficeKitDocumentClass, renderNextSlideLayer)); // As above - CPPUNIT_ASSERT_EQUAL(documentClassOffset(74), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(78), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a17a1ea9d447..a40cb44f9a86 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1285,6 +1285,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 { @@ -1482,6 +1495,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(); @@ -5583,6 +5601,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); diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 2a0df3348f8d..49a577d72ed9 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -526,6 +526,22 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::setAllowChangeComments(). void (*setAllowChangeComments) (LibreOfficeKitDocument* pThis, int nId, const bool allow); + /// @see lok::Document::getPresentationInfo + char* (*getPresentationInfo) (LibreOfficeKitDocument* pThis); + + /// @see lok::Document::createSlideRenderer + bool (*createSlideRenderer) ( + LibreOfficeKitDocument* pThis, + int nSlideNumber, unsigned* nViewWidth, unsigned* nViewHeight, + bool bRenderBackground, bool bRenderMasterPage); + + /// @see lok::Document::postSlideshowCleanup + void (*postSlideshowCleanup)(LibreOfficeKitDocument* pThis); + + /// @see lok::Document::renderNextSlideLayer + bool (*renderNextSlideLayer)( + LibreOfficeKitDocument* pThis, unsigned char* pBuffer, bool* bIsBitmapLayer, char** pJsonMessage); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 14ad6a86f913..ba1e039e9f74 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -909,6 +909,33 @@ public: return mpDoc->pClass->getA11yCaretPosition(mpDoc); } + /// Get the information about the current presentation (Impress only). + char* getPresentationInfo() + { + return mpDoc->pClass->getPresentationInfo(mpDoc); + } + + /// Create a slide renderer in core for the input slide. + bool createSlideRenderer( + int nSlideNumber, unsigned* nViewWidth, unsigned* nViewHeight, + bool bRenderBackground, bool bRenderMasterPage) + { + return mpDoc->pClass->createSlideRenderer( + mpDoc, nSlideNumber, nViewWidth, nViewHeight, bRenderBackground, bRenderMasterPage); + } + + /// Clean-up the slideshow (slide renderer) + void postSlideshowCleanup() + { + mpDoc->pClass->postSlideshowCleanup(mpDoc); + } + + /// Render the slide layer + bool renderNextSlideLayer(unsigned char* pBuffer, bool* bIsBitmapLayer, char** pJsonMessage) + { + return mpDoc->pClass->renderNextSlideLayer(mpDoc, pBuffer, bIsBitmapLayer, pJsonMessage); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; |