From e1511ce551f27a5560600029193f076fd65ece17 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Fri, 9 Jul 2021 14:41:21 +0900 Subject: indexing: add LOKit API to render the search result into a bitmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a new LOKit API to render the search result into a bitmap buffer. It combines the SearchResultLocator to get the location inside the document of the search result (a series of rectangles) and the existing LOKit paintTile API to render the result into a bitmap (byte) buffer. It also adds a LOKit test to show how the API is used and to render a search result of a example document. Change-Id: I4284d90188777fd28158d029daa04151e71022bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118670 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- include/LibreOfficeKit/LibreOfficeKit.h | 6 ++++++ include/LibreOfficeKit/LibreOfficeKit.hxx | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'include/LibreOfficeKit') diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 82738d65ff93..8c9e0012552e 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -458,6 +458,12 @@ struct _LibreOfficeKitDocumentClass void (*sendFormFieldEvent) (LibreOfficeKitDocument* pThis, const char* pArguments); + /// @see lok::Document::renderSearchResult + bool (*renderSearchResult) (LibreOfficeKitDocument* pThis, + const char* pSearchResult, + unsigned char** pBitmapBuffer, + int* pWidth, int* pHeight, size_t* pByteSize); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 06fe5abc19e2..b1d579849cbd 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -787,6 +787,22 @@ public: mpDoc->pClass->sendFormFieldEvent(mpDoc, pArguments); } + /** + * Render input search result to a bitmap buffer. + * + * @param pSearchResult payload containing the search result data + * @param pBitmapBuffer contains the bitmap; use free to deallocate. + * @param nWidth output bitmap width + * @param nHeight output bitmap height + * @param nByteSize output bitmap byte size + * @return true if successful + */ + bool renderSearchResult(const char* pSearchResult, unsigned char** pBitmapBuffer, + int* pWidth, int* pHeight, size_t* pByteSize) + { + return mpDoc->pClass->renderSearchResult(mpDoc, pSearchResult, pBitmapBuffer, pWidth, pHeight, pByteSize); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; -- cgit