diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-12-19 08:32:57 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2019-12-19 07:36:58 +0100 |
commit | dc456be2f315bacea4e65d63d3765a54b126cb86 (patch) | |
tree | abbff9f0ad76c57553268b6e15587d246431ac6f /editeng | |
parent | 1582de1f4865b0327aa14c4f67657cd8b36fadac (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>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 384c44ea93b1..7b920638537c 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -867,6 +867,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 ... @@ -1121,21 +1138,34 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor ) } else { + // is cursor at a mispelled word ? Reference< linguistic2::XSpellChecker1 > xSpeller( pEditEngine->pImpEditEngine->GetSpeller() ); bool bIsWrong = xSpeller.is() && IsWrongSpelledWord(aPaM, /*bMarkIfWrong*/ false); - OString sHyperlink; + if (const SvxFieldItem* pFld = GetField(aPos, nullptr, nullptr)) { 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()); + } + } } } |