From 7aedeab27cbef89fd3f831b4a1ef2c06f24c9790 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Tue, 28 Apr 2020 15:51:02 +0200 Subject: lok: MSForms: Add callback for form field button. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show and hide the button and send the button area, where it should be displayed. Change-Id: I5922eb9f5e544483dd4efd12e4218d2e51270632 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93657 Tested-by: Jenkins Reviewed-by: Tamás Zolnai --- sw/source/core/crsr/bookmrk.cxx | 45 +++++++++++++++++++++++++++++++++++++++++ sw/source/core/inc/bookmrk.hxx | 8 ++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 796da73697af..a0cb5a6f7c47 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -39,6 +39,10 @@ #include #include #include +#include +#include +#include +#include using namespace ::sw::mark; using namespace ::com::sun::star; @@ -664,6 +668,7 @@ namespace sw::mark DropDownFieldmark::~DropDownFieldmark() { + SendLOKMessage("hide"); } void DropDownFieldmark::ShowButton(SwEditWin* pEditWin) @@ -674,9 +679,22 @@ namespace sw::mark m_pButton = VclPtr::Create(pEditWin, *this); m_pButton->CalcPosAndSize(m_aPortionPaintArea); m_pButton->Show(); + SendLOKMessage("show"); } } + void DropDownFieldmark::HideButton() + { + SendLOKMessage("hide"); + FieldmarkWithDropDownButton::HideButton(); + } + + void DropDownFieldmark::RemoveButton() + { + SendLOKMessage("hide"); + FieldmarkWithDropDownButton::RemoveButton(); + } + void DropDownFieldmark::SetPortionPaintArea(const SwRect& rPortionPaintArea) { if(m_aPortionPaintArea == rPortionPaintArea && @@ -689,6 +707,33 @@ namespace sw::mark m_pButton->Show(); m_pButton->CalcPosAndSize(m_aPortionPaintArea); m_pButton->Invalidate(); + SendLOKMessage("show"); + } + } + + void DropDownFieldmark::SendLOKMessage(const OString& sAction) + { + if (comphelper::LibreOfficeKit::isActive()) + { + if (!m_pButton) + return; + + SwEditWin* pEditWin = dynamic_cast(m_pButton->GetParent()); + if (!pEditWin) + return; + + OString sPayload; + if (sAction == "show") + { + sPayload = OStringLiteral("{\"action\": \"show\"," + " \"type\": \"drop-down\", \"textArea\": \"") + + m_aPortionPaintArea.SVRect().toString() + "\"}"; + } + else + { + sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}"; + } + pEditWin->GetView().GetWrtShell().GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, sPayload.getStr()); } } diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index fe5bff942568..90be64f1644a 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -280,8 +280,8 @@ namespace sw { virtual ~FieldmarkWithDropDownButton() override; virtual void ShowButton(SwEditWin* pEditWin) = 0; - void HideButton(); - void RemoveButton(); + virtual void HideButton(); + virtual void RemoveButton(); protected: VclPtr m_pButton; @@ -296,10 +296,14 @@ namespace sw { virtual ~DropDownFieldmark() override; virtual void ShowButton(SwEditWin* pEditWin) override; + virtual void HideButton() override; + virtual void RemoveButton() override; // This method should be called only by the portion so we can now the portion's painting area void SetPortionPaintArea(const SwRect& rPortionPaintArea); + void SendLOKMessage(const OString& sAction); + private: SwRect m_aPortionPaintArea; }; -- cgit v1.2.3