[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Mar 18 09:09:48 UTC 2019


 sw/source/uibase/shells/textfld.cxx |   24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

New commits:
commit eac303d9b4081f5e13a3b8dd7cad6da67e1f27e7
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Feb 21 13:39:27 2019 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Mar 18 10:09:27 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>
    (cherry picked from commit c138047c75dcd0d6c572a58870edf2a7761ae35e)
    Reviewed-on: https://gerrit.libreoffice.org/69192
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index a91bd65084c1..d810ed63cec2 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -933,6 +933,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:
@@ -940,6 +946,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