[Libreoffice-commits] core.git: sd/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 8 08:29:32 UTC 2019


 sd/source/ui/view/drviews7.cxx |   14 ++++++--------
 sd/source/ui/view/drviewsf.cxx |   35 ++++++++++++++++++++++++++---------
 2 files changed, 32 insertions(+), 17 deletions(-)

New commits:
commit 1c6218df32838dc77da8e15dc5ce47eadad1a13f
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Mon Jul 8 08:22:33 2019 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Jul 8 10:28:45 2019 +0200

    Related tdf#98575 Allow editing link even when URL field is not selected
    
    When the cursor is directly before or behind the URL field,
    just extend the selection so that the link is editable.
    
    Change-Id: I80afe40a1c40e2a02ec6adb18dbdb27b6e39c7d1
    Reviewed-on: https://gerrit.libreoffice.org/75190
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 1e663a8e4b61..801a70d2042a 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1454,16 +1454,14 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
             OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
             if (pOLV)
             {
-                const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+                const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
+                if (!pFieldItem)
+                    pFieldItem = pOLV->GetFieldAtSelection();
                 if (pFieldItem)
                 {
-                    ESelection aSel = pOLV->GetSelection();
-                    if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
-                    {
-                        const SvxFieldData* pField = pFieldItem->GetField();
-                        if ( dynamic_cast< const SvxURLField *>( pField ) !=  nullptr )
-                            bDisableEditHyperlink = false;
-                    }
+                    const SvxFieldData* pField = pFieldItem->GetField();
+                    if (dynamic_cast<const SvxURLField*>(pField))
+                        bDisableEditHyperlink = false;
                 }
             }
         }
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 0d5081cbfd17..dc6d8f97c3f2 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -93,17 +93,34 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
             const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
             if (pFieldItem)
             {
+                // Make sure the whole field is selected
                 ESelection aSel = pOLV->GetSelection();
-                if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
+                if (aSel.nStartPos == aSel.nEndPos)
                 {
-                    const SvxFieldData* pField = pFieldItem->GetField();
-                    if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
-                    {
-                        aHLinkItem.SetName(pUrlField->GetRepresentation());
-                        aHLinkItem.SetURL(pUrlField->GetURL());
-                        aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
-                        bField = true;
-                    }
+                    aSel.nEndPos++;
+                    pOLV->SetSelection(aSel);
+                }
+            }
+            if (!pFieldItem)
+            {
+                // Cursor probably behind the field - extend selection to select the field
+                ESelection aSel = pOLV->GetSelection();
+                if (aSel.nStartPos == aSel.nEndPos)
+                {
+                    aSel.nStartPos--;
+                    pOLV->SetSelection(aSel);
+                    pFieldItem = pOLV->GetFieldAtSelection();
+                }
+            }
+            if (pFieldItem)
+            {
+                const SvxFieldData* pField = pFieldItem->GetField();
+                if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
+                {
+                    aHLinkItem.SetName(pUrlField->GetRepresentation());
+                    aHLinkItem.SetURL(pUrlField->GetURL());
+                    aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
+                    bField = true;
                 }
             }
             if (!bField)


More information about the Libreoffice-commits mailing list