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

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 15 06:54:16 UTC 2019


 editeng/source/misc/urlfieldhelper.cxx     |   17 +++++++++++++++++
 include/editeng/urlfieldhelper.hxx         |    1 +
 sd/source/ui/view/drviewsf.cxx             |   18 ++----------------
 sw/sdi/drwtxtsh.sdi                        |   12 ++++++++++++
 sw/source/uibase/shells/drwtxtex.cxx       |   25 ++++++++++++++++++++++++-
 sw/uiconfig/swriter/popupmenu/drawtext.xml |    3 +++
 6 files changed, 59 insertions(+), 17 deletions(-)

New commits:
commit 86cb2a1f98c0585d2121e6ae34fe62f072ef9a63
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Fri Jul 12 10:37:41 2019 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 15 08:53:22 2019 +0200

    tdf#112543 Add Edit/Remove hyperlink to text boxes/shapes in Writer
    
    Change-Id: I9052387cf39135c2324b9db03662dc0365323400
    Reviewed-on: https://gerrit.libreoffice.org/75479
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx
index 961a946ca142..f2499dbf3792 100644
--- a/editeng/source/misc/urlfieldhelper.cxx
+++ b/editeng/source/misc/urlfieldhelper.cxx
@@ -24,4 +24,21 @@ void URLFieldHelper::RemoveURLField(Outliner* pOutl, OutlinerView* pOLV)
     }
 }
 
+bool URLFieldHelper::IsCursorAtURLField(OutlinerView* pOLV)
+{
+    if (!pOLV)
+        return false;
+
+    const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
+    if (!pFieldItem)
+        pFieldItem = pOLV->GetFieldAtSelection();
+    if (pFieldItem)
+    {
+        const SvxFieldData* pField = pFieldItem->GetField();
+        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/include/editeng/urlfieldhelper.hxx b/include/editeng/urlfieldhelper.hxx
index 698a22077225..a2f20b560065 100644
--- a/include/editeng/urlfieldhelper.hxx
+++ b/include/editeng/urlfieldhelper.hxx
@@ -17,6 +17,7 @@ class EDITENG_DLLPUBLIC URLFieldHelper
 {
 public:
     static void RemoveURLField(Outliner* pOutl, OutlinerView* pOLV);
+    static bool IsCursorAtURLField(OutlinerView* pOLV);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index df68fa2fb0a5..d420c6f49f03 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -475,22 +475,8 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
 
             case SID_REMOVE_HYPERLINK:
             {
-                OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
-                if (pOLV)
-                {
-                    bool bField = false;
-                    const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
-                    if (!pFieldItem)
-                        pFieldItem = pOLV->GetFieldAtSelection();
-                    if (pFieldItem)
-                    {
-                        const SvxFieldData* pField = pFieldItem->GetField();
-                        if (dynamic_cast<const SvxURLField*>(pField))
-                            bField = true;
-                    }
-                    if (!bField)
-                        rSet.DisableItem(nWhich);
-                }
+                if (!URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
+                    rSet.DisableItem(nWhich);
             }
             break;
 
diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi
index 2046fdf585da..c5a0e6477c0e 100644
--- a/sw/sdi/drwtxtsh.sdi
+++ b/sw/sdi/drwtxtsh.sdi
@@ -546,6 +546,18 @@ interface TextDrawText
     [
         StateMethod = StateInsert ;
     ]
+    FN_EDIT_HYPERLINK
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState;
+        DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
+    ]
+    FN_REMOVE_HYPERLINK
+    [
+        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 16f5ca169daf..898cc8743fe5 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -47,6 +47,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/stritem.hxx>
@@ -485,6 +486,21 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
         }
         break;
 
+        case FN_EDIT_HYPERLINK:
+        {
+            // Ensure the field is selected first
+            pOLV->GetFieldAtCursor();
+            GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HYPERLINK_DIALOG);
+        }
+        break;
+
+        case FN_REMOVE_HYPERLINK:
+        {
+            URLFieldHelper::RemoveURLField(pSdrView->GetTextEditOutliner(),
+                                           pOLV);
+        }
+        break;
+
         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
             // Shell switch!
@@ -884,12 +900,19 @@ void SwDrawTextShell::GetState(SfxItemSet& rSet)
                     rSet.DisableItem(nWhich);
             }
             break;
+            case FN_REMOVE_HYPERLINK:
+            case FN_EDIT_HYPERLINK:
+            {
+                if (!URLFieldHelper::IsCursorAtURLField(pOLV))
+                    rSet.DisableItem(nWhich);
+            }
+            break;
             default:
                 nSlotId = 0; // don't know this slot
                 break;
         }
 
-        if (nSlotId)
+        if (nSlotId && bFlag)
             rSet.Put(SfxBoolItem(nWhich, bFlag));
 
         nWhich = aIter.NextWhich();
diff --git a/sw/uiconfig/swriter/popupmenu/drawtext.xml b/sw/uiconfig/swriter/popupmenu/drawtext.xml
index e13990ca0af9..7536d60f7fd7 100644
--- a/sw/uiconfig/swriter/popupmenu/drawtext.xml
+++ b/sw/uiconfig/swriter/popupmenu/drawtext.xml
@@ -25,5 +25,8 @@
   <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
   <menu:menuseparator/>
+  <menu:menuitem menu:id=".uno:EditHyperlink"/>
+  <menu:menuitem menu:id=".uno:RemoveHyperlink"/>
+  <menu:menuseparator/>
   <menu:menuitem menu:id=".uno:ResetAttributes"/>
 </menu:menupopup>


More information about the Libreoffice-commits mailing list