summaryrefslogtreecommitdiff
path: root/cui/source
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2023-07-26 10:31:56 +0200
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2023-07-27 09:01:57 +0200
commit89d3735e05b98223a49a387421386fd736fc3de6 (patch)
treee5891f7cda1cd34b4d1040b5f2c1ee705ebaae1a /cui/source
parentcf8f7b91f41821b79495c0388359c4cb1156ea67 (diff)
tdf#146576 - Propose clipboard content when inserting a hyperlink
Change-Id: I30067b88b3d1e196f7ecfd150f5215cc93adf095 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154931 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'cui/source')
-rw-r--r--cui/source/dialogs/hltpbase.cxx33
1 files changed, 29 insertions, 4 deletions
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index 01776c80d25e..f2448460ee66 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -450,14 +450,39 @@ void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& rItemSet)
if ( pHyperlinkItem )
{
+ // tdf#146576 - propose clipboard content when inserting a hyperlink
+ OUString aStrURL(pHyperlinkItem->GetURL());
+ // Store initial URL
+ maStrInitURL = aStrURL;
+ if (aStrURL.isEmpty())
+ {
+ if (auto xClipboard = GetSystemClipboard())
+ {
+ if (auto xTransferable = xClipboard->getContents())
+ {
+ css::datatransfer::DataFlavor aFlavor;
+ SotExchange::GetFormatDataFlavor(SotClipboardFormatId::STRING, aFlavor);
+ if (xTransferable->isDataFlavorSupported(aFlavor))
+ {
+ OUString aClipBoardConentent;
+ if (xTransferable->getTransferData(aFlavor) >>= aClipBoardConentent)
+ {
+ INetURLObject aURL;
+ aURL.SetSmartURL(aClipBoardConentent);
+ if (!aURL.HasError())
+ aStrURL
+ = aURL.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous);
+ }
+ }
+ }
+ }
+ }
+
// set dialog-fields
FillStandardDlgFields (pHyperlinkItem);
// set all other fields
- FillDlgFields ( pHyperlinkItem->GetURL() );
-
- // Store initial URL
- maStrInitURL = pHyperlinkItem->GetURL();
+ FillDlgFields(aStrURL);
}
}