diff options
-rw-r--r-- | include/sfx2/lokhelper.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 18 |
3 files changed, 22 insertions, 5 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index f87432c792b8..e1827ef1967f 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -83,7 +83,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 f924ca8edaf4..56f7d7f4bc32 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -367,7 +367,7 @@ 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) { if (DisableCallbacks::disabled()) return; @@ -375,8 +375,11 @@ void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisVie OString sPayload; if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation()) { + OString sHyperlink = rHyperlink.isEmpty() ? "{}" : rHyperlink; sPayload = OStringLiteral("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView()) + - "\", \"rectangle\": \"" + rRectangle + "\", \"mispelledWord\": \"" + OString::number(bMispelledWord ? 1 : 0) + "\" }"; + "\", \"rectangle\": \"" + rRectangle + + "\", \"mispelledWord\": \"" + OString::number(bMispelledWord ? 1 : 0) + + "\", \"hyperlink\": " + sHyperlink + " }"; } else { diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 4c61a86bfbd5..400b79c869e1 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -49,6 +49,7 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> #include <sfx2/lokhelper.hxx> +#include <boost/property_tree/json_parser.hpp> #include <comphelper/string.hxx> #include <paintfrm.hxx> #include <PostItMgr.hxx> @@ -238,18 +239,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); } } |