summaryrefslogtreecommitdiff
path: root/vcl
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 /vcl
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 'vcl')
-rw-r--r--vcl/inc/salvtables.hxx3
-rw-r--r--vcl/inc/window.h2
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx40
-rw-r--r--vcl/source/app/salvtables.cxx2
-rw-r--r--vcl/source/control/button.cxx22
-rw-r--r--vcl/source/control/field.cxx24
-rw-r--r--vcl/source/control/fmtfield.cxx16
-rw-r--r--vcl/source/control/listbox.cxx35
-rw-r--r--vcl/source/control/tabctrl.cxx27
-rw-r--r--vcl/source/window/layout.cxx33
-rw-r--r--vcl/source/window/toolbox2.cxx36
-rw-r--r--vcl/source/window/window.cxx42
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx2
13 files changed, 122 insertions, 162 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index f1fbb4136076..3e748bf5a657 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -377,8 +377,7 @@ public:
virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() override;
- virtual void
- connect_get_property_tree(const Link<boost::property_tree::ptree&, void>& rLink) override;
+ virtual void connect_get_property_tree(const Link<tools::JsonWriter&, void>& rLink) override;
virtual void set_stack_background() override;
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 6b362e7d3bd9..8533f8bea80d 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -249,7 +249,7 @@ public:
std::set<Link<VclWindowEvent&,void>> maChildEventListenersDeleted;
Link<vcl::Window&, bool> maHelpRequestHdl;
Link<vcl::Window&, bool> maMnemonicActivateHdl;
- Link<boost::property_tree::ptree&, void> maDumpAsPropertyTreeHdl;
+ Link<tools::JsonWriter&, void> maDumpAsPropertyTreeHdl;
// The canvas interface for this VCL window. Is persistent after the first GetCanvas() call
css::uno::WeakReference< css::rendering::XCanvas > mxCanvas;
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);
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 9a9484397274..f395d5240182 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -501,7 +501,7 @@ css::uno::Reference<css::datatransfer::dnd::XDropTarget> SalInstanceWidget::get_
}
void SalInstanceWidget::connect_get_property_tree(
- const Link<boost::property_tree::ptree&, void>& rLink)
+ const Link<tools::JsonWriter&, void>& rLink)
{
m_xWidget->SetDumpAsPropertyTreeHdl(rLink);
}
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index afc27c18dd5c..05e8aa46eca7 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -45,6 +45,7 @@
#include <comphelper/lok.hxx>
#include <officecfg/Office/Common.hxx>
#include <boost/property_tree/ptree.hpp>
+#include <tools/json_writer.hxx>
using namespace css;
@@ -552,11 +553,10 @@ FactoryFunction Button::GetUITestFactory() const
return ButtonUIObject::create;
}
-boost::property_tree::ptree Button::DumpAsPropertyTree()
+void Button::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(Control::DumpAsPropertyTree());
- aTree.put("text", GetText());
- return aTree;
+ Control::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("text", GetText());
}
IMPL_STATIC_LINK( Button, dispatchCommandHandler, Button*, pButton, void )
@@ -2844,11 +2844,10 @@ void RadioButton::ShowFocus(const tools::Rectangle& rRect)
Button::ShowFocus(rRect);
}
-boost::property_tree::ptree RadioButton::DumpAsPropertyTree()
+void RadioButton::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(Button::DumpAsPropertyTree());
- aTree.put("checked", IsChecked());
- return aTree;
+ Button::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("checked", IsChecked());
}
FactoryFunction RadioButton::GetUITestFactory() const
@@ -3661,11 +3660,10 @@ void CheckBox::ShowFocus(const tools::Rectangle& rRect)
Button::ShowFocus(rRect);
}
-boost::property_tree::ptree CheckBox::DumpAsPropertyTree()
+void CheckBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(Button::DumpAsPropertyTree());
- aTree.put("checked", IsChecked());
- return aTree;
+ Button::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("checked", IsChecked());
}
FactoryFunction CheckBox::GetUITestFactory() const
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index d81c3b3e2beb..e7a6472713fa 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -43,6 +43,7 @@
#include <unotools/localedatawrapper.hxx>
#include <boost/property_tree/ptree.hpp>
+#include <tools/json_writer.hxx>
using namespace ::com::sun::star;
using namespace ::comphelper;
@@ -871,12 +872,11 @@ void NumericField::Last()
SpinField::Last();
}
-boost::property_tree::ptree NumericField::DumpAsPropertyTree()
+void NumericField::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(SpinField::DumpAsPropertyTree());
- aTree.put("min", GetMin());
- aTree.put("max", GetMax());
- return aTree;
+ SpinField::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("min", GetMin());
+ rJsonWriter.put("max", GetMax());
}
namespace
@@ -1712,17 +1712,15 @@ void MetricField::Last()
SpinField::Last();
}
-boost::property_tree::ptree MetricField::DumpAsPropertyTree()
+void MetricField::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(SpinField::DumpAsPropertyTree());
- aTree.put("min", GetMin());
- aTree.put("max", GetMax());
- aTree.put("unit", FieldUnitToString(GetUnit()));
+ SpinField::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("min", GetMin());
+ rJsonWriter.put("max", GetMax());
+ rJsonWriter.put("unit", FieldUnitToString(GetUnit()));
OUString sValue = Application::GetSettings().GetNeutralLocaleDataWrapper().
getNum(GetValue(), GetDecimalDigits(), false, false);
- aTree.put("value", sValue.toUtf8().getStr());
-
- return aTree;
+ rJsonWriter.put("value", sValue);
}
FactoryFunction MetricField::GetUITestFactory() const
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 87ff8b7b68c9..c00a721250dc 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -38,6 +38,7 @@
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
+#include <tools/json_writer.hxx>
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::util;
@@ -1091,17 +1092,12 @@ void FormattedField::UseInputStringForFormatting()
m_bUseInputStringForFormatting = true;
}
-boost::property_tree::ptree FormattedField::DumpAsPropertyTree()
+void FormattedField::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(SpinField::DumpAsPropertyTree());
- aTree.put("min", rtl::math::doubleToString(GetMinValue(),
- rtl_math_StringFormat_F, GetDecimalDigits(), '.').getStr());
- aTree.put("max", rtl::math::doubleToString(GetMaxValue(),
- rtl_math_StringFormat_F, GetDecimalDigits(), '.').getStr());
- aTree.put("value", rtl::math::doubleToString(GetValue(),
- rtl_math_StringFormat_F, GetDecimalDigits(), '.').getStr());
-
- return aTree;
+ SpinField::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("min", GetMinValue());
+ rJsonWriter.put("max", GetMaxValue());
+ rJsonWriter.put("value", GetValue());
}
FactoryFunction FormattedField::GetUITestFactory() const
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index 9b3cb51c1248..fc7806d732a7 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
#include <boost/property_tree/ptree.hpp>
+#include <tools/json_writer.hxx>
ListBox::ListBox(WindowType nType)
: Control(nType)
@@ -1394,33 +1395,29 @@ FactoryFunction ListBox::GetUITestFactory() const
return ListBoxUIObject::create;
}
-boost::property_tree::ptree ListBox::DumpAsPropertyTree()
+void ListBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(Control::DumpAsPropertyTree());
- boost::property_tree::ptree aEntries;
+ Control::DumpAsPropertyTree(rJsonWriter);
- for (int i = 0; i < GetEntryCount(); ++i)
{
- boost::property_tree::ptree aEntry;
- aEntry.put("", GetEntry(i));
- aEntries.push_back(std::make_pair("", aEntry));
+ auto entriesNode = rJsonWriter.startNode("entries");
+ for (int i = 0; i < GetEntryCount(); ++i)
+ {
+ auto entryNode = rJsonWriter.startNode("");
+ rJsonWriter.put("", GetEntry(i));
+ }
}
- aTree.add_child("entries", aEntries);
+ rJsonWriter.put("selectedCount", GetSelectedEntryCount());
- boost::property_tree::ptree aSelected;
-
- for (int i = 0; i < GetSelectedEntryCount(); ++i)
{
- boost::property_tree::ptree aEntry;
- aEntry.put("", GetSelectedEntryPos(i));
- aSelected.push_back(std::make_pair("", aEntry));
+ auto entriesNode = rJsonWriter.startNode("selectedEntries");
+ for (int i = 0; i < GetSelectedEntryCount(); ++i)
+ {
+ auto entryNode = rJsonWriter.startNode("");
+ rJsonWriter.put("", GetSelectedEntryPos(i));
+ }
}
-
- aTree.put("selectedCount", GetSelectedEntryCount());
- aTree.add_child("selectedEntries", aSelected);
-
- return aTree;
}
MultiListBox::MultiListBox( vcl::Window* pParent, WinBits nStyle ) :
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 0afb0008c9d3..728e4c379858 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -34,6 +34,7 @@
#include <vcl/settings.hxx>
#include <vcl/uitest/uiobject.hxx>
#include <bitmaps.hlst>
+#include <tools/json_writer.hxx>
#include <controldata.hxx>
#include <svdata.hxx>
@@ -2160,24 +2161,20 @@ FactoryFunction TabControl::GetUITestFactory() const
return TabControlUIObject::create;
}
-boost::property_tree::ptree TabControl::DumpAsPropertyTree()
+void TabControl::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree = Control::DumpAsPropertyTree();
-
- boost::property_tree::ptree aTabs;
- for(auto id : GetPageIDs())
+ Control::DumpAsPropertyTree(rJsonWriter);
{
- boost::property_tree::ptree aTab;
- aTab.put("text", GetPageText(id));
- aTab.put("id", id);
- aTab.put("name", GetPageName(id));
- aTabs.push_back(std::make_pair("", aTab));
+ auto tabsNode = rJsonWriter.startNode("tabs");
+ for(auto id : GetPageIDs())
+ {
+ auto tabNode = rJsonWriter.startNode("");
+ rJsonWriter.put("text", GetPageText(id));
+ rJsonWriter.put("id", id);
+ rJsonWriter.put("name", GetPageName(id));
+ }
}
-
- aTree.add_child("tabs", aTabs);
- aTree.put("selected", GetCurPageId());
-
- return aTree;
+ rJsonWriter.put("selected", GetCurPageId());
}
sal_uInt16 NotebookbarTabControlBase::m_nHeaderHeight = 0;
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index af7208c52cb8..f09563fddaad 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -27,6 +27,7 @@
#include <boost/property_tree/ptree.hpp>
#include <vcl/vclmedit.hxx>
#include <sal/log.hxx>
+#include <tools/json_writer.hxx>
VclContainer::VclContainer(vcl::Window *pParent, WinBits nStyle)
: Window(WindowType::CONTAINER)
@@ -360,11 +361,10 @@ bool VclBox::set_property(const OString &rKey, const OUString &rValue)
return true;
}
-boost::property_tree::ptree VclBox::DumpAsPropertyTree()
+void VclBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(VclContainer::DumpAsPropertyTree());
- aTree.put("vertical", m_bVerticalContainer);
- return aTree;
+ VclContainer::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("vertical", m_bVerticalContainer);
}
sal_uInt16 VclBox::getDefaultAccessibleRole() const
@@ -1308,11 +1308,10 @@ void VclGrid::setAllocation(const Size& rAllocation)
}
}
-boost::property_tree::ptree VclGrid::DumpAsPropertyTree()
+void VclGrid::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(VclContainer::DumpAsPropertyTree());
- aTree.put("type", "grid");
- return aTree;
+ VclContainer::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("type", "grid");
}
bool toBool(const OUString &rValue)
@@ -1493,11 +1492,10 @@ OUString VclFrame::getDefaultAccessibleName() const
return VclBin::getDefaultAccessibleName();
}
-boost::property_tree::ptree VclFrame::DumpAsPropertyTree()
+void VclFrame::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(VclBin::DumpAsPropertyTree());
- aTree.put("type", "frame");
- return aTree;
+ VclBin::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("type", "frame");
}
Size VclAlignment::calculateRequisition() const
@@ -2855,25 +2853,24 @@ VclScrolledWindow::~VclScrolledWindow()
disposeOnce();
}
-boost::property_tree::ptree VclDrawingArea::DumpAsPropertyTree()
+void VclDrawingArea::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(Control::DumpAsPropertyTree());
- aTree.put("type", "drawingarea");
+ Control::DumpAsPropertyTree(rJsonWriter);
+ rJsonWriter.put("type", "drawingarea");
+
ScopedVclPtrInstance<VirtualDevice> pDevice;
pDevice->SetOutputSize( GetSizePixel() );
tools::Rectangle aRect(Point(0,0), GetSizePixel());
Paint(*pDevice, aRect);
BitmapEx aImage = pDevice->GetBitmapEx( Point(0,0), GetSizePixel() );
SvMemoryStream aOStm(65535, 65535);
-
if(GraphicConverter::Export(aOStm, aImage, ConvertDataFormat::PNG) == ERRCODE_NONE)
{
css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell());
OUStringBuffer aBuffer("data:image/png;base64,");
::comphelper::Base64::encode(aBuffer, aSeq);
- aTree.put("image", aBuffer.makeStringAndClear());
+ rJsonWriter.put("image", aBuffer.makeStringAndClear());
}
- return aTree;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 3d1bcd7d1739..6ee94e7b0ae5 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -39,6 +39,7 @@
#include <toolbox.h>
#include <unotools/confignode.hxx>
+#include <tools/json_writer.hxx>
using namespace vcl;
@@ -1745,34 +1746,25 @@ void ToolBox::WillUsePopupMode( bool b )
mpData->mbWillUsePopupMode = b;
}
-boost::property_tree::ptree ToolBox::DumpAsPropertyTree()
+void ToolBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- boost::property_tree::ptree aTree(DockingWindow::DumpAsPropertyTree());
- boost::property_tree::ptree aChildren;
+ DockingWindow::DumpAsPropertyTree(rJsonWriter);
- boost::property_tree::ptree::const_assoc_iterator found = aTree.find("children");
- if (found == aTree.not_found())
+ auto childrenNode = rJsonWriter.startNode("children");
+ for (ToolBox::ImplToolItems::size_type i = 0; i < GetItemCount(); ++i)
{
- for (ToolBox::ImplToolItems::size_type i = 0; i < GetItemCount(); ++i)
+ ToolBoxItemType type = GetItemType(i);
+ if (type == ToolBoxItemType::BUTTON)
{
- ToolBoxItemType type = GetItemType(i);
- if (type == ToolBoxItemType::BUTTON)
- {
- boost::property_tree::ptree aEntry;
- int nId = GetItemId(i);
- if (!IsItemVisible(nId))
- continue;
- aEntry.put("type", "toolitem");
- aEntry.put("text", GetItemText(nId));
- aEntry.put("command", GetItemCommand(nId));
- aChildren.push_back(std::make_pair("", aEntry));
- }
+ auto childNode = rJsonWriter.startNode("");
+ int nId = GetItemId(i);
+ if (!IsItemVisible(nId))
+ continue;
+ rJsonWriter.put("type", "toolitem");
+ rJsonWriter.put("text", GetItemText(nId));
+ rJsonWriter.put("command", GetItemCommand(nId));
}
-
- aTree.add_child("children", aChildren);
}
-
- return aTree;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index c3baf5e6547c..e1c498de28ac 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -68,6 +68,7 @@
#include <unotools/configmgr.hxx>
#include <osl/diagnose.h>
#include <tools/debug.hxx>
+#include <tools/json_writer.hxx>
#include <boost/property_tree/ptree.hpp>
#include <cassert>
@@ -1768,7 +1769,7 @@ void Window::ImplNewInputContext()
pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
}
-void Window::SetDumpAsPropertyTreeHdl(const Link<boost::property_tree::ptree&, void>& rLink)
+void Window::SetDumpAsPropertyTreeHdl(const Link<tools::JsonWriter&, void>& rLink)
{
if (mpWindowImpl) // may be called after dispose
{
@@ -3380,47 +3381,34 @@ const char* windowTypeName(WindowType nWindowType)
}
-boost::property_tree::ptree Window::DumpAsPropertyTree()
+void Window::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
- // This is for the code in sc/source/ui/sidebar/AlignmentPropertyPanel.cxx.
- // Also see commit f27c6320e8496d690b5d341d3718430709263a1c
- // "lok: remove complex rotation / alignment settings"
- if (get_id() == "textorientbox") {
- return boost::property_tree::ptree();
- }
-
- boost::property_tree::ptree aTree;
- aTree.put("id", get_id()); // TODO could be missing - sort out
- aTree.put("type", windowTypeName(GetType()));
- aTree.put("text", GetText());
- aTree.put("enabled", IsEnabled());
+ rJsonWriter.put("id", get_id()); // TODO could be missing - sort out
+ rJsonWriter.put("type", windowTypeName(GetType()));
+ rJsonWriter.put("text", GetText());
+ rJsonWriter.put("enabled", IsEnabled());
- boost::property_tree::ptree aChildren;
if (vcl::Window* pChild = mpWindowImpl->mpFirstChild)
{
+ auto childrenNode = rJsonWriter.startNode("children");
while (pChild)
{
if (pChild->IsVisible()) {
- boost::property_tree::ptree aSubTree = pChild->DumpAsPropertyTree();
- int nLeft = pChild->get_grid_left_attach();
- int nTop = pChild->get_grid_top_attach();
+ auto childNode = rJsonWriter.startNode("");
+ pChild->DumpAsPropertyTree(rJsonWriter);
+ sal_Int32 nLeft = pChild->get_grid_left_attach();
+ sal_Int32 nTop = pChild->get_grid_top_attach();
if (nLeft != -1 && nTop != -1)
{
- OUString sLeft = OUString::number(nLeft);
- OUString sTop = OUString::number(nTop);
- aSubTree.put("left", sLeft);
- aSubTree.put("top", sTop);
+ rJsonWriter.put("left", nLeft);
+ rJsonWriter.put("top", nTop);
}
- aChildren.push_back(std::make_pair("", aSubTree));
}
pChild = pChild->mpWindowImpl->mpNext;
}
- aTree.add_child("children", aChildren);
}
- mpWindowImpl->maDumpAsPropertyTreeHdl.Call(aTree);
-
- return aTree;
+ mpWindowImpl->maDumpAsPropertyTreeHdl.Call(rJsonWriter);
}
void Window::ImplCallDeactivateListeners( vcl::Window *pNew )
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index c38e1ebe373a..7270e3e21be5 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -2906,7 +2906,7 @@ public:
return m_xDropTarget.get();
}
- virtual void connect_get_property_tree(const Link<boost::property_tree::ptree&, void>& /*rLink*/) override
+ virtual void connect_get_property_tree(const Link<tools::JsonWriter&, void>& /*rLink*/) override
{
//not implemented for the gtk variant
}