diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-10-20 08:52:02 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-20 16:30:53 +0200 |
commit | 17311a5d0e3b4474d961df51a02507246542785d (patch) | |
tree | 16daa7cf549b808d87a9837a6d199571d9097e88 /libreofficekit | |
parent | fbcde15089977ca8354c981fc8794a026fceea1e (diff) |
sw content controls, alias: add LOK API
And implement sample handling of it in lokdocview.
(cherry picked from commit e368d26a7f24dc25f3d855511baabc128bc151e6)
Change-Id: Ia1975e4daef6260e2030e5d0dba8fb4293a9484f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141567
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
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 051970538a08..cfab453a5a35 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -126,6 +126,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; @@ -1407,10 +1409,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") { @@ -1873,6 +1886,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. |