From 044b9fdd6890b4fd34324d44fabb675daa8ff356 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 19 Jul 2016 15:57:29 +0200 Subject: lokdocview: still allow view selections/cursors from other Writer views Writer pages are exposed as parts, but it still makes sense showing selections/cursors from other parts in that case. Change-Id: Ic76d93291bde2d959c149cf2ef5eba7ed33a45e8 Reviewed-on: https://gerrit.libreoffice.org/27321 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 3c425926d48e513937ad727a56ab7744ca379e63) --- libreofficekit/source/gtk/lokdocview.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 09ba343f8017..6386d2670dfb 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -172,9 +172,12 @@ struct LOKDocViewPrivateImpl /// View ID, returned by createView() or 0 by default. int m_nViewId; - /// Part ID, returned by getPart(). + /// Cached part ID, returned by getPart(). int m_nPartId; + /// Cached document type, returned by getDocumentType(). + LibreOfficeKitDocumentType m_eDocumentType; + /** * Contains a freshly set zoom level: logic size of a tile. * It gets reset back to 0 when LOK was informed about this zoom change. @@ -1586,7 +1589,8 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) if (itVisibility != priv->m_aViewCursorVisibilities.end() && !itVisibility->second) continue; - if (rPair.second.m_nPart != priv->m_nPartId) + // Show view cursors when in Writer or when the part matches. + if (rPair.second.m_nPart != priv->m_nPartId && priv->m_eDocumentType != LOK_DOCTYPE_TEXT) continue; GdkRectangle& rCursor = rPair.second.m_aRectangle; @@ -1662,7 +1666,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) // Selections of other views. for (auto& rPair : priv->m_aTextViewSelectionRectangles) { - if (rPair.second.m_nPart != priv->m_nPartId) + if (rPair.second.m_nPart != priv->m_nPartId && priv->m_eDocumentType != LOK_DOCTYPE_TEXT) continue; for (GdkRectangle& rRectangle : rPair.second.m_aRectangles) @@ -1689,7 +1693,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo) for (auto& rPair : priv->m_aGraphicViewSelections) { const ViewRectangle& rRectangle = rPair.second; - if (rRectangle.m_nPart != priv->m_nPartId) + if (rRectangle.m_nPart != priv->m_nPartId && priv->m_eDocumentType != LOK_DOCTYPE_TEXT) continue; const GdkRGBA& rDark = getDarkColor(rPair.first); @@ -2046,6 +2050,7 @@ openDocumentInThread (gpointer data) priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, globalCallbackWorker, pDocView); priv->m_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, priv->m_aDocPath ); + priv->m_eDocumentType = static_cast(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument)); if ( !priv->m_pDocument ) { char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice ); @@ -2319,6 +2324,7 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal break; case PROP_DOC_POINTER: priv->m_pDocument = static_cast(g_value_get_pointer(value)); + priv->m_eDocumentType = static_cast(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument)); break; case PROP_EDITABLE: lok_doc_view_set_edit (pDocView, g_value_get_boolean (value)); -- cgit v1.2.3