summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-12-19 08:32:57 +0300
committerMichael Meeks <michael.meeks@collabora.com>2020-05-23 15:15:41 +0100
commitd886d6bfc14aaff91325956f241c166d40cb2640 (patch)
treed8349830dc0d2cd660279e3bd125fee579c02141 /editeng
parentd6d7c7f7c0b28b29f6b3096162386c317c88fee2 (diff)
lok: Resolves: Calc - selecting a hyperlink doesn't show link in dialog
Change-Id: Ic4264fad8035029ba6593c91fa57efa772d394ca Reviewed-on: https://gerrit.libreoffice.org/85468 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89705 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/impedit.cxx41
1 files changed, 35 insertions, 6 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index e7e1c661fef1..7a2a3e412301 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -897,6 +897,23 @@ void ImpEditView::CalcAnchorPoint()
}
}
+namespace
+{
+
+// Build JSON message to be sent to Online
+OString buildHyperlinkJSON(const OUString& sText, const OUString& sLink)
+{
+ boost::property_tree::ptree aTree;
+ aTree.put("text", sText);
+ aTree.put("link", sLink);
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree, false);
+
+ return OString(aStream.str().c_str()).trim();
+}
+
+} // End of anon namespace
+
void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
{
// No ShowCursor in an empty View ...
@@ -1139,12 +1156,24 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
{
if (auto pUrlField = dynamic_cast<const SvxURLField*>(pFld->GetField()))
{
- boost::property_tree::ptree aTree;
- aTree.put("text", pUrlField->GetRepresentation());
- aTree.put("link", pUrlField->GetURL());
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aTree, false);
- sHyperlink = OString(aStream.str().c_str()).trim();
+ sHyperlink = buildHyperlinkJSON(pUrlField->GetRepresentation(), pUrlField->GetURL());
+ }
+ }
+ else if (GetEditSelection().HasRange())
+ {
+ EditView* pActiveView = GetEditViewPtr();
+
+ if (pActiveView)
+ {
+ const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( auto pUrlField = dynamic_cast<const SvxURLField*>( pField) )
+ {
+ sHyperlink = buildHyperlinkJSON(pUrlField->GetRepresentation(), pUrlField->GetURL());
+ }
+ }
}
}