include/vcl/toolkit/prgsbar.hxx | 3 +++ include/vcl/wintypes.hxx | 3 ++- vcl/inc/jsdialog/jsdialogbuilder.hxx | 10 ++++++++++ vcl/inc/salvtables.hxx | 19 +++++++++++++++++++ vcl/jsdialog/jsdialogbuilder.cxx | 25 +++++++++++++++++++++++++ vcl/source/app/salvtables.cxx | 19 ------------------- vcl/source/control/prgsbar.cxx | 8 ++++++++ vcl/source/window/window.cxx | 1 + 8 files changed, 68 insertions(+), 20 deletions(-)
New commits: commit 7586da84124f4aa73fd21081610de78d5d416fe6 Author: Hubert Figuière <h...@collabora.com> AuthorDate: Fri Mar 22 09:59:54 2024 -0400 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Mar 25 15:39:27 2024 +0100 vcl: Implement JSLevelBar This fixes the JSDialog layout of the sheet protection dialog. This was introduced for 24.02 to provide password strength indication of the sheet password. Defined a new WindowType of PROGRESSBAR. The type property in JSDialog JSON will be "progressbar". Change-Id: I202528a81706943e1838f3c37fb555f4a1bf889e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165168 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/vcl/toolkit/prgsbar.hxx b/include/vcl/toolkit/prgsbar.hxx index 1fcba74fdaba..bced6fc9e259 100644 --- a/include/vcl/toolkit/prgsbar.hxx +++ b/include/vcl/toolkit/prgsbar.hxx @@ -73,6 +73,9 @@ private: SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); SAL_DLLPRIVATE void ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nNewPerc); +protected: + virtual void DumpAsPropertyTree(tools::JsonWriter&) override; + public: ProgressBar( vcl::Window* pParent, WinBits nWinBits, BarStyle eBarStyle ); diff --git a/include/vcl/wintypes.hxx b/include/vcl/wintypes.hxx index 644b2405cc2a..c025e83b0afe 100644 --- a/include/vcl/wintypes.hxx +++ b/include/vcl/wintypes.hxx @@ -98,7 +98,8 @@ enum class WindowType : sal_uInt16 RULER , HEADERBAR , VERTICALTABCONTROL , - LAST = VERTICALTABCONTROL, + PROGRESSBAR , + LAST = PROGRESSBAR, // only used in vclxtoolkit.cxx TOOLKIT_FRAMEWINDOW = 0x1000, TOOLKIT_SYSTEMCHILDWINDOW = 0x1001, diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 066dcddfcfc8..3d98e7e61a19 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -16,6 +16,7 @@ #include <salvtables.hxx> #include <vcl/toolkit/button.hxx> #include <vcl/toolkit/fmtfield.hxx> +#include <vcl/toolkit/prgsbar.hxx> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -311,6 +312,7 @@ public: virtual std::unique_ptr<weld::Box> weld_box(const OUString& id) override; virtual std::unique_ptr<weld::Widget> weld_widget(const OUString& id) override; virtual std::unique_ptr<weld::Image> weld_image(const OUString& id) override; + virtual std::unique_ptr<weld::LevelBar> weld_level_bar(const OUString& id) override; virtual std::unique_ptr<weld::Calendar> weld_calendar(const OUString& id) override; static weld::MessageDialog* @@ -889,6 +891,14 @@ public: virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override; }; +class JSLevelBar : public JSWidget<SalInstanceLevelBar, ::ProgressBar> +{ +public: + JSLevelBar(JSDialogSender* pSender, ::ProgressBar* pProgressBar, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void set_percentage(double fPercentage) override; +}; + class JSCalendar : public JSWidget<SalInstanceCalendar, ::Calendar> { public: diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 4074e097a4f4..46aa3da22b71 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -22,6 +22,7 @@ #include <vcl/toolkit/fixedhyper.hxx> #include <vcl/toolkit/lstbox.hxx> #include <vcl/toolkit/menubtn.hxx> +#include <vcl/toolkit/prgsbar.hxx> #include <vcl/toolkit/combobox.hxx> #include <vcl/tabctrl.hxx> #include <vcl/layout.hxx> @@ -2182,6 +2183,24 @@ public: virtual ~SalInstanceScrolledWindow() override; }; +class SalInstanceLevelBar : public SalInstanceWidget, public virtual weld::LevelBar +{ +private: + VclPtr<::ProgressBar> m_xLevelBar; + +public: + SalInstanceLevelBar(::ProgressBar* pLevelBar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceWidget(pLevelBar, pBuilder, bTakeOwnership) + , m_xLevelBar(pLevelBar) + { + } + + virtual void set_percentage(double fPercentage) override + { + m_xLevelBar->SetValue(static_cast<sal_uInt16>(fPercentage)); + } +}; + class SalInstanceCalendar : public SalInstanceWidget, public virtual weld::Calendar { private: diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 97675b6267c1..1704988084f1 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1269,6 +1269,19 @@ std::unique_ptr<weld::Image> JSInstanceBuilder::weld_image(const OUString& id) return pWeldWidget; } +std::unique_ptr<weld::LevelBar> JSInstanceBuilder::weld_level_bar(const OUString& id) +{ + ::ProgressBar* pLevelBar = m_xBuilder->get<::ProgressBar>(id); + + auto pWeldWidget + = pLevelBar ? std::make_unique<JSLevelBar>(this, pLevelBar, this, false) : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + std::unique_ptr<weld::Calendar> JSInstanceBuilder::weld_calendar(const OUString& id) { ::Calendar* pCalendar = m_xBuilder->get<::Calendar>(id); @@ -2353,6 +2366,18 @@ void JSImage::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImag sendUpdate(); } +JSLevelBar::JSLevelBar(JSDialogSender* pSender, ::ProgressBar* pProgressBar, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceLevelBar, ::ProgressBar>(pSender, pProgressBar, pBuilder, bTakeOwnership) +{ +} + +void JSLevelBar::set_percentage(double fPercentage) +{ + SalInstanceLevelBar::set_percentage(fPercentage); + sendUpdate(); +} + JSCalendar::JSCalendar(JSDialogSender* pSender, ::Calendar* pCalendar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceCalendar, ::Calendar>(pSender, pCalendar, pBuilder, bTakeOwnership) diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 50ecd194bdcd..9ed790a2b6ec 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -58,7 +58,6 @@ #include <vcl/toolkit/ivctrl.hxx> #include <vcl/layout.hxx> #include <vcl/toolkit/menubtn.hxx> -#include <vcl/toolkit/prgsbar.hxx> #include <vcl/ptrstyle.hxx> #include <slider.hxx> #include <vcl/sysdata.hxx> @@ -3308,24 +3307,6 @@ public: virtual void set_text(const OUString& rText) override { m_xProgressBar->SetText(rText); } }; - -class SalInstanceLevelBar : public SalInstanceWidget, public virtual weld::LevelBar -{ -private: - VclPtr<::ProgressBar> m_xLevelBar; - -public: - SalInstanceLevelBar(::ProgressBar* pLevelBar, SalInstanceBuilder* pBuilder, bool bTakeOwnership) - : SalInstanceWidget(pLevelBar, pBuilder, bTakeOwnership) - , m_xLevelBar(pLevelBar) - { - } - - virtual void set_percentage(double fPercentage) override - { - m_xLevelBar->SetValue(static_cast<sal_uInt16>(fPercentage)); - } -}; } IMPL_LINK_NOARG(SalInstanceCalendar, SelectHdl, ::Calendar*, void) diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx index e15c7c055dbe..f4727b97ad6e 100644 --- a/vcl/source/control/prgsbar.cxx +++ b/vcl/source/control/prgsbar.cxx @@ -24,6 +24,7 @@ #include <sal/log.hxx> #include <vcl/svapp.hxx> #include <vcl/idle.hxx> +#include <tools/json_writer.hxx> #define PROGRESSBAR_OFFSET 3 #define PROGRESSBAR_WIN_OFFSET 2 @@ -35,6 +36,7 @@ void ProgressBar::ImplInit() mnPercent = 0; mnPercentCount = 0; mbCalcNew = true; + SetType(WindowType::PROGRESSBAR); ImplInitSettings( true, true, true ); } @@ -236,4 +238,10 @@ void ProgressBar::DataChanged( const DataChangedEvent& rDCEvt ) Window::DataChanged( rDCEvt ); } +void ProgressBar::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) +{ + vcl::Window::DumpAsPropertyTree(rJsonWriter); + rJsonWriter.put("value", mnPercent); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index d683f9b4156e..3da1dfe90de3 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -3345,6 +3345,7 @@ std::string_view windowTypeName(WindowType nWindowType) case WindowType::RULER: return "ruler"; case WindowType::HEADERBAR: return "headerbar"; case WindowType::VERTICALTABCONTROL: return "verticaltabcontrol"; + case WindowType::PROGRESSBAR: return "progressbar"; // nothing to do here, but for completeness case WindowType::TOOLKIT_FRAMEWINDOW: return "toolkit_framewindow";