desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 ++++- desktop/source/lib/init.cxx | 18 ++++++++++++++++++ include/LibreOfficeKit/LibreOfficeKit.h | 3 +++ include/LibreOfficeKit/LibreOfficeKit.hxx | 5 +++++ include/vcl/ITiledRenderable.hxx | 6 ++++++ sc/inc/docuno.hxx | 3 +++ sc/source/ui/unoobj/docuno.cxx | 6 ++++++ sd/source/ui/inc/unomodel.hxx | 2 ++ sd/source/ui/unoidl/unomodel.cxx | 6 ++++++ sw/inc/unotxdoc.hxx | 2 ++ sw/source/uibase/uno/unotxdoc.cxx | 5 +++++ 11 files changed, 60 insertions(+), 1 deletion(-)
New commits: commit 6fc77c2fa419137abe6e1950eda3d4a0bffe105e Author: Gökay Şatır <[email protected]> AuthorDate: Tue Nov 28 14:32:59 2023 +0300 Commit: Gökay ŞATIR <[email protected]> CommitDate: Thu Dec 28 13:33:59 2023 +0100 In readonly mode, we restrict many events like click. In readonly mode, Online users need to be able to click on a hyperlink and get the related info. For this purpose, this PR adds a new function template that sends the hyperlink info if there is any at the clicked position. I will send the implementation with the next commit. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I886ea22a7097aac73ade0da78a88ddfc95ad819c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160022 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161372 Tested-by: Jenkins diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index b3410bd8eb49..cc4360807717 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3702,8 +3702,11 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(71), offsetof(struct _LibreOfficeKitDocumentClass, getA11yCaretPosition)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), + offsetof(struct _LibreOfficeKitDocumentClass, hyperlinkInfoAtPosition)); + // As above - CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(73), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 76772b4162be..2f82ab48225d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1139,6 +1139,9 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText); + +static char* doc_hyperlinkInfoAtPosition(LibreOfficeKitDocument *pThis, int x, int y); + static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, @@ -1424,6 +1427,7 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC m_pDocumentClass->registerCallback = doc_registerCallback; m_pDocumentClass->postKeyEvent = doc_postKeyEvent; m_pDocumentClass->postWindowExtTextInputEvent = doc_postWindowExtTextInputEvent; + m_pDocumentClass->hyperlinkInfoAtPosition = doc_hyperlinkInfoAtPosition; m_pDocumentClass->removeTextContext = doc_removeTextContext; m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent; @@ -4693,6 +4697,20 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig SfxLokHelper::postExtTextEventAsync(pWindow, nType, OUString::fromUtf8(std::string_view(pText, strlen(pText)))); } +static char* doc_hyperlinkInfoAtPosition(LibreOfficeKitDocument* pThis, int x, int y) +{ + SolarMutexGuard aGuard; + + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + SetLastExceptionMsg("Document doesn't support tiled rendering"); + return nullptr; + } + + return convertOUString(pDoc->hyperlinkInfoAtPosition(x, y)); +} + static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, int nCharAfter) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 96d6a3d3aca7..ed7f4e7f2d28 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -511,6 +511,9 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::getA11yCaretPosition. int (*getA11yCaretPosition) (LibreOfficeKitDocument* pThis); + /// @see lok::Document::hyperlinkInfoAtPosition(). + char* (*hyperlinkInfoAtPosition) (LibreOfficeKitDocument* pThis, int x,int y); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index c06d2f6d6619..6f75eb6be5cb 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -362,6 +362,11 @@ public: mpDoc->pClass->setTextSelection(mpDoc, nType, nX, nY); } + char* hyperlinkInfoAtPosition(int x, int y) + { + return mpDoc->pClass->hyperlinkInfoAtPosition(mpDoc, x, y); + } + /** * Gets the currently selected text. * diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index be6c050ad36d..41d1143bf019 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -166,6 +166,12 @@ public: */ virtual void setTextSelection(int nType, int nX, int nY) = 0; + /* + * Gets the info of hyperlink under the mouse position if any. + * @see lok::Document::hyperlinkInfoAtPosition(). + */ + virtual OUString hyperlinkInfoAtPosition(int x, int y) = 0; + /** * Gets the selection as a transferable for later processing */ diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 611b0c22d2b9..bc4608efbc3f 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -346,6 +346,9 @@ public: /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) override; + /// @see vcl::ITiledRenderable::hyperlinkInfoAtPosition(). + virtual OUString hyperlinkInfoAtPosition(int x, int y) override; + /// @see vcl::ITiledRenderable::getSelection(). virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index aab1e6a0e81f..66f805b37c78 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -893,6 +893,12 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY) } } +OUString ScModelObj::hyperlinkInfoAtPosition(int /*x*/, int /*y*/) +{ + // To be implemented.. + return OUString(); +} + uno::Reference<datatransfer::XTransferable> ScModelObj::getSelection() { SolarMutexGuard aGuard; diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index e0fa051d8826..37ead03a9279 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -254,6 +254,8 @@ public: virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) override; + /// @see vcl::ITiledRenderable::hyperlinkInfoAtPosition(). + virtual OUString hyperlinkInfoAtPosition(int x, int y) override; /// @see vcl::ITiledRenderable::getSelection(). virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; /// @see vcl::ITiledRenderable::setGraphicSelection(). diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 680a1d7c6228..52c95e556561 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2707,6 +2707,12 @@ void SdXImpressDocument::setTextSelection(int nType, int nX, int nY) } } +OUString SdXImpressDocument::hyperlinkInfoAtPosition(int /*x*/, int /*y*/) +{ + // To be implemented.. + return OUString(); +} + uno::Reference<datatransfer::XTransferable> SdXImpressDocument::getSelection() { SolarMutexGuard aGuard; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 4fce95eda9ec..65728f403e15 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -445,6 +445,8 @@ public: virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) override; + /// @see vcl::ITiledRenderable::hyperlinkInfoAtPosition(). + virtual OUString hyperlinkInfoAtPosition(int x, int y) override; /// @see vcl::ITiledRenderable::getSelection(). virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; /// @see vcl::ITiledRenderable::setGraphicSelection(). diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 5b7e3533fbe6..7dc4f1ccdeeb 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3711,6 +3711,11 @@ void SwXTextDocument::setTextSelection(int nType, int nX, int nY) } } +OUString SwXTextDocument::hyperlinkInfoAtPosition(int x, int y) +{ + return OUString::createFromAscii(std::to_string(x + y)); +} + uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection() { SolarMutexGuard aGuard;
