editeng/Library_editeng.mk                                           |    1 
 editeng/source/editeng/editview.cxx                                  |   34 
+++++++
 editeng/source/misc/urlfieldhelper.cxx                               |   47 
++++++++++
 editeng/source/outliner/outlvw.cxx                                   |   10 ++
 include/LibreOfficeKit/LibreOfficeKitEnums.h                         |    7 -
 include/editeng/editview.hxx                                         |    4 
 include/editeng/outliner.hxx                                         |    4 
 include/editeng/urlfieldhelper.hxx                                   |   28 
+++++
 include/svx/svxids.hrc                                               |    2 
 include/vcl/unohelp2.hxx                                             |    6 +
 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu |    5 +
 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu  |    5 -
 sc/sdi/drtxtob.sdi                                                   |    1 
 sc/sdi/editsh.sdi                                                    |    2 
 sc/source/ui/drawfunc/drtxtob.cxx                                    |   19 
+++-
 sc/source/ui/view/editsh.cxx                                         |   33 
+++++--
 sc/uiconfig/scalc/popupmenu/celledit.xml                             |    1 
 sc/uiconfig/scalc/popupmenu/drawtext.xml                             |    1 
 sd/sdi/_drvwsh.sdi                                                   |    5 +
 sd/source/ui/view/drviews2.cxx                                       |   31 
++++++
 sd/source/ui/view/drviews7.cxx                                       |    3 
 sd/uiconfig/sdraw/popupmenu/drawtext.xml                             |    1 
 sd/uiconfig/simpress/popupmenu/drawtext.xml                          |    1 
 svx/sdi/svx.sdi                                                      |   17 +++
 sw/sdi/_textsh.sdi                                                   |    2 
 sw/sdi/drwtxtsh.sdi                                                  |    8 +
 sw/sdi/swriter.sdi                                                   |   18 ---
 sw/source/uibase/shells/drwtxtex.cxx                                 |   20 
++++
 sw/source/uibase/shells/textsh1.cxx                                  |   30 
+++++-
 sw/uiconfig/sglobal/popupmenu/drawtext.xml                           |    2 
 sw/uiconfig/swform/popupmenu/drawtext.xml                            |    2 
 sw/uiconfig/swreport/popupmenu/drawtext.xml                          |    2 
 sw/uiconfig/swriter/popupmenu/drawtext.xml                           |    2 
 sw/uiconfig/swxform/popupmenu/drawtext.xml                           |    2 
 vcl/source/app/unohelp2.cxx                                          |   13 ++
 35 files changed, 325 insertions(+), 44 deletions(-)

New commits:
commit ecbfd8963ce5b8459c00da589216ecf78d99a7f8
Author:     gokaysatir <gokaysa...@collabora.com>
AuthorDate: Tue Sep 22 13:00:44 2020 +0300
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Oct 6 08:28:20 2020 +0200

    Online: Copy hyperlink location. / Core side.
    
    Payload format is added to LOK_CALLBACK_CLIPBOARD_CHANGED.
    Clipboard changed event is not fired when "copy hyperlink location" command 
is issued.
    So i added a call to LOK_CALLBACK_CLIPBOARD_CHANGED inside 
TextDataObject::CopyStringTo function.
    
    Change-Id: I8157572288da88b5522662e13abe151ef8548b34
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103164
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103729
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index 87e23b8628da..4d72c918523c 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -97,6 +97,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
     editeng/source/misc/swafopt \
     editeng/source/misc/txtrange \
     editeng/source/misc/unolingu \
+    editeng/source/misc/urlfieldhelper \
     editeng/source/outliner/outleeng \
     editeng/source/outliner/outlin2 \
     editeng/source/outliner/outliner \
diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index aa39a3ce9716..6a3db26c8838 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1293,6 +1293,40 @@ const SvxFieldItem* EditView::GetFieldAtSelection() const
     return nullptr;
 }
 
+void EditView::SelectFieldAtCursor()
+{
+    const SvxFieldItem* pFieldItem = GetFieldAtSelection();
+    if (pFieldItem)
+    {
+        // Make sure the whole field is selected
+        ESelection aSel = GetSelection();
+        if (aSel.nStartPos == aSel.nEndPos)
+        {
+            aSel.nEndPos++;
+            SetSelection(aSel);
+        }
+    }
+    if (!pFieldItem)
+    {
+        // Cursor probably behind the field - extend selection to select the 
field
+        ESelection aSel = GetSelection();
+        if (aSel.nStartPos > 0 && aSel.nStartPos == aSel.nEndPos)
+        {
+            aSel.nStartPos--;
+            SetSelection(aSel);
+        }
+    }
+}
+
+const SvxFieldData* EditView::GetFieldAtCursor() const
+{
+    const SvxFieldItem* pFieldItem = GetFieldUnderMousePointer();
+    if (!pFieldItem)
+        pFieldItem = GetFieldAtSelection();
+
+    return pFieldItem ? pFieldItem->GetField() : nullptr;
+}
+
 void EditView::SetInvalidateMore( sal_uInt16 nPixel )
 {
     pImpEditView->SetInvalidateMore( nPixel );
diff --git a/editeng/source/misc/urlfieldhelper.cxx 
b/editeng/source/misc/urlfieldhelper.cxx
new file mode 100644
index 000000000000..564bc54e781e
--- /dev/null
+++ b/editeng/source/misc/urlfieldhelper.cxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <editeng/urlfieldhelper.hxx>
+
+#include <editeng/flditem.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
+
+void URLFieldHelper::RemoveURLField(EditView& pEditView)
+{
+    pEditView.SelectFieldAtCursor();
+    const SvxFieldData* pField = pEditView.GetFieldAtCursor();
+    if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField))
+    {
+        ESelection aSel = pEditView.GetSelection();
+        
pEditView.GetEditEngine()->QuickInsertText(pUrlField->GetRepresentation(), 
aSel);
+        pEditView.Invalidate();
+    }
+}
+
+bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView)
+{
+    // tdf#128666 Make sure only URL field (or nothing) is selected
+    ESelection aSel = pEditView.GetSelection();
+    auto nSelectedParas = aSel.nEndPara - aSel.nStartPara;
+    auto nSelectedChars = aSel.nEndPos - aSel.nStartPos;
+    bool bIsValidSelection
+        = nSelectedParas == 0
+          && (nSelectedChars == 0 || nSelectedChars == 1 || nSelectedChars == 
-1);
+    if (!bIsValidSelection)
+        return false;
+
+    const SvxFieldData* pField = pEditView.GetFieldAtCursor();
+    if (dynamic_cast<const SvxURLField*>(pField))
+        return true;
+
+    return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/editeng/source/outliner/outlvw.cxx 
b/editeng/source/outliner/outlvw.cxx
index 98ca96a18fe7..17b9f33b6b9d 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1349,6 +1349,16 @@ const SvxFieldItem* OutlinerView::GetFieldAtSelection() 
const
     return pEditView->GetFieldAtSelection();
 }
 
+const SvxFieldData* OutlinerView::GetFieldAtCursor() const
+{
+    return pEditView->GetFieldAtCursor();
+}
+
+void OutlinerView::SelectFieldAtCursor()
+{
+    pEditView->SelectFieldAtCursor();
+}
+
 void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel )
 {
     pEditView->SetInvalidateMore( nPixel );
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 208ad9065950..287894fce122 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -644,10 +644,9 @@ typedef enum
      * Notification that the clipboard contents have changed.
      * Typically fired in response to copying to clipboard.
      *
-     * The payload currently is empty and it's up to the
-     * client to get the contents, if necessary. However,
-     * in the future the contents might be included for
-     * convenience.
+     * Payload is optional. When payload is empty, Online gets string from 
selected text.
+     * Payload format is JSON.
+     * Example: { "mimeType": "string", "content": "some content" }
      */
     LOK_CALLBACK_CLIPBOARD_CHANGED = 38,
 
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 1d9ceece9d59..d7dff247593d 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -31,6 +31,7 @@
 #include <vcl/cursor.hxx>
 #include <vcl/errcode.hxx>
 #include <editeng/editstat.hxx>
+#include <editeng/flditem.hxx>
 #include <svl/languageoptions.hxx>
 #include <LibreOfficeKit/LibreOfficeKitTypes.h>
 #include <editeng/editdata.hxx>
@@ -270,6 +271,9 @@ public:
     const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = 
nullptr, sal_Int32* pnPos = nullptr ) const;
 
     const SvxFieldItem* GetFieldAtSelection() const;
+    /// Select and return the field at the current cursor position
+    const SvxFieldData* GetFieldAtCursor() const;
+    void SelectFieldAtCursor();
 
     void            SetInvalidateMore( sal_uInt16 nPixel );
     sal_uInt16      GetInvalidateMore() const;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 68b13a311f36..e5c4796c5b04 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -313,6 +313,10 @@ public:
     void                InsertField( const SvxFieldItem& rFld );
     const SvxFieldItem* GetFieldUnderMousePointer() const;
     const SvxFieldItem* GetFieldAtSelection() const;
+    /// Return the field at the current cursor position or nullptr if no field 
found
+    const SvxFieldData* GetFieldAtCursor() const;
+    /// Select the field at the current cursor position
+    void SelectFieldAtCursor();
 
     /** enables bullets for the selected paragraphs if the bullets/numbering 
of the first paragraph is off
         or disables bullets/numbering for the selected paragraphs if the 
bullets/numbering of the first paragraph is on
diff --git a/include/editeng/urlfieldhelper.hxx 
b/include/editeng/urlfieldhelper.hxx
new file mode 100644
index 000000000000..9a1d53d15512
--- /dev/null
+++ b/include/editeng/urlfieldhelper.hxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+#include <editeng/editengdllapi.h>
+#include <editeng/outliner.hxx>
+#include <editeng/editview.hxx>
+
+class EDITENG_DLLPUBLIC URLFieldHelper
+{
+public:
+    static void RemoveURLField(EditView& pEditView);
+    static bool IsCursorAtURLField(const EditView& pEditView);
+    static bool IsCursorAtURLField(const OutlinerView* pOLV)
+    {
+        return pOLV && IsCursorAtURLField(pOLV->GetEditView());
+    }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 0ffe72e3bb30..7ab0eb4bab45 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -994,6 +994,8 @@ class SfxStringItem;
 
 #define SID_TOGGLE_RESOLVED_NOTES                       ( SID_SVX_START + 1189 
)
 
+#define SID_COPY_HYPERLINK_LOCATION                     ( SID_SVX_START + 1193 
)
+
 // #define SID_SHOW_SIDEBAR                                ( SID_SVX_START + 
1190 ) -> sfxsids.hrc
 // #define SID_HIDE_SIDEBAR                                ( SID_SVX_START + 
1191 ) -> sfxsids.hrc
 
diff --git a/include/vcl/unohelp2.hxx b/include/vcl/unohelp2.hxx
index 6a59541198a0..c5e042333a40 100644
--- a/include/vcl/unohelp2.hxx
+++ b/include/vcl/unohelp2.hxx
@@ -25,6 +25,9 @@
 #include <rtl/ustring.hxx>
 #include <osl/mutex.hxx>
 #include <vcl/dllapi.h>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <boost/property_tree/json_parser.hpp>
 
 namespace com { namespace sun { namespace star { namespace datatransfer { 
namespace clipboard {
     class XClipboard;
@@ -56,7 +59,8 @@ namespace vcl { namespace unohelper {
         /// copies a given string to a given clipboard
         static  void    CopyStringTo(
             const OUString& rContent,
-            const css::uno::Reference< 
css::datatransfer::clipboard::XClipboard >& rxClipboard
+            const css::uno::Reference< 
css::datatransfer::clipboard::XClipboard >& rxClipboard,
+            std::function<void (int, const char*)> *callback = nullptr
         );
     };
 
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index a9c962b136e1..8f5af73972cf 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -3250,6 +3250,11 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:CopyHyperlinkLocation" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Copy Hyperlink Location</value>
+        </prop>
+      </node>
       <node oor:name=".uno:OpenSmartTagMenuOnCursor" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Smart Tags</value>
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index 6ef6fcd224e7..663ee9c81d28 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -441,11 +441,6 @@
           <value xml:lang="en-US">Remove Hyperlink</value>
         </prop>
       </node>
-      <node oor:name=".uno:CopyHyperlinkLocation" oor:op="replace">
-        <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Copy Hyperlink Location</value>
-        </prop>
-      </node>
       <node oor:name=".uno:InsertBookmark" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Bookmar~k...</value>
diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi
index 1cf966be6ffa..3f42f7d05550 100644
--- a/sc/sdi/drtxtob.sdi
+++ b/sc/sdi/drtxtob.sdi
@@ -130,6 +130,7 @@ interface TableDrawText
     SID_HYPERLINK_SETLINK   [ ExecMethod = Execute; Export = FALSE; ]
     SID_HYPERLINK_GETLINK   [ StateMethod = GetState; Export = FALSE; ]
         SID_OPEN_HYPERLINK      [ ExecMethod = Execute; StateMethod = 
GetState; Export = FALSE; ]
+    SID_COPY_HYPERLINK_LOCATION [ ExecMethod = Execute; StateMethod = 
GetState; Export = FALSE; ]
     SID_ENABLE_HYPHENATION  [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
 
     SID_TEXTDIRECTION_LEFT_TO_RIGHT     [ ExecMethod = Execute; StateMethod = 
GetAttrState; Export = FALSE; ]
diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi
index f854fe897191..9cda7e3f5dd4 100644
--- a/sc/sdi/editsh.sdi
+++ b/sc/sdi/editsh.sdi
@@ -79,7 +79,7 @@ interface TableText
     SID_HYPERLINK_SETLINK   [ ExecMethod = Execute; Export = FALSE; ]
     SID_HYPERLINK_GETLINK   [ StateMethod = GetState; Export = FALSE; ]
         SID_OPEN_HYPERLINK      [ ExecMethod = Execute; StateMethod = 
GetState; Export = FALSE; ]
-
+    SID_COPY_HYPERLINK_LOCATION [ ExecMethod = Execute; StateMethod = 
GetState; Export = FALSE; ]
     SID_TRANSLITERATE_SENTENCE_CASE [ ExecMethod = ExecuteTrans; StateMethod = 
GetState;  Export = FALSE; ]
     SID_TRANSLITERATE_TITLE_CASE    [ ExecMethod = ExecuteTrans; StateMethod = 
GetState;  Export = FALSE; ]
     SID_TRANSLITERATE_TOGGLE_CASE   [ ExecMethod = ExecuteTrans; StateMethod = 
GetState;  Export = FALSE; ]
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 771bac8ceb19..550e64b4516c 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -60,6 +60,7 @@
 #include <svx/svxdlg.hxx>
 #include <svx/dialogs.hrc>
 #include <vcl/EnumContext.hxx>
+#include <vcl/unohelp2.hxx>
 
 #include <sc.hrc>
 #include <globstr.hrc>
@@ -323,6 +324,18 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
             }
             break;
 
+        case SID_COPY_HYPERLINK_LOCATION:
+            {
+                const SvxFieldData* pField = pOutView->GetFieldAtCursor();
+                if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
+                {
+                    uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
+                        = pOutView->GetWindow()->GetClipboard();
+                    
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
+                }
+            }
+            break;
+
         case SID_ENABLE_HYPHENATION:
         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
@@ -401,7 +414,8 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
         rSet.Put(aHLinkItem);
     }
 
-    if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SfxItemState::UNKNOWN )
+    if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SfxItemState::UNKNOWN
+        || rSet.GetItemState(SID_COPY_HYPERLINK_LOCATION) != 
SfxItemState::UNKNOWN)
     {
         SdrView* pView = pViewData->GetScDrawView();
         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
@@ -416,7 +430,10 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
             }
         }
         if( !bEnable )
+        {
             rSet.DisableItem( SID_OPEN_HYPERLINK );
+            rSet.DisableItem( SID_COPY_HYPERLINK_LOCATION );
+        }
     }
 
     if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != 
SfxItemState::UNKNOWN )
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 2eb92e18ce4e..f03ff89f10e1 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -55,6 +55,7 @@
 #include <svl/whiter.hxx>
 #include <sot/formats.hxx>
 #include <vcl/transfer.hxx>
+#include <vcl/unohelp2.hxx>
 #include <svl/stritem.hxx>
 #include <editeng/colritem.hxx>
 
@@ -614,15 +615,34 @@ void ScEditShell::Execute( SfxRequest& rReq )
                     }
                 }
             }
-            break;
+        break;
 
-            case SID_OPEN_HYPERLINK:
+        case SID_OPEN_HYPERLINK:
+            {
+                const SvxURLField* pURLField = GetURLField();
+                if ( pURLField )
+                    ScGlobal::OpenURL( pURLField->GetURL(), 
pURLField->GetTargetFrame(), /*BypassCtrlClickSecurity:*/ true );
+                return;
+            }
+        break;
+        case SID_COPY_HYPERLINK_LOCATION:
+        {
+                const SvxFieldData* pField = pEditView->GetFieldAtCursor();
+                if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
                 {
-                    const SvxURLField* pURLField = GetURLField();
-                    if ( pURLField )
-                        ScGlobal::OpenURL( pURLField->GetURL(), 
pURLField->GetTargetFrame(), /*BypassCtrlClickSecurity:*/ true );
-                    return;
+                    uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
+                        = pEditView->GetWindow()->GetClipboard();
+
+                    if (comphelper::LibreOfficeKit::isActive())
+                    {
+                        std::function<void (int, const char*)> callback = [&] 
(int callbackType, const char* text) { 
pViewData->GetViewShell()->libreOfficeKitViewCallback(callbackType, text); } ;
+                        
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, 
&callback);
+                    }
+                    else
+                        
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, 
nullptr);
                 }
+            }
+        break;
 
         case FN_INSERT_SOFT_HYPHEN:
             lclInsertCharacter( pTableView, pTopView, CHAR_SHY );
@@ -745,6 +765,7 @@ void ScEditShell::GetState( SfxItemSet& rSet )
                 break;
 
             case SID_OPEN_HYPERLINK:
+            case SID_COPY_HYPERLINK_LOCATION:
                 {
                     if ( !GetURLField() )
                         rSet.DisableItem( nWhich );
diff --git a/sc/uiconfig/scalc/popupmenu/celledit.xml 
b/sc/uiconfig/scalc/popupmenu/celledit.xml
index 27e7efe4e02d..bc111a951f49 100644
--- a/sc/uiconfig/scalc/popupmenu/celledit.xml
+++ b/sc/uiconfig/scalc/popupmenu/celledit.xml
@@ -26,6 +26,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:FontDialog"/>
   <menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
diff --git a/sc/uiconfig/scalc/popupmenu/drawtext.xml 
b/sc/uiconfig/scalc/popupmenu/drawtext.xml
index b070b3231df3..46aa721180cf 100644
--- a/sc/uiconfig/scalc/popupmenu/drawtext.xml
+++ b/sc/uiconfig/scalc/popupmenu/drawtext.xml
@@ -24,6 +24,7 @@
   <menu:menuitem menu:id=".uno:ParagraphDialog"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:StandardTextAttributes"/>
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index d7c836cc5b58..c6165d1e0456 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -2262,6 +2262,11 @@ interface DrawView
         ExecMethod = FuTemporary ;
         StateMethod = GetMenuState ;
     ]
+    SID_COPY_HYPERLINK_LOCATION // ole : no, status : ?
+    [
+        ExecMethod = FuTemporary ;
+        StateMethod = GetMenuState ;
+    ]
     SID_HIDE_LAST_LEVEL // ole : no, status : ?
     [
         ExecMethod = FuTemporary ;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 2806de91bf46..e49add9e34e5 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -100,6 +100,7 @@
 
 #include <vcl/graph.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/unohelp2.hxx>
 #include <vcl/waitobj.hxx>
 #include <vcl/weld.hxx>
 
@@ -2210,6 +2211,36 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         }
         break;
 
+        case SID_COPY_HYPERLINK_LOCATION:
+        {
+            OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
+            if ( pOutView )
+            {
+                const SvxFieldData* pField = pOutView->GetFieldAtCursor();
+                if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
+                {
+                    uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
+                        = pOutView->GetWindow()->GetClipboard();
+
+                    if (comphelper::LibreOfficeKit::isActive())
+                    {
+                        std::function<void (int, const char*)> callback = [&] 
(int callbackType, const char* text)
+                        {
+                            SfxViewFrame* pFrame = GetViewFrame();
+                            
pFrame->GetViewShell()->libreOfficeKitViewCallback(callbackType, text);
+                        };
+                        
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, 
&callback);
+                    }
+                    else
+                        
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
+                }
+            }
+
+            Cancel();
+            rReq.Done ();
+        }
+        break;
+
         case SID_HYPERLINK_SETLINK:
         {
             const SfxItemSet* pReqArgs = rReq.GetArgs();
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 318a36af8856..bff0ceea6f29 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1507,7 +1507,10 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
         rSet.DisableItem( SID_EDIT_HYPERLINK );
 
     if ( bDisableEditHyperlink )
+    {
         rSet.DisableItem( SID_OPEN_HYPERLINK );
+        rSet.DisableItem( SID_COPY_HYPERLINK_LOCATION );
+    }
 
     //fdo#78151 enable show next level/hide last level if editing a master page
     //PRESOBJ_OUTLINE object and the current selection allow that to happen
diff --git a/sd/uiconfig/sdraw/popupmenu/drawtext.xml 
b/sd/uiconfig/sdraw/popupmenu/drawtext.xml
index 0b47863183e6..75fd87f33834 100644
--- a/sd/uiconfig/sdraw/popupmenu/drawtext.xml
+++ b/sd/uiconfig/sdraw/popupmenu/drawtext.xml
@@ -19,6 +19,7 @@
   <menu:menuitem menu:id=".uno:ParagraphDialog"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:SetDefault"/>
diff --git a/sd/uiconfig/simpress/popupmenu/drawtext.xml 
b/sd/uiconfig/simpress/popupmenu/drawtext.xml
index 53d8910b4d8c..f8d24606bd80 100644
--- a/sd/uiconfig/simpress/popupmenu/drawtext.xml
+++ b/sd/uiconfig/simpress/popupmenu/drawtext.xml
@@ -18,6 +18,7 @@
   <menu:menuitem menu:id=".uno:ParagraphDialog"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:SetDefault"/>
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 2d8ef16ecae4..04a0908e89a0 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12088,6 +12088,23 @@ SfxVoidItem SignSignatureLine SID_SIGN_SIGNATURELINE
     GroupId = SfxGroupId::Edit;
 ]
 
+SfxVoidItem CopyHyperlinkLocation SID_COPY_HYPERLINK_LOCATION
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Edit;
+]
+
 SfxVoidItem SpellCheckIgnore SID_SPELLCHECK_IGNORE
 (SfxStringItem Type FN_PARAM_1)
 [
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index ad353ad5e099..fe6c9b9f52ef 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -347,7 +347,7 @@ interface BaseText
         StateMethod = GetState;
         DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
     ]
-    FN_COPY_HYPERLINK_LOCATION
+    SID_COPY_HYPERLINK_LOCATION
     [
         ExecMethod = Execute ;
         StateMethod = GetState;
diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi
index a8e79c298b4f..c9aa46977015 100644
--- a/sw/sdi/drwtxtsh.sdi
+++ b/sw/sdi/drwtxtsh.sdi
@@ -540,6 +540,14 @@ interface TextDrawText
     [
         StateMethod = StateInsert ;
     ]
+
+    SID_COPY_HYPERLINK_LOCATION
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
+
     SID_TRANSLITERATE_SENTENCE_CASE
     [
         ExecMethod = ExecTransliteration;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 68fe312b9105..fc7b2903512b 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7400,24 +7400,6 @@ SfxVoidItem RemoveHyperlink FN_REMOVE_HYPERLINK
     GroupId = SfxGroupId::Edit;
 ]
 
-SfxVoidItem CopyHyperlinkLocation FN_COPY_HYPERLINK_LOCATION
-[
-    AutoUpdate = FALSE,
-    FastCall = FALSE,
-    ReadOnlyDoc = FALSE,
-    Toggle = FALSE,
-    Container = FALSE,
-    RecordAbsolute = FALSE,
-    RecordPerSet;
-    Asynchron;
-
-
-    AccelConfig = TRUE,
-    MenuConfig = TRUE,
-    ToolBoxConfig = TRUE,
-    GroupId = SfxGroupId::Edit;
-]
-
 SfxVoidItem NavigateBack FN_NAVIGATION_BACK
 [
     AutoUpdate = TRUE,
diff --git a/sw/source/uibase/shells/drwtxtex.cxx 
b/sw/source/uibase/shells/drwtxtex.cxx
index 93b813650812..2221e68a6767 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -45,6 +45,7 @@
 #include <editeng/contouritem.hxx>
 #include <editeng/postitem.hxx>
 #include <editeng/frmdiritem.hxx>
+#include <editeng/urlfieldhelper.hxx>
 #include <svx/svdoutl.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <svl/whiter.hxx>
@@ -70,6 +71,7 @@
 #include <vcl/window.hxx>
 #include <editeng/editview.hxx>
 #include <vcl/outdev.hxx>
+#include <vcl/unohelp2.hxx>
 #include <editeng/hyphenzoneitem.hxx>
 #include <tools/diagnose_ex.h>
 
@@ -521,6 +523,18 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
         }
         break;
 
+        case SID_COPY_HYPERLINK_LOCATION:
+        {
+            const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+            if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
+            {
+                uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
+                    = GetView().GetEditWin().GetClipboard();
+                
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
+            }
+        }
+        break;
+
         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
             // Shell switch!
@@ -909,6 +923,12 @@ ASK_ESCAPE:
                 rSet.DisableItem(nWhich);
         }
         break;
+        case SID_COPY_HYPERLINK_LOCATION:
+        {
+            if (!URLFieldHelper::IsCursorAtURLField(pOLV))
+                rSet.DisableItem(nWhich);
+        }
+        break;
         default:
             nSlotId = 0;                // don't know this slot
             break;
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index b3fc13963a99..9a032880ea18 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -127,6 +127,7 @@
 #include <bookmrk.hxx>
 #include <linguistic/misc.hxx>
 #include <editeng/splwrap.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 using namespace ::com::sun::star;
 using namespace com::sun::star::beans;
@@ -1327,7 +1328,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
     }
     break;
     case SID_OPEN_HYPERLINK:
-    case FN_COPY_HYPERLINK_LOCATION:
+    case SID_COPY_HYPERLINK_LOCATION:
     {
         SfxItemSet aSet(GetPool(),
                         svl::Items<RES_TXTATR_INETFMT,
@@ -1336,12 +1337,18 @@ void SwTextShell::Execute(SfxRequest &rReq)
         if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT ))
         {
             const SwFormatINetFormat& rINetFormat = dynamic_cast<const 
SwFormatINetFormat&>( aSet.Get(RES_TXTATR_INETFMT) );
-            if( nSlot == FN_COPY_HYPERLINK_LOCATION )
+            if( nSlot == SID_COPY_HYPERLINK_LOCATION )
             {
+                OUString hyperlinkLocation = rINetFormat.GetValue();
                 ::uno::Reference< datatransfer::clipboard::XClipboard > 
xClipboard = GetView().GetEditWin().GetClipboard();
-                vcl::unohelper::TextDataObject::CopyStringTo(
-                        rINetFormat.GetValue(),
-                        xClipboard );
+
+                if (comphelper::LibreOfficeKit::isActive())
+                {
+                    std::function<void (int, const char*)> callback = [&] (int 
callbackType, const char* text) { 
GetView().libreOfficeKitViewCallback(callbackType, text); } ;
+                    
vcl::unohelper::TextDataObject::CopyStringTo(hyperlinkLocation, xClipboard, 
&callback );
+                }
+                else
+                    
vcl::unohelper::TextDataObject::CopyStringTo(hyperlinkLocation, xClipboard, 
nullptr );
             }
             else
                 rWrtSh.ClickToINetAttr(rINetFormat);
@@ -1939,7 +1946,18 @@ void SwTextShell::GetState( SfxItemSet &rSet )
                     rSet.Put(SfxBoolItem( nWhich, nullptr != 
GetView().GetViewFrame()->GetChildWindow( nWhich ) ));
                 }
                 break;
-
+            case SID_COPY_HYPERLINK_LOCATION:
+                {
+                    SfxItemSet aSet(GetPool(),
+                        svl::Items<RES_TXTATR_INETFMT,
+                        RES_TXTATR_INETFMT>{});
+                    rSh.GetCurAttr(aSet);
+                    if(SfxItemState::SET > aSet.GetItemState( 
RES_TXTATR_INETFMT ) || rSh.HasReadonlySel())
+                    {
+                        rSet.DisableItem(nWhich);
+                    }
+                }
+            break;
             case FN_EDIT_HYPERLINK:
             case FN_COPY_HYPERLINK_LOCATION:
                 {
diff --git a/sw/uiconfig/sglobal/popupmenu/drawtext.xml 
b/sw/uiconfig/sglobal/popupmenu/drawtext.xml
index e13990ca0af9..d2ee8e024236 100644
--- a/sw/uiconfig/sglobal/popupmenu/drawtext.xml
+++ b/sw/uiconfig/sglobal/popupmenu/drawtext.xml
@@ -25,5 +25,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
+  <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
 </menu:menupopup>
diff --git a/sw/uiconfig/swform/popupmenu/drawtext.xml 
b/sw/uiconfig/swform/popupmenu/drawtext.xml
index e13990ca0af9..d2ee8e024236 100644
--- a/sw/uiconfig/swform/popupmenu/drawtext.xml
+++ b/sw/uiconfig/swform/popupmenu/drawtext.xml
@@ -25,5 +25,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
+  <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
 </menu:menupopup>
diff --git a/sw/uiconfig/swreport/popupmenu/drawtext.xml 
b/sw/uiconfig/swreport/popupmenu/drawtext.xml
index e13990ca0af9..d2ee8e024236 100644
--- a/sw/uiconfig/swreport/popupmenu/drawtext.xml
+++ b/sw/uiconfig/swreport/popupmenu/drawtext.xml
@@ -25,5 +25,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
+  <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
 </menu:menupopup>
diff --git a/sw/uiconfig/swriter/popupmenu/drawtext.xml 
b/sw/uiconfig/swriter/popupmenu/drawtext.xml
index e13990ca0af9..d2ee8e024236 100644
--- a/sw/uiconfig/swriter/popupmenu/drawtext.xml
+++ b/sw/uiconfig/swriter/popupmenu/drawtext.xml
@@ -25,5 +25,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
+  <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
 </menu:menupopup>
diff --git a/sw/uiconfig/swxform/popupmenu/drawtext.xml 
b/sw/uiconfig/swxform/popupmenu/drawtext.xml
index e13990ca0af9..d2ee8e024236 100644
--- a/sw/uiconfig/swxform/popupmenu/drawtext.xml
+++ b/sw/uiconfig/swxform/popupmenu/drawtext.xml
@@ -25,5 +25,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
+  <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
 </menu:menupopup>
diff --git a/vcl/source/app/unohelp2.cxx b/vcl/source/app/unohelp2.cxx
index 832156788215..5cf0744467e5 100644
--- a/vcl/source/app/unohelp2.cxx
+++ b/vcl/source/app/unohelp2.cxx
@@ -40,7 +40,8 @@ namespace vcl { namespace unohelper {
     }
 
     void TextDataObject::CopyStringTo( const OUString& rContent,
-        const uno::Reference< datatransfer::clipboard::XClipboard >& 
rxClipboard )
+        const uno::Reference< datatransfer::clipboard::XClipboard >& 
rxClipboard,
+        std::function<void (int, const char*)> *callback)
     {
         SAL_WARN_IF( !rxClipboard.is(), "vcl", "TextDataObject::CopyStringTo: 
invalid clipboard!" );
         if ( !rxClipboard.is() )
@@ -56,6 +57,16 @@ namespace vcl { namespace unohelper {
             uno::Reference< datatransfer::clipboard::XFlushableClipboard > 
xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
+
+            if (callback != nullptr && comphelper::LibreOfficeKit::isActive())
+            {
+                boost::property_tree::ptree aTree;
+                aTree.put("content", rContent);
+                aTree.put("mimeType", "text/plain");
+                std::stringstream aStream;
+                boost::property_tree::write_json(aStream, aTree);
+                (*callback)(LOK_CALLBACK_CLIPBOARD_CHANGED, 
aStream.str().c_str());
+            }
         }
         catch( const uno::Exception& )
         {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to