diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-22 16:39:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-07-22 15:13:07 +0000 |
commit | 897189cfc6b3f6f3a9a0148b060ea25e5f8d9eaa (patch) | |
tree | d0323d739785025c1ac3296a2212c350159ce7c9 /libreofficekit | |
parent | 4da8378302093dd3e3dc3e201ac5e188c55f8009 (diff) |
sw: add new LOK_CALLBACK_VIEW_LOCK callback
When we're after SdrBeginTextEdit(), but before SdrEndTextEdit(), and
have multiple views, then only the active view paints the edited text,
the other views look like the shape has no text at all.
Add a new callback that exposes the position and size of the rectangle
where the shape text will be painted after text edit ended, so clients
can draw some kind of locking indicator there. This way the rendered
result can differ in the "shape has no text" and the "shape text is
edited in an other view" cases.
Change-Id: I6096479a8a05c2547d15222e6d997b848af02945
Reviewed-on: https://gerrit.libreoffice.org/27441
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index d5a1dd34be93..f604b583e985 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -190,6 +190,10 @@ struct LOKDocViewPrivateImpl /// Event source ID for handleTimeout() of this widget. guint m_nTimeoutId; + /// Rectangles of view locks. The current view can only see + /// them, can't modify them. Key is the view id. + std::map<int, ViewRectangle> m_aViewLockRectangles; + LOKDocViewPrivateImpl() : m_aLOPath(nullptr), m_pUserProfileURL(nullptr), @@ -415,6 +419,8 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_UNO_COMMAND_RESULT"; case LOK_CALLBACK_ERROR: return "LOK_CALLBACK_ERROR"; + case LOK_CALLBACK_VIEW_LOCK: + return "LOK_CALLBACK_VIEW_LOCK"; } g_assert(false); return nullptr; @@ -1314,6 +1320,25 @@ callback (gpointer pData) gtk_widget_queue_draw(GTK_WIDGET(pDocView)); break; } + case LOK_CALLBACK_VIEW_LOCK: + { + std::stringstream aStream(pCallback->m_aPayload); + boost::property_tree::ptree aTree; + boost::property_tree::read_json(aStream, aTree); + int nViewId = aTree.get<int>("viewId"); + int nPart = aTree.get<int>("part"); + const std::string& rRectangle = aTree.get<std::string>("rectangle"); + if (rRectangle != "EMPTY") + priv->m_aViewLockRectangles[nViewId] = ViewRectangle(nPart, payloadToRectangle(pDocView, rRectangle.c_str())); + else + { + auto it = priv->m_aViewLockRectangles.find(nViewId); + if (it != priv->m_aViewLockRectangles.end()) + priv->m_aViewLockRectangles.erase(it); + } + gtk_widget_queue_draw(GTK_WIDGET(pDocView)); + break; + } default: g_assert(false); break; @@ -1746,6 +1771,40 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) cairo_stroke(pCairo); } + // View locks: they are colored. + for (auto& rPair : priv->m_aViewLockRectangles) + { + const ViewRectangle& rRectangle = rPair.second; + if (rRectangle.m_nPart != priv->m_nPartId) + continue; + + // Draw a rectangle. + const GdkRGBA& rDark = getDarkColor(rPair.first); + cairo_set_source_rgb(pCairo, rDark.red, rDark.green, rDark.blue); + cairo_rectangle(pCairo, + twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.width, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.height, priv->m_fZoom)); + cairo_set_line_width(pCairo, 2.0); + cairo_stroke(pCairo); + + // Cross it. + cairo_move_to(pCairo, + twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom)); + cairo_line_to(pCairo, + twipToPixel(rRectangle.m_aRectangle.x + rRectangle.m_aRectangle.width, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.y + rRectangle.m_aRectangle.height, priv->m_fZoom)); + cairo_move_to(pCairo, + twipToPixel(rRectangle.m_aRectangle.x, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.y + rRectangle.m_aRectangle.height, priv->m_fZoom)); + cairo_line_to(pCairo, + twipToPixel(rRectangle.m_aRectangle.x + rRectangle.m_aRectangle.width, priv->m_fZoom), + twipToPixel(rRectangle.m_aRectangle.y, priv->m_fZoom)); + cairo_stroke(pCairo); + } + return FALSE; } |