desktop/source/lib/lokinteractionhandler.cxx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
New commits: commit 643e0fe7fc16345e3f534f270f7eb5b5276e26a2 Author: Gökay ŞATIR <[email protected]> AuthorDate: Tue Aug 31 13:01:31 2021 +0300 Commit: Noel Grandin <[email protected]> CommitDate: Tue Aug 31 15:05:43 2021 +0200 lokinteractionhandler: Use json_writer for JSon types. This patch is for making more use of new json_writer class. Change-Id: Ic8dd6694887635a363a74d2cf5bd1e3e2987463d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121364 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx index 325e5893184a..1e794c0ff651 100644 --- a/desktop/source/lib/lokinteractionhandler.cxx +++ b/desktop/source/lib/lokinteractionhandler.cxx @@ -49,6 +49,8 @@ #include <sfx2/viewsh.hxx> #include <vcl/svapp.hxx> +#include <tools/json_writer.hxx> + using namespace com::sun::star; LOKInteractionHandler::LOKInteractionHandler( @@ -99,7 +101,7 @@ void SAL_CALL LOKInteractionHandler::handle( void LOKInteractionHandler::postError(css::task::InteractionClassification classif, const char* kind, ErrCode code, const OUString &message) { - const char *classification = "error"; + std::string classification = "error"; switch (classif) { case task::InteractionClassification_ERROR: break; @@ -110,21 +112,18 @@ void LOKInteractionHandler::postError(css::task::InteractionClassification class } // create the JSON representation - boost::property_tree::ptree aTree; - aTree.put("classification", classification); - aTree.put("cmd", m_command.getStr()); - aTree.put("kind", kind); - aTree.put("code", code); - aTree.put("message", message.toUtf8()); - - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); + tools::JsonWriter aJson; + aJson.put("classification", classification); + aJson.put("cmd", m_command.getStr()); + aJson.put("kind", kind); + aJson.put("code", static_cast<sal_uInt32>(code)); + aJson.put("message", message.toUtf8()); std::size_t nView = SfxViewShell::Current() ? SfxLokHelper::getView() : 0; if (m_pLOKDocument && m_pLOKDocument->mpCallbackFlushHandlers.count(nView)) - m_pLOKDocument->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_ERROR, aStream.str().c_str()); + m_pLOKDocument->mpCallbackFlushHandlers[nView]->queue(LOK_CALLBACK_ERROR, aJson.extractAsOString().getStr()); else if (m_pLOKit->mpCallback) - m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aStream.str().c_str(), m_pLOKit->mpCallbackData); + m_pLOKit->mpCallback(LOK_CALLBACK_ERROR, aJson.extractAsOString().getStr(), m_pLOKit->mpCallbackData); } namespace {
