sc/sdi/drtxtob.sdi                       |    1 +
 sc/sdi/editsh.sdi                        |    1 +
 sc/source/ui/drawfunc/drtxtob.cxx        |   15 +++++++++++++++
 sc/source/ui/view/editsh.cxx             |   13 +++++++++++++
 sc/uiconfig/scalc/popupmenu/celledit.xml |    1 +
 sc/uiconfig/scalc/popupmenu/drawtext.xml |    1 +
 6 files changed, 32 insertions(+)

New commits:
commit a8b400ee8f9a7c80905afe147b7c9b991c6742cd
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Tue Aug 6 12:27:03 2019 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
CommitDate: Tue Aug 6 13:33:49 2019 +0200

    Add "Copy hyperlink location" to sc context menus
    
    Change-Id: I93840c7a7e6bbbba0c5dedb6fa460a46d1785e80
    Reviewed-on: https://gerrit.libreoffice.org/77018
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>

diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi
index 89be1b24c3ee..bbc68728c947 100644
--- a/sc/sdi/drtxtob.sdi
+++ b/sc/sdi/drtxtob.sdi
@@ -131,6 +131,7 @@ interface TableDrawText
     SID_HYPERLINK_GETLINK   [ StateMethod = GetState; Export = FALSE; ]
     SID_OPEN_HYPERLINK      [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
     SID_EDIT_HYPERLINK      [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
+    SID_COPY_HYPERLINK_LOCATION [ ExecMethod = Execute; StateMethod = 
GetState; Export = FALSE; ]
     SID_REMOVE_HYPERLINK    [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
     SID_ENABLE_HYPHENATION  [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
 
diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi
index 5718fc63407e..934e6e8a6535 100644
--- a/sc/sdi/editsh.sdi
+++ b/sc/sdi/editsh.sdi
@@ -80,6 +80,7 @@ interface TableText
     SID_HYPERLINK_GETLINK   [ StateMethod = GetState; Export = FALSE; ]
     SID_OPEN_HYPERLINK      [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
     SID_EDIT_HYPERLINK      [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
+    SID_COPY_HYPERLINK_LOCATION [ ExecMethod = Execute; StateMethod = 
GetState; Export = FALSE; ]
     SID_REMOVE_HYPERLINK      [ ExecMethod = Execute; StateMethod = GetState; 
Export = FALSE; ]
 
     SID_TRANSLITERATE_SENTENCE_CASE [ ExecMethod = ExecuteTrans; StateMethod = 
GetState;  Export = FALSE; ]
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 58943add8cbd..334f1933a88b 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -58,6 +58,7 @@
 
 #include <svx/svxdlg.hxx>
 #include <vcl/EnumContext.hxx>
+#include <vcl/unohelp2.hxx>
 
 #include <sc.hrc>
 #include <globstr.hrc>
@@ -310,6 +311,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_REMOVE_HYPERLINK:
             {
                 URLFieldHelper::RemoveURLField(pOutliner, pOutView);
@@ -393,6 +406,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
 
     if (rSet.GetItemState(SID_OPEN_HYPERLINK) != SfxItemState::UNKNOWN
         || rSet.GetItemState(SID_EDIT_HYPERLINK) != SfxItemState::UNKNOWN
+        || rSet.GetItemState(SID_COPY_HYPERLINK_LOCATION) != 
SfxItemState::UNKNOWN
         || rSet.GetItemState(SID_REMOVE_HYPERLINK) != SfxItemState::UNKNOWN)
     {
         SdrView* pView = pViewData->GetScDrawView();
@@ -401,6 +415,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
         {
             rSet.DisableItem( SID_OPEN_HYPERLINK );
             rSet.DisableItem( SID_EDIT_HYPERLINK );
+            rSet.DisableItem( SID_COPY_HYPERLINK_LOCATION );
             rSet.DisableItem( SID_REMOVE_HYPERLINK );
         }
     }
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 7140f7499c06..3d8cf4c88312 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -56,6 +56,7 @@
 #include <svl/whiter.hxx>
 #include <sot/formats.hxx>
 #include <vcl/transfer.hxx>
+#include <vcl/unohelp2.hxx>
 #include <svl/stritem.hxx>
 
 #include <editsh.hxx>
@@ -636,6 +637,17 @@ void ScEditShell::Execute( SfxRequest& rReq )
                     SID_HYPERLINK_DIALOG);
             }
         break;
+        case SID_COPY_HYPERLINK_LOCATION:
+            {
+                const SvxFieldData* pField = pEditView->GetFieldAtCursor();
+                if (const SvxURLField* pURLField = dynamic_cast<const 
SvxURLField*>(pField))
+                {
+                    uno::Reference<datatransfer::clipboard::XClipboard> 
xClipboard
+                        = pEditView->GetWindow()->GetClipboard();
+                    
vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
+                }
+            }
+        break;
         case SID_REMOVE_HYPERLINK:
             {
                 // Ensure the field is selected first
@@ -775,6 +787,7 @@ void ScEditShell::GetState( SfxItemSet& rSet )
 
             case SID_OPEN_HYPERLINK:
             case SID_EDIT_HYPERLINK:
+            case SID_COPY_HYPERLINK_LOCATION:
             case SID_REMOVE_HYPERLINK:
                 {
                     if ( !GetURLField() )
diff --git a/sc/uiconfig/scalc/popupmenu/celledit.xml 
b/sc/uiconfig/scalc/popupmenu/celledit.xml
index 526b47df2453..12bac415d953 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:OpenHyperlinkOnCursor"/>
   <menu:menuitem menu:id=".uno:EditHyperlink"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
   <menu:menuitem menu:id=".uno:RemoveHyperlink"/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
diff --git a/sc/uiconfig/scalc/popupmenu/drawtext.xml 
b/sc/uiconfig/scalc/popupmenu/drawtext.xml
index d05b1bf8a57d..62a4f9141cee 100644
--- a/sc/uiconfig/scalc/popupmenu/drawtext.xml
+++ b/sc/uiconfig/scalc/popupmenu/drawtext.xml
@@ -25,6 +25,7 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
   <menu:menuitem menu:id=".uno:EditHyperlink"/>
+  <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/>
   <menu:menuitem menu:id=".uno:RemoveHyperlink"/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to