diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-12-19 11:35:13 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-05-16 19:24:16 +0100 |
commit | e910d27a297c9d05945ff160b2aac559f8703df5 (patch) | |
tree | f9d24d4f9324b83a9e0c42d453a93466709fe602 | |
parent | 6e69240276aa8aa473e3417a819a7d5a8a6bc796 (diff) |
lok: Improve hyperlink insertion to cell with content
Change-Id: I520939dd5b44236cf835108ee2bc96c29f0a9677
Reviewed-on: https://gerrit.libreoffice.org/85509
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Tested-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89707
Tested-by: Jenkins
Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
-rw-r--r-- | sc/source/ui/view/tabvwshe.cxx | 21 |
1 files changed, 19 insertions, 2 deletions
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(); |