include/sfx2/lokhelper.hxx | 2 +- sfx2/source/view/lokhelper.cxx | 7 +++++-- sw/source/core/crsr/viscrs.cxx | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-)
New commits: commit da7d8464b19b7bcda08bdee2db5d2a2b7e8bde07 Author: Grzegorz Araminowicz <grzegorz.araminow...@collabora.com> AuthorDate: Mon Oct 21 12:59:12 2019 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Thu Oct 31 12:38:55 2019 +0100 lok: send hyperlink text and address under cursor Change-Id: I827c51ae859b3d3649ec9d293b5ae8eaf4cbd630 Reviewed-on: https://gerrit.libreoffice.org/81219 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index ae796e0c7120..57ff680cfdb0 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -55,7 +55,7 @@ public: /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload); /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it according to setOptionalFeatures() if needed. - static void notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord = false); + static void notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord = false, const OString& rHyperlink = ""); /// Notifies all views with the given type and payload. static void notifyAllViews(int nType, const OString& rPayload); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index e1c1b42a0e53..035c4c7fff06 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -254,13 +254,16 @@ void SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc } } -void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord) +void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord, const OString& rHyperlink) { OString sPayload; if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation()) { + OString sHyperlink = rHyperlink.isEmpty() ? "{}" : rHyperlink; sPayload = OString("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView()) + - "\", \"rectangle\": \"" + rRectangle + "\", \"mispelledWord\": \"" + OString::number(bMispelledWord) + "\" }"; + "\", \"rectangle\": \"" + rRectangle + + "\", \"mispelledWord\": \"" + OString::number(bMispelledWord) + + "\", \"hyperlink\": " + sHyperlink + " }"; } else { diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 2b14ffa27093..a1c1555858aa 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -241,18 +241,31 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell const * pViewShell) } } + OString sHyperlink; + SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr); + if (const_cast<SwCursorShell*>(m_pCursorShell)->GetContentAtPos(aRect.Pos(), aContentAtPos)) + { + const SwFormatINetFormat* pItem = static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr); + boost::property_tree::ptree aTree; + aTree.put("text", aContentAtPos.sStr); + aTree.put("link", pItem->GetValue()); + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree, false); + sHyperlink = OString(aStream.str().c_str()).trim(); + } + if (pViewShell) { if (pViewShell == m_pCursorShell->GetSfxViewShell()) { - SfxLokHelper::notifyVisCursorInvalidation(pViewShell, sRect, bIsWrong); + SfxLokHelper::notifyVisCursorInvalidation(pViewShell, sRect, bIsWrong, sHyperlink); } else SfxLokHelper::notifyOtherView(m_pCursorShell->GetSfxViewShell(), pViewShell, LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect); } else { - SfxLokHelper::notifyVisCursorInvalidation(m_pCursorShell->GetSfxViewShell(), sRect, bIsWrong); + SfxLokHelper::notifyVisCursorInvalidation(m_pCursorShell->GetSfxViewShell(), sRect, bIsWrong, sHyperlink); SfxLokHelper::notifyOtherViews(m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits