lok: rework form field button message handling.
To make it work properly with more users editing the same document. Change-Id: I1f3d8ef9fc9c25b440a3dc36a40709723ed342f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110710 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> (cherry picked from commit 20335d5ed549af25f02467c7da21df10c8df956a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110759 Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
This commit is contained in:
@@ -1529,6 +1529,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
|
||||
case LOK_CALLBACK_TEXT_VIEW_SELECTION:
|
||||
case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
|
||||
case LOK_CALLBACK_CALC_FUNCTION_LIST:
|
||||
case LOK_CALLBACK_FORM_FIELD_BUTTON:
|
||||
{
|
||||
// deleting the duplicate of visible cursor message can cause hyperlink popup not to show up on second/or more click on the same place.
|
||||
// If the hyperlink is not empty we can bypass that to show the popup
|
||||
|
@@ -661,7 +661,6 @@ namespace sw::mark
|
||||
|
||||
DropDownFieldmark::~DropDownFieldmark()
|
||||
{
|
||||
SendLOKMessage("hide");
|
||||
}
|
||||
|
||||
void DropDownFieldmark::ShowButton(SwEditWin* pEditWin)
|
||||
@@ -672,13 +671,11 @@ namespace sw::mark
|
||||
m_pButton = VclPtr<DropDownFormFieldButton>::Create(pEditWin, *this);
|
||||
m_pButton->CalcPosAndSize(m_aPortionPaintArea);
|
||||
m_pButton->Show();
|
||||
SendLOKMessage("show");
|
||||
}
|
||||
}
|
||||
|
||||
void DropDownFieldmark::RemoveButton()
|
||||
{
|
||||
SendLOKMessage("hide");
|
||||
FieldmarkWithDropDownButton::RemoveButton();
|
||||
}
|
||||
|
||||
@@ -689,32 +686,21 @@ namespace sw::mark
|
||||
{
|
||||
m_pButton->Show();
|
||||
m_pButton->CalcPosAndSize(m_aPortionPaintArea);
|
||||
SendLOKMessage("show");
|
||||
}
|
||||
}
|
||||
|
||||
void DropDownFieldmark::SendLOKMessage(std::string_view sAction)
|
||||
void DropDownFieldmark::SendLOKMessage(SfxViewShell* pViewShell, std::string_view sAction)
|
||||
{
|
||||
const SfxViewShell* pViewShell = SfxViewShell::Current();
|
||||
if (!pViewShell || pViewShell->isLOKMobilePhone())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!comphelper::LibreOfficeKit::isActive())
|
||||
return;
|
||||
|
||||
if (!m_pButton)
|
||||
return;
|
||||
|
||||
SwEditWin* pEditWin = dynamic_cast<SwEditWin*>(m_pButton->GetParent());
|
||||
if (!pEditWin)
|
||||
if (!pViewShell || pViewShell->isLOKMobilePhone())
|
||||
return;
|
||||
|
||||
OStringBuffer sPayload;
|
||||
if (sAction == "show")
|
||||
{
|
||||
if(m_aPortionPaintArea.IsEmpty())
|
||||
if (m_aPortionPaintArea.IsEmpty())
|
||||
return;
|
||||
|
||||
sPayload = OStringLiteral("{\"action\": \"show\","
|
||||
@@ -750,12 +736,10 @@ namespace sw::mark
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(sAction == "hide");
|
||||
sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
|
||||
}
|
||||
if (sPayload.toString() != m_sLastSentLOKMsg) {
|
||||
m_sLastSentLOKMsg = sPayload.toString();
|
||||
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, m_sLastSentLOKMsg.getStr());
|
||||
}
|
||||
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, sPayload.toString().getStr());
|
||||
}
|
||||
|
||||
DateFieldmark::DateFieldmark(const SwPaM& rPaM)
|
||||
|
@@ -47,6 +47,7 @@
|
||||
|
||||
#include <libxml/xmlstring.h>
|
||||
#include <libxml/xmlwriter.h>
|
||||
#include <comphelper/lok.hxx>
|
||||
|
||||
using namespace ::sw::mark;
|
||||
|
||||
@@ -1517,6 +1518,8 @@ namespace sw::mark
|
||||
if(pNewActiveFieldmark)
|
||||
pNewActiveFieldmark->ShowButton(&rEditWin);
|
||||
}
|
||||
|
||||
LOKUpdateActiveField(pSwView);
|
||||
}
|
||||
|
||||
void MarkManager::ClearFieldActivation()
|
||||
@@ -1527,6 +1530,38 @@ namespace sw::mark
|
||||
m_pLastActiveFieldmark = nullptr;
|
||||
}
|
||||
|
||||
void MarkManager::LOKUpdateActiveField(SfxViewShell* pViewShell)
|
||||
{
|
||||
if (!comphelper::LibreOfficeKit::isActive())
|
||||
return;
|
||||
|
||||
if (m_pLastActiveFieldmark)
|
||||
{
|
||||
if (m_pLastActiveFieldmark->GetFieldname() == ODF_FORMDROPDOWN)
|
||||
{
|
||||
auto pDrowDown = dynamic_cast<::sw::mark::DropDownFieldmark*>(m_pLastActiveFieldmark);
|
||||
pDrowDown->SendLOKMessage(pViewShell, "show");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check whether we have any drop down fieldmark at all.
|
||||
::sw::mark::DropDownFieldmark* pDrowDown = nullptr;
|
||||
for (auto aIter = m_vFieldmarks.begin(); aIter != m_vFieldmarks.end(); ++aIter)
|
||||
{
|
||||
IFieldmark *pMark = dynamic_cast<IFieldmark*>(*aIter);
|
||||
if (pMark && pMark->GetFieldname() == ODF_FORMDROPDOWN)
|
||||
{
|
||||
pDrowDown = dynamic_cast<::sw::mark::DropDownFieldmark*>(pMark);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pDrowDown)
|
||||
pDrowDown->SendLOKMessage(pViewShell, "hide");
|
||||
}
|
||||
}
|
||||
|
||||
IFieldmark* MarkManager::getDropDownFor(const SwPosition& rPos) const
|
||||
{
|
||||
IFieldmark *pMark = getFieldmarkAt(rPos);
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <memory>
|
||||
|
||||
class SwCursorShell;
|
||||
class SfxViewShell;
|
||||
|
||||
namespace sw::mark {
|
||||
typedef std::unordered_map<OUString, sal_Int32> MarkBasenameMapUniqueOffset_t;
|
||||
@@ -100,6 +101,7 @@ namespace sw::mark {
|
||||
|
||||
virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) override;
|
||||
virtual void ClearFieldActivation() override;
|
||||
virtual void LOKUpdateActiveField(SfxViewShell* pViewShell);
|
||||
|
||||
void dumpAsXml(xmlTextWriterPtr pWriter) const;
|
||||
|
||||
|
@@ -39,6 +39,7 @@ class SwDoc;
|
||||
class SwEditWin;
|
||||
class SwServerObject;
|
||||
class SvNumberFormatter;
|
||||
class SfxViewShell;
|
||||
|
||||
namespace sw::mark {
|
||||
class MarkBase
|
||||
@@ -293,11 +294,10 @@ namespace sw::mark {
|
||||
// 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(std::string_view sAction);
|
||||
void SendLOKMessage(SfxViewShell* pViewShell, std::string_view sAction);
|
||||
|
||||
private:
|
||||
SwRect m_aPortionPaintArea;
|
||||
OString m_sLastSentLOKMsg;
|
||||
};
|
||||
|
||||
/// Fieldmark representing a date form field.
|
||||
|
Reference in New Issue
Block a user