diff options
author | gokaysatir <gokaysatir@collabora.com> | 2020-09-22 13:00:44 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-10-06 08:28:20 +0200 |
commit | ecbfd8963ce5b8459c00da589216ecf78d99a7f8 (patch) | |
tree | 166344d2a7d2f4203c635294b524c037b712e6d6 /sc/source/ui | |
parent | d483df8fee614261170f7b7b6ad8a3e155727a21 (diff) |
Online: Copy hyperlink location. / Core side.
Payload format is added to LOK_CALLBACK_CLIPBOARD_CHANGED.
Clipboard changed event is not fired when "copy hyperlink location" command is issued.
So i added a call to LOK_CALLBACK_CLIPBOARD_CHANGED inside TextDataObject::CopyStringTo function.
Change-Id: I8157572288da88b5522662e13abe151ef8548b34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103164
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103729
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/drawfunc/drtxtob.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/view/editsh.cxx | 33 |
2 files changed, 45 insertions, 7 deletions
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 771bac8ceb19..550e64b4516c 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -60,6 +60,7 @@ #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> #include <vcl/EnumContext.hxx> +#include <vcl/unohelp2.hxx> #include <sc.hrc> #include <globstr.hrc> @@ -323,6 +324,18 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq ) } break; + case SID_COPY_HYPERLINK_LOCATION: + { + const SvxFieldData* pField = pOutView->GetFieldAtCursor(); + if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) + { + uno::Reference<datatransfer::clipboard::XClipboard> xClipboard + = pOutView->GetWindow()->GetClipboard(); + vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard); + } + } + break; + case SID_ENABLE_HYPHENATION: case SID_TEXTDIRECTION_LEFT_TO_RIGHT: case SID_TEXTDIRECTION_TOP_TO_BOTTOM: @@ -401,7 +414,8 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) rSet.Put(aHLinkItem); } - if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SfxItemState::UNKNOWN ) + if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SfxItemState::UNKNOWN + || rSet.GetItemState(SID_COPY_HYPERLINK_LOCATION) != SfxItemState::UNKNOWN) { SdrView* pView = pViewData->GetScDrawView(); OutlinerView* pOutView = pView->GetTextEditOutlinerView(); @@ -416,7 +430,10 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) } } if( !bEnable ) + { rSet.DisableItem( SID_OPEN_HYPERLINK ); + rSet.DisableItem( SID_COPY_HYPERLINK_LOCATION ); + } } if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SfxItemState::UNKNOWN ) diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index 2eb92e18ce4e..f03ff89f10e1 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -55,6 +55,7 @@ #include <svl/whiter.hxx> #include <sot/formats.hxx> #include <vcl/transfer.hxx> +#include <vcl/unohelp2.hxx> #include <svl/stritem.hxx> #include <editeng/colritem.hxx> @@ -614,15 +615,34 @@ void ScEditShell::Execute( SfxRequest& rReq ) } } } - break; + break; - case SID_OPEN_HYPERLINK: + case SID_OPEN_HYPERLINK: + { + const SvxURLField* pURLField = GetURLField(); + if ( pURLField ) + ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame(), /*BypassCtrlClickSecurity:*/ true ); + return; + } + break; + case SID_COPY_HYPERLINK_LOCATION: + { + const SvxFieldData* pField = pEditView->GetFieldAtCursor(); + if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) { - const SvxURLField* pURLField = GetURLField(); - if ( pURLField ) - ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame(), /*BypassCtrlClickSecurity:*/ true ); - return; + uno::Reference<datatransfer::clipboard::XClipboard> xClipboard + = pEditView->GetWindow()->GetClipboard(); + + if (comphelper::LibreOfficeKit::isActive()) + { + std::function<void (int, const char*)> callback = [&] (int callbackType, const char* text) { pViewData->GetViewShell()->libreOfficeKitViewCallback(callbackType, text); } ; + vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, &callback); + } + else + vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, nullptr); } + } + break; case FN_INSERT_SOFT_HYPHEN: lclInsertCharacter( pTableView, pTopView, CHAR_SHY ); @@ -745,6 +765,7 @@ void ScEditShell::GetState( SfxItemSet& rSet ) break; case SID_OPEN_HYPERLINK: + case SID_COPY_HYPERLINK_LOCATION: { if ( !GetURLField() ) rSet.DisableItem( nWhich ); |