From 68c5c0bb7eed007bbfbb2e51107fc0196825e85a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 1 Jul 2016 10:55:27 +0200 Subject: 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 Tested-by: Jenkins --- libreofficekit/source/gtk/lokdocview.cxx | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'libreofficekit') diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 8e2d2784e85f..cb2118e02087 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 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("viewId"); + const std::string& rRectangle = aTree.get("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; } -- cgit