[Libreoffice-commits] core.git: sw/sdi sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Feb 16 17:35:19 UTC 2019


 sw/sdi/_textsh.sdi                  |    6 +++
 sw/source/uibase/shells/textsh1.cxx |   59 ++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

New commits:
commit 770ef0d216a30efd756b4be26e9fc6e077748fed
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 14:11:37 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Feb 16 18:34:57 2019 +0100

    MSForms: Make Control Properties menu to work with drop-down form field
    
    Always forward the Execute and State method to the form shell,
    so if a form control is selected the Control Properites will
    work correctly.
    Otherwise we check whether there is any field next to the cursor.
    
    Change-Id: I25055c17d887a2f2a716d8325f46825cc408179e
    Reviewed-on: https://gerrit.libreoffice.org/67911
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index f8c2daee6d65..3724ee041ecc 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1694,5 +1694,11 @@ interface BaseText
         StateMethod = StateField ;
     ]
 
+    SID_FM_CTL_PROPERTIES
+    [
+        ExecMethod = Execute ;
+        StateMethod = GetState ;
+    ]
+
 }  // end of interface text
 
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index fd759463b971..270fcabc08dc 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -119,6 +119,8 @@
 #include <svx/drawitem.hxx>
 #include <numrule.hxx>
 #include <memory>
+#include <xmloff/odffields.hxx>
+#include <swabstdlg.hxx>
 
 using namespace ::com::sun::star;
 using namespace com::sun::star::beans;
@@ -1367,6 +1369,32 @@ void SwTextShell::Execute(SfxRequest &rReq)
         GetView().UpdateWordCount(this, nSlot);
     }
     break;
+    case SID_FM_CTL_PROPERTIES:
+    {
+        SwPosition aPos(*GetShell().GetCursor()->GetPoint());
+        sw::mark::IFieldmark* pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+        if ( !pFieldBM )
+        {
+            --aPos.nContent;
+            pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+        }
+
+        if ( pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN )
+        {
+            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+            ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateDropDownFormFieldDialog(rWrtSh.GetView().GetFrameWeld(), pFieldBM));
+            pDlg->Execute();
+            pFieldBM->Invalidate();
+            rWrtSh.InvalidateWindows( rWrtSh.GetView().GetVisArea() );
+        }
+        else
+        {
+            SfxRequest aReq( GetView().GetViewFrame(), SID_FM_CTL_PROPERTIES );
+            aReq.AppendItem( SfxBoolItem( SID_FM_CTL_PROPERTIES, true ) );
+            rWrtSh.GetView().GetFormShell()->Execute( aReq );
+        }
+    }
+    break;
     default:
         OSL_ENSURE(false, "wrong dispatcher");
         return;
@@ -1906,6 +1934,37 @@ void SwTextShell::GetState( SfxItemSet &rSet )
                     rSet.DisableItem(nWhich);
             }
             break;
+            case SID_FM_CTL_PROPERTIES:
+            {
+                bool bDisable = false;
+
+                // First get the state from the form shell
+                SfxItemSet aSet(GetShell().GetAttrPool(), svl::Items<SID_FM_CTL_PROPERTIES, SID_FM_CTL_PROPERTIES>{});
+                aSet.Put(SfxBoolItem( SID_FM_CTL_PROPERTIES, true ));
+                GetShell().GetView().GetFormShell()->GetState( aSet );
+
+                if(SfxItemState::DISABLED == aSet.GetItemState(SID_FM_CTL_PROPERTIES))
+                {
+                    bDisable = true;
+                }
+
+                // Enable it if we have a valid object other than what form shell knows
+                SwPosition aPos(*GetShell().GetCursor()->GetPoint());
+                sw::mark::IFieldmark* pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+                if ( !pFieldBM )
+                {
+                    --aPos.nContent;
+                    pFieldBM = GetShell().getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+                }
+                if ( pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN )
+                {
+                    bDisable = false;
+                }
+
+                if(bDisable)
+                    rSet.DisableItem(nWhich);
+            }
+            break;
         }
         nWhich = aIter.NextWhich();
     }


More information about the Libreoffice-commits mailing list