diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-12-19 11:35:13 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2019-12-19 17:49:06 +0100 |
commit | 65d304a97377011a15c2c09e5d019c04c46ac442 (patch) | |
tree | a9b2cb9369891fd5bd6b3c845642098ce71f19b3 /sc | |
parent | 2d90583fb9026b3c8ee466029423dad3e957eb7e (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>
Diffstat (limited to 'sc')
-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 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(); |