diff options
author | Tor Lillqvist <tml@collabora.com> | 2023-03-07 11:43:00 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2023-03-07 14:40:02 +0000 |
commit | 1f4e9eacc36413bba92f119ebed931cfdb975e80 (patch) | |
tree | 7038f3ab5b5f4624bf0cdfc7326fbb2fd4ca39ad /desktop | |
parent | 311edc37b202f5463a86eddc1f9b476dbe5b47fa (diff) |
Drop the LibreOfficeKit paintThumbnail() API
It turns out that Mert's original idea is actually the simplest and it
is known to work. And in that, the separate paintThumbnail() is rather
pointless, as all paintThumbnail() did was to call paintTile(). The
caller (in Collabora Online) knows when a file is opened specifically
for thumbnailing, and can call paintTile() itself with the appropriate
parameters.
My misguided idea would have had paintThumbnail() somehow figure out
the physical Twip coordinates of the current location (for text
documents, the insertion caret location) in the document. (Or, as
LibreOfficeKit for some reason calls them, "logical" coordinates, even
if a Twip is a very physical length unit.) Then it would have called
paintTile() with those coordinates. But it turned out to be rather
hard to figure out the Twip coordinates of the current location in
the document.
Mert's idea was that when a document is opened for thumbnailing, only
Online actually needs to know that. From LibreOfficeKit's and core's
point of view it is a normal document load operation. Then Online
performs the .uno:OpenHyperlink magic, which makes core move the
current position to the requested "target" or "mark" (the terminology
varies) location. And then a "cursor" callback is used by Online to
get the Twip coordinates of the target. It is a bit unclear to me
whether .uno:HyperLink causes the document to be opened an extra time,
but whatever, this way is said to work. So let's do it like that.
This reverts the paintThumbnail part of
1aa37ca99112c0760552600d7774ba7224581c5b.
Change-Id: I8f3d9917ee362c1518834fc10a57c57ebc4a6edb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148390
Tested-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 34 |
2 files changed, 1 insertions, 37 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index c143662d7dd4..217b537fa214 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3635,11 +3635,9 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), offsetof(struct _LibreOfficeKitDocumentClass, getEditMode)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(68), offsetof(struct _LibreOfficeKitDocumentClass, setViewTimezone)); - CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), offsetof(struct _LibreOfficeKitDocumentClass, paintThumbnail)); - // As above - CPPUNIT_ASSERT_EQUAL(documentClassOffset(70), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(69), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 903dc2b06687..ee1f47a8ea96 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1114,12 +1114,6 @@ 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 bufferWidth, - int bufferHeight, - int width, - const char* pURL); #ifdef IOS static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, void* rCGContext, @@ -1393,7 +1387,6 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC m_pDocumentClass->setPartMode = doc_setPartMode; m_pDocumentClass->getEditMode = doc_getEditMode; m_pDocumentClass->paintTile = doc_paintTile; - m_pDocumentClass->paintThumbnail = doc_paintThumbnail; #ifdef IOS m_pDocumentClass->paintTileToCGContext = doc_paintTileToCGContext; #endif @@ -4015,33 +4008,6 @@ static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, #endif -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; - constexpr int pixelWidthTwips = pixelWidth * 15 / zoom; - constexpr int pixelHeightTwips = pixelHeight * 15 / zoom; - constexpr int offsetXTwips = 15 * 15; // start 15 px/twips before the target to get a clearer thumbnail - 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, unsigned char* pBuffer, const int nPart, |