include/vcl/jsdialog/jsdialogbuilder.hxx | 14 +++++++++ include/vcl/salvtables.hxx | 2 - include/vcl/svapp.hxx | 3 +- sc/source/core/data/validat.cxx | 7 ++++ vcl/jsdialog/jsdialogbuilder.cxx | 44 +++++++++++++++++++++++++++++++ vcl/source/window/builder.cxx | 8 ++++- 6 files changed, 73 insertions(+), 5 deletions(-)
New commits: commit f89557039270791e7d269460fd5cb988f9380260 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Mar 17 14:50:39 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Jun 22 13:49:16 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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96836 Tested-by: Jenkins diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index 74e1264829bc..543184eeb35a 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 insert_page(const OString& rIdent, const OUString& rLabel, int nPos) 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 ad5827a82e61..fbb87a1dc907 100644 --- a/include/vcl/salvtables.hxx +++ b/include/vcl/salvtables.hxx @@ -1062,7 +1062,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 48a764b80125..4cf23a71d64a 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1332,7 +1332,8 @@ public: static weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile); //for the duration of vcl parent windows 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 e2921aaf7368..e4a8f9548ad7 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 88d84d56da94..c360eee7b9e6 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -6,6 +6,7 @@ #include <vcl/toolkit/dialog.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/toolkit/combobox.hxx> +#include <messagedialog.hxx> void JSDialogSender::notifyDialogState() { @@ -204,6 +205,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 +347,22 @@ void JSNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int SalInstanceNotebook::insert_page(rIdent, rLabel, nPos); 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 e6e2d7415933..7837320d30b5 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -178,9 +178,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 libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits