diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 10:55:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-01 09:28:49 +0000 |
commit | 68c5c0bb7eed007bbfbb2e51107fc0196825e85a (patch) | |
tree | 1f910b8de64b99211525bf629ecd44918a15c7ef /libreofficekit/source/gtk | |
parent | 3fc82623635ff8e57df2c92811abd9d7e481c046 (diff) |
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@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'libreofficekit/source/gtk')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
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<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; } |