[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/vcl sc/source vcl/jsdialog vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 19 08:11:48 UTC 2020
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 | 43 +++++++++++++++++++++++++++++++
vcl/source/window/builder.cxx | 8 ++++-
6 files changed, 72 insertions(+), 5 deletions(-)
New commits:
commit 98c696e0b8ac10fb43616db625d57278f4dbb851
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Mar 17 14:50:39 2020 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue May 19 10:11:17 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 <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
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 0fb282d385c7..dad0e71d5137 100644
--- a/include/vcl/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -733,7 +733,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 f8be58bb6629..0707a4668e14 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1381,7 +1381,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 c194da86e3e2..8766f0a65dd5 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -47,6 +47,8 @@
#include <tokenarray.hxx>
#include <scmatrix.hxx>
#include <cellvalue.hxx>
+#include <comphelper/lok.hxx>
+#include <sfx2/lokhelper.hxx>
#include <math.h>
#include <memory>
@@ -403,8 +405,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 36ca28e20f7e..86fb614b9489 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -164,9 +164,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)
More information about the Libreoffice-commits
mailing list