[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/LOKitHelper.hpp loolwsd/LOOLKit.cpp
Tor Lillqvist
tml at collabora.com
Fri Mar 4 09:52:02 UTC 2016
loolwsd/ChildProcessSession.cpp | 52 ++-----------------------------------
loolwsd/LOKitHelper.hpp | 55 ++++++++++++++++++++++++++++++++++++++++
loolwsd/LOOLKit.cpp | 25 +-----------------
3 files changed, 60 insertions(+), 72 deletions(-)
New commits:
commit 6859c85543121ab069aeef9dbcaab0b5b5b280b2
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Mar 4 11:49:46 2016 +0200
Factor out function to get the symbolic name for a LibreOfficeKitCallbackType
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index a2e28f9..fe77656 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -72,58 +72,12 @@ public:
{
}
- std::string callbackTypeToString (const int nType)
- {
- switch (nType)
- {
- case LOK_CALLBACK_INVALIDATE_TILES:
- return std::string("LOK_CALLBACK_INVALIDATE_TILES");
- case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
- return std::string("LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR");
- case LOK_CALLBACK_TEXT_SELECTION:
- return std::string("LOK_CALLBACK_TEXT_SELECTION");
- case LOK_CALLBACK_TEXT_SELECTION_START:
- return std::string("LOK_CALLBACK_TEXT_SELECTION_START");
- case LOK_CALLBACK_TEXT_SELECTION_END:
- return std::string("LOK_CALLBACK_TEXT_SELECTION_END");
- case LOK_CALLBACK_CURSOR_VISIBLE:
- return std::string("LOK_CALLBACK_CURSOR_VISIBLE");
- case LOK_CALLBACK_GRAPHIC_SELECTION:
- return std::string("LOK_CALLBACK_GRAPHIC_SELECTION");
- case LOK_CALLBACK_CELL_CURSOR:
- return std::string("LOK_CALLBACK_CELL_CURSOR");
- case LOK_CALLBACK_CELL_FORMULA:
- return std::string("LOK_CALLBACK_CELL_FORMULA");
- case LOK_CALLBACK_MOUSE_POINTER:
- return std::string("LOK_CALLBACK_MOUSE_POINTER");
- case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
- return std::string("LOK_CALLBACK_SEARCH_RESULT_SELECTION");
- case LOK_CALLBACK_UNO_COMMAND_RESULT:
- return std::string("LOK_CALLBACK_UNO_COMMAND_RESULT");
- case LOK_CALLBACK_HYPERLINK_CLICKED:
- return std::string("LOK_CALLBACK_HYPERLINK_CLICKED");
- case LOK_CALLBACK_STATE_CHANGED:
- return std::string("LOK_CALLBACK_STATE_CHANGED");
- case LOK_CALLBACK_SEARCH_NOT_FOUND:
- return std::string("LOK_CALLBACK_SEARCH_NOT_FOUND");
- case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
- return std::string("LOK_CALLBACK_DOCUMENT_SIZE_CHANGED");
- case LOK_CALLBACK_SET_PART:
- return std::string("LOK_CALLBACK_SET_PART");
- case LOK_CALLBACK_DOCUMENT_PASSWORD:
- return std::string("LOK_CALLBACK_DOCUMENT_PASSWORD");
- case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
- return std::string("LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY");
- }
- return std::to_string(nType);
- }
-
void callback(const int nType, const std::string& rPayload)
{
auto lock = _session.getLock();
Log::trace() << "CallbackWorker::callback [" << _session.getViewId() << "] "
- << callbackTypeToString(nType)
+ << LOKitHelper::kitCallbackTypeToString(nType)
<< " [" << rPayload << "]." << Log::end;
if (_session.isDisconnected())
{
@@ -268,14 +222,14 @@ public:
}
catch (const Exception& exc)
{
- Log::error() << "Error while handling callback [" << callbackTypeToString(nType) << "]. "
+ Log::error() << "Error while handling callback [" << LOKitHelper::kitCallbackTypeToString(nType) << "]. "
<< exc.displayText()
<< (exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")
<< Log::end;
}
catch (const std::exception& exc)
{
- Log::error("Error while handling callback [" + callbackTypeToString(nType) + "]. " +
+ Log::error("Error while handling callback [" + LOKitHelper::kitCallbackTypeToString(nType) + "]. " +
std::string("Exception: ") + exc.what());
}
}
diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index fb0cdbc..b6756fe 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -37,6 +37,61 @@ namespace LOKitHelper
}
inline
+ std::string kitCallbackTypeToString (const int nType)
+ {
+ // Keep in the same order as in LibreOfficeKitEnums.h
+ switch (nType)
+ {
+ case LOK_CALLBACK_INVALIDATE_TILES:
+ return "INVALIDATE_TILES";
+ case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
+ return "INVALIDATE_VISIBLE_CURSOR";
+ case LOK_CALLBACK_TEXT_SELECTION:
+ return "TEXT_SELECTION";
+ case LOK_CALLBACK_TEXT_SELECTION_START:
+ return "TEXT_SELECTION_START";
+ case LOK_CALLBACK_TEXT_SELECTION_END:
+ return "TEXT_SELECTION_END";
+ case LOK_CALLBACK_CURSOR_VISIBLE:
+ return "CURSOR_VISIBLE";
+ case LOK_CALLBACK_GRAPHIC_SELECTION:
+ return "GRAPHIC_SELECTION";
+ case LOK_CALLBACK_HYPERLINK_CLICKED:
+ return "HYPERLINK_CLICKED";
+ case LOK_CALLBACK_STATE_CHANGED:
+ return "STATE_CHANGED";
+ case LOK_CALLBACK_STATUS_INDICATOR_START:
+ return "STATUS_INDICATOR_START";
+ case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
+ return "STATUS_INDICATOR_SET_VALUE";
+ case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
+ return "STATUS_INDICATOR_FINISH";
+ case LOK_CALLBACK_SEARCH_NOT_FOUND:
+ return "SEARCH_NOT_FOUND";
+ case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+ return "DOCUMENT_SIZE_CHANGED";
+ case LOK_CALLBACK_SET_PART:
+ return "SET_PART";
+ case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
+ return "SEARCH_RESULT_SELECTION";
+ case LOK_CALLBACK_UNO_COMMAND_RESULT:
+ return "UNO_COMMAND_RESULT";
+ case LOK_CALLBACK_CELL_CURSOR:
+ return "CELL_CURSOR";
+ case LOK_CALLBACK_MOUSE_POINTER:
+ return "MOUSE_POINTER";
+ case LOK_CALLBACK_CELL_FORMULA:
+ return "CELL_FORMULA";
+ case LOK_CALLBACK_DOCUMENT_PASSWORD:
+ return "DOCUMENT_PASSWORD";
+ case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
+ return "DOCUMENT_PASSWORD_TO_MODIFY";
+ }
+
+ return std::to_string(nType);
+ }
+
+ inline
std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
{
std::string typeString(documentTypeToString(static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument))));
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index e335360..9b3a66e 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -46,6 +46,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include "Common.hpp"
+#include "LOKitHelper.hpp"
#include "QueueHandler.hpp"
#include "Util.hpp"
#include "ChildProcessSession.hpp"
@@ -502,34 +503,12 @@ public:
Log::info("setDocumentPassword returned");
}
-
private:
-
- static std::string KitCallbackTypeToString (const int nType)
- {
- switch (nType)
- {
- case LOK_CALLBACK_STATUS_INDICATOR_START:
- return std::string("LOK_CALLBACK_STATUS_INDICATOR_START");
- case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
- return std::string("LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE");
- case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
- return std::string("LOK_CALLBACK_STATUS_INDICATOR_FINISH");
- case LOK_CALLBACK_DOCUMENT_PASSWORD:
- return std::string("LOK_CALLBACK_DOCUMENT_PASSWORD");
- case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
- return std::string("LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY");
- }
-
- return std::to_string(nType);
- }
-
-
static void KitCallback(int nType, const char* pPayload, void* pData)
{
Document* self = reinterpret_cast<Document*>(pData);
Log::trace() << "Document::KitCallback "
- << KitCallbackTypeToString(nType)
+ << LOKitHelper::kitCallbackTypeToString(nType)
<< " [" << (pPayload ? pPayload : "") << "]." << Log::end;
if (self)
More information about the Libreoffice-commits
mailing list