summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Figuière <hub@collabora.com>2024-03-22 09:59:54 -0400
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-03-28 09:36:17 +0100
commit460a7103664ac8dc60e260c56e5113d689b8072f (patch)
treebd6af06335ef49422aa3ddf7cb6c81f21596cfe6
parente347cff87bec2e8d802fb2dfb8abd3d7d94f8103 (diff)
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/+/165236 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r--include/vcl/toolkit/prgsbar.hxx3
-rw-r--r--include/vcl/wintypes.hxx3
-rw-r--r--vcl/inc/jsdialog/jsdialogbuilder.hxx10
-rw-r--r--vcl/inc/salvtables.hxx19
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx25
-rw-r--r--vcl/source/app/salvtables.cxx19
-rw-r--r--vcl/source/control/prgsbar.cxx8
-rw-r--r--vcl/source/window/window.cxx1
8 files changed, 68 insertions, 20 deletions
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 34fdb7a068d5..2c544146dfad 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>
@@ -312,6 +313,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*
@@ -892,6 +894,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 cc7b34092d01..54abb89ffa21 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>
@@ -2181,6 +2182,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 1f56bda71bba..fa574088c7c6 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1264,6 +1264,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);
@@ -2348,6 +2361,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 3f007783498d..12f4537f4df0 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>
@@ -3310,24 +3309,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 62bc5029f84d..7a6dfb335b01 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3351,6 +3351,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";