desktop/source/lib/init.cxx | 23 +++++++++++++++++++++-- include/LibreOfficeKit/LibreOfficeKit.h | 7 +++++-- include/LibreOfficeKit/LibreOfficeKit.hxx | 24 ++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-)
New commits: commit 91afabee6bece4cbf61a8f32a6e6a69becd857ae Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Tue Feb 28 18:23:06 2023 +0200 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed Mar 1 08:28:21 2023 +0000 Improve the LibreOfficeKit Document::paintThumbnail() API No implementation yet. Change-Id: Ie1dc955bc8b589bd336af0545a2270cbe84a8b9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148028 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index eee57facee65..903dc2b06687 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1114,7 +1114,12 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight); -static void doc_paintThumbnail(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int x, int y); +static void doc_paintThumbnail(LibreOfficeKitDocument* pThis, + unsigned char* pBuffer, + int bufferWidth, + int bufferHeight, + int width, + const char* pURL); #ifdef IOS static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, void* rCGContext, @@ -4010,8 +4015,14 @@ static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, #endif -static void doc_paintThumbnail(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, int x, int y) +static void doc_paintThumbnail(LibreOfficeKitDocument* pThis, + unsigned char* pBuffer, + int bufferWidth, + int bufferHeight, + int width, + const char* pURL) { +#if 0 constexpr float zoom = 0.5f; constexpr int pixelWidth = 120; constexpr int pixelHeight = 120; @@ -4021,6 +4032,14 @@ static void doc_paintThumbnail(LibreOfficeKitDocument* pThis, unsigned char* pBu constexpr int offsetYTwips = 15 * 15; doc_paintTile(pThis, pBuffer, pixelWidth, pixelHeight, x-offsetXTwips, y-offsetYTwips, pixelWidthTwips, pixelHeightTwips); +#else + (void) pThis; + (void) pBuffer; + (void) bufferWidth; + (void) bufferHeight; + (void) width; + (void) pURL; +#endif } static void doc_paintPartTile(LibreOfficeKitDocument* pThis, diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 4de2380998b4..09d3e91e8640 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -501,10 +501,13 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::setViewTimezone(). void (*setViewTimezone) (LibreOfficeKitDocument* pThis, int nId, const char* timezone); + /// @see lok::Document::paintThumbnail(). void (*paintThumbnail) (LibreOfficeKitDocument* pThis, unsigned char* pBuffer, - int x, - int y); + int bufferWidth, + int bufferHeight, + int width, + const char* pURL); #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 17fc518fbe13..04a3b82e6eca 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -886,9 +886,29 @@ public: mpDoc->pClass->setViewTimezone(mpDoc, nId, timezone); } - void paintThumbnail(unsigned char* pBuffer, int x, int y) + /** + * Create a thumbnail of a location in the document. + * + * @param pBuffer Where the thumbnail is painted. Same format as a tile painted + * by paintTile(). + * @param bufferWidth number of pixels in a row of pBuffer. + * @param bufferHeight number of pixels in a column of pBuffer. + * @param width logical width of the rendered rectangle, in TWIPs. + * @param pURL Just the fragment part of a URL, indicating the location in the document + * to render as a thumbnail. As returned by extractRequest(), or null, meaning the start + * of the document. + * + * Note that there is no parameter for the logical height of the + * rendered rectangle. The aspect ratio of the rendered rectangle + * is determined by the bufferWidth and bufferHeight parameters. + */ + void paintThumbnail(unsigned char* pBuffer, + int bufferWidth, + int bufferHeight, + int width, + const char* pURL) { - return mpDoc->pClass->paintThumbnail(mpDoc, pBuffer, x, y); + return mpDoc->pClass->paintThumbnail(mpDoc, pBuffer, bufferWidth, bufferHeight, width, pURL); } #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY