diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-22 16:45:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-25 10:16:37 +0200 |
commit | 01e37e3e5626551b6e8d261e357afcea1ba7c758 (patch) | |
tree | bbd1bd5402b07c44747d7962a9db48f9c04c1de0 /vcl/jsdialog | |
parent | e318d5d8146d18e2c76e23f2e3c39527f2af9f36 (diff) |
use tools::JsonWriter for dumping property tree
Change-Id: I8f55af19ba10b71bd621e69b27000ab7cb565309
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96677
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/jsdialog')
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index fa7f25d33c00..e27bc81cb39f 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -9,13 +9,15 @@ #include <jsdialog/jsdialogbuilder.hxx> #include <sal/log.hxx> -#include <boost/property_tree/json_parser.hpp> #include <comphelper/lok.hxx> #include <vcl/tabpage.hxx> #include <vcl/toolkit/dialog.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/toolkit/combobox.hxx> #include <messagedialog.hxx> +#include <tools/json_writer.hxx> +#include <o3tl/deleter.hxx> +#include <memory> JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow) : Idle("JSDialog notify") @@ -35,15 +37,14 @@ void JSDialogNotifyIdle::Invoke() const vcl::ILibreOfficeKitNotifier* pNotifier = m_aWindow->GetLOKNotifier(); if (pNotifier) { - std::stringstream aStream; - boost::property_tree::ptree aTree = m_aWindow->DumpAsPropertyTree(); - aTree.put("id", m_aWindow->GetLOKWindowId()); - boost::property_tree::write_json(aStream, aTree); - const std::string message = aStream.str(); - if (message != m_LastNotificationMessage) + tools::JsonWriter aJsonWriter; + m_aWindow->DumpAsPropertyTree(aJsonWriter); + aJsonWriter.put("id", m_aWindow->GetLOKWindowId()); + if (!aJsonWriter.isDataEquals(m_LastNotificationMessage)) { - m_LastNotificationMessage = message; - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + m_LastNotificationMessage = aJsonWriter.extractAsStdString(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, + m_LastNotificationMessage.c_str()); } } } @@ -143,12 +144,10 @@ std::unique_ptr<weld::Dialog> JSInstanceBuilder::weld_dialog(const OString& id, const vcl::ILibreOfficeKitNotifier* pNotifier = pDialog->GetLOKNotifier(); if (pNotifier) { - std::stringstream aStream; - boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree(); - aTree.put("id", m_aOwnedToplevel->GetLOKWindowId()); - boost::property_tree::write_json(aStream, aTree); - const std::string message = aStream.str(); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + tools::JsonWriter aJsonWriter; + m_aOwnedToplevel->DumpAsPropertyTree(aJsonWriter); + aJsonWriter.put("id", m_aOwnedToplevel->GetLOKWindowId()); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aJsonWriter.extractData()); } return pRet; @@ -280,12 +279,11 @@ weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen const vcl::ILibreOfficeKitNotifier* pNotifier = xMessageDialog->GetLOKNotifier(); if (pNotifier) { - std::stringstream aStream; - boost::property_tree::ptree aTree = xMessageDialog->DumpAsPropertyTree(); - aTree.put("id", xMessageDialog->GetLOKWindowId()); - boost::property_tree::write_json(aStream, aTree); - const std::string message = aStream.str(); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + tools::JsonWriter aJsonWriter; + xMessageDialog->DumpAsPropertyTree(aJsonWriter); + aJsonWriter.put("id", xMessageDialog->GetLOKWindowId()); + std::unique_ptr<char[], o3tl::free_delete> message(aJsonWriter.extractData()); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.get()); } return new JSMessageDialog(xMessageDialog, nullptr, true); |