Kaydet (Commit) 3ebaaebf authored tarafından Pranav Kant's avatar Pranav Kant

Change CB_DIALOG_INVALIDATE to CB_DIALOG

We can specify whether it is an invalidation or something else in the
payload.

Change-Id: I95c5fc0a0a88b5277eaa93c8d1f9b937bddce7b3
üst 77bb77ae
......@@ -785,7 +785,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_SET_PART:
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
case LOK_CALLBACK_INVALIDATE_HEADER:
case LOK_CALLBACK_DIALOG_INVALIDATE:
case LOK_CALLBACK_DIALOG:
{
const auto& pos = std::find_if(m_queue.rbegin(), m_queue.rend(),
[type] (const queue_type::value_type& elem) { return (elem.first == type); });
......
......@@ -525,7 +525,7 @@ typedef enum
/**
* Dialog invalidation
*/
LOK_CALLBACK_DIALOG_INVALIDATE = 36,
LOK_CALLBACK_DIALOG = 36,
/**
* Invalidation corresponding to dialog's children.
......
......@@ -40,8 +40,8 @@ public:
static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
/// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
/// Emits a LOK_CALLBACK_DIALOG_INVALIDATE with 'invalidate' action
static void notifyDialogInvalidation(const OUString& rPayload);
/// Emits a LOK_CALLBACK_DIALOG
static void notifyDialog(const OUString& rPayload, const OUString& rAction);
/// Emits a LOK_CALLBACK_DIALOG_CHILD
static void notifyDialogChild(const OUString& rDialogID, const OUString& rAction, const Point& rPos);
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
......
......@@ -46,7 +46,7 @@ public:
int nCount, int nButtons, int nModifier) = 0;
// Callbacks
virtual void notifyDialogInvalidation(const DialogID& rDialogID) = 0;
virtual void notifyDialog(const DialogID& rDialogID, const OUString& rAction) = 0;
virtual void notifyDialogChild(const DialogID& rDialogID, const OUString& rAction, const Point& rPos) = 0;
};
......
......@@ -314,7 +314,7 @@ static void setupDocView(GtvApplicationWindow* window)
g_signal_connect(window->lokdocview, "formula-changed", G_CALLBACK(LOKDocViewSigHandlers::formulaChanged), nullptr);
g_signal_connect(window->lokdocview, "password-required", G_CALLBACK(LOKDocViewSigHandlers::passwordRequired), nullptr);
g_signal_connect(window->lokdocview, "comment", G_CALLBACK(LOKDocViewSigHandlers::comment), nullptr);
g_signal_connect(window->lokdocview, "dialog-invalidate", G_CALLBACK(LOKDocViewSigHandlers::dialogInvalidate), nullptr);
g_signal_connect(window->lokdocview, "dialog", G_CALLBACK(LOKDocViewSigHandlers::dialog), nullptr);
g_signal_connect(window->lokdocview, "dialog-child", G_CALLBACK(LOKDocViewSigHandlers::dialogChild), nullptr);
g_signal_connect(window->lokdocview, "configure-event", G_CALLBACK(LOKDocViewSigHandlers::configureEvent), nullptr);
......
......@@ -281,10 +281,19 @@ void LOKDocViewSigHandlers::comment(LOKDocView* pDocView, gchar* pComment, gpoin
}
}
void LOKDocViewSigHandlers::dialogInvalidate(LOKDocView* pDocView, gchar* pPayload, gpointer)
void LOKDocViewSigHandlers::dialog(LOKDocView* pDocView, gchar* pPayload, gpointer)
{
GtvApplicationWindow* window = GTV_APPLICATION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(pDocView)));
// GtkWindow* pDialog = gtv_application_window_get_child_window_by_id(window, pDialogId);
std::stringstream aStream(pPayload);
boost::property_tree::ptree aRoot;
boost::property_tree::read_json(aStream, aRoot);
//std::string aDialogId = aRoot.get<std::string>("dialogId");
std::string aAction = aRoot.get<std::string>("action");
// we only understand 'invalidate' as of now
if (aAction != "invalidate")
return;
// temporary hack to invalidate all open dialogs
GList* pChildWins = gtv_application_window_get_all_child_windows(window);
......@@ -293,11 +302,6 @@ void LOKDocViewSigHandlers::dialogInvalidate(LOKDocView* pDocView, gchar* pPaylo
{
gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pIt->data));
}
/* if (pDialog)
{
gtv_lok_dialog_invalidate(GTV_LOK_DIALOG(pDialog));
}
*/
}
void LOKDocViewSigHandlers::dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer)
......
......@@ -25,7 +25,7 @@ namespace LOKDocViewSigHandlers {
void formulaChanged(LOKDocView* pDocView, char* pPayload, gpointer);
void passwordRequired(LOKDocView* pDocView, char* pUrl, gboolean bModify, gpointer);
void comment(LOKDocView* pDocView, gchar* pComment, gpointer);
void dialogInvalidate(LOKDocView* pDocView, gchar* pDialogId, gpointer);
void dialog(LOKDocView* pDocView, gchar* pDialogId, gpointer);
void dialogChild(LOKDocView* pDocView, gchar* pPayload, gpointer);
gboolean configureEvent(GtkWidget* pWidget, GdkEventConfigure* pEvent, gpointer pData);
......
......@@ -279,7 +279,7 @@ enum
PASSWORD_REQUIRED,
COMMENT,
RULER,
DIALOG_INVALIDATE,
DIALOG,
DIALOG_CHILD,
LAST_SIGNAL
......@@ -438,8 +438,8 @@ callbackTypeToString (int nType)
return "LOK_CALLBACK_COMMENT";
case LOK_CALLBACK_RULER_UPDATE:
return "LOK_CALLBACK_RULER_UPDATE";
case LOK_CALLBACK_DIALOG_INVALIDATE:
return "LOK_CALLBACK_DIALOG_INVALIDATE";
case LOK_CALLBACK_DIALOG:
return "LOK_CALLBACK_DIALOG";
case LOK_CALLBACK_DIALOG_CHILD:
return "LOK_CALLBACK_DIALOG_CHILD";
}
......@@ -1414,8 +1414,9 @@ callback (gpointer pData)
break;
case LOK_CALLBACK_RULER_UPDATE:
g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, pCallback->m_aPayload.c_str());
case LOK_CALLBACK_DIALOG_INVALIDATE:
g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG_INVALIDATE], 0, pCallback->m_aPayload.c_str());
break;
case LOK_CALLBACK_DIALOG:
g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG], 0, pCallback->m_aPayload.c_str());
break;
case LOK_CALLBACK_DIALOG_CHILD:
g_signal_emit(pCallback->m_pDocView, doc_view_signals[DIALOG_CHILD], 0, pCallback->m_aPayload.c_str());
......@@ -3222,8 +3223,8 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
* @pDocView: the #LOKDocView on which the signal is emitted
* @pDialogId: The uno command for the dialog (dialog ID)
*/
doc_view_signals[DIALOG_INVALIDATE] =
g_signal_new("dialog-invalidate",
doc_view_signals[DIALOG] =
g_signal_new("dialog",
G_TYPE_FROM_CLASS(pGObjectClass),
G_SIGNAL_RUN_FIRST,
0,
......
......@@ -144,15 +144,19 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
}
}
void SfxLokHelper::notifyDialogInvalidation(const OUString& rDialogID)
void SfxLokHelper::notifyDialog(const OUString& rDialogID, const OUString& rAction)
{
if (SfxLokHelper::getViewsCount() <= 0)
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
const OString aPayload = OString("{ \"dialogId\": \"") + OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr() +
OString("\", \"action\": \"") + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8).getStr() +
+ "\" }";
while (pViewShell)
{
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG_INVALIDATE, OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr());
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG, aPayload.getStr());
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
......
......@@ -442,7 +442,7 @@ public:
void postDialogChildMouseEvent(const vcl::DialogID& rDialogID, int nType, int nX, int nY,
int nCount, int nButtons, int nModifier) override;
void notifyDialogInvalidation(const vcl::DialogID& rDialogID) override;
void notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction) override;
void notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos) override;
......
......@@ -3783,9 +3783,9 @@ void SwXTextDocument::postDialogChildMouseEvent(const vcl::DialogID& rDialogID,
}
}
void SwXTextDocument::notifyDialogInvalidation(const vcl::DialogID& rDialogID)
void SwXTextDocument::notifyDialog(const vcl::DialogID& rDialogID, const OUString& rAction)
{
SfxLokHelper::notifyDialogInvalidation(rDialogID);
SfxLokHelper::notifyDialog(rDialogID, rAction);
}
void SwXTextDocument::notifyDialogChild(const vcl::DialogID& rDialogID, const OUString& rAction, const Point& rPos)
......
......@@ -962,7 +962,7 @@ void Dialog::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
{
if (!comphelper::LibreOfficeKit::isDialogPainting() && mpDialogRenderable && !maID.isEmpty())
{
mpDialogRenderable->notifyDialogInvalidation(maID);
mpDialogRenderable->notifyDialog(maID, "invalidate");
}
}
......
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