summaryrefslogtreecommitdiff
path: root/libreofficekit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-21 11:30:04 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-07-20 17:14:30 +0200
commitda9595dca88ca207b1ac9c2f236230202aaa9500 (patch)
treea2c9a8bea405b3e83d7ca5cbd36d383ccb41841b /libreofficekit
parentc64ac7b2e9898cc56266ea8b32321bdd8558da34 (diff)
lokdocview: handle LOK_CALLBACK_TEXT_VIEW_SELECTION
It's similar to the normal selection, but it's colored and has no handles. Change-Id: Ibd9594b4834ff4f9b1cfd85912ed5cee3c8b8c71 Reviewed-on: https://gerrit.libreoffice.org/26543 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 6b9053d371fc8b8543faf7add5fb6d61aab26605)
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx30
1 files changed, 28 insertions, 2 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 9289d441653d..4d3bae20c1dd 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -89,6 +89,9 @@ struct LOKDocViewPrivateImpl
guint32 m_nKeyModifier;
/// Rectangles of the current text selection.
std::vector<GdkRectangle> m_aTextSelectionRectangles;
+ /// Rectangles of view selections. The current view can only see
+ /// them, can't modify them. Key is the view id.
+ std::map<std::uintptr_t, std::vector<GdkRectangle>> m_aTextViewSelectionRectangles;
/// Position and size of the selection start (as if there would be a cursor caret there).
GdkRectangle m_aTextSelectionStart;
/// Position and size of the selection end.
@@ -1173,7 +1176,13 @@ callback (gpointer pData)
}
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
{
- // TODO: Implement me
+ std::stringstream aStream(pCallback->m_aPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ std::uintptr_t nViewId = aTree.get<std::uintptr_t>("viewId");
+ const std::string& rSelection = aTree.get<std::string>("selection");
+ priv->m_aTextViewSelectionRectangles[nViewId] = payloadToRectangles(pDocView, rSelection.c_str());
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView));
break;
}
default:
@@ -1469,7 +1478,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
// Set a minimal width if it would be 0.
rCursor.width = 30;
- const GdkRGBA& rDark = getDarkColor(priv->m_nViewId);
+ 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),
@@ -1534,6 +1543,23 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
}
}
+ // Selections of other views.
+ for (std::pair<const std::uintptr_t, std::vector<GdkRectangle>>& rPair : priv->m_aTextViewSelectionRectangles)
+ {
+ for (GdkRectangle& rRectangle : rPair.second)
+ {
+ const GdkRGBA& rDark = getDarkColor(rPair.first);
+ // 75% transparency.
+ cairo_set_source_rgba(pCairo, rDark.red, rDark.green, rDark.blue, 0.25);
+ cairo_rectangle(pCairo,
+ twipToPixel(rRectangle.x, priv->m_fZoom),
+ twipToPixel(rRectangle.y, priv->m_fZoom),
+ twipToPixel(rRectangle.width, priv->m_fZoom),
+ twipToPixel(rRectangle.height, priv->m_fZoom));
+ cairo_fill(pCairo);
+ }
+ }
+
if (!isEmptyRectangle(priv->m_aGraphicSelection))
{
gchar* handleGraphicPath = g_strconcat (priv->m_aLOPath, CURSOR_HANDLE_DIR, "handle_graphic.png", nullptr);