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 /sw | |
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 'sw')
-rw-r--r-- | sw/sdi/_textsh.sdi | 2 | ||||
-rw-r--r-- | sw/sdi/drwtxtsh.sdi | 8 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 18 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwtxtex.cxx | 20 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 30 | ||||
-rw-r--r-- | sw/uiconfig/sglobal/popupmenu/drawtext.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swform/popupmenu/drawtext.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swreport/popupmenu/drawtext.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/popupmenu/drawtext.xml | 2 | ||||
-rw-r--r-- | sw/uiconfig/swxform/popupmenu/drawtext.xml | 2 |
10 files changed, 63 insertions, 25 deletions
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index ad353ad5e099..fe6c9b9f52ef 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -347,7 +347,7 @@ interface BaseText StateMethod = GetState; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] - FN_COPY_HYPERLINK_LOCATION + SID_COPY_HYPERLINK_LOCATION [ ExecMethod = Execute ; StateMethod = GetState; diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi index a8e79c298b4f..c9aa46977015 100644 --- a/sw/sdi/drwtxtsh.sdi +++ b/sw/sdi/drwtxtsh.sdi @@ -540,6 +540,14 @@ interface TextDrawText [ StateMethod = StateInsert ; ] + + SID_COPY_HYPERLINK_LOCATION + [ + ExecMethod = Execute ; + StateMethod = GetState; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + SID_TRANSLITERATE_SENTENCE_CASE [ ExecMethod = ExecTransliteration; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 68fe312b9105..fc7b2903512b 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7400,24 +7400,6 @@ SfxVoidItem RemoveHyperlink FN_REMOVE_HYPERLINK GroupId = SfxGroupId::Edit; ] -SfxVoidItem CopyHyperlinkLocation FN_COPY_HYPERLINK_LOCATION -[ - AutoUpdate = FALSE, - FastCall = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - - AccelConfig = TRUE, - MenuConfig = TRUE, - ToolBoxConfig = TRUE, - GroupId = SfxGroupId::Edit; -] - SfxVoidItem NavigateBack FN_NAVIGATION_BACK [ AutoUpdate = TRUE, diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index 93b813650812..2221e68a6767 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -45,6 +45,7 @@ #include <editeng/contouritem.hxx> #include <editeng/postitem.hxx> #include <editeng/frmdiritem.hxx> +#include <editeng/urlfieldhelper.hxx> #include <svx/svdoutl.hxx> #include <sfx2/viewfrm.hxx> #include <svl/whiter.hxx> @@ -70,6 +71,7 @@ #include <vcl/window.hxx> #include <editeng/editview.hxx> #include <vcl/outdev.hxx> +#include <vcl/unohelp2.hxx> #include <editeng/hyphenzoneitem.hxx> #include <tools/diagnose_ex.h> @@ -521,6 +523,18 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) } break; + case SID_COPY_HYPERLINK_LOCATION: + { + const SvxFieldData* pField = pOLV->GetFieldAtCursor(); + if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) + { + uno::Reference<datatransfer::clipboard::XClipboard> xClipboard + = GetView().GetEditWin().GetClipboard(); + vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard); + } + } + break; + case SID_TEXTDIRECTION_LEFT_TO_RIGHT: case SID_TEXTDIRECTION_TOP_TO_BOTTOM: // Shell switch! @@ -909,6 +923,12 @@ ASK_ESCAPE: rSet.DisableItem(nWhich); } break; + case SID_COPY_HYPERLINK_LOCATION: + { + if (!URLFieldHelper::IsCursorAtURLField(pOLV)) + rSet.DisableItem(nWhich); + } + break; default: nSlotId = 0; // don't know this slot break; diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index b3fc13963a99..9a032880ea18 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -127,6 +127,7 @@ #include <bookmrk.hxx> #include <linguistic/misc.hxx> #include <editeng/splwrap.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> using namespace ::com::sun::star; using namespace com::sun::star::beans; @@ -1327,7 +1328,7 @@ void SwTextShell::Execute(SfxRequest &rReq) } break; case SID_OPEN_HYPERLINK: - case FN_COPY_HYPERLINK_LOCATION: + case SID_COPY_HYPERLINK_LOCATION: { SfxItemSet aSet(GetPool(), svl::Items<RES_TXTATR_INETFMT, @@ -1336,12 +1337,18 @@ void SwTextShell::Execute(SfxRequest &rReq) if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT )) { const SwFormatINetFormat& rINetFormat = dynamic_cast<const SwFormatINetFormat&>( aSet.Get(RES_TXTATR_INETFMT) ); - if( nSlot == FN_COPY_HYPERLINK_LOCATION ) + if( nSlot == SID_COPY_HYPERLINK_LOCATION ) { + OUString hyperlinkLocation = rINetFormat.GetValue(); ::uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetView().GetEditWin().GetClipboard(); - vcl::unohelper::TextDataObject::CopyStringTo( - rINetFormat.GetValue(), - xClipboard ); + + if (comphelper::LibreOfficeKit::isActive()) + { + std::function<void (int, const char*)> callback = [&] (int callbackType, const char* text) { GetView().libreOfficeKitViewCallback(callbackType, text); } ; + vcl::unohelper::TextDataObject::CopyStringTo(hyperlinkLocation, xClipboard, &callback ); + } + else + vcl::unohelper::TextDataObject::CopyStringTo(hyperlinkLocation, xClipboard, nullptr ); } else rWrtSh.ClickToINetAttr(rINetFormat); @@ -1939,7 +1946,18 @@ void SwTextShell::GetState( SfxItemSet &rSet ) rSet.Put(SfxBoolItem( nWhich, nullptr != GetView().GetViewFrame()->GetChildWindow( nWhich ) )); } break; - + case SID_COPY_HYPERLINK_LOCATION: + { + SfxItemSet aSet(GetPool(), + svl::Items<RES_TXTATR_INETFMT, + RES_TXTATR_INETFMT>{}); + rSh.GetCurAttr(aSet); + if(SfxItemState::SET > aSet.GetItemState( RES_TXTATR_INETFMT ) || rSh.HasReadonlySel()) + { + rSet.DisableItem(nWhich); + } + } + break; case FN_EDIT_HYPERLINK: case FN_COPY_HYPERLINK_LOCATION: { diff --git a/sw/uiconfig/sglobal/popupmenu/drawtext.xml b/sw/uiconfig/sglobal/popupmenu/drawtext.xml index e13990ca0af9..d2ee8e024236 100644 --- a/sw/uiconfig/sglobal/popupmenu/drawtext.xml +++ b/sw/uiconfig/sglobal/popupmenu/drawtext.xml @@ -25,5 +25,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:ThesaurusFromContext"/> <menu:menuseparator/> + <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/> + <menu:menuseparator/> <menu:menuitem menu:id=".uno:ResetAttributes"/> </menu:menupopup> diff --git a/sw/uiconfig/swform/popupmenu/drawtext.xml b/sw/uiconfig/swform/popupmenu/drawtext.xml index e13990ca0af9..d2ee8e024236 100644 --- a/sw/uiconfig/swform/popupmenu/drawtext.xml +++ b/sw/uiconfig/swform/popupmenu/drawtext.xml @@ -25,5 +25,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:ThesaurusFromContext"/> <menu:menuseparator/> + <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/> + <menu:menuseparator/> <menu:menuitem menu:id=".uno:ResetAttributes"/> </menu:menupopup> diff --git a/sw/uiconfig/swreport/popupmenu/drawtext.xml b/sw/uiconfig/swreport/popupmenu/drawtext.xml index e13990ca0af9..d2ee8e024236 100644 --- a/sw/uiconfig/swreport/popupmenu/drawtext.xml +++ b/sw/uiconfig/swreport/popupmenu/drawtext.xml @@ -25,5 +25,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:ThesaurusFromContext"/> <menu:menuseparator/> + <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/> + <menu:menuseparator/> <menu:menuitem menu:id=".uno:ResetAttributes"/> </menu:menupopup> diff --git a/sw/uiconfig/swriter/popupmenu/drawtext.xml b/sw/uiconfig/swriter/popupmenu/drawtext.xml index e13990ca0af9..d2ee8e024236 100644 --- a/sw/uiconfig/swriter/popupmenu/drawtext.xml +++ b/sw/uiconfig/swriter/popupmenu/drawtext.xml @@ -25,5 +25,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:ThesaurusFromContext"/> <menu:menuseparator/> + <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/> + <menu:menuseparator/> <menu:menuitem menu:id=".uno:ResetAttributes"/> </menu:menupopup> diff --git a/sw/uiconfig/swxform/popupmenu/drawtext.xml b/sw/uiconfig/swxform/popupmenu/drawtext.xml index e13990ca0af9..d2ee8e024236 100644 --- a/sw/uiconfig/swxform/popupmenu/drawtext.xml +++ b/sw/uiconfig/swxform/popupmenu/drawtext.xml @@ -25,5 +25,7 @@ <menu:menuseparator/> <menu:menuitem menu:id=".uno:ThesaurusFromContext"/> <menu:menuseparator/> + <menu:menuitem menu:id=".uno:CopyHyperlinkLocation"/> + <menu:menuseparator/> <menu:menuitem menu:id=".uno:ResetAttributes"/> </menu:menupopup> |