summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-21 11:29:49 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 17:02:12 +0200
commitc64ac7b2e9898cc56266ea8b32321bdd8558da34 (patch)
tree60b4be9385437b130b0949fa604bca47bfe64de8
parentf31e970376b77d905bc30cbf65d54ceddccb8994 (diff)
sw lok: add LOK_CALLBACK_TEXT_VIEW_SELECTION
So a view can be aware where selections of other views are. Change-Id: I5026b1ff2b99a4eedfd0bde32a05ceb8e2f424bc Reviewed-on: https://gerrit.libreoffice.org/26542 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 9f66db9c474f71f43d7a3667230241fd4fa4183f)
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h16
-rw-r--r--include/sfx2/lokhelper.hxx4
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx7
-rw-r--r--sfx2/source/view/lokhelper.cxx25
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx2
-rw-r--r--sw/source/core/crsr/viscrs.cxx23
6 files changed, 55 insertions, 22 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 4229e73e6728..4dfb8be670a1 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -316,7 +316,6 @@ typedef enum
* The size and/or the position of the view cursor changed. A view cursor
* is a cursor of an other view, the current view can't change it.
*
- * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
* The payload format:
*
* {
@@ -329,6 +328,21 @@ typedef enum
*/
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR,
+ /**
+ * The the text selection in one of the other views has changed.
+ *
+ * The payload format:
+ *
+ * {
+ * "viewId": "..."
+ * "selection": "..."
+ * }
+ *
+ * - viewId is a value returned earlier by lok::Document::createView()
+ * - selection uses the format of LOK_CALLBACK_TEXT_SELECTION.
+ */
+ LOK_CALLBACK_TEXT_VIEW_SELECTION,
+
}
LibreOfficeKitCallbackType;
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index ec68ed6e313a..4cfe0817539f 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -13,6 +13,7 @@
#include <sfx2/dllapi.h>
#include <cstddef>
#include <cstdint>
+#include <rtl/string.hxx>
class SfxViewShell;
@@ -29,6 +30,9 @@ public:
static std::uintptr_t getView(SfxViewShell* pViewShell = nullptr);
/// Get the number of views of the current object shell.
static std::size_t getViews();
+
+ /// Invoke the LOK callback of all views except pThisView, with a payload of rKey-rPayload.
+ static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
};
#endif
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 64a6396bc456..9289d441653d 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -346,6 +346,8 @@ callbackTypeToString (int nType)
return "LOK_CALLBACK_CONTEXT_MENU";
case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
return "LOK_CALLBACK_INVALIDATE_VIEW_CURSOR";
+ case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+ return "LOK_CALLBACK_TEXT_VIEW_SELECTION";
}
return nullptr;
}
@@ -1169,6 +1171,11 @@ callback (gpointer pData)
gtk_widget_queue_draw(GTK_WIDGET(pDocView));
break;
}
+ case LOK_CALLBACK_TEXT_VIEW_SELECTION:
+ {
+ // TODO: Implement me
+ break;
+ }
default:
g_assert(false);
break;
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index c994877e9540..b44392c9dfef 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -8,6 +8,9 @@
*/
#include <sfx2/lokhelper.hxx>
+
+#include <boost/property_tree/json_parser.hpp>
+
#include <sfx2/viewsh.hxx>
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
@@ -86,4 +89,26 @@ std::size_t SfxLokHelper::getViews()
return nRet;
}
+void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload)
+{
+ if (SfxLokHelper::getViews() <= 1)
+ return;
+
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ if (pViewShell != pThisView)
+ {
+ boost::property_tree::ptree aTree;
+ aTree.put("viewId", SfxLokHelper::getView(pThisView));
+ aTree.put(rKey.getStr(), rPayload.getStr());
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ OString aPayload = aStream.str().c_str();
+ pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr());
+ }
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 10d7b654f8e8..5034537a0c81 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -552,7 +552,7 @@ public:
ViewCallback()
: m_bOwnCursorInvalidated(false),
- m_bViewCursorInvalidated(false)
+ m_bViewCursorInvalidated(false)
{
}
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index bb1c3630f1e3..585a0f414738 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -198,26 +198,7 @@ void SwVisibleCursor::_SetPosAndShow()
Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
OString sRect = aSVRect.toString();
m_pCursorShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
-
- if (SfxLokHelper::getViews() > 1)
- {
- // Notify other views about the invalidated cursor.
- SfxViewShell* pViewShell = SfxViewShell::GetFirst();
- while (pViewShell)
- {
- if (pViewShell != m_pCursorShell->GetSfxViewShell())
- {
- boost::property_tree::ptree aTree;
- aTree.put("viewId", SfxLokHelper::getView(m_pCursorShell->GetSfxViewShell()));
- aTree.put("rectangle", sRect.getStr());
- std::stringstream aStream;
- boost::property_tree::write_json(aStream, aTree);
- OString aPayload = aStream.str().c_str();
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, aPayload.getStr());
- }
- pViewShell = SfxViewShell::GetNext(*pViewShell);
- }
- }
+ SfxLokHelper::notifyOtherViews(m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
}
if ( !m_pCursorShell->IsCursorReadonly() || m_pCursorShell->GetViewOptions()->IsSelectionInReadonly() )
@@ -416,6 +397,7 @@ void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
if (!pSelectionRectangles)
{
GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+ SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
}
else
pSelectionRectangles->push_back(sRect);
@@ -625,6 +607,7 @@ void SwShellCursor::Show()
}
OString sRect = comphelper::string::join("; ", aRect);
GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+ SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
}
}