summaryrefslogtreecommitdiff
path: root/vcl/source/window
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/source/window
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/source/window')
-rw-r--r--vcl/source/window/layout.cxx33
-rw-r--r--vcl/source/window/toolbox2.cxx36
-rw-r--r--vcl/source/window/window.cxx42
3 files changed, 44 insertions, 67 deletions
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 )