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 a4f3b97e506f38e0c43d6fbf1192cc523750a9fd
Author:     Gökay Şatır <gokaysa...@collabora.com>
AuthorDate: Tue Nov 28 14:32:59 2023 +0300
Commit:     Gökay ŞATIR <gokaysa...@collabora.com>
CommitDate: Tue Dec 19 15:22:07 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 <gokaysa...@collabora.com>
    Change-Id: I886ea22a7097aac73ade0da78a88ddfc95ad819c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160022
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 65d6a4231960..ea572c8e8a41 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3734,8 +3734,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 8855e9a60ed2..3491dd6323f5 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1160,6 +1160,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,
@@ -1445,6 +1448,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;
@@ -4732,6 +4736,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 9879d8ff5dbf..6f2c0a1aa8df 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -361,6 +361,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 9b76eb11200e..cc018d1c6dbd 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 63cce6873057..dd1f6a2b1ef1 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -891,6 +891,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 a2fe9415afa4..0a59fe6f5a46 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 6fc250ec8895..cfc6ec8266b5 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2701,6 +2701,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 01619df1d382..e13ddde2c299 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -420,6 +420,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 34697711355a..1c588d2b3298 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3777,6 +3777,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;

Reply via email to