diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2023-07-06 15:44:24 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-07-11 12:45:03 +0200 |
commit | 8cb85fba92aff08969aec510d32beb7b28d0e551 (patch) | |
tree | 67893c3d3597e32f1d419a6189dc26f21b132afc /vcl | |
parent | 41f4e472a6bb76976164e5a6e975b111d954cd95 (diff) |
jsdialog: calendar widget
Change-Id: I5b2b8a1516ed2e851309dca6ef3200ed522d1b7b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154136
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 8 | ||||
-rw-r--r-- | vcl/jsdialog/enabled.cxx | 1 | ||||
-rw-r--r-- | vcl/jsdialog/executor.cxx | 21 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 19 |
4 files changed, 49 insertions, 0 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 25281fb33236..85f6c8140369 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -314,6 +314,7 @@ public: virtual std::unique_ptr<weld::Box> weld_box(const OString& id) override; virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id) override; virtual std::unique_ptr<weld::Image> weld_image(const OString& id) override; + virtual std::unique_ptr<weld::Calendar> weld_calendar(const OString& id) override; static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, @@ -861,4 +862,11 @@ public: virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override; }; +class JSCalendar : public JSWidget<SalInstanceCalendar, ::Calendar> +{ +public: + JSCalendar(JSDialogSender* pSender, ::Calendar* pCalendar, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 885eeb520bb6..647cec05602b 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -285,6 +285,7 @@ bool isBuilderEnabledForPopup(std::u16string_view rUIFile) || rUIFile == u"modules/scalc/ui/floatingborderstyle.ui" || rUIFile == u"modules/scalc/ui/floatinglinestyle.ui" // svt + || rUIFile == u"svt/ui/datewindow.ui" || rUIFile == u"svt/ui/linewindow.ui" // svx || rUIFile == u"svx/ui/colorwindow.ui" diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index 750b10c0b606..e509504db24c 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -603,6 +603,27 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM } } } + else if (sControlType == "calendar") + { + auto pCalendar = dynamic_cast<weld::Calendar*>(pWidget); + if (pCalendar && sAction == "selectdate") + { + // MM/DD/YYYY + OUString aDate = rData["data"]; + + if (aDate.getLength() < 10) + return false; + + sal_Int32 aMonth = o3tl::toInt32(aDate.subView(0, 2)); + sal_Int32 aDay = o3tl::toInt32(aDate.subView(3, 2)); + sal_Int32 aYear = o3tl::toInt32(aDate.subView(6, 4)); + + pCalendar->set_date(Date(aDay, aMonth, aYear)); + LOKTrigger::trigger_selected(*pCalendar); + LOKTrigger::trigger_activated(*pCalendar); + return true; + } + } } return false; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 6944cc817af7..9bb60861aadf 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1261,6 +1261,19 @@ std::unique_ptr<weld::Image> JSInstanceBuilder::weld_image(const OString& id) return pWeldWidget; } +std::unique_ptr<weld::Calendar> JSInstanceBuilder::weld_calendar(const OString& id) +{ + ::Calendar* pCalendar = m_xBuilder->get<::Calendar>(id); + + auto pWeldWidget + = pCalendar ? std::make_unique<JSCalendar>(this, pCalendar, this, false) : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString& rPrimaryMessage, @@ -2246,4 +2259,10 @@ void JSImage::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImag sendUpdate(); } +JSCalendar::JSCalendar(JSDialogSender* pSender, ::Calendar* pCalendar, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : JSWidget<SalInstanceCalendar, ::Calendar>(pSender, pCalendar, pBuilder, bTakeOwnership) +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |