vcl/inc/jsdialog/jsdialogbuilder.hxx | 27 ++++++++++++++++-- vcl/jsdialog/jsdialogbuilder.cxx | 51 ++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 15 deletions(-)
New commits: commit 9c78d8d0a8bd69fc45d845b96bcbc3bdded5f521 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Feb 24 18:35:18 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue May 19 13:36:22 2020 +0200 Resend jsdialog on entry change Change-Id: Ic255b8ba56f5b355a95ddc9a9587e1747b66702a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94071 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94487 Tested-by: Jenkins diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 9d8c68516320..956c3001fc22 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -8,6 +8,19 @@ #include <vcl/builder.hxx> #include <salvtables.hxx> +class JSDialogSender +{ + VclPtr<vcl::Window> m_aOwnedToplevel; + +public: + JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel) + : m_aOwnedToplevel(aOwnedToplevel) + { + } + + void notifyDialogState(); +}; + class VCL_DLLPUBLIC JSInstanceBuilder : public SalInstanceBuilder { public: @@ -16,16 +29,24 @@ public: bool bTakeOwnership = true) override; virtual std::unique_ptr<weld::Label> weld_label(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, + bool bTakeOwnership = false) override; }; -class VCL_DLLPUBLIC JSLabel : public SalInstanceLabel +class VCL_DLLPUBLIC JSLabel : public SalInstanceLabel, public JSDialogSender { - VclPtr<vcl::Window> m_aOwnedToplevel; - public: JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership); virtual void set_label(const OUString& rText) override; }; +class VCL_DLLPUBLIC JSEntry : public SalInstanceEntry, public JSDialogSender +{ +public: + JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void set_text(const OUString& rText) override; +}; + #endif \ No newline at end of file diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index ff85796d3a09..8429eae74e11 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -5,6 +5,23 @@ #include <vcl/toolkit/dialog.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +void JSDialogSender::notifyDialogState() +{ + if (!m_aOwnedToplevel) + return; + + const vcl::ILibreOfficeKitNotifier* pNotifier = m_aOwnedToplevel->GetLOKNotifier(); + if (pNotifier) + { + std::stringstream aStream; + boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree(); + aTree.put("id", m_aOwnedToplevel->GetLOKWindowId()); + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + } +} + JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) : SalInstanceBuilder(dynamic_cast<SalInstanceWidget*>(pParent) @@ -46,25 +63,35 @@ std::unique_ptr<weld::Label> JSInstanceBuilder::weld_label(const OString& id, bo return std::make_unique<JSLabel>(m_aOwnedToplevel, pLabel, this, bTakeOwnership); } +std::unique_ptr<weld::Entry> JSInstanceBuilder::weld_entry(const OString& id, bool bTakeOwnership) +{ + Edit* pEntry = m_xBuilder->get<Edit>(id); + return pEntry ? std::make_unique<JSEntry>(m_aOwnedToplevel, pEntry, this, bTakeOwnership) + : nullptr; +} + JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceLabel(pLabel, pBuilder, bTakeOwnership) - , m_aOwnedToplevel(aOwnedToplevel) + , JSDialogSender(aOwnedToplevel) { } void JSLabel::set_label(const OUString& rText) { SalInstanceLabel::set_label(rText); - - const vcl::ILibreOfficeKitNotifier* pNotifier = m_aOwnedToplevel->GetLOKNotifier(); - if (pNotifier) - { - std::stringstream aStream; - boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree(); - aTree.put("id", m_aOwnedToplevel->GetLOKWindowId()); - boost::property_tree::write_json(aStream, aTree); - const std::string message = aStream.str(); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); - } + notifyDialogState(); }; + +JSEntry::JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceEntry(pEntry, pBuilder, bTakeOwnership) + , JSDialogSender(aOwnedToplevel) +{ +} + +void JSEntry::set_text(const OUString& rText) +{ + SalInstanceEntry::set_text(rText); + notifyDialogState(); +} _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits