diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2023-03-03 08:13:58 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-03-04 07:07:50 +0000 |
commit | a5e2201643392d0509cb970faf1c1e7038d14f4e (patch) | |
tree | 7727d7ba15134efa67f104681f8bbecd8d0114f9 | |
parent | feda414f8b70f50a9f6745d2ce8828316d4711cd (diff) |
jsdialog: correct structure for RoadmapWizard
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Id9837c208653311608bf39d6066cbf1345efc565
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148214
Tested-by: Jenkins
-rw-r--r-- | include/vcl/toolkit/dialog.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/wizdlg.hxx | 2 | ||||
-rw-r--r-- | vcl/source/control/roadmapwizard.cxx | 72 |
3 files changed, 75 insertions, 1 deletions
diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx index 31326106cbd5..679c0232ea30 100644 --- a/include/vcl/toolkit/dialog.hxx +++ b/include/vcl/toolkit/dialog.hxx @@ -101,6 +101,7 @@ protected: friend class SalInstanceBuilder; void set_action_area(VclButtonBox* pBox); void set_content_area(VclBox* pBox); + vcl::Window* GetFirstControlForFocus(); public: explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default ); @@ -132,7 +133,6 @@ private: static void ImplEndExecuteModal(); void ImplSetModalInputMode(bool bModal); - vcl::Window* GetFirstControlForFocus(); public: /// Commence execution of a modal dialog, disposes owner on failure diff --git a/vcl/inc/wizdlg.hxx b/vcl/inc/wizdlg.hxx index 04f6e88c4acd..1fd0f9bad41e 100644 --- a/vcl/inc/wizdlg.hxx +++ b/vcl/inc/wizdlg.hxx @@ -255,6 +255,8 @@ namespace vcl DECL_LINK(OnFinish, Button*, void); void implConstruct( const WizardButtonFlags _nButtonFlags ); + + virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override; }; /// helper class to temporarily suspend any traveling in the wizard diff --git a/vcl/source/control/roadmapwizard.cxx b/vcl/source/control/roadmapwizard.cxx index 49c28de9bfe9..0aef0d00527e 100644 --- a/vcl/source/control/roadmapwizard.cxx +++ b/vcl/source/control/roadmapwizard.cxx @@ -20,6 +20,7 @@ #include <vcl/toolkit/roadmap.hxx> #include <tools/debug.hxx> +#include <tools/json_writer.hxx> #include <osl/diagnose.h> #include <strings.hrc> @@ -798,6 +799,77 @@ namespace vcl return RoadmapWizardUIObject::create; } + namespace + { + bool isButton(WindowType eType) + { + return eType == WindowType::PUSHBUTTON || eType == WindowType::OKBUTTON + || eType == WindowType::CANCELBUTTON || eType == WindowType::HELPBUTTON; + } + } + + void RoadmapWizard::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) + { + rJsonWriter.put("id", get_id()); + rJsonWriter.put("type", "dialog"); + rJsonWriter.put("title", GetText()); + + OUString sDialogId = OStringToOUString(GetHelpId(), RTL_TEXTENCODING_ASCII_US); + sal_Int32 nStartPos = sDialogId.lastIndexOf('/'); + nStartPos = nStartPos >= 0 ? nStartPos + 1 : 0; + rJsonWriter.put("dialogid", sDialogId.copy(nStartPos)); + + vcl::Window* pFocusControl = GetFirstControlForFocus(); + if (pFocusControl) + rJsonWriter.put("init_focus_id", pFocusControl->get_id()); + + { + auto childrenNode = rJsonWriter.startArray("children"); + + auto containerNode = rJsonWriter.startStruct(); + rJsonWriter.put("id", "container"); + rJsonWriter.put("type", "container"); + rJsonWriter.put("vertical", true); + + { + auto containerChildrenNode = rJsonWriter.startArray("children"); + + // tabpages + for (int i = 0; i < GetChildCount(); i++) + { + vcl::Window* pChild = GetChild(i); + + if (!isButton(pChild->GetType()) && pChild != mpViewWindow) + { + auto childNode = rJsonWriter.startStruct(); + pChild->DumpAsPropertyTree(rJsonWriter); + } + } + + // buttons + { + auto buttonsNode = rJsonWriter.startStruct(); + rJsonWriter.put("id", "buttons"); + rJsonWriter.put("type", "buttonbox"); + rJsonWriter.put("layoutstyle", "end"); + { + auto buttonsChildrenNode = rJsonWriter.startArray("children"); + for (int i = 0; i < GetChildCount(); i++) + { + vcl::Window* pChild = GetChild(i); + + if (isButton(pChild->GetType())) + { + auto childNode = rJsonWriter.startStruct(); + pChild->DumpAsPropertyTree(rJsonWriter); + } + } + } + } + } + } + } + } // namespace vcl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |