diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-10-20 08:52:02 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-20 11:39:04 +0200 |
commit | e368d26a7f24dc25f3d855511baabc128bc151e6 (patch) | |
tree | 373dbf8627eb3bf6d2b4db7439e7078c424d9b99 /libreofficekit | |
parent | 82594fd81ba375d5e7ed919bef0b7b4b8072c02f (diff) |
sw content controls, alias: add LOK API
And implement sample handling of it in lokdocview.
Change-Id: Ia1975e4daef6260e2030e5d0dba8fb4293a9484f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141541
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 4c5dbdd9f595..eb06f2608520 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -127,6 +127,8 @@ struct LOKDocViewPrivateImpl std::vector<GdkRectangle> m_aTextSelectionRectangles; /// Rectangles of the current content control. std::vector<GdkRectangle> m_aContentControlRectangles; + /// Alias/title of the current content control. + std::string m_aContentControlAlias; /// Rectangles of view selections. The current view can only see /// them, can't modify them. Key is the view id. std::map<int, ViewRectangles> m_aTextViewSelectionRectangles; @@ -1406,10 +1408,21 @@ callback (gpointer pData) { auto aRectangles = aTree.get<std::string>("rectangles"); priv->m_aContentControlRectangles = payloadToRectangles(pDocView, aRectangles.c_str()); + + auto it = aTree.find("alias"); + if (it == aTree.not_found()) + { + priv->m_aContentControlAlias.clear(); + } + else + { + priv->m_aContentControlAlias = it->second.get_value<std::string>(); + } } else if (aAction == "hide") { priv->m_aContentControlRectangles.clear(); + priv->m_aContentControlAlias.clear(); } else if (aAction == "change-picture") { @@ -1872,6 +1885,27 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) twipToPixel(rRectangle.height, priv->m_fZoom)); cairo_fill(pCairo); } + + if (!priv->m_aContentControlAlias.empty()) + { + cairo_text_extents_t aExtents; + cairo_text_extents(pCairo, priv->m_aContentControlAlias.c_str(), &aExtents); + // Blue with 75% transparency. + cairo_set_source_rgba(pCairo, 0, 0, 1, 0.25); + cairo_rectangle(pCairo, + twipToPixel(priv->m_aContentControlRectangles[0].x, priv->m_fZoom) + aExtents.x_bearing, + twipToPixel(priv->m_aContentControlRectangles[0].y, priv->m_fZoom) + aExtents.y_bearing, + aExtents.width, + aExtents.height); + cairo_fill(pCairo); + + cairo_move_to(pCairo, + twipToPixel(priv->m_aContentControlRectangles[0].x, priv->m_fZoom), + twipToPixel(priv->m_aContentControlRectangles[0].y, priv->m_fZoom)); + cairo_set_source_rgb(pCairo, 0, 0, 0); + cairo_show_text(pCairo, priv->m_aContentControlAlias.c_str()); + cairo_fill(pCairo); + } } // Selections of other views. |