Kaydet (Commit) 79940606 authored tarafından Andrzej Hunt's avatar Andrzej Hunt

sc lok: Cell Cursor callback

This only works correctly for the default zoom level - since
the updateLibreOfficeKitCellCursor call happens during the
internal / hidden rendering, it uses the internal zoom values,
which can differ from the tiled-rendering zoom values.

Conflicts:
	include/LibreOfficeKit/LibreOfficeKitEnums.h

Change-Id: Ie4f344fe771078fca10ad9d6f7a93e88fb93880a
üst eda52500
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment