lok: sc: notify cell cursor position to address control in client
A new callback has been introduced for notifying the client: LOK_CALLBACK_CELL_ADDRESS Change-Id: I40b38a3cb8fb658c3f00332d56cfcbaf98e13771 Reviewed-on: https://gerrit.libreoffice.org/37357 Reviewed-by: pranavk <pranavk@collabora.co.uk> Tested-by: pranavk <pranavk@collabora.co.uk>
This commit is contained in:
parent
b973b184a0
commit
9cc9300bc2
5 changed files with 103 additions and 8 deletions
|
@ -673,6 +673,7 @@ CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
|
|||
m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL");
|
||||
m_states.emplace(LOK_CALLBACK_CELL_CURSOR, "NIL");
|
||||
m_states.emplace(LOK_CALLBACK_CELL_FORMULA, "NIL");
|
||||
m_states.emplace(LOK_CALLBACK_CELL_ADDRESS, "NIL");
|
||||
m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE, "NIL");
|
||||
m_states.emplace(LOK_CALLBACK_SET_PART, "NIL");
|
||||
|
||||
|
@ -752,6 +753,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
|
|||
case LOK_CALLBACK_CELL_CURSOR:
|
||||
case LOK_CALLBACK_CELL_VIEW_CURSOR:
|
||||
case LOK_CALLBACK_CELL_FORMULA:
|
||||
case LOK_CALLBACK_CELL_ADDRESS:
|
||||
case LOK_CALLBACK_CURSOR_VISIBLE:
|
||||
case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
|
||||
case LOK_CALLBACK_SET_PART:
|
||||
|
@ -812,6 +814,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
|
|||
case LOK_CALLBACK_MOUSE_POINTER:
|
||||
case LOK_CALLBACK_CELL_CURSOR:
|
||||
case LOK_CALLBACK_CELL_FORMULA:
|
||||
case LOK_CALLBACK_CELL_ADDRESS:
|
||||
case LOK_CALLBACK_CURSOR_VISIBLE:
|
||||
case LOK_CALLBACK_SET_PART:
|
||||
case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
|
||||
|
|
|
@ -500,7 +500,12 @@ typedef enum
|
|||
*
|
||||
* The payload says if we are invalidating a row or column header.
|
||||
*/
|
||||
LOK_CALLBACK_INVALIDATE_HEADER = 33
|
||||
LOK_CALLBACK_INVALIDATE_HEADER = 33,
|
||||
/**
|
||||
* The text content of the address field in Calc.
|
||||
*/
|
||||
LOK_CALLBACK_CELL_ADDRESS = 34
|
||||
|
||||
}
|
||||
LibreOfficeKitCallbackType;
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ public:
|
|||
GtkToolItem* m_pInsertAnnotation;
|
||||
GtkToolItem* m_pDeleteComment;
|
||||
GtkToolItem* m_pTrackChanges;
|
||||
GtkWidget* m_pAddressbarEntry;
|
||||
GtkWidget* m_pFormulabarEntry;
|
||||
GtkWidget* m_pScrolledWindow;
|
||||
std::map<GtkToolItem*, std::string> m_aToolItemCommandNames;
|
||||
|
@ -590,6 +591,7 @@ gboolean TiledRowColumnBar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfi
|
|||
}
|
||||
gtk_widget_show(rWindow.m_pColumnBar->m_pDrawingArea);
|
||||
gtk_widget_queue_draw(rWindow.m_pColumnBar->m_pDrawingArea);
|
||||
gtk_widget_show(rWindow.m_pAddressbarEntry);
|
||||
gtk_widget_show(rWindow.m_pFormulabarEntry);
|
||||
|
||||
}
|
||||
|
@ -1402,6 +1404,39 @@ static gboolean signalFindbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/// Handles the key-press-event of the address entry widget.
|
||||
static gboolean signalAddressbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer /*pData*/)
|
||||
{
|
||||
TiledWindow& rWindow = lcl_getTiledWindow(pWidget);
|
||||
switch(pEvent->keyval)
|
||||
{
|
||||
case GDK_KEY_Return:
|
||||
{
|
||||
GtkEntry* pEntry = GTK_ENTRY(rWindow.m_pAddressbarEntry);
|
||||
const char* pText = gtk_entry_get_text(pEntry);
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
aTree.put(boost::property_tree::ptree::path_type("ToPoint/type", '/'), "string");
|
||||
aTree.put(boost::property_tree::ptree::path_type("ToPoint/value", '/'), pText);
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
std::string aArguments = aStream.str();
|
||||
|
||||
lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), ".uno:GoToCell", aArguments.c_str(), false);
|
||||
gtk_widget_grab_focus(rWindow.m_pDocView);
|
||||
return TRUE;
|
||||
}
|
||||
case GDK_KEY_Escape:
|
||||
{
|
||||
std::string aArguments;
|
||||
lok_doc_view_post_command(LOK_DOC_VIEW(rWindow.m_pDocView), ".uno:Cancel", aArguments.c_str(), false);
|
||||
gtk_widget_grab_focus(rWindow.m_pDocView);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/// Handles the key-press-event of the formula entry widget.
|
||||
static gboolean signalFormulabar(GtkWidget* /*pWidget*/, GdkEventKey* /*pEvent*/, gpointer /*pData*/)
|
||||
{
|
||||
|
@ -1593,6 +1628,13 @@ static void cursorChanged(LOKDocView* pDocView, gint nX, gint nY,
|
|||
gtk_adjustment_set_value(hadj, lok_doc_view_twip_to_pixel(LOK_DOC_VIEW(pDocView), x));
|
||||
}
|
||||
|
||||
/// LOKDocView the address has changed
|
||||
static void addressChanged(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
|
||||
{
|
||||
TiledWindow& rWindow = lcl_getTiledWindow(GTK_WIDGET(pLOKDocView));
|
||||
gtk_entry_set_text(GTK_ENTRY(rWindow.m_pAddressbarEntry), pPayload);
|
||||
}
|
||||
|
||||
/// LOKDocView the formula has changed
|
||||
static void formulaChanged(LOKDocView* pLOKDocView, char* pPayload, gpointer /*pData*/)
|
||||
{
|
||||
|
@ -2088,6 +2130,14 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
|
|||
lcl_registerToolItem(rWindow, rWindow.m_pTrackChanges, ".uno:TrackChanges");
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(rWindow.m_pTrackChanges), false);
|
||||
|
||||
// Address bar
|
||||
GtkToolItem* pAddressEntryContainer = gtk_tool_item_new();
|
||||
rWindow.m_pAddressbarEntry = gtk_entry_new();
|
||||
gtk_container_add(GTK_CONTAINER(pAddressEntryContainer), rWindow.m_pAddressbarEntry);
|
||||
g_signal_connect(rWindow.m_pAddressbarEntry, "key-press-event", G_CALLBACK(signalAddressbar), 0);
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(pLowerToolbar), pAddressEntryContainer, -1);
|
||||
gtk_box_pack_start(GTK_BOX(rWindow.m_pVBox), pLowerToolbar, FALSE, FALSE, 0 ); // Adds to top.
|
||||
|
||||
// Formula bar
|
||||
GtkToolItem* pFormulaEntryContainer = gtk_tool_item_new();
|
||||
rWindow.m_pFormulabarEntry = gtk_entry_new();
|
||||
|
@ -2188,6 +2238,7 @@ static GtkWidget* createWindow(TiledWindow& rWindow)
|
|||
gtk_widget_hide(rWindow.m_pCornerButton->m_pDrawingArea);
|
||||
gtk_widget_hide(rWindow.m_pRowBar->m_pDrawingArea);
|
||||
gtk_widget_hide(rWindow.m_pColumnBar->m_pDrawingArea);
|
||||
gtk_widget_hide(rWindow.m_pAddressbarEntry);
|
||||
gtk_widget_hide(rWindow.m_pFormulabarEntry);
|
||||
// Hide the non-progressbar children of the status bar by default.
|
||||
gtk_widget_hide(rWindow.m_pStatusbarLabel);
|
||||
|
@ -2214,6 +2265,7 @@ static void setupDocView(GtkWidget* pDocView)
|
|||
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), nullptr);
|
||||
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), nullptr);
|
||||
g_signal_connect(pDocView, "cursor-changed", G_CALLBACK(cursorChanged), nullptr);
|
||||
g_signal_connect(pDocView, "address-changed", G_CALLBACK(addressChanged), nullptr);
|
||||
g_signal_connect(pDocView, "formula-changed", G_CALLBACK(formulaChanged), nullptr);
|
||||
g_signal_connect(pDocView, "password-required", G_CALLBACK(passwordRequired), nullptr);
|
||||
g_signal_connect(pDocView, "comment", G_CALLBACK(commentCallback), nullptr);
|
||||
|
|
|
@ -273,6 +273,7 @@ enum
|
|||
CURSOR_CHANGED,
|
||||
SEARCH_RESULT_COUNT,
|
||||
COMMAND_RESULT,
|
||||
ADDRESS_CHANGED,
|
||||
FORMULA_CHANGED,
|
||||
TEXT_SELECTION,
|
||||
PASSWORD_REQUIRED,
|
||||
|
@ -416,6 +417,8 @@ callbackTypeToString (int nType)
|
|||
return "LOK_CALLBACK_TEXT_VIEW_SELECTION";
|
||||
case LOK_CALLBACK_CELL_VIEW_CURSOR:
|
||||
return "LOK_CALLBACK_CELL_VIEW_CURSOR";
|
||||
case LOK_CALLBACK_CELL_ADDRESS:
|
||||
return "LOK_CALLBACK_CELL_ADDRESS";
|
||||
case LOK_CALLBACK_CELL_FORMULA:
|
||||
return "LOK_CALLBACK_CELL_FORMULA";
|
||||
case LOK_CALLBACK_UNO_COMMAND_RESULT:
|
||||
|
@ -882,6 +885,11 @@ static void commandResult(LOKDocView* pDocView, const std::string& rString)
|
|||
g_signal_emit(pDocView, doc_view_signals[COMMAND_RESULT], 0, rString.c_str());
|
||||
}
|
||||
|
||||
static void addressChanged(LOKDocView* pDocView, const std::string& rString)
|
||||
{
|
||||
g_signal_emit(pDocView, doc_view_signals[ADDRESS_CHANGED], 0, rString.c_str());
|
||||
}
|
||||
|
||||
static void formulaChanged(LOKDocView* pDocView, const std::string& rString)
|
||||
{
|
||||
g_signal_emit(pDocView, doc_view_signals[FORMULA_CHANGED], 0, rString.c_str());
|
||||
|
@ -1301,6 +1309,11 @@ callback (gpointer pData)
|
|||
commandResult(pDocView, pCallback->m_aPayload);
|
||||
}
|
||||
break;
|
||||
case LOK_CALLBACK_CELL_ADDRESS:
|
||||
{
|
||||
addressChanged(pDocView, pCallback->m_aPayload);
|
||||
}
|
||||
break;
|
||||
case LOK_CALLBACK_CELL_FORMULA:
|
||||
{
|
||||
formulaChanged(pDocView, pCallback->m_aPayload);
|
||||
|
@ -3071,6 +3084,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
|
|||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
/**
|
||||
* LOKDocView::address-changed:
|
||||
* @pDocView: the #LOKDocView on which the signal is emitted
|
||||
* @aCommand: formula text content
|
||||
*/
|
||||
doc_view_signals[ADDRESS_CHANGED] =
|
||||
g_signal_new("address-changed",
|
||||
G_TYPE_FROM_CLASS(pGObjectClass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0,
|
||||
nullptr, nullptr,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
/**
|
||||
* LOKDocView::formula-changed:
|
||||
* @pDocView: the #LOKDocView on which the signal is emitted
|
||||
|
|
|
@ -3662,7 +3662,7 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
|
|||
}
|
||||
}
|
||||
|
||||
if ( pInputWin ) // Named range input
|
||||
if ( pInputWin || comphelper::LibreOfficeKit::isActive()) // Named range input
|
||||
{
|
||||
OUString aPosStr;
|
||||
const ScAddress::Details aAddrDetails( &rDoc, aCursorPos );
|
||||
|
@ -3688,12 +3688,19 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
|
|||
aPosStr = aCursorPos.Format(ScRefFlags::VALID | nFlags, &rDoc, aAddrDetails);
|
||||
}
|
||||
|
||||
// Disable the accessible VALUE_CHANGE event
|
||||
bool bIsSuppressed = pInputWin->IsAccessibilityEventsSuppressed(false);
|
||||
pInputWin->SetAccessibilityEventsSuppressed(true);
|
||||
pInputWin->SetPosString(aPosStr);
|
||||
pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed);
|
||||
pInputWin->SetSumAssignMode();
|
||||
if (pInputWin)
|
||||
{
|
||||
// Disable the accessible VALUE_CHANGE event
|
||||
bool bIsSuppressed = pInputWin->IsAccessibilityEventsSuppressed(false);
|
||||
pInputWin->SetAccessibilityEventsSuppressed(true);
|
||||
pInputWin->SetPosString(aPosStr);
|
||||
pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed);
|
||||
pInputWin->SetSumAssignMode();
|
||||
}
|
||||
else if (pActiveViewSh)
|
||||
{
|
||||
pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_ADDRESS, aPosStr.toUtf8().getStr());
|
||||
}
|
||||
}
|
||||
|
||||
if (bStopEditing)
|
||||
|
|
Loading…
Reference in a new issue