include/vcl/jsdialog/jsdialogbuilder.hxx | 39 +++++++++++- include/vcl/salvtables.hxx | 2 include/vcl/svapp.hxx | 3 sc/source/core/data/validat.cxx | 7 +- vcl/jsdialog/jsdialogbuilder.cxx | 99 +++++++++++++++++++++++++++++++ vcl/source/window/builder.cxx | 8 +- 6 files changed, 152 insertions(+), 6 deletions(-)
New commits: commit 8edb208758d5420fa44ecfa424fc458b6fc9fbc9 Author: Szymon Kłos <[email protected]> AuthorDate: Tue Mar 10 17:10:38 2020 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Wed May 20 10:30:27 2020 +0200 jsdialog: weld SpinButton and CheckButton Change-Id: I0dfa163b8a52594cde9e3529df8f433dc93bc459 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94432 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index 660be3ea75d3..32b279dea66d 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -9,6 +9,7 @@ #include <vcl/salvtables.hxx> #include <vcl/combobox.hxx> #include <vcl/button.hxx> +#include <vcl/fmtfield.hxx> typedef std::map<OString, weld::Widget*> WidgetMap; @@ -51,6 +52,10 @@ public: bool bTakeOwnership = false) override; virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::SpinButton> + weld_spin_button(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::CheckButton> + weld_check_button(const OString& id, bool bTakeOwnership = false) override; static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, @@ -150,6 +155,15 @@ public: virtual void append_page(const OString& rIdent, const OUString& rLabel) override; }; +class VCL_DLLPUBLIC JSSpinButton : public JSWidget<SalInstanceSpinButton, ::FormattedField> +{ +public: + JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_value(int value) override; +}; + class VCL_DLLPUBLIC JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender { public: @@ -160,4 +174,13 @@ public: virtual void set_secondary_text(const OUString& rText) override; }; +class VCL_DLLPUBLIC JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox> +{ +public: + JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_active(bool active) override; +}; + #endif diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 15a482e0ac48..9246bda13b86 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -204,6 +204,36 @@ std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& return pWeldWidget; } +std::unique_ptr<weld::SpinButton> JSInstanceBuilder::weld_spin_button(const OString& id, + bool bTakeOwnership) +{ + FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id); + auto pWeldWidget = pSpinButton ? std::make_unique<JSSpinButton>( + m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, + pSpinButton, this, bTakeOwnership) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + +std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const OString& id, + bool bTakeOwnership) +{ + CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id); + auto pWeldWidget = pCheckButton ? std::make_unique<JSCheckButton>( + m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog, + pCheckButton, this, bTakeOwnership) + : nullptr; + + if (pWeldWidget) + RememberWidget(id, pWeldWidget.get()); + + return pWeldWidget; +} + weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, @@ -347,6 +377,19 @@ void JSNotebook::append_page(const OString& rIdent, const OUString& rLabel) notifyDialogState(); } +JSSpinButton::JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceSpinButton, ::FormattedField>(aOwnedToplevel, pSpin, pBuilder, + bTakeOwnership) +{ +} + +void JSSpinButton::set_value(int value) +{ + SalInstanceSpinButton::set_value(value); + notifyDialogState(); +} + JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) @@ -365,3 +408,16 @@ void JSMessageDialog::set_secondary_text(const OUString& rText) SalInstanceMessageDialog::set_secondary_text(rText); notifyDialogState(); } + +JSCheckButton::JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceCheckButton, ::CheckBox>(aOwnedToplevel, pCheckBox, pBuilder, + bTakeOwnership) +{ +} + +void JSCheckButton::set_active(bool active) +{ + SalInstanceCheckButton::set_active(active); + notifyDialogState(); +} commit bc551d879062359627d74482b9a7c2bb423be9a8 Author: Szymon Kłos <[email protected]> AuthorDate: Tue Mar 17 14:50:39 2020 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Wed May 20 10:30:07 2020 +0200 jsdialog: use for message dialogs on mobile Change-Id: Ib172dc264d7f55fef08dc474f7e6f4d1b3108085 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94431 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index 8befb2b0f79b..660be3ea75d3 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -52,6 +52,10 @@ public: virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, bool bTakeOwnership = false) override; + static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, + VclMessageType eMessageType, + VclButtonsType eButtonType, + const OUString& rPrimaryMessage); static weld::Widget* FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, const OString& rWidget); }; @@ -146,4 +150,14 @@ public: virtual void append_page(const OString& rIdent, const OUString& rLabel) override; }; +class VCL_DLLPUBLIC JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender +{ +public: + JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_primary_text(const OUString& rText) override; + + virtual void set_secondary_text(const OUString& rText) override; +}; + #endif diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx index 6222423551bc..a6cd713e19c4 100644 --- a/include/vcl/salvtables.hxx +++ b/include/vcl/salvtables.hxx @@ -906,7 +906,7 @@ public: class SalInstanceMessageDialog : public SalInstanceDialog, public virtual weld::MessageDialog { -private: +protected: VclPtr<::MessageDialog> m_xMessageDialog; public: diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 7392ef3be86f..08efa5a95c0f 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1345,7 +1345,8 @@ public: static weld::Builder* CreateInterimBuilder(weld::Widget* pParent, const OUString &rUIFile); //for the duration of same SfxTabPages in mixed parent types static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, - VclButtonsType eButtonType, const OUString& rPrimaryMessage); + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + bool bMobile = false); static weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow); private: diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx index 4fd89ccb206f..409ecbe6c70d 100644 --- a/sc/source/core/data/validat.cxx +++ b/sc/source/core/data/validat.cxx @@ -49,6 +49,8 @@ #include <tokenarray.hxx> #include <scmatrix.hxx> #include <cellvalue.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> #include <math.h> #include <memory> @@ -405,8 +407,11 @@ bool ScValidationData::DoError(weld::Window* pParent, const OUString& rInput, break; } + bool bIsMobile = comphelper::LibreOfficeKit::isActive() + && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone(); + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, eType, - eStyle, aMessage)); + eStyle, aMessage, bIsMobile)); xBox->set_title(aTitle); switch (eErrorStyle) diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 080d5089eeb2..15a482e0ac48 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -204,6 +204,30 @@ std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& return pWeldWidget; } +weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, + VclMessageType eMessageType, + VclButtonsType eButtonType, + const OUString& rPrimaryMessage) +{ + SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent); + SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr; + VclPtrInstance<::MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType, + eButtonType); + + const vcl::ILibreOfficeKitNotifier* pNotifier = xMessageDialog->GetLOKNotifier(); + if (pNotifier) + { + std::stringstream aStream; + boost::property_tree::ptree aTree = xMessageDialog->DumpAsPropertyTree(); + aTree.put("id", xMessageDialog->GetLOKWindowId()); + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + } + + return new JSMessageDialog(xMessageDialog, nullptr, true); +} + JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership) @@ -322,3 +346,22 @@ void JSNotebook::append_page(const OString& rIdent, const OUString& rLabel) SalInstanceNotebook::append_page(rIdent, rLabel); notifyDialogState(); } + +JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceMessageDialog(pDialog, pBuilder, bTakeOwnership) + , JSDialogSender(m_xMessageDialog) +{ +} + +void JSMessageDialog::set_primary_text(const OUString& rText) +{ + SalInstanceMessageDialog::set_primary_text(rText); + notifyDialogState(); +} + +void JSMessageDialog::set_secondary_text(const OUString& rText) +{ + SalInstanceMessageDialog::set_secondary_text(rText); + notifyDialogState(); +} diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index eb87ea7403f2..92d4ea38fefd 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -171,9 +171,13 @@ weld::Builder* Application::CreateInterimBuilder(vcl::Window* pParent, const OUS } weld::MessageDialog* Application::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, - VclButtonsType eButtonType, const OUString& rPrimaryMessage) + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + bool bMobile) { - return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); + if (bMobile) + return JSInstanceBuilder::CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); + else + return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); } weld::Window* Application::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
