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

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 19 16:49:47 UTC 2019


 sc/source/ui/view/tabvwshe.cxx |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

New commits:
commit 65d304a97377011a15c2c09e5d019c04c46ac442
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Thu Dec 19 11:35:13 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Thu Dec 19 17:49:06 2019 +0100

    lok: Improve hyperlink insertion to cell with content
    
    Change-Id: I520939dd5b44236cf835108ee2bc96c29f0a9677
    Reviewed-on: https://gerrit.libreoffice.org/85509
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Marco Cecchetti <marco.cecchetti at collabora.com>
    Tested-by: Marco Cecchetti <marco.cecchetti at collabora.com>

diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index 0059534c22dd..c0c96af2cb0e 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <comphelper/string.hxx>
+#include <comphelper/lok.hxx>
 #include <editeng/eeitem.hxx>
 
 #include <scitems.hxx>
@@ -174,7 +175,11 @@ void ScTabViewShell::InsertURLField( const OUString& rName, const OUString& rURL
     ScInputHandler* pHdl        = pScMod->GetInputHdl( rViewData.GetViewShell() );
 
     bool bSelectFirst = false;
-    if ( !pScMod->IsEditMode() )
+    bool bIsEditMode = pScMod->IsEditMode();
+    int nSelInd = 1;
+    OUString sSeltext(GetSelectionText());
+
+    if ( !bIsEditMode )
     {
         if ( !SelectionEditable() )
         {
@@ -191,12 +196,24 @@ void ScTabViewShell::InsertURLField( const OUString& rName, const OUString& rURL
     EditView*       pTableView  = pHdl->GetTableView();
     OSL_ENSURE( pTopView || pTableView, "No EditView" );
 
+    // Check if user selected a whole cell by single click,
+    // cell has content, and user didn't change the name/text
+    // of the link something different than the content via the hyperlink dialog.
+    // If true, assign the given hyperlink to the whole content
+    // instead of inserting a duplicate, or appending the url.
+    if (comphelper::LibreOfficeKit::isActive() && !bIsEditMode && !bSelectFirst
+            && pTableView && !sSeltext.isEmpty() && sSeltext == rName)
+    {
+        nSelInd = sSeltext.getLength();
+        bSelectFirst = true;
+    }
+
     if ( bSelectFirst )
     {
         if ( pTopView )
             pTopView->SetSelection( ESelection(0,0,0,1) );
         if ( pTableView )
-            pTableView->SetSelection( ESelection(0,0,0,1) );
+            pTableView->SetSelection( ESelection(0,0,0,nSelInd) );
     }
 
     pHdl->DataChanging();


More information about the Libreoffice-commits mailing list