include/vcl/jsdialog/executor.hxx |    5 +++++
 include/vcl/toolkit/fixed.hxx     |    2 +-
 include/vcl/weld.hxx              |    2 ++
 include/vcl/wintypes.hxx          |    3 ++-
 vcl/jsdialog/executor.cxx         |   12 ++++++++++++
 vcl/source/control/fixed.cxx      |    4 ++--
 vcl/source/control/fixedhyper.cxx |    2 +-
 vcl/source/window/window.cxx      |    1 +
 8 files changed, 26 insertions(+), 5 deletions(-)

New commits:
commit 6f7acc14866136f22d26cae1e8656d8719b58300
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu May 2 14:32:52 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri May 3 07:13:22 2024 +0200

    jsdialog: support for LinkButton as an independent widget
    
    This adds support for the (weld)LinkButton (FixedHyperlink) as an
    independent widget and not part of FixedText to jsdialog. In addition
    add "click" event that triggers activate_link method.
    
    Change-Id: Id110b4a0fd60fc24592e00235243783d46ae4575
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166898
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/include/vcl/jsdialog/executor.hxx 
b/include/vcl/jsdialog/executor.hxx
index b60c035d587a..ef667a70ce26 100644
--- a/include/vcl/jsdialog/executor.hxx
+++ b/include/vcl/jsdialog/executor.hxx
@@ -126,6 +126,11 @@ public:
     {
         rNotebook.m_aLeavePageHdl.Call(rPage);
     }
+
+    static bool activate_link(weld::LinkButton& rLinkButton)
+    {
+        return rLinkButton.signal_activate_link();
+    }
 };
 
 namespace jsdialog
diff --git a/include/vcl/toolkit/fixed.hxx b/include/vcl/toolkit/fixed.hxx
index f4c410c974af..313e717c5a2f 100644
--- a/include/vcl/toolkit/fixed.hxx
+++ b/include/vcl/toolkit/fixed.hxx
@@ -53,7 +53,7 @@ protected:
     virtual vcl::Window* getAccessibleRelationLabelFor() const override;
 
 public:
-    explicit        FixedText( vcl::Window* pParent, WinBits nStyle = 0 );
+    explicit FixedText(vcl::Window* pParent, WinBits nStyle = 0, WindowType 
eType = WindowType::FIXEDTEXT);
     virtual         ~FixedText() override;
     virtual void    dispose() override;
 
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 8b9495e9e4e8..bd394dc5d3bc 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1665,6 +1665,8 @@ class VCL_DLLPUBLIC RadioButton : virtual public 
CheckButton
 
 class VCL_DLLPUBLIC LinkButton : virtual public Widget
 {
+    friend class ::LOKTrigger;
+
     Link<LinkButton&, bool> m_aActivateLinkHdl;
 
 protected:
diff --git a/include/vcl/wintypes.hxx b/include/vcl/wintypes.hxx
index c025e83b0afe..d0d6208d735b 100644
--- a/include/vcl/wintypes.hxx
+++ b/include/vcl/wintypes.hxx
@@ -99,7 +99,8 @@ enum class WindowType : sal_uInt16
     HEADERBAR            ,
     VERTICALTABCONTROL   ,
     PROGRESSBAR          ,
-    LAST                 = PROGRESSBAR,
+    LINK_BUTTON,
+    LAST = LINK_BUTTON,
     // only used in vclxtoolkit.cxx
     TOOLKIT_FRAMEWINDOW        = 0x1000,
     TOOLKIT_SYSTEMCHILDWINDOW  = 0x1001,
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 7c36eb3bdc1e..3eebd350ef88 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -164,6 +164,18 @@ bool ExecuteAction(const OUString& nWindowId, const 
OUString& rWidget, StringMap
                 }
             }
         }
+        else if (sControlType == "linkbutton")
+        {
+            auto pButton = dynamic_cast<weld::LinkButton*>(pWidget);
+            if (pButton)
+            {
+                if (sAction == "click")
+                {
+                    LOKTrigger::activate_link(*pButton);
+                    return true;
+                }
+            }
+        }
         else if (sControlType == "menubutton")
         {
             auto pButton = dynamic_cast<weld::MenuButton*>(pWidget);
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index 068332e5b610..ce5bbf486c85 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -94,8 +94,8 @@ const Color& FixedText::GetCanonicalTextColor( const 
StyleSettings& _rStyle ) co
     return _rStyle.GetLabelTextColor();
 }
 
-FixedText::FixedText( vcl::Window* pParent, WinBits nStyle )
-    : Control(WindowType::FIXEDTEXT)
+FixedText::FixedText(vcl::Window* pParent, WinBits nStyle, WindowType eType)
+    : Control(eType)
     , m_nMaxWidthChars(-1)
     , m_nMinWidthChars(-1)
     , m_pMnemonicWindow(nullptr)
diff --git a/vcl/source/control/fixedhyper.cxx 
b/vcl/source/control/fixedhyper.cxx
index 5b4960d92f86..5c8e9e4a29d1 100644
--- a/vcl/source/control/fixedhyper.cxx
+++ b/vcl/source/control/fixedhyper.cxx
@@ -34,7 +34,7 @@
 using namespace css;
 
 FixedHyperlink::FixedHyperlink(vcl::Window* pParent, WinBits nWinStyle)
-    : FixedText(pParent, nWinStyle)
+    : FixedText(pParent, nWinStyle, WindowType::LINK_BUTTON)
     , m_nTextLen(0)
     , m_aOldPointer(PointerStyle::Arrow)
 {
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 3dd289ddb1b3..06a60a209483 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3352,6 +3352,7 @@ std::string_view windowTypeName(WindowType nWindowType)
         case WindowType::HEADERBAR:                 return "headerbar";
         case WindowType::VERTICALTABCONTROL:        return 
"verticaltabcontrol";
         case WindowType::PROGRESSBAR:               return "progressbar";
+        case WindowType::LINK_BUTTON:               return "linkbutton";
 
         // nothing to do here, but for completeness
         case WindowType::TOOLKIT_FRAMEWINDOW:       return 
"toolkit_framewindow";

Reply via email to