[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - sd/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 5 08:12:12 UTC 2021


 sd/source/ui/view/drviews2.cxx |   49 ++++++++++++++++++++---------------------
 sd/source/ui/view/drviews7.cxx |   16 ++-----------
 sd/source/ui/view/drviewsf.cxx |   39 +++++---------------------------
 3 files changed, 34 insertions(+), 70 deletions(-)

New commits:
commit 40b9beb175c896c6eb29644f92e07f59353b9eb7
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Aug 6 15:14:00 2019 +0200
Commit:     Pranam Lashkari <lpranam at collabora.com>
CommitDate: Fri Feb 5 09:11:55 2021 +0100

    Select hyperlink before editing in sd
    
    Otherwise you can't edit a hyperlink when the cursor is behind the field.
    
    Change-Id: Iea937e16d5be1187f78cbaa565698232cb10dc64
    Reviewed-on: https://gerrit.libreoffice.org/77028
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110315
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index c293d0369266..688400950c9d 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -2163,6 +2163,11 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_EDIT_HYPERLINK :
         {
+            // Ensure the field is selected first
+            OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
+            if (pOutView)
+                pOutView->GetFieldAtCursor();
+
             GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
 
             Cancel();
@@ -2192,35 +2197,31 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
             if ( pOutView )
             {
-                const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
-                if ( pFieldItem )
+                const SvxFieldData* pField = pOutView->GetFieldAtCursor();
+                if( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) )
                 {
-                    const SvxFieldData* pField = pFieldItem->GetField();
-                    if( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) )
-                    {
-                        SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
-                        SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
+                    SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
+                    SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
 
-                        OUString aReferName;
-                        SfxViewFrame* pFrame = GetViewFrame();
-                        SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
-                        if (pMed)
-                            aReferName = pMed->GetName();
+                    OUString aReferName;
+                    SfxViewFrame* pFrame = GetViewFrame();
+                    SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
+                    if (pMed)
+                        aReferName = pMed->GetName();
 
-                        SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
-                        SfxStringItem aReferer( SID_REFERER, aReferName );
+                    SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
+                    SfxStringItem aReferer( SID_REFERER, aReferName );
 
-                        SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, false );
-                        SfxBoolItem aBrowsing( SID_BROWSE, true );
+                    SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, false );
+                    SfxBoolItem aBrowsing( SID_BROWSE, true );
 
-                        SfxViewFrame* pViewFrm = SfxViewFrame::Current();
-                        if (pViewFrm)
-                        {
-                            pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC,
-                                SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
-                                { &aUrl, &aTarget, &aFrm, &aReferer,
-                                  &aNewView, &aBrowsing });
-                        }
+                    SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+                    if (pViewFrm)
+                    {
+                        pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC,
+                            SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
+                            { &aUrl, &aTarget, &aFrm, &aReferer,
+                                &aNewView, &aBrowsing });
                     }
                 }
             }
commit 7c5b671c5e57782c8872347b9adc91ef0ba8adec
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Thu Jan 28 22:20:36 2021 +0530
Commit:     Pranam Lashkari <lpranam at collabora.com>
CommitDate: Fri Feb 5 09:11:40 2021 +0100

    avoid automatical text selection in impress text box
    
    to avoid character besides the cursor getting selected after adding hyperlink in text box
    
    Change-Id: I35609829fe0f43568001eaf95ca2ebe7c50aa17d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110314
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index bf7e6a426231..a74e9858df4e 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -37,6 +37,7 @@
 #include <editeng/sizeitem.hxx>
 #include <editeng/ulspitem.hxx>
 #include <editeng/lrspitem.hxx>
+#include <editeng/urlfieldhelper.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <officecfg/Office/Impress.hxx>
 #include <svx/svxids.hrc>
@@ -1443,19 +1444,8 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
     {
         if( mpDrawView->IsTextEdit() )
         {
-            OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
-            if (pOLV)
-            {
-                const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
-                if (!pFieldItem)
-                    pFieldItem = pOLV->GetFieldAtSelection();
-                if (pFieldItem)
-                {
-                    const SvxFieldData* pField = pFieldItem->GetField();
-                    if (dynamic_cast<const SvxURLField*>(pField))
-                        bDisableEditHyperlink = false;
-                }
-            }
+            if (URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
+                bDisableEditHyperlink = false;
         }
         else
         {
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 24edd1887ad9..28c0c2db8f51 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -95,41 +95,14 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
 
         if (pOLV)
         {
-            bool bField = false;
-            const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
-            if (pFieldItem)
+            const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+            if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
             {
-                // Make sure the whole field is selected
-                ESelection aSel = pOLV->GetSelection();
-                if (aSel.nStartPos == aSel.nEndPos)
-                {
-                    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();
-                }
+                aHLinkItem.SetName(pUrlField->GetRepresentation());
+                aHLinkItem.SetURL(pUrlField->GetURL());
+                aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
             }
-            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)
+            else
             {
                 // use selected text as name for urls
                 OUString sReturn = pOLV->GetSelected();


More information about the Libreoffice-commits mailing list