diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-02-24 18:35:18 +0100 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2020-05-14 16:38:47 +0200 |
commit | 6a947fe26a651384974052c3c0acb2d88f123d18 (patch) | |
tree | b72d9d33e4b1cae4a4a88138e71bd25efb47f108 /vcl/jsdialog | |
parent | 43aa6897526fbc44e13d3295e97dfebbc8430e23 (diff) |
Resend jsdialog on entry change
Change-Id: Ic255b8ba56f5b355a95ddc9a9587e1747b66702a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94071
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl/jsdialog')
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 8807c3a35907..fc1c7a0159e9 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -7,6 +7,23 @@ using namespace weld; +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) @@ -48,25 +65,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(); +} |