summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-02-21 13:39:27 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-03-09 14:01:23 +0100
commitc138047c75dcd0d6c572a58870edf2a7761ae35e (patch)
treeb2b99234cdb0ef9e2c268876d000078abb255478 /sw
parentba296f8e413f0cb1cd4095a342495b511df2aea4 (diff)
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: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/shells/textfld.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index ccf3952aaa97..c172b613339d 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -923,6 +923,12 @@ void SwTextShell::StateField( SfxItemSet &rSet )
case FN_INSERT_FLD_TITLE:
case FN_INSERT_FLD_TOPIC:
case FN_INSERT_DBFIELD:
+ if ( rSh.CursorInsideInputField() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
case FN_INSERT_TEXT_FORMFIELD:
case FN_INSERT_CHECKBOX_FORMFIELD:
case FN_INSERT_DROPDOWN_FORMFIELD:
@@ -930,6 +936,24 @@ void SwTextShell::StateField( SfxItemSet &rSet )
{
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;
}