diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-12-19 11:35:13 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2020-03-01 01:42:37 +0100 |
commit | f92bb02f19aeae7b84a55f2c7455248304becb85 (patch) | |
tree | 35dca0c16fe4192c5b7a1336f8da963eef39c459 /sc/source | |
parent | 48295aead3e15c62d31157f963bd5728f7278db5 (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>
Diffstat (limited to 'sc/source')
-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(); |