[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit libreofficekit/source sc/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Jul 1 09:29:20 UTC 2016
desktop/source/lib/init.cxx | 2 +
include/LibreOfficeKit/LibreOfficeKitEnums.h | 17 ++++++++++
libreofficekit/source/gtk/lokdocview.cxx | 43 +++++++++++++++++++++++++++
sc/source/ui/view/gridwin.cxx | 3 +
4 files changed, 64 insertions(+), 1 deletion(-)
New commits:
commit 68c5c0bb7eed007bbfbb2e51107fc0196825e85a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jul 1 10:55:27 2016 +0200
sc lok: add LOK_CALLBACK_CELL_VIEW_CURSOR
So a view can be aware where the cell cursors of other views are.
Change-Id: Ifcf06c0019c6af8b859e2e92222e4f3fd18da74f
Reviewed-on: https://gerrit.libreoffice.org/26844
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 10f3430..581eb89 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -451,6 +451,7 @@ CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL");
m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL");
m_states.emplace(LOK_CALLBACK_CELL_CURSOR, "NIL");
+ m_states.emplace(LOK_CALLBACK_CELL_VIEW_CURSOR, "NIL");
m_states.emplace(LOK_CALLBACK_CELL_FORMULA, "NIL");
m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE, "NIL");
m_states.emplace(LOK_CALLBACK_SET_PART, "NIL");
@@ -553,6 +554,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_GRAPHIC_SELECTION:
case LOK_CALLBACK_MOUSE_POINTER:
case LOK_CALLBACK_CELL_CURSOR:
+ case LOK_CALLBACK_CELL_VIEW_CURSOR:
case LOK_CALLBACK_CELL_FORMULA:
case LOK_CALLBACK_CURSOR_VISIBLE:
case LOK_CALLBACK_SET_PART:
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 4dfb8be..c687879 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -329,7 +329,7 @@ typedef enum
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR,
/**
- * The the text selection in one of the other views has changed.
+ * The text selection in one of the other views has changed.
*
* The payload format:
*
@@ -343,6 +343,21 @@ typedef enum
*/
LOK_CALLBACK_TEXT_VIEW_SELECTION,
+ /**
+ * The cell cursor in one of the other views has changed.
+ *
+ * The payload format:
+ *
+ * {
+ * "viewId": "..."
+ * "rectangle": "..."
+ * }
+ *
+ * - viewId is a value returned earlier by lok::Document::createView()
+ * - rectangle uses the format of LOK_CALLBACK_CELL_CURSOR.
+ */
+ LOK_CALLBACK_CELL_VIEW_CURSOR,
+
}
LibreOfficeKitCallbackType;
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 8e2d278..cb2118e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -102,6 +102,9 @@ struct LOKDocViewPrivateImpl
GdkRectangle m_aTextSelectionEnd;
GdkRectangle m_aGraphicSelection;
GdkRectangle m_aCellCursor;
+ /// Position and size of the cell view cursors. The current view can only
+ //see / them, can't modify them. Key is the view id.
+ std::map<int, GdkRectangle> m_aCellViewCursors;
gboolean m_bInDragGraphicSelection;
/// @name Start/middle/end handle.
@@ -355,7 +358,12 @@ callbackTypeToString (int nType)
return "LOK_CALLBACK_INVALIDATE_VIEW_CURSOR";
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
return "LOK_CALLBACK_TEXT_VIEW_SELECTION";
+ case LOK_CALLBACK_CELL_VIEW_CURSOR:
+ return "LOK_CALLBACK_CELL_VIEW_CURSOR";
+ case LOK_CALLBACK_CELL_FORMULA:
+ return "LOK_CALLBACK_CELL_FORMULA";
}
+ g_assert(false);
return nullptr;
}
@@ -1193,6 +1201,24 @@ callback (gpointer pData)
gtk_widget_queue_draw(GTK_WIDGET(pDocView));
break;
}
+ case LOK_CALLBACK_CELL_VIEW_CURSOR:
+ {
+ std::stringstream aStream(pCallback->m_aPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ int nViewId = aTree.get<int>("viewId");
+ const std::string& rRectangle = aTree.get<std::string>("rectangle");
+ if (rRectangle != "EMPTY")
+ priv->m_aCellViewCursors[nViewId] = payloadToRectangle(pDocView, rRectangle.c_str());
+ else
+ {
+ auto it = priv->m_aCellViewCursors.find(nViewId);
+ if (it != priv->m_aCellViewCursors.end())
+ priv->m_aCellViewCursors.erase(it);
+ }
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView));
+ break;
+ }
default:
g_assert(false);
break;
@@ -1580,6 +1606,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
g_free (handleGraphicPath);
}
+ // Draw the cell cursor.
if (!isEmptyRectangle(priv->m_aCellCursor))
{
cairo_set_source_rgb(pCairo, 0, 0, 0);
@@ -1596,6 +1623,22 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
cairo_stroke(pCairo);
}
+ // Cell view cursors: they are colored.
+ for (auto& rPair : priv->m_aCellViewCursors)
+ {
+ GdkRectangle& rCursor = rPair.second;
+
+ const GdkRGBA& rDark = getDarkColor(rPair.first);
+ cairo_set_source_rgb(pCairo, rDark.red, rDark.green, rDark.blue);
+ cairo_rectangle(pCairo,
+ twipToPixel(rCursor.x, priv->m_fZoom),
+ twipToPixel(rCursor.y, priv->m_fZoom),
+ twipToPixel(rCursor.width, priv->m_fZoom),
+ twipToPixel(rCursor.height, priv->m_fZoom));
+ cairo_set_line_width(pCairo, 2.0);
+ cairo_stroke(pCairo);
+ }
+
return FALSE;
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 6fb3966..6d17141 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -137,6 +137,7 @@
#include <svx/sdr/overlay/overlayselection.hxx>
#include <comphelper/string.hxx>
#include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -5722,6 +5723,7 @@ void ScGridWindow::updateLibreOfficeKitCellCursor()
OString aCursor = getCellCursor(pViewData->GetZoomX(), pViewData->GetZoomY());
ScTabViewShell* pViewShell = pViewData->GetViewShell();
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, aCursor.getStr());
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", aCursor);
}
void ScGridWindow::CursorChanged()
@@ -5766,6 +5768,7 @@ void ScGridWindow::DeleteCursorOverlay()
{
ScTabViewShell* pViewShell = pViewData->GetViewShell();
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_CURSOR, "EMPTY");
+ SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_CELL_VIEW_CURSOR, "rectangle", "EMPTY");
mpOOCursors.reset();
}
More information about the Libreoffice-commits
mailing list