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>
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 39676f3..802be93 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.
@@ -1179,7 +1182,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:
@@ -1475,7 +1484,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),
@@ -1540,6 +1549,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);