[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Mar 9 13:01:44 UTC 2019
sw/source/uibase/shells/textfld.cxx | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
New commits:
commit c138047c75dcd0d6c572a58870edf2a7761ae35e
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Feb 21 13:39:27 2019 +0100
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Mar 9 14:01:23 2019 +0100
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 at collabora.com>
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;
}
More information about the Libreoffice-commits
mailing list