[Libreoffice-commits] core.git: sw/sdi sw/source sw/uiconfig

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 6 09:59:49 UTC 2019


 sw/sdi/drwtxtsh.sdi                        |   12 +++++++++++
 sw/source/uibase/shells/drwtxtex.cxx       |   30 +++++++++++++++++++++++++++++
 sw/uiconfig/swriter/popupmenu/drawtext.xml |    2 +
 3 files changed, 44 insertions(+)

New commits:
commit e959f4446cbba0e07c89c2be468e4ade29e7ef0c
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Aug 6 10:41:52 2019 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Aug 6 11:58:56 2019 +0200

    Add missing hyperlink context menu entries to sw shapes
    
    "Copy Hyperlink location" and "Open hyperlink" were missing.
    
    Change-Id: I53ede27570a7b2378e5eb8be05d77bb131a87ab7
    Reviewed-on: https://gerrit.libreoffice.org/77011
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi
index 560c60b9d7d1..259ed1e8be66 100644
--- a/sw/sdi/drwtxtsh.sdi
+++ b/sw/sdi/drwtxtsh.sdi
@@ -546,6 +546,12 @@ interface TextDrawText
     [
         StateMethod = StateInsert ;
     ]
+    SID_OPEN_HYPERLINK
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
     SID_EDIT_HYPERLINK
     [
         ExecMethod = Execute ;
@@ -558,6 +564,12 @@ interface TextDrawText
         StateMethod = GetState;
         DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
     ]
+    FN_COPY_HYPERLINK_LOCATION
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
     SID_TRANSLITERATE_SENTENCE_CASE
     [
         ExecMethod = ExecTransliteration;
diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index e5c63fbb0f77..e802654a7717 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -74,6 +74,7 @@
 #include <editeng/outliner.hxx>
 #include <editeng/editview.hxx>
 #include <vcl/outdev.hxx>
+#include <vcl/unohelp2.hxx>
 #include <editeng/hyphenzoneitem.hxx>
 #include <tools/diagnose_ex.h>
 
@@ -501,6 +502,33 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
         }
         break;
 
+        case SID_OPEN_HYPERLINK:
+        {
+            const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+            if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
+            {
+                SfxStringItem aUrl(SID_FILE_NAME, pURLField->GetURL());
+                SfxStringItem aTarget(SID_TARGETNAME, pURLField->GetTargetFrame());
+                SfxBoolItem aNewView(SID_OPEN_NEW_VIEW, false);
+                SfxBoolItem aBrowsing(SID_BROWSE, true);
+                GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
+                    SID_OPENDOC, SfxCallMode::SYNCHRON, { &aUrl, &aTarget, &aNewView, &aBrowsing });
+            }
+        }
+        break;
+
+        case FN_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!
@@ -902,6 +930,8 @@ void SwDrawTextShell::GetState(SfxItemSet& rSet)
             break;
             case SID_REMOVE_HYPERLINK:
             case SID_EDIT_HYPERLINK:
+            case SID_OPEN_HYPERLINK:
+            case FN_COPY_HYPERLINK_LOCATION:
             {
                 if (!URLFieldHelper::IsCursorAtURLField(pOLV))
                     rSet.DisableItem(nWhich);
diff --git a/sw/uiconfig/swriter/popupmenu/drawtext.xml b/sw/uiconfig/swriter/popupmenu/drawtext.xml
index 7536d60f7fd7..07a09cccae9d 100644
--- a/sw/uiconfig/swriter/popupmenu/drawtext.xml
+++ b/sw/uiconfig/swriter/popupmenu/drawtext.xml
@@ -25,7 +25,9 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <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:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>


More information about the Libreoffice-commits mailing list