Kaydet (Commit) c138047c authored tarafından Tamás Zolnai's avatar Tamás Zolnai

MSForms: Disable legacy field menu slots if the cursor is inside a text field

Insertion of fields inside fields is not an allowed operation.

Change-Id: Icfdbc1add9c828227201b70cd545a83b6dcbc3e6
Reviewed-on: https://gerrit.libreoffice.org/68957
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst ba296f8e
...@@ -923,6 +923,12 @@ void SwTextShell::StateField( SfxItemSet &rSet ) ...@@ -923,6 +923,12 @@ void SwTextShell::StateField( SfxItemSet &rSet )
case FN_INSERT_FLD_TITLE: case FN_INSERT_FLD_TITLE:
case FN_INSERT_FLD_TOPIC: case FN_INSERT_FLD_TOPIC:
case FN_INSERT_DBFIELD: case FN_INSERT_DBFIELD:
if ( rSh.CursorInsideInputField() )
{
rSet.DisableItem(nWhich);
}
break;
case FN_INSERT_TEXT_FORMFIELD: case FN_INSERT_TEXT_FORMFIELD:
case FN_INSERT_CHECKBOX_FORMFIELD: case FN_INSERT_CHECKBOX_FORMFIELD:
case FN_INSERT_DROPDOWN_FORMFIELD: case FN_INSERT_DROPDOWN_FORMFIELD:
...@@ -930,6 +936,24 @@ void SwTextShell::StateField( SfxItemSet &rSet ) ...@@ -930,6 +936,24 @@ void SwTextShell::StateField( SfxItemSet &rSet )
{ {
rSet.DisableItem(nWhich); rSet.DisableItem(nWhich);
} }
else
{
// Check whether we are in a text form field
SwPosition aCursorPos(*rSh.GetCursor()->GetPoint());
sw::mark::IFieldmark* pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aCursorPos);
if ((!pFieldBM || pFieldBM->GetFieldname() != ODF_FORMTEXT)
&& aCursorPos.nContent.GetIndex() > 0)
{
SwPosition aPos(aCursorPos);
--aPos.nContent;
pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
}
if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMTEXT &&
(aCursorPos > pFieldBM->GetMarkStart() && aCursorPos < pFieldBM->GetMarkEnd() ))
{
rSet.DisableItem(nWhich);
}
}
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment