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

New commits:
commit f92bb02f19aeae7b84a55f2c7455248304becb85
Author:     Muhammet Kara <muhammet.k...@collabora.com>
AuthorDate: Thu Dec 19 11:35:13 2019 +0300
Commit:     Muhammet Kara <muhammet.k...@collabora.com>
CommitDate: Sun Mar 1 01:42:37 2020 +0100

    lok: Improve hyperlink insertion to cell with content
    
    Change-Id: I520939dd5b44236cf835108ee2bc96c29f0a9677
    Reviewed-on: https://gerrit.libreoffice.org/85509
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Marco Cecchetti <marco.cecche...@collabora.com>
    Tested-by: Marco Cecchetti <marco.cecche...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89707
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.k...@collabora.com>

diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index fece06e7d8ec..d3fa448a6538 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 <editeng/editview.hxx>
@@ -172,7 +173,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() )
         {
@@ -189,12 +194,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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to