summaryrefslogtreecommitdiff
path: root/sw/source/core/crsr/bookmrk.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/crsr/bookmrk.cxx')
-rw-r--r--sw/source/core/crsr/bookmrk.cxx98
1 files changed, 41 insertions, 57 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 472c0af54557..4a4aad532aaa 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -624,7 +624,6 @@ namespace sw { namespace mark
DropDownFieldmark::~DropDownFieldmark()
{
- SendLOKMessage("hide");
}
void DropDownFieldmark::ShowButton(SwEditWin* pEditWin)
@@ -635,13 +634,11 @@ namespace sw { namespace 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();
}
@@ -652,74 +649,61 @@ namespace sw { namespace mark
{
m_pButton->Show();
m_pButton->CalcPosAndSize(m_aPortionPaintArea);
- SendLOKMessage("show");
}
}
- void DropDownFieldmark::SendLOKMessage(const OString& sAction)
+ void DropDownFieldmark::SendLOKMessage(SfxViewShell* pViewShell, const OString& sAction)
{
- const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
if (!pViewShell || pViewShell->isLOKMobilePhone())
- {
- return;
- }
+ return;
- if (comphelper::LibreOfficeKit::isActive())
+ OStringBuffer sPayload;
+ if (sAction == "show")
{
- if (!m_pButton)
- return;
-
- SwEditWin* pEditWin = dynamic_cast<SwEditWin*>(m_pButton->GetParent());
- if (!pEditWin)
+ if (m_aPortionPaintArea.IsEmpty())
return;
- OStringBuffer sPayload;
- if (sAction == "show")
+ sPayload = OStringLiteral("{\"action\": \"show\","
+ " \"type\": \"drop-down\", \"textArea\": \"") +
+ m_aPortionPaintArea.SVRect().toString() + "\",";
+ // Add field params to the message
+ sPayload.append(" \"params\": { \"items\": [");
+
+ // List items
+ auto pParameters = this->GetParameters();
+ auto pListEntriesIter = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
+ css::uno::Sequence<OUString> vListEntries;
+ if (pListEntriesIter != pParameters->end())
{
- if(m_aPortionPaintArea.IsEmpty())
- return;
-
- sPayload = OStringLiteral("{\"action\": \"show\","
- " \"type\": \"drop-down\", \"textArea\": \"") +
- m_aPortionPaintArea.SVRect().toString() + "\",";
- // Add field params to the message
- sPayload.append(" \"params\": { \"items\": [");
-
- // List items
- auto pParameters = this->GetParameters();
- auto pListEntriesIter = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
- css::uno::Sequence<OUString> vListEntries;
- if (pListEntriesIter != pParameters->end())
- {
- pListEntriesIter->second >>= vListEntries;
- for (const OUString& sItem : std::as_const(vListEntries))
- sPayload.append("\"" + OUStringToOString(sItem, RTL_TEXTENCODING_UTF8) + "\", ");
- sPayload.setLength(sPayload.getLength() - 2);
- }
- sPayload.append("], ");
-
- // Selected item
- OUString sResultKey = ODF_FORMDROPDOWN_RESULT;
- auto pSelectedItemIter = pParameters->find(sResultKey);
- sal_Int32 nSelection = -1;
- if (pSelectedItemIter != pParameters->end())
- {
- pSelectedItemIter->second >>= nSelection;
- }
- sPayload.append("\"selected\": \"" + OString::number(nSelection) + "\", ");
-
- // Placeholder text
- sPayload.append("\"placeholderText\": \"" + OUStringToOString(SwResId(STR_DROP_DOWN_EMPTY_LIST), RTL_TEXTENCODING_UTF8) + "\"}}");
+ pListEntriesIter->second >>= vListEntries;
+ for (const OUString& sItem : std::as_const(vListEntries))
+ sPayload.append("\"" + OUStringToOString(sItem, RTL_TEXTENCODING_UTF8) + "\", ");
+ sPayload.setLength(sPayload.getLength() - 2);
}
- else
+ sPayload.append("], ");
+
+ // Selected item
+ OUString sResultKey = ODF_FORMDROPDOWN_RESULT;
+ auto pSelectedItemIter = pParameters->find(sResultKey);
+ sal_Int32 nSelection = -1;
+ if (pSelectedItemIter != pParameters->end())
{
- 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());
+ pSelectedItemIter->second >>= nSelection;
}
+ sPayload.append("\"selected\": \"" + OString::number(nSelection) + "\", ");
+
+ // Placeholder text
+ sPayload.append("\"placeholderText\": \"" + OUStringToOString(SwResId(STR_DROP_DOWN_EMPTY_LIST), RTL_TEXTENCODING_UTF8) + "\"}}");
+ }
+ else
+ {
+ assert(sAction == "hide");
+ sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
}
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, sPayload.toString().getStr());
}
DateFieldmark::DateFieldmark(const SwPaM& rPaM)