[Libreoffice-commits] core.git: include/sfx2 sfx2/source sw/source
Grzegorz Araminowicz (via logerrit)
logerrit at kemper.freedesktop.org
Fri Feb 28 12:26:04 UTC 2020
include/sfx2/lokhelper.hxx | 2 +-
sfx2/source/view/lokhelper.cxx | 7 +++++--
sw/source/core/crsr/viscrs.cxx | 18 ++++++++++++++++--
3 files changed, 22 insertions(+), 5 deletions(-)
New commits:
commit ee78313613605f50795d8ba0fbcd4138c9845a51
Author: Grzegorz Araminowicz <grzegorz.araminowicz at collabora.com>
AuthorDate: Mon Oct 21 12:59:12 2019 +0200
Commit: Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Fri Feb 28 13:25:21 2020 +0100
lok: send hyperlink text and address under cursor
Change-Id: I827c51ae859b3d3649ec9d293b5ae8eaf4cbd630
Reviewed-on: https://gerrit.libreoffice.org/81219
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89691
Tested-by: Jenkins
Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
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);
}
}
More information about the Libreoffice-commits
mailing list