summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h9
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx30
-rw-r--r--sc/source/ui/view/gridwin.cxx31
3 files changed, 66 insertions, 4 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 86d9e6bfd873..bf6267585a0a 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -195,7 +195,14 @@ typedef enum
* // TODO "result": "..." // UNO Any converted to JSON (not implemented yet)
* }
*/
- LOK_CALLBACK_UNO_COMMAND_RESULT
+ LOK_CALLBACK_UNO_COMMAND_RESULT,
+
+ /**
+ * The size and/or the position of the cell cursor changed.
+ *
+ * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
+ */
+ LOK_CALLBACK_CELL_CURSOR
}
LibreOfficeKitCallbackType;
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index dcf6d5ff77cd..9aaa5eff1b79 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -79,6 +79,7 @@ struct LOKDocViewPrivateImpl
/// Position and size of the selection end.
GdkRectangle m_aTextSelectionEnd;
GdkRectangle m_aGraphicSelection;
+ GdkRectangle m_aCellCursor;
gboolean m_bInDragGraphicSelection;
/// @name Start/middle/end handle.
@@ -140,6 +141,7 @@ struct LOKDocViewPrivateImpl
m_aTextSelectionStart({0, 0, 0, 0}),
m_aTextSelectionEnd({0, 0, 0, 0}),
m_aGraphicSelection({0, 0, 0, 0}),
+ m_aCellCursor({0, 0, 0, 0}),
m_bInDragGraphicSelection(false),
m_pHandleStart(0),
m_aHandleStartRect({0, 0, 0, 0}),
@@ -275,6 +277,8 @@ callbackTypeToString (int nType)
return "LOK_CALLBACK_CURSOR_VISIBLE";
case LOK_CALLBACK_GRAPHIC_SELECTION:
return "LOK_CALLBACK_GRAPHIC_SELECTION";
+ case LOK_CALLBACK_CELL_CURSOR:
+ return "LOK_CALLBACK_CELL_CURSOR";
case LOK_CALLBACK_HYPERLINK_CLICKED:
return "LOK_CALLBACK_HYPERLINK_CLICKED";
case LOK_CALLBACK_STATE_CHANGED:
@@ -719,6 +723,15 @@ callback (gpointer pData)
gtk_widget_queue_draw(GTK_WIDGET(pDocView));
}
break;
+ case LOK_CALLBACK_CELL_CURSOR:
+ {
+ if (pCallback->m_aPayload != "EMPTY")
+ priv->m_aCellCursor = payloadToRectangle(pDocView, pCallback->m_aPayload.c_str());
+ else
+ memset(&priv->m_aCellCursor, 0, sizeof(priv->m_aCellCursor));
+ gtk_widget_queue_draw(GTK_WIDGET(pDocView));
+ }
+ break;
case LOK_CALLBACK_HYPERLINK_CLICKED:
{
hyperlinkClicked(pDocView, pCallback->m_aPayload);
@@ -1074,6 +1087,22 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
g_free (handleGraphicPath);
}
+ if (!isEmptyRectangle(priv->m_aCellCursor))
+ {
+ cairo_set_source_rgb(pCairo, 0, 0, 0);
+ cairo_rectangle(pCairo,
+ twipToPixel(priv->m_aCellCursor.x, priv->m_fZoom),
+ twipToPixel(priv->m_aCellCursor.y, priv->m_fZoom),
+ twipToPixel(priv->m_aCellCursor.width, priv->m_fZoom),
+ twipToPixel(priv->m_aCellCursor.height, priv->m_fZoom));
+ // priv->m_aCellCursor.x - 1,
+ // priv->m_aCellCursor.y - 1,
+ // priv->m_aCellCursor.width + 2,
+ // priv->m_aCellCursor.height + 2);
+ cairo_set_line_width(pCairo, 2.0);
+ cairo_stroke(pCairo);
+ }
+
return FALSE;
}
@@ -2331,6 +2360,7 @@ lok_doc_view_reset_view(LOKDocView* pDocView)
memset(&priv->m_aTextSelectionEnd, 0, sizeof(priv->m_aTextSelectionEnd));
memset(&priv->m_aGraphicSelection, 0, sizeof(priv->m_aGraphicSelection));
priv->m_bInDragGraphicSelection = false;
+ memset(&priv->m_aCellCursor, 0, sizeof(priv->m_aCellCursor));
cairo_surface_destroy(priv->m_pHandleStart);
priv->m_pHandleStart = 0;
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0c37ab92fe60..59bf9e00b09c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5775,12 +5775,38 @@ bool ScGridWindow::InsideVisibleRange( SCCOL nPosX, SCROW nPosY )
return maVisibleRange.isInside(nPosX, nPosY);
}
+static void updateLibreOfficeKitCellCursor(ScViewData* pViewData, ScSplitPos eWhich) {
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+
+ if (!pDrawLayer->isTiledRendering())
+ return;
+
+ SCCOL nX = pViewData->GetCurX();
+ SCROW nY = pViewData->GetCurY();
+ Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true );
+
+ long nSizeXPix;
+ long nSizeYPix;
+ pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
+
+ double fPPTX = pViewData->GetPPTX();
+ double fPPTY = pViewData->GetPPTY();
+ Rectangle aRect(Point(aScrPos.getX() / fPPTX, aScrPos.getY() / fPPTY),
+ Size(nSizeXPix / fPPTX, nSizeYPix / fPPTY));
+
+ pDrawLayer->libreOfficeKitCallback(LOK_CALLBACK_CELL_CURSOR, aRect.toString().getStr());
+
+}
+
void ScGridWindow::CursorChanged()
{
// here the created OverlayObjects may be transformed in later versions. For
// now, just re-create them
UpdateCursorOverlay();
+
+ updateLibreOfficeKitCellCursor(pViewData, eWhich);
}
void ScGridWindow::ImpCreateOverlayObjects()
@@ -5932,9 +5958,8 @@ void ScGridWindow::UpdateCursorOverlay()
{
ScDocument* pDoc = pViewData->GetDocument();
- // never show the cell cursor when the tiled rendering is going on; either
- // we want to show the editeng selection, or the cell selection, but not
- // the cell cursor by itself
+ // The cursor is rendered client-side in tiled rendering -
+ // see updateLibreOfficeKitCellCursor.
if (pDoc->GetDrawLayer()->isTiledRendering())
return;