summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-06-22 16:45:03 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-06-25 10:16:37 +0200
commit01e37e3e5626551b6e8d261e357afcea1ba7c758 (patch)
treebbd1bd5402b07c44747d7962a9db48f9c04c1de0 /sfx2
parente318d5d8146d18e2c76e23f2e3c39527f2af9f36 (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 'sfx2')
-rw-r--r--sfx2/source/sidebar/Deck.cxx35
-rw-r--r--sfx2/source/sidebar/Panel.cxx12
-rw-r--r--sfx2/source/sidebar/SidebarDockingWindow.cxx13
3 files changed, 25 insertions, 35 deletions
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index d96305c3e2df..3088eb245497 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -35,7 +35,7 @@
#include <vcl/IDialogRenderable.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/svborder.hxx>
-#include <boost/property_tree/ptree.hpp>
+#include <tools/json_writer.hxx>
#include <sal/log.hxx>
using namespace css;
@@ -194,15 +194,14 @@ void Deck::Resize()
* Get the ordering as is shown in the layout, and our type as 'deck'
* also elide nested panel windows.
*/
-boost::property_tree::ptree Deck::DumpAsPropertyTree()
+void Deck::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree;
- aTree.put("id", get_id()); // TODO could be missing - sort out
- aTree.put("type", "deck");
- aTree.put("text", GetText());
- aTree.put("enabled", IsEnabled());
+ rJsonWriter.put("id", get_id()); // TODO could be missing - sort out
+ rJsonWriter.put("type", "deck");
+ rJsonWriter.put("text", GetText());
+ rJsonWriter.put("enabled", IsEnabled());
- boost::property_tree::ptree aPanelNodes;
+ auto childrenNode = rJsonWriter.startNode("children");
for (auto &it : maPanels)
{
if (it->IsLurking())
@@ -216,21 +215,15 @@ boost::property_tree::ptree Deck::DumpAsPropertyTree()
if (!pWindow)
continue;
- boost::property_tree::ptree aPanel;
- aPanel.put("id", it->GetId());
- aPanel.put("type", "panel");
- aPanel.put("text", it->GetText());
- aPanel.put("enabled", it->IsEnabled());
+ auto childNode = rJsonWriter.startNode("");
+ rJsonWriter.put("id", it->GetId());
+ rJsonWriter.put("type", "panel");
+ rJsonWriter.put("text", it->GetText());
+ rJsonWriter.put("enabled", it->IsEnabled());
- boost::property_tree::ptree aChildren;
- aChildren.push_back(std::make_pair("", pWindow->DumpAsPropertyTree()));
- aPanel.add_child("children", aChildren);
-
- aPanelNodes.push_back(std::make_pair("", aPanel));
+ auto children2Node = rJsonWriter.startNode("children");
+ pWindow->DumpAsPropertyTree(rJsonWriter);
}
- aTree.add_child("children", aPanelNodes);
-
- return aTree;
}
bool Deck::ProcessWheelEvent(CommandEvent const * pCommandEvent)
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 85b6ebf14d3e..6c7824b43cfd 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -25,6 +25,7 @@
#include <sfx2/sidebar/ResourceManager.hxx>
#include <sfx2/sidebar/SidebarController.hxx>
+#include <tools/json_writer.hxx>
#ifdef DEBUG
@@ -37,8 +38,6 @@
#include <com/sun/star/ui/XSidebarPanel.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
-#include <boost/property_tree/ptree.hpp>
-
using namespace css;
using namespace css::uno;
@@ -83,16 +82,13 @@ void Panel::ApplySettings(vcl::RenderContext& rRenderContext)
rRenderContext.SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
}
-boost::property_tree::ptree Panel::DumpAsPropertyTree()
+void Panel::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
if (!IsLurking())
{
- boost::property_tree::ptree aTree(vcl::Window::DumpAsPropertyTree());
- aTree.put("type", "panel");
- return aTree;
+ vcl::Window::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("type", "panel");
}
- else
- return boost::property_tree::ptree();
}
void Panel::dispose()
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 7039983f9cfd..8cc420001210 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -29,6 +29,7 @@
#include <sfx2/viewfrm.hxx>
#include <svtools/acceleratorexecute.hxx>
#include <tools/gen.hxx>
+#include <tools/json_writer.hxx>
#include <vcl/event.hxx>
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -68,15 +69,15 @@ public:
if (pMobileNotifier && pMobileNotifier->isLOKMobilePhone())
{
// Mobile phone.
- std::stringstream aStream;
- boost::property_tree::ptree aTree = m_rSidebarDockingWin.DumpAsPropertyTree();
- aTree.put("id", m_rSidebarDockingWin.GetLOKWindowId());
- boost::property_tree::write_json(aStream, aTree);
- const std::string message = aStream.str();
+ tools::JsonWriter aJsonWriter;
+ m_rSidebarDockingWin.DumpAsPropertyTree(aJsonWriter);
+ aJsonWriter.put("id", m_rSidebarDockingWin.GetLOKWindowId());
+ std::unique_ptr<char[]> data( aJsonWriter.extractData());
+ std::string_view message(data.get());
if (message != m_LastNotificationMessage)
{
m_LastNotificationMessage = message;
- pMobileNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+ pMobileNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, m_LastNotificationMessage.c_str());
}
}