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 <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2016-07-19 15:57:29 +02:00
parent 3aa52d3682
commit 3c425926d4

View File

@@ -172,9 +172,12 @@ struct LOKDocViewPrivateImpl
/// View ID, returned by createView() or 0 by default. /// View ID, returned by createView() or 0 by default.
int m_nViewId; int m_nViewId;
/// Part ID, returned by getPart(). /// Cached part ID, returned by getPart().
int m_nPartId; int m_nPartId;
/// Cached document type, returned by getDocumentType().
LibreOfficeKitDocumentType m_eDocumentType;
/** /**
* Contains a freshly set zoom level: logic size of a tile. * 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. * It gets reset back to 0 when LOK was informed about this zoom change.
@@ -1601,7 +1604,8 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
if (itVisibility != priv->m_aViewCursorVisibilities.end() && !itVisibility->second) if (itVisibility != priv->m_aViewCursorVisibilities.end() && !itVisibility->second)
continue; 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; continue;
GdkRectangle& rCursor = rPair.second.m_aRectangle; GdkRectangle& rCursor = rPair.second.m_aRectangle;
@@ -1677,7 +1681,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
// Selections of other views. // Selections of other views.
for (auto& rPair : priv->m_aTextViewSelectionRectangles) 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; continue;
for (GdkRectangle& rRectangle : rPair.second.m_aRectangles) for (GdkRectangle& rRectangle : rPair.second.m_aRectangles)
@@ -1704,7 +1708,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
for (auto& rPair : priv->m_aGraphicViewSelections) for (auto& rPair : priv->m_aGraphicViewSelections)
{ {
const ViewRectangle& rRectangle = rPair.second; 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; continue;
const GdkRGBA& rDark = getDarkColor(rPair.first); const GdkRGBA& rDark = getDarkColor(rPair.first);
@@ -2061,6 +2065,7 @@ openDocumentInThread (gpointer data)
priv->m_pOffice->pClass->registerCallback(priv->m_pOffice, globalCallbackWorker, pDocView); 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_pDocument = priv->m_pOffice->pClass->documentLoad( priv->m_pOffice, priv->m_aDocPath );
priv->m_eDocumentType = static_cast<LibreOfficeKitDocumentType>(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument));
if ( !priv->m_pDocument ) if ( !priv->m_pDocument )
{ {
char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice ); char *pError = priv->m_pOffice->pClass->getError( priv->m_pOffice );
@@ -2334,6 +2339,7 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
break; break;
case PROP_DOC_POINTER: case PROP_DOC_POINTER:
priv->m_pDocument = static_cast<LibreOfficeKitDocument*>(g_value_get_pointer(value)); priv->m_pDocument = static_cast<LibreOfficeKitDocument*>(g_value_get_pointer(value));
priv->m_eDocumentType = static_cast<LibreOfficeKitDocumentType>(priv->m_pDocument->pClass->getDocumentType(priv->m_pDocument));
break; break;
case PROP_EDITABLE: case PROP_EDITABLE:
lok_doc_view_set_edit (pDocView, g_value_get_boolean (value)); lok_doc_view_set_edit (pDocView, g_value_get_boolean (value));