diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-04-28 15:51:02 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-05-09 09:36:15 +0200 |
commit | 31c2fd5059d6c73ee46ecbbe94bd7578de4ca1a1 (patch) | |
tree | 8def45e2075e228c8bf7de667ebc92a7936e0846 /sw/source | |
parent | 2b77fd26283bab07e55542e4354f2019ef446968 (diff) |
lok: MSForms: Add callback for form field button.
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 <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/crsr/bookmrk.cxx | 45 | ||||
-rw-r--r-- | sw/source/core/inc/bookmrk.hxx | 8 |
2 files changed, 51 insertions, 2 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 14fab9d32da5..0aaa78493e7b 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -43,6 +43,10 @@ #include <svx/numfmtsh.hxx> #include <ndtxt.hxx> #include <DocumentContentOperationsManager.hxx> +#include <comphelper/lok.hxx> +#include <view.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <wrtsh.hxx> using namespace ::sw::mark; using namespace ::com::sun::star; @@ -521,6 +525,7 @@ namespace sw { namespace mark DropDownFieldmark::~DropDownFieldmark() { + SendLOKMessage("hide"); } void DropDownFieldmark::ShowButton(SwEditWin* pEditWin) @@ -531,9 +536,22 @@ namespace sw { namespace mark m_pButton = VclPtr<DropDownFormFieldButton>::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 && @@ -546,6 +564,33 @@ namespace sw { namespace 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<SwEditWin*>(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 2107b3640616..c156a86c9772 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -279,8 +279,8 @@ namespace sw { virtual ~FieldmarkWithDropDownButton() override; virtual void ShowButton(SwEditWin* pEditWin) = 0; - void HideButton(); - void RemoveButton(); + virtual void HideButton(); + virtual void RemoveButton(); protected: VclPtr<FormFieldButton> m_pButton; @@ -295,10 +295,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; }; |