[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 11 commits - framework/inc framework/source include/svtools include/unotools include/xmloff officecfg/registry svtools/source svtools/uiconfig sw/inc sw/Library_swui.mk sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk unotools/Library_utl.mk unotools/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 19 14:00:33 UTC 2019


 framework/inc/services/layoutmanager.hxx                             |    2 
 framework/source/layoutmanager/layoutmanager.cxx                     |  168 ++++--
 include/svtools/restartdialog.hxx                                    |    3 
 include/unotools/compatibilityviewoptions.hxx                        |   40 +
 include/unotools/itemholderbase.hxx                                  |    1 
 include/xmloff/odffields.hxx                                         |    1 
 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu |   24 
 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu  |   15 
 officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs    |   13 
 svtools/source/dialogs/restartdialog.cxx                             |    3 
 svtools/uiconfig/ui/restartdialog.ui                                 |   17 
 sw/Library_swui.mk                                                   |    1 
 sw/UIConfig_swriter.mk                                               |    2 
 sw/inc/cmdid.h                                                       |    6 
 sw/inc/swabstdlg.hxx                                                 |    4 
 sw/sdi/_textsh.sdi                                                   |   24 
 sw/sdi/swriter.sdi                                                   |   52 +
 sw/source/core/doc/docbm.cxx                                         |    6 
 sw/source/core/text/itrform2.cxx                                     |    4 
 sw/source/ui/config/optcomp.cxx                                      |   43 +
 sw/source/ui/dialog/swdlgfact.cxx                                    |   12 
 sw/source/ui/dialog/swdlgfact.hxx                                    |   14 
 sw/source/ui/dialog/swuiexp.cxx                                      |    1 
 sw/source/ui/fldui/DropDownFormFieldDialog.cxx                       |  191 +++++++
 sw/source/uibase/inc/DropDownFormFieldDialog.hxx                     |   69 ++
 sw/source/uibase/inc/optcomp.hxx                                     |    7 
 sw/source/uibase/shells/textfld.cxx                                  |   45 +
 sw/source/uibase/shells/textsh1.cxx                                  |   59 ++
 sw/source/uibase/uiview/viewling.cxx                                 |   11 
 sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml                |   40 +
 sw/uiconfig/swriter/ui/dropdownformfielddialog.ui                    |  272 ++++++++++
 sw/uiconfig/swriter/ui/optcompatpage.ui                              |   81 ++
 unotools/Library_utl.mk                                              |    1 
 unotools/source/config/compatibilityviewoptions.cxx                  |  171 ++++++
 unotools/source/config/itemholder1.cxx                               |    5 
 35 files changed, 1357 insertions(+), 51 deletions(-)

New commits:
commit 29c1084e155d045d7a8709ad5bfffdaf5740a3bc
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Feb 19 10:24:46 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:58:30 2019 +0200

    MSForms: Fix a regression in inplace menu handling
    
    We should not call implts_resetInplaceMenuBar() unconditionally.
    The problem which was fixed by that call can be solved by setting
    m_bInplaceMenuSet to false, which is the proper solution. So after
    the menu cleared up (inplace menu too), this indicator flag also
    contains the right value.
    
    Regression from:
    dc3a2546bd0ad0afe20cba9940934405174fd593
    
    Change-Id: I85243417eb273629cc57b762b98fdd32dc9b1dd5
    Reviewed-on: https://gerrit.libreoffice.org/68010
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 86182188c708..af370d042bd9 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -217,8 +217,6 @@ void LayoutManager::impl_clearUpMenuBar()
 {
     implts_lock();
 
-    implts_resetInplaceMenuBar();
-
     // Clear up VCL menu bar to prepare shutdown
     if ( m_xContainerWindow.is() )
     {
@@ -269,6 +267,7 @@ void LayoutManager::impl_clearUpMenuBar()
         m_xInplaceMenuBar.clear();
     }
     pMenuBar.disposeAndClear();
+    m_bInplaceMenuSet = false;
 
     Reference< XComponent > xComp( m_xMenuBar, UNO_QUERY );
     if ( xComp.is() )
commit 4e1549ba5b55ab566b3693c8c772515794f95efd
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jun 19 15:54:27 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:54:27 2019 +0200

    MSForms: Rework the MS compatible Forms menu a bit
    
    * DateField is saved as a content control in MSO file formats
    so let have it under content controls submenu
    * The MS compatible forms menu is a Writer specific thing so better
    to have the related commands as Writer commands.
    
    Reviewed-on: https://gerrit.libreoffice.org/67912
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 6a4653ed1b24a161950a9cd84caabdd5ad4fe536)
    
    Change-Id: I2d66130f54c055a422f56b18ff2c98667e4f6469
    Reviewed-on: https://gerrit.libreoffice.org/67927
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index af13c9b12afa..bb4e841388ca 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6853,16 +6853,6 @@
           <value xml:lang="en-US">More Fields</value>
         </prop>
       </node>
-      <node oor:name=".uno:MSCompatActiveXControls" oor:op="replace">
-        <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">ActiveX Controls</value>
-        </prop>
-      </node>
-      <node oor:name=".uno:MSCompatLegacyControls" oor:op="replace">
-        <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Legacy Forms</value>
-        </prop>
-      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index 75b5eb0f62b6..848d598e620a 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -3394,6 +3394,21 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:MSCompatActiveXControls" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">ActiveX Controls</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:MSCompatLegacyControls" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Legacy Form Fields</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:MSCompatContentControls" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Content Controls</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
index 4c8e34467d3e..4d157908dd71 100644
--- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
+++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
@@ -21,7 +21,6 @@
           <menu:menuitem menu:id=".uno:RadioButton"/>
           <menu:menuitem menu:id=".uno:ListBox"/>
           <menu:menuitem menu:id=".uno:Pushbutton"/>
-          <menu:menuitem menu:id=".uno:DateField"/>
         </menu:menupopup>
       </menu:menu>
       <menu:menu menu:id=".uno:MSCompatLegacyControls">
@@ -31,6 +30,11 @@
           <menu:menuitem menu:id=".uno:DropDownFormField"/>
         </menu:menupopup>
       </menu:menu>
+      <menu:menu menu:id=".uno:MSCompatContentControls">
+        <menu:menupopup>
+          <menu:menuitem menu:id=".uno:DateField"/>
+        </menu:menupopup>
+      </menu:menu>
     </menu:menupopup>
   </menu:menu>
 </menu:menubar>
commit 930c1ca26a1d98016d3fe5c2e4408661fd2f5ef4
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: Wed Jun 19 15:50:53 2019 +0200

    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>
    (cherry picked from commit 770ef0d216a30efd756b4be26e9fc6e077748fed)

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 dde3a8a853e3..ae9db9357140 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;
@@ -1338,6 +1340,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;
@@ -1877,6 +1905,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();
     }
commit cc91bd99df3b7f841507c38a73e72af4ca52ef67
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Feb 14 13:15:41 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:46:55 2019 +0200

    MSForms: Don't show popup dialog of drop-down field when there is no item list
    
    Change-Id: Ife361e0ee18437da6f188e77713ea51403b70dbc
    Reviewed-on: https://gerrit.libreoffice.org/67910
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 575438b0b68baeee3d37d887d8645757a4505971)
    Reviewed-on: https://gerrit.libreoffice.org/67925
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 935f974ce75a..c29c1637ab87 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -912,6 +912,17 @@ IMPL_LINK_NOARG(SwView, FieldPopupModeEndHdl, FloatingWindow*, void)
 
 void SwView::ExecFieldPopup( const Point& rPt, IFieldmark *fieldBM )
 {
+    // Don't show popup if there is no list item
+    auto pListEntries = fieldBM->GetParameters()->find( ODF_FORMDROPDOWN_LISTENTRY );
+    Sequence< OUString > vListEntries;
+    if(pListEntries != fieldBM->GetParameters()->end())
+    {
+        pListEntries->second >>= vListEntries;
+    }
+
+    if(vListEntries.getLength() == 0)
+        return;
+
     const Point aPixPos = GetEditWin().LogicToPixel( rPt );
 
     m_pFieldPopup = VclPtr<SwFieldDialog>::Create( m_pEditWin, fieldBM );
commit 532944dea7244e149e52007b2cc63e39403777cf
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 19:23:53 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:42:59 2019 +0200

    MSForms: Introduce a properties dialog for Drop-down form field
    
    - Dialog created similar to the edit dialog of Input field
    - On the dialog, the user can edit the list of the drop down field
    - This dialog is only for editing of the field, so the user can't select
    an item from the list to display in the field.
    
    Change-Id: I6222aba9b211afeb0e9d10d97a49347921ff7353
    Reviewed-on: https://gerrit.libreoffice.org/67909
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 117da8dab05986380db586f1fae6a2f0af9ce389)

diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk
index bbacb517f697..2da933936257 100644
--- a/sw/Library_swui.mk
+++ b/sw/Library_swui.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,swui,\
     sw/source/ui/envelp/labprt \
     sw/source/ui/envelp/mailmrge \
     sw/source/ui/fldui/DropDownFieldDialog \
+    sw/source/ui/fldui/DropDownFormFieldDialog \
     sw/source/ui/fldui/FldRefTreeListBox \
     sw/source/ui/fldui/changedb \
     sw/source/ui/fldui/flddb \
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 99d2eebfb39a..695d0f16b9c6 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -123,6 +123,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/datasourcesunavailabledialog \
 	sw/uiconfig/swriter/ui/dropcapspage \
 	sw/uiconfig/swriter/ui/dropdownfielddialog \
+	sw/uiconfig/swriter/ui/dropdownformfielddialog \
 	sw/uiconfig/swriter/ui/editcategories \
 	sw/uiconfig/swriter/ui/editfielddialog \
 	sw/uiconfig/swriter/ui/editsectiondialog \
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 2e97df323db9..845f5db1daec 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -76,6 +76,9 @@ namespace com{namespace sun{namespace star{
     namespace container { class XNamed; }
 }}}
 
+
+namespace sw { namespace mark { class IFieldmark; } }
+
 typedef   void (*SwLabDlgMethod) (css::uno::Reference< css::frame::XModel> const & xModel, const SwLabItem& rItem);
 
 typedef OUString    (*GlossaryGetCurrGroup)();
@@ -387,6 +390,7 @@ public:
 
     virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh,
         SwField* pField, bool bPrevButton, bool bNextButton) = 0;
+    virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Window* pParent, sw::mark::IFieldmark* pDropDownField) = 0;
     virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) = 0;
 
     virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 1705fe76312c..7e8c6ad4ab3a 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -40,6 +40,7 @@
 #include <docfnote.hxx>
 #include <docstdlg.hxx>
 #include <DropDownFieldDialog.hxx>
+#include <DropDownFormFieldDialog.hxx>
 #include <envlop.hxx>
 #include <label.hxx>
 #include <drpcps.hxx>
@@ -85,6 +86,7 @@
 #include <uiborder.hxx>
 #include <mmresultdialogs.hxx>
 
+
 using namespace ::com::sun::star;
 using namespace css::frame;
 using namespace css::uno;
@@ -173,6 +175,11 @@ short AbstractDropDownFieldDialog_Impl::Execute()
     return m_xDlg->run();
 }
 
+short AbstractDropDownFormFieldDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
+
 short AbstractSwLabDlg_Impl::Execute()
 {
     return m_xDlg->run();
@@ -862,6 +869,11 @@ VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDown
     return VclPtr<AbstractDropDownFieldDialog_Impl>::Create(o3tl::make_unique<sw::DropDownFieldDialog>(pParent, rSh, pField, bPrevButton, bNextButton));
 }
 
+VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(weld::Window *pParent, sw::mark::IFieldmark* pDropDownField)
+{
+    return VclPtr<AbstractDropDownFormFieldDialog_Impl>::Create(o3tl::make_unique<sw::DropDownFormFieldDialog>(pParent, pDropDownField));
+}
+
 VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet,
                                                                  SwWrtShell* pWrtSh, Printer* pPrt,
                                                                  bool bInsert)
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 05eab8cbcb35..f11b86b1e145 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -49,6 +49,7 @@ class SwSplitTableDlg;
 namespace sw
 {
 class DropDownFieldDialog;
+class DropDownFormFieldDialog;
 }
 
 #define DECL_ABSTDLG_BASE(Class,DialogClass)        \
@@ -314,6 +315,18 @@ public:
     virtual bool          NextButtonPressed() const override;
 };
 
+class AbstractDropDownFormFieldDialog_Impl : public VclAbstractDialog
+{
+protected:
+    std::unique_ptr<sw::DropDownFormFieldDialog> m_xDlg;
+public:
+    explicit AbstractDropDownFormFieldDialog_Impl(std::unique_ptr<sw::DropDownFormFieldDialog> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short Execute() override;
+};
+
 class AbstractSwLabDlg_Impl  : public AbstractSwLabDlg
 {
 protected:
@@ -624,6 +637,7 @@ public:
 
     virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh,
         SwField* pField, bool bPrevButton, bool bNextButton) override;
+    virtual VclPtr<VclAbstractDialog> CreateDropDownFormFieldDialog(weld::Window* pParent, sw::mark::IFieldmark* pDropDownField) override;
     virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) override;
     virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
                                                      SwDBManager* pDBManager, bool bLabel) override;
diff --git a/sw/source/ui/dialog/swuiexp.cxx b/sw/source/ui/dialog/swuiexp.cxx
index ba351e57ced5..85b73e3af372 100644
--- a/sw/source/ui/dialog/swuiexp.cxx
+++ b/sw/source/ui/dialog/swuiexp.cxx
@@ -27,6 +27,7 @@
 #include <srtdlg.hxx>
 #include <dbinsdlg.hxx>
 #include <DropDownFieldDialog.hxx>
+#include <DropDownFormFieldDialog.hxx>
 #include <fldtdlg.hxx>
 #include <glossary.hxx>
 #include <inpdlg.hxx>
diff --git a/sw/source/ui/fldui/DropDownFormFieldDialog.cxx b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
new file mode 100644
index 000000000000..cb00cc2a255b
--- /dev/null
+++ b/sw/source/ui/fldui/DropDownFormFieldDialog.cxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <DropDownFormFieldDialog.hxx>
+#include <vcl/event.hxx>
+#include <IMark.hxx>
+#include <xmloff/odffields.hxx>
+
+namespace sw
+{
+DropDownFormFieldDialog::DropDownFormFieldDialog(weld::Window* pParent,
+                                                 mark::IFieldmark* pDropDownField)
+    : GenericDialogController(pParent, "modules/swriter/ui/dropdownformfielddialog.ui",
+                              "DropDownFormFieldDialog")
+    , m_pDropDownField(pDropDownField)
+    , m_bListHasChanged(false)
+    , m_xListItemEntry(m_xBuilder->weld_entry("item_entry"))
+    , m_xListAddButton(m_xBuilder->weld_button("add_button"))
+    , m_xListItemsTreeView(m_xBuilder->weld_tree_view("items_treeview"))
+    , m_xListRemoveButton(m_xBuilder->weld_button("remove_button"))
+    , m_xListUpButton(m_xBuilder->weld_button("up_button"))
+    , m_xListDownButton(m_xBuilder->weld_button("down_button"))
+{
+    getDialog()->connect_key_press(LINK(this, DropDownFormFieldDialog, KeyPressedHdl));
+    getDialog()->connect_key_release(LINK(this, DropDownFormFieldDialog, KeyReleasedHdl));
+
+    m_xListItemsTreeView->set_size_request(m_xListItemEntry->get_preferred_size().Width(),
+                                           m_xListItemEntry->get_preferred_size().Height() * 5);
+    m_xListItemsTreeView->connect_changed(LINK(this, DropDownFormFieldDialog, ListChangedHdl));
+
+    Link<weld::Button&, void> aPushButtonLink(LINK(this, DropDownFormFieldDialog, ButtonPushedHdl));
+    m_xListAddButton->connect_clicked(aPushButtonLink);
+    m_xListRemoveButton->connect_clicked(aPushButtonLink);
+    m_xListUpButton->connect_clicked(aPushButtonLink);
+    m_xListDownButton->connect_clicked(aPushButtonLink);
+
+    InitControls();
+}
+
+DropDownFormFieldDialog::~DropDownFormFieldDialog() {}
+
+IMPL_LINK_NOARG(DropDownFormFieldDialog, ListChangedHdl, weld::TreeView&, void) { UpdateButtons(); }
+
+IMPL_LINK(DropDownFormFieldDialog, KeyPressedHdl, const KeyEvent&, rEvent, bool)
+{
+    if (m_xListItemEntry->has_focus() && rEvent.GetKeyCode().GetCode() == KEY_RETURN)
+    {
+        AppendItemToList();
+    }
+    return false; // Call the dialog's input handler too
+}
+
+IMPL_LINK_NOARG(DropDownFormFieldDialog, KeyReleasedHdl, const KeyEvent&, bool)
+{
+    if (m_xListItemEntry->has_focus())
+    {
+        UpdateButtons();
+    }
+    return false; // Call the dialog's input handler too
+}
+
+IMPL_LINK(DropDownFormFieldDialog, ButtonPushedHdl, weld::Button&, rButton, void)
+{
+    if (&rButton == m_xListAddButton.get())
+    {
+        AppendItemToList();
+    }
+    else if (m_xListItemsTreeView->get_selected_index() != -1)
+    {
+        int nSelPos = m_xListItemsTreeView->get_selected_index();
+        if (&rButton == m_xListRemoveButton.get())
+        {
+            m_xListItemsTreeView->remove(nSelPos);
+            m_xListItemsTreeView->select(nSelPos > 0 ? nSelPos - 1 : 0);
+        }
+        else if (&rButton == m_xListUpButton.get())
+        {
+            const OUString sEntry = m_xListItemsTreeView->get_selected_text();
+            m_xListItemsTreeView->remove(nSelPos);
+            nSelPos--;
+            m_xListItemsTreeView->insert_text(nSelPos, sEntry);
+            m_xListItemsTreeView->select(nSelPos);
+        }
+        else if (&rButton == m_xListDownButton.get())
+        {
+            const OUString sEntry = m_xListItemsTreeView->get_selected_text();
+            m_xListItemsTreeView->remove(nSelPos);
+            nSelPos++;
+            m_xListItemsTreeView->insert_text(nSelPos, sEntry);
+            m_xListItemsTreeView->select(nSelPos);
+        }
+        m_bListHasChanged = true;
+    }
+    UpdateButtons();
+}
+
+void DropDownFormFieldDialog::InitControls()
+{
+    if (m_pDropDownField != nullptr)
+    {
+        const mark::IFieldmark::parameter_map_t* const pParameters
+            = m_pDropDownField->GetParameters();
+
+        auto pListEntries = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
+        if (pListEntries != pParameters->end())
+        {
+            css::uno::Sequence<OUString> vListEntries;
+            pListEntries->second >>= vListEntries;
+            for (const OUString& rItem : vListEntries)
+                m_xListItemsTreeView->append_text(rItem);
+
+            // Select the current one
+            auto pResult = pParameters->find(ODF_FORMDROPDOWN_RESULT);
+            if (pResult != pParameters->end())
+            {
+                sal_Int32 nSelection = -1;
+                pResult->second >>= nSelection;
+                m_xListItemsTreeView->select_text(vListEntries[nSelection]);
+            }
+        }
+    }
+    UpdateButtons();
+}
+
+void DropDownFormFieldDialog::AppendItemToList()
+{
+    if (m_xListAddButton->get_sensitive())
+    {
+        const OUString sEntry(m_xListItemEntry->get_text());
+        if (!sEntry.isEmpty())
+        {
+            m_xListItemsTreeView->append_text(sEntry);
+            m_xListItemsTreeView->select_text(sEntry);
+            m_bListHasChanged = true;
+
+            // Clear entry
+            m_xListItemEntry->set_text(OUString());
+            m_xListItemEntry->grab_focus();
+        }
+        UpdateButtons();
+    }
+}
+
+void DropDownFormFieldDialog::UpdateButtons()
+{
+    m_xListAddButton->set_sensitive(!m_xListItemEntry->get_text().isEmpty()
+                                    && m_xListItemsTreeView->find_text(m_xListItemEntry->get_text())
+                                           == -1);
+
+    int nSelPos = m_xListItemsTreeView->get_selected_index();
+    m_xListRemoveButton->set_sensitive(nSelPos != -1);
+    m_xListUpButton->set_sensitive(nSelPos > 0);
+    m_xListDownButton->set_sensitive(nSelPos != -1
+                                     && nSelPos < m_xListItemsTreeView->n_children() - 1);
+}
+
+void DropDownFormFieldDialog::Apply()
+{
+    if (m_pDropDownField != nullptr && m_bListHasChanged)
+    {
+        mark::IFieldmark::parameter_map_t* pParameters = m_pDropDownField->GetParameters();
+
+        css::uno::Sequence<OUString> vListEntries(m_xListItemsTreeView->n_children());
+        for (int nIndex = 0; nIndex < m_xListItemsTreeView->n_children(); ++nIndex)
+        {
+            vListEntries[nIndex] = m_xListItemsTreeView->get_text(nIndex);
+        }
+
+        if (m_xListItemsTreeView->n_children() != 0)
+        {
+            (*pParameters)[ODF_FORMDROPDOWN_LISTENTRY] <<= vListEntries;
+        }
+        else
+        {
+            pParameters->erase(ODF_FORMDROPDOWN_LISTENTRY);
+        }
+
+        // After editing the drop down field's list we don't specify the selected item
+        pParameters->erase(ODF_FORMDROPDOWN_RESULT);
+    }
+}
+
+} // namespace sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sw/source/uibase/inc/DropDownFormFieldDialog.hxx b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
new file mode 100644
index 000000000000..3fbb59db0ebc
--- /dev/null
+++ b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_DROPDOWNFORMFIELDDIALOG_HXX
+#define INCLUDED_SW_SOURCE_UIBASE_INC_DROPDOWNFORMFIELDDIALOG_HXX
+
+#include <vcl/weld.hxx>
+#include "actctrl.hxx"
+
+namespace sw
+{
+namespace mark
+{
+class IFieldmark;
+}
+} // namespace sw
+
+/// Dialog to specify the properties of drop-down form field
+namespace sw
+{
+class DropDownFormFieldDialog : public weld::GenericDialogController
+{
+private:
+    mark::IFieldmark* m_pDropDownField;
+    bool m_bListHasChanged;
+
+    std::unique_ptr<weld::Entry> m_xListItemEntry;
+    std::unique_ptr<weld::Button> m_xListAddButton;
+
+    std::unique_ptr<weld::TreeView> m_xListItemsTreeView;
+
+    std::unique_ptr<weld::Button> m_xListRemoveButton;
+    std::unique_ptr<weld::Button> m_xListUpButton;
+    std::unique_ptr<weld::Button> m_xListDownButton;
+
+    DECL_LINK(ListChangedHdl, weld::TreeView&, void);
+    DECL_LINK(KeyPressedHdl, const KeyEvent&, bool);
+    DECL_LINK(KeyReleasedHdl, const KeyEvent&, bool);
+    DECL_LINK(ButtonPushedHdl, weld::Button&, void);
+
+    void InitControls();
+    void AppendItemToList();
+    void UpdateButtons();
+    void Apply();
+
+public:
+    DropDownFormFieldDialog(weld::Window* pParent, mark::IFieldmark* pDropDownField);
+    virtual ~DropDownFormFieldDialog() override;
+
+    virtual short run() override
+    {
+        short nRet = GenericDialogController::run();
+        if (nRet == RET_OK)
+            Apply();
+        return nRet;
+    }
+};
+
+} // namespace sw
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sw/uiconfig/swriter/ui/dropdownformfielddialog.ui b/sw/uiconfig/swriter/ui/dropdownformfielddialog.ui
new file mode 100644
index 000000000000..3a170b7cf41d
--- /dev/null
+++ b/sw/uiconfig/swriter/ui/dropdownformfielddialog.ui
@@ -0,0 +1,272 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface domain="sw">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkDialog" id="DropDownFormFieldDialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">6</property>
+    <property name="title" translatable="yes" context="dropdownformfielddialog|DropDownFormFieldDialog">Drop-down Form Field</property>
+    <property name="resizable">True</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="ok">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="help">
+                <property name="label">gtk-help</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkGrid" id="list_grid">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="row_spacing">12</property>
+            <child>
+              <object class="GtkGrid" id="grid9">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="row_spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="item_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" context="dropdownformfielddialog|item_label">Item</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">item_entry</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="item_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="add_button">
+                <property name="label">gtk-add</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="halign">start</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkGrid" id="grid6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="listitem_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" context="dropdownformfielddialog|listitem_label">Items on list</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">items_treeview</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScrolledWindow">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="items_treeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="model">liststore1</property>
+                        <property name="headers_visible">False</property>
+                        <property name="headers_clickable">False</property>
+                        <property name="search_column">0</property>
+                        <property name="show_expanders">False</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection1"/>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                              <attributes>
+                                <attribute name="text">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButtonBox" id="buttonbox1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">6</property>
+                    <property name="layout_style">start</property>
+                    <child>
+                      <object class="GtkButton" id="remove_button">
+                        <property name="label">gtk-remove</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="up_button">
+                        <property name="label" translatable="yes" context="dropdownformfielddialog|up">Move Up</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="down_button">
+                        <property name="label" translatable="yes" context="dropdownformfielddialog|down">Move Down</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">ok</action-widget>
+      <action-widget response="-6">cancel</action-widget>
+      <action-widget response="-11">help</action-widget>
+    </action-widgets>
+  </object>
+</interface>
commit 9caa2ba5ff9915eb68a3ea04abb7d7fe4be9a30a
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Feb 14 12:33:39 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:29:28 2019 +0200

    MSForms: Make Drop-Down form field to have a default size
    
    Similar to MSO Drop-down form field and LO Input List.
    
    Change-Id: Idba278d8c2a2106b6f3cc22d8b9f8570f45bfae9
    Reviewed-on: https://gerrit.libreoffice.org/67908
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit d24fe1116ddd9eec3a0884c7b222455c44bd6eb4)
    Reviewed-on: https://gerrit.libreoffice.org/67923
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx
index bbc1becb6576..27525fb39374 100644
--- a/include/xmloff/odffields.hxx
+++ b/include/xmloff/odffields.hxx
@@ -22,7 +22,7 @@
 
 
 #define ODF_FORMTEXT "vnd.oasis.opendocument.field.FORMTEXT"
-#define ODF_FORMTEXT_DEFAULT_LENGTH 5
+#define ODF_FORMFIELD_DEFAULT_LENGTH 5
 
 #define ODF_FORMCHECKBOX "vnd.oasis.opendocument.field.FORMCHECKBOX"
 #define ODF_FORMCHECKBOX_HELPTEXT "Checkbox_HelpText"
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index a0778ad9a064..3517812be531 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -859,7 +859,9 @@ namespace sw { namespace mark {
             if (nCurrentIdx < vListEntries.getLength())
                 return vListEntries[nCurrentIdx];
         }
-        return OUString();
+
+        sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
+        return OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH);
     }
 } }
 
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index dd7f93783d02..095d89bc1182 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -726,8 +726,8 @@ FIELD_INSERT:
                 if(pCursorPos)
                 {
                     // Insert five enspace into the text field so the field has extent
-                    sal_Unicode vEnSpaces[ODF_FORMTEXT_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
-                    bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMTEXT_DEFAULT_LENGTH));
+                    sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
+                    bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH));
                     if(bSuccess)
                     {
                         IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
commit dd7323411feb18513311b3bba50c820d9f272a8c
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jun 19 15:24:06 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:24:06 2019 +0200

    MSForms: Insert Legacy Form Fields from MS compatible Forms menu
    
    I added a new submenu under MS compatible Forms menu called Legacy Forms.
    Under this submenu user can insert the three legacy form fields. These
    fields were already supported by DOC / DOCX filters, but were missing from
    the UI.
    When inserting text form field we insert 5 enspace to make the
    field visible, otherwise we use the same insertion methods what is
    called by DOC import.
    
    Reviewed-on: https://gerrit.libreoffice.org/67907
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 5a94be3e677e4b7ccb2990a3a79fbf2219322f80)
    
    Change-Id: I1fb8c03d969b4c547ca92e783ac5e216767685d5
    Reviewed-on: https://gerrit.libreoffice.org/67922
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/xmloff/odffields.hxx b/include/xmloff/odffields.hxx
index 1a4bb2b623f6..bbc1becb6576 100644
--- a/include/xmloff/odffields.hxx
+++ b/include/xmloff/odffields.hxx
@@ -22,6 +22,7 @@
 
 
 #define ODF_FORMTEXT "vnd.oasis.opendocument.field.FORMTEXT"
+#define ODF_FORMTEXT_DEFAULT_LENGTH 5
 
 #define ODF_FORMCHECKBOX "vnd.oasis.opendocument.field.FORMCHECKBOX"
 #define ODF_FORMCHECKBOX_HELPTEXT "Checkbox_HelpText"
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index fee50cba3d59..af13c9b12afa 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6316,6 +6316,30 @@
           <value xml:lang="en-US">Synony~ms</value>
         </prop>
       </node>
+      <node oor:name=".uno:TextFormField" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Text Form Field</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:CheckBoxFormField" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Check Box Form Field</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:DropDownFormField" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Drop-Down Form Field</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
     </node>
     <node oor:name="Popups">
       <node oor:name=".uno:PasteSpecialMenu" oor:op="replace">
@@ -6834,6 +6858,11 @@
           <value xml:lang="en-US">ActiveX Controls</value>
         </prop>
       </node>
+      <node oor:name=".uno:MSCompatLegacyControls" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Legacy Forms</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 28a13ea71abd..2e48818cff90 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -272,6 +272,12 @@
 #define FN_INSERT_MULTI_TOX         (FN_INSERT2 + 20)   /* insert any TOX */
 #define FN_INSERT_AUTH_ENTRY_DLG    (FN_INSERT2 + 21)   /* insert entry for table of authorities*/
 
+// MSO legacy form fields
+#define FN_INSERT_TEXT_FORMFIELD        (FN_INSERT2 + 22)
+#define FN_INSERT_CHECKBOX_FORMFIELD    (FN_INSERT2 + 23)
+#define FN_INSERT_DROPDOWN_FORMFIELD    (FN_INSERT2 + 24)
+
+
 // Region: Format
 #define FN_AUTOFORMAT_APPLY     (FN_FORMAT + 1 ) /* apply autoformat options */
 #define FN_AUTOFORMAT_AUTO      (FN_FORMAT + 2 ) /* apply autoformat during user input */
diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi
index 463738966dea..f8c2daee6d65 100644
--- a/sw/sdi/_textsh.sdi
+++ b/sw/sdi/_textsh.sdi
@@ -1676,5 +1676,23 @@ interface BaseText
         DisableFlags="SfxDisableFlags::SwOnProtectedCursor";  // e.g. disable for read-only documents
     ]
 
+    FN_INSERT_TEXT_FORMFIELD
+    [
+        ExecMethod = ExecField ;
+        StateMethod = StateField ;
+    ]
+
+    FN_INSERT_CHECKBOX_FORMFIELD
+    [
+        ExecMethod = ExecField ;
+        StateMethod = StateField ;
+    ]
+
+    FN_INSERT_DROPDOWN_FORMFIELD
+    [
+        ExecMethod = ExecField ;
+        StateMethod = StateField ;
+    ]
+
 }  // end of interface text
 
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 416b596965e4..4933a9e605c9 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7685,6 +7685,58 @@ SfxBoolItem ShowInlineTooltips FN_SHOW_INLINETOOLTIPS
     GroupId = SfxGroupId::View;
 ]
 
+SfxVoidItem TextFormField FN_INSERT_TEXT_FORMFIELD
+
+[
+    AutoUpdate = TRUE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Controls;
+]
+
+SfxVoidItem CheckBoxFormField FN_INSERT_CHECKBOX_FORMFIELD
+
+[
+    AutoUpdate = TRUE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::View;
+]
+
+SfxVoidItem DropDownFormField FN_INSERT_DROPDOWN_FORMFIELD
+
+[
+    AutoUpdate = TRUE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Controls;
+]
+
 SfxBoolItem UseHeaderFooterMenu FN_USE_HEADERFOOTERMENU
 ()
 [
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index aaa9731bba31..f48e3c626cc2 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -507,6 +507,9 @@ namespace sw { namespace mark
         const OUString& rName,
         const OUString& rType)
     {
+        bool bEnableSetModified = m_pDoc->getIDocumentState().IsEnableSetModified();
+        m_pDoc->getIDocumentState().SetEnableSetModified(false);
+
         sw::mark::IMark* pMark = makeMark( rPaM, rName,
                 IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK,
                 sw::mark::InsertMode::New);
@@ -514,6 +517,9 @@ namespace sw { namespace mark
         if (pFieldMark)
             pFieldMark->SetFieldname( rType );
 
+        m_pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
+        m_pDoc->getIDocumentState().SetModified();
+
         return pFieldMark;
     }
 
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 68c49f0f2d7c..dd7f93783d02 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -71,6 +71,9 @@
 #include <cstddef>
 #include <memory>
 #include <swmodule.hxx>
+#include <MarkManager.hxx>
+#include <xmloff/odffields.hxx>
+#include <IDocumentContentOperations.hxx>
 
 using namespace nsSwDocInfoSubType;
 
@@ -716,6 +719,45 @@ FIELD_INSERT:
                 rReq.Done();
             }
             break;
+
+            case FN_INSERT_TEXT_FORMFIELD:
+            {
+                SwPaM* pCursorPos = rSh.GetCursor();
+                if(pCursorPos)
+                {
+                    // Insert five enspace into the text field so the field has extent
+                    sal_Unicode vEnSpaces[ODF_FORMTEXT_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194};
+                    bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMTEXT_DEFAULT_LENGTH));
+                    if(bSuccess)
+                    {
+                        IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+                        SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()-5,
+                                        pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex());
+                        pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT);
+                    }
+                }
+            }
+            break;
+            case FN_INSERT_CHECKBOX_FORMFIELD:
+            {
+                SwPaM* pCursorPos = rSh.GetCursor();
+                if(pCursorPos)
+                {
+                    IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+                    pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMCHECKBOX);
+                }
+            }
+            break;
+            case FN_INSERT_DROPDOWN_FORMFIELD:
+            {
+                SwPaM* pCursorPos = rSh.GetCursor();
+                if(pCursorPos)
+                {
+                    IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
+                    pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDROPDOWN);
+                }
+            }
+            break;
             default:
                 OSL_FAIL("wrong dispatcher");
                 return;
@@ -866,6 +908,9 @@ void SwTextShell::StateField( SfxItemSet &rSet )
         case FN_INSERT_FLD_TITLE:
         case FN_INSERT_FLD_TOPIC:
         case FN_INSERT_DBFIELD:
+        case FN_INSERT_TEXT_FORMFIELD:
+        case FN_INSERT_CHECKBOX_FORMFIELD:
+        case FN_INSERT_DROPDOWN_FORMFIELD:
             if ( rSh.CursorInsideInputField() )
             {
                 rSet.DisableItem(nWhich);
diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
index 4b8f5ea0e714..4c8e34467d3e 100644
--- a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
+++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
@@ -24,6 +24,13 @@
           <menu:menuitem menu:id=".uno:DateField"/>
         </menu:menupopup>
       </menu:menu>
+      <menu:menu menu:id=".uno:MSCompatLegacyControls">
+        <menu:menupopup>
+          <menu:menuitem menu:id=".uno:TextFormField"/>
+          <menu:menuitem menu:id=".uno:CheckBoxFormField"/>
+          <menu:menuitem menu:id=".uno:DropDownFormField"/>
+        </menu:menupopup>
+      </menu:menu>
     </menu:menupopup>
   </menu:menu>
 </menu:menubar>
commit 95b4d7d1a6c596561782c9c99a204d89a6a76132
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Feb 16 17:05:34 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:18:14 2019 +0200

    MSForms: Show restart dialog when MS compatible Forms menu setting is changed
    
    Reviewed-on: https://gerrit.libreoffice.org/67906
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 54b2615e0d209f815b3d503523fd4c517dc6b5cd)
    
    Change-Id: Icb98dac73dea5f5cb18e1ca34e37e9d9bf84782e
    Reviewed-on: https://gerrit.libreoffice.org/67921
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/svtools/restartdialog.hxx b/include/svtools/restartdialog.hxx
index f29366c1b592..d5f4565f4e18 100644
--- a/include/svtools/restartdialog.hxx
+++ b/include/svtools/restartdialog.hxx
@@ -54,6 +54,9 @@ enum RestartReason {
         // "For the extension to work properly,
         // %PRODUCTNAME must be restarted."
     RESTART_REASON_OPENGL,
+    // For restructuring the Forms menu,
+    // %PRODUCTNAME must be restarted:
+    RESTART_REASON_MSCOMPATIBLE_FORMS_MENU,
         // No particular reason
     RESTART_REASON_NONE
 };
diff --git a/svtools/source/dialogs/restartdialog.cxx b/svtools/source/dialogs/restartdialog.cxx
index 079cc5e28f21..f7f5fd2bb4e0 100644
--- a/svtools/source/dialogs/restartdialog.cxx
+++ b/svtools/source/dialogs/restartdialog.cxx
@@ -62,6 +62,9 @@ public:
         case svtools::RESTART_REASON_OPENGL:
             reason_ = m_xBuilder->weld_widget("reason_opengl");
             break;
+        case svtools::RESTART_REASON_MSCOMPATIBLE_FORMS_MENU:
+            reason_ = m_xBuilder->weld_widget("reason_mscompatible_formsmenu");
+            break;
         default:
             assert(false); // this cannot happen
         }
diff --git a/svtools/uiconfig/ui/restartdialog.ui b/svtools/uiconfig/ui/restartdialog.ui
index f9c4ebc95b28..bd605c3a7a7d 100644
--- a/svtools/uiconfig/ui/restartdialog.ui
+++ b/svtools/uiconfig/ui/restartdialog.ui
@@ -229,6 +229,21 @@
               </packing>
             </child>
             <child>
+              <object class="GtkLabel" id="reason_mscompatible_formsmenu">
+                <property name="can_focus">False</property>
+                <property name="no_show_all">True</property>
+                <property name="label" translatable="yes" context="restartdialog|reason_mscompatible_formsmenu">For restructuring the Forms menu, %PRODUCTNAME must be restarted.</property>
+                <property name="wrap">True</property>
+                <property name="max_width_chars">50</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">11</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkLabel" id="label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -239,7 +254,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">11</property>
+                <property name="position">12</property>
               </packing>
             </child>
           </object>
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 7b76258c99d5..524e8642276b 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -35,6 +35,8 @@
 #include <vcl/treelistentry.hxx>
 #include <IDocumentSettingAccess.hxx>
 #include <vector>
+#include <svtools/restartdialog.hxx>
+#include <comphelper/processfactory.hxx>
 
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::document;
@@ -452,6 +454,18 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet*  )
         m_aViewConfigItem.SetMSOCompatibleFormsMenu(bNewMSFormsMenuOption);
         m_bSavedMSFormsMenuOption = bNewMSFormsMenuOption;
         bModified = true;
+
+        // Show a message about that the option needs a restart to be applied
+        {
+            {
+                SolarMutexGuard aGuard;
+                if (svtools::executeRestartDialog(comphelper::getProcessComponentContext(),
+                                                  GetFrameWeld(), svtools::RESTART_REASON_MSCOMPATIBLE_FORMS_MENU))
+                {
+                    GetParentDialog()->EndDialog(RET_OK);
+                }
+            }
+        }
     }
 
     return bModified;
commit 0a9020a84da16385f1d5ba0fd9992433450dfd3c
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 18:37:40 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:09:24 2019 +0200

    MSForms: Introduce a new Forms menu which is compatible with MS Word
    
    * It's a Writer only menu by now
    * Displayed when the compatibility option is set
    * The menubar is changed during creation, so the option
    has an effect only after a restart.
    * MS compatible Forms menu contains only some ActiveX controls now
    
    Reviewed-on: https://gerrit.libreoffice.org/67904
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit dc3a2546bd0ad0afe20cba9940934405174fd593)
    
    Change-Id: I459f489c15ea7a25514f379b1800b926cc2087ce
    Reviewed-on: https://gerrit.libreoffice.org/67920
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index 1cd9f1d99ff7..6e15d58e2442 100644
--- a/framework/inc/services/layoutmanager.hxx
+++ b/framework/inc/services/layoutmanager.hxx
@@ -178,6 +178,7 @@ namespace framework
             void implts_reset( bool bAttach );
             void implts_updateMenuBarClose();
             bool implts_resetMenuBar();
+            void implts_createMSCompatibleMenuBar(const OUString& rName);
 
             //  locking
 
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index 8520b7bd8bad..86182188c708 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -73,6 +73,7 @@
 #include <comphelper/uno3.hxx>
 #include <rtl/instance.hxx>
 #include <unotools/cmdoptions.hxx>
+#include <unotools/compatibilityviewoptions.hxx>
 
 #include <rtl/ref.hxx>
 #include <rtl/strbuf.hxx>
@@ -156,6 +157,14 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
 {
     SolarMutexClearableGuard aWriteLock;
 
+    // Create a customized menu if compatibility mode is on
+    SvtCompatibilityViewOptions aCompOptions;
+    if( aCompOptions.HasMSOCompatibleFormsMenu() && m_aModuleIdentifier == "com.sun.star.text.TextDocument" )
+    {
+        implts_createMSCompatibleMenuBar(rMenuBarName);
+    }
+
+    // Create the default menubar otherwise
     if (!m_bInplaceMenuSet && !m_xMenuBar.is())
     {
         m_xMenuBar = implts_createElement( rMenuBarName );
@@ -208,6 +217,8 @@ void LayoutManager::impl_clearUpMenuBar()
 {
     implts_lock();
 
+    implts_resetInplaceMenuBar();
+
     // Clear up VCL menu bar to prepare shutdown
     if ( m_xContainerWindow.is() )
     {
@@ -2524,6 +2535,60 @@ bool LayoutManager::implts_resetMenuBar()
     return false;
 }
 
+void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName )
+{
+    SolarMutexClearableGuard aWriteLock;
+
+    // Find Forms menu in the original menubar
+    m_xMenuBar = implts_createElement( aName );
+    uno::Reference< XUIElementSettings > xMenuBarSettings(m_xMenuBar, UNO_QUERY);
+    uno::Reference< container::XIndexReplace > xMenuIndex(xMenuBarSettings->getSettings(true), UNO_QUERY);
+
+    sal_Int32 nFormsMenu = -1;
+    for (sal_Int32 nIndex = 0; nIndex < xMenuIndex->getCount(); ++nIndex)
+    {
+        uno::Sequence< beans::PropertyValue > aProps;
+        xMenuIndex->getByIndex( nIndex ) >>= aProps;
+        OUString aCommand;
+        for (sal_Int32 nSeqInd = 0; nSeqInd < aProps.getLength(); ++nSeqInd)
+        {
+            if (aProps[nSeqInd].Name == "CommandURL")
+            {
+                aProps[nSeqInd].Value >>= aCommand;
+                break;
+            }
+        }
+
+        if (aCommand == ".uno:FormatFormMenu")
+            nFormsMenu = nIndex;
+    }
+    assert(nFormsMenu != -1);
+
+    // Create the MS compatible Forms menu
+    css::uno::Reference< css::ui::XUIElement > xFormsMenu = implts_createElement( "private:resource/menubar/mscompatibleformsmenu" );
+    if(!xFormsMenu.is())
+        return;
+
+    // Merge the MS compatible Forms menu into the menubar
+    uno::Reference< XUIElementSettings > xFormsMenuSettings(xFormsMenu, UNO_QUERY);
+    uno::Reference< container::XIndexAccess > xFormsMenuIndex(xFormsMenuSettings->getSettings(true));
+
+    assert(xFormsMenuIndex->getCount() >= 1);
+    uno::Sequence< beans::PropertyValue > aNewFormsMenu;
+    xFormsMenuIndex->getByIndex( 0 ) >>= aNewFormsMenu;
+    xMenuIndex->replaceByIndex(nFormsMenu, uno::makeAny(aNewFormsMenu));
+
+    setMergedMenuBar( xMenuIndex );
+
+    // Clear up the temporal forms menubar
+    Reference< XComponent > xFormsMenuComp( xFormsMenu, UNO_QUERY );
+    if ( xFormsMenuComp.is() )
+        xFormsMenuComp->dispose();
+    xFormsMenu.clear();
+
+    aWriteLock.clear();
+}
+
 IMPL_LINK_NOARG(LayoutManager, MenuBarClose, void*, void)
 {
     SolarMutexClearableGuard aReadLock;
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 2bc7f9584a3a..fee50cba3d59 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6829,6 +6829,11 @@
           <value xml:lang="en-US">More Fields</value>
         </prop>
       </node>
+      <node oor:name=".uno:MSCompatActiveXControls" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">ActiveX Controls</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index bba8c908e805..99d2eebfb39a 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_UIConfig_UIConfig,modules/swriter))
 
 $(eval $(call gb_UIConfig_add_menubarfiles,modules/swriter,\
 	sw/uiconfig/swriter/menubar/menubar \
+	sw/uiconfig/swriter/menubar/mscompatibleformsmenu \
 ))
 
 $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swriter,\
diff --git a/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
new file mode 100644
index 000000000000..4b8f5ea0e714
--- /dev/null
+++ b/sw/uiconfig/swriter/menubar/mscompatibleformsmenu.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<menu:menubar xmlns:menu="http://openoffice.org/2001/menu">
+  <menu:menu menu:id=".uno:FormatFormMenu">
+    <menu:menupopup>
+      <menu:menuitem menu:id=".uno:SwitchControlDesignMode"/>
+      <menu:menuitem menu:id=".uno:ControlProperties"/>
+      <menu:menuseparator/>
+      <menu:menu menu:id=".uno:MSCompatActiveXControls">
+        <menu:menupopup>
+          <menu:menuitem menu:id=".uno:Label"/>
+          <menu:menuitem menu:id=".uno:Edit"/>
+          <menu:menuitem menu:id=".uno:CheckBox"/>
+          <menu:menuitem menu:id=".uno:RadioButton"/>
+          <menu:menuitem menu:id=".uno:ListBox"/>
+          <menu:menuitem menu:id=".uno:Pushbutton"/>
+          <menu:menuitem menu:id=".uno:DateField"/>
+        </menu:menupopup>
+      </menu:menu>
+    </menu:menupopup>
+  </menu:menu>
+</menu:menubar>
commit 2b6d47bda916a5bbf6865e9d7a5d2a0ca915f4c1
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 18:36:25 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:06:40 2019 +0200

    MSForms: Extract menu creation to a separate method
    
    No functional change is intended.
    
    Change-Id: Ieb88e746b08c6a6daac14c08a206db73cbeef8a9
    Reviewed-on: https://gerrit.libreoffice.org/67903
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 5599dfc71b4bd0a2f9130cb51a0dc8fe7eaf9fdb)
    Reviewed-on: https://gerrit.libreoffice.org/67919
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx
index eaecc6fa8e87..1cd9f1d99ff7 100644
--- a/framework/inc/services/layoutmanager.hxx
+++ b/framework/inc/services/layoutmanager.hxx
@@ -173,6 +173,7 @@ namespace framework
 
             //  menu bar
 
+            void implts_createMenuBar( const OUString& rMenuBarName );
             void impl_clearUpMenuBar();
             void implts_reset( bool bAttach );
             void implts_updateMenuBarClose();
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index b33f92557fd9..8520b7bd8bad 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -152,6 +152,57 @@ LayoutManager::~LayoutManager()
     m_pGlobalSettings.reset();
 }
 
+void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
+{
+    SolarMutexClearableGuard aWriteLock;
+
+    if (!m_bInplaceMenuSet && !m_xMenuBar.is())
+    {
+        m_xMenuBar = implts_createElement( rMenuBarName );
+        if ( m_xMenuBar.is() )
+        {
+            SolarMutexGuard aGuard;
+
+            SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
+            if ( pSysWindow )
+            {
+                Reference< awt::XMenuBar > xMenuBar;
+
+                Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
+                if ( xPropSet.is() )
+                {
+                    try
+                    {
+                        xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
+                    }
+                    catch (const beans::UnknownPropertyException&)
+                    {
+                    }
+                    catch (const lang::WrappedTargetException&)
+                    {
+                    }
+                }
+
+                if ( xMenuBar.is() )
+                {
+                    VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar );
+                    if ( pAwtMenuBar )
+                    {
+                        MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
+                        if ( pMenuBar )
+                        {
+                            pSysWindow->SetMenuBar(pMenuBar);
+                            pMenuBar->SetDisplayable( m_bMenuVisible );
+                            implts_updateMenuBarClose();
+                        }
+                    }
+                }
+            }
+        }
+    }
+    aWriteLock.clear();
+}
+
 // Internal helper function
 void LayoutManager::impl_clearUpMenuBar()
 {
@@ -1379,7 +1430,6 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName )
 
     SolarMutexClearableGuard aReadLock;
     Reference< XFrame > xFrame = m_xFrame;
-    bool    bInPlaceMenu = m_bInplaceMenuSet;
     aReadLock.clear();
 
     if ( !xFrame.is() )
@@ -1415,55 +1465,13 @@ void SAL_CALL LayoutManager::createElement( const OUString& aName )
             bMustBeLayouted = m_xToolbarManager->isLayoutDirty();
         }
         else if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
-                  aElementName.equalsIgnoreAsciiCase("menubar") )
+                  aElementName.equalsIgnoreAsciiCase("menubar") &&
+                  implts_isFrameOrWindowTop(xFrame) )
         {
-            // #i38743# don't create a menubar if frame isn't top
-            if ( !bInPlaceMenu && !m_xMenuBar.is() && implts_isFrameOrWindowTop( xFrame ))
-            {
-                m_xMenuBar = implts_createElement( aName );
-                if ( m_xMenuBar.is() )
-                {
-                    SolarMutexGuard aGuard;
+            implts_createMenuBar( aName );
+            if (m_bMenuVisible)
+                bNotify = true;
 
-                    SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
-                    if ( pSysWindow )
-                    {
-                        Reference< awt::XMenuBar > xMenuBar;
-
-                        Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
-                        if ( xPropSet.is() )
-                        {
-                            try
-                            {
-                                xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
-                            }
-                            catch (const beans::UnknownPropertyException&)
-                            {
-                            }
-                            catch (const lang::WrappedTargetException&)
-                            {
-                            }
-                        }
-
-                        if ( xMenuBar.is() )
-                        {
-                            VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar );
-                            if ( pAwtMenuBar )
-                            {
-                                MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
-                                if ( pMenuBar )
-                                {
-                                    pSysWindow->SetMenuBar(pMenuBar);
-                                    pMenuBar->SetDisplayable( m_bMenuVisible );
-                                    if ( m_bMenuVisible )
-                                        bNotify = true;
-                                    implts_updateMenuBarClose();
-                                }
-                            }
-                        }
-                    }
-                }
-            }
             aWriteLock.clear();
         }
         else if ( aElementType.equalsIgnoreAsciiCase("statusbar") &&
commit 18b15f7de68bd264fce1f1dc657147821ef87805
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Feb 15 18:34:56 2019 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Wed Jun 19 15:05:45 2019 +0200

    MSForms: Introduce a new compatibility flag to enable MS compatible Forms menu
    
    * It's a global option not a document level setting (like other compatibility
    options) so I created a separate section on the GUI for this option on the
    same tab page.
    * In the configuration the option is placed under Compatibility/View since
    the existing Compatibility/FormattingOptions seems related to document formating
    and not the GUI.
    * Since it was added with a new configuration root I needed to add also a new
    ConfigItem derviative class to handle this option.
    
    Reviewed-on: https://gerrit.libreoffice.org/67902
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 11669b9cf970d953d41b8dd2c5ce85d6fa7e31ef)
    
    Change-Id: I54668ae9808a1ca3c3b7fe81f2f201720257b3fb
    Reviewed-on: https://gerrit.libreoffice.org/67918
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/unotools/compatibilityviewoptions.hxx b/include/unotools/compatibilityviewoptions.hxx
new file mode 100644
index 000000000000..573979714e7e
--- /dev/null
+++ b/include/unotools/compatibilityviewoptions.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SVTOOLS_COMPATIBILITYVIEWOPTIONS_HXX
+#define INCLUDED_SVTOOLS_COMPATIBILITYVIEWOPTIONS_HXX
+
+#include <svtools/svtdllapi.h>
+#include <unotools/options.hxx>
+#include <osl/mutex.hxx>
+
+class SvtCompatibilityViewOptions_Impl;
+
+/// Compatibility settings which affects the GUI. These are not document level settings
+/// (like SvtCompatibilityOptions), but global options affecting the application's
+/// behavior in general.
+class UNOTOOLS_DLLPUBLIC SvtCompatibilityViewOptions : public utl::detail::Options
+{
+public:
+    SvtCompatibilityViewOptions();
+    virtual ~SvtCompatibilityViewOptions() override;
+
+    bool HasMSOCompatibleFormsMenu() const;
+    void SetMSOCompatibleFormsMenu(bool bSet);
+
+private:
+    /// Return a reference to a static mutex
+    UNOTOOLS_DLLPRIVATE static osl::Mutex& GetOwnStaticMutex();
+
+    std::shared_ptr<SvtCompatibilityViewOptions_Impl> m_pImpl;
+};
+
+#endif // #ifndef INCLUDED_SVTOOLS_COMPATIBILITYVIEWOPTIONS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/unotools/itemholderbase.hxx b/include/unotools/itemholderbase.hxx
index 865d45e8b4d8..b401de3435c1 100644
--- a/include/unotools/itemholderbase.hxx
+++ b/include/unotools/itemholderbase.hxx
@@ -37,6 +37,7 @@ enum class EItem
     CmdOptions                    ,
     ColorConfig                   ,   // 2
     Compatibility                 ,
+    CompatibilityView             ,
     CTLOptions                    ,   // 2
 
     DefaultOptions                ,
diff --git a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
index a47d27074cba..7c587319beef 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
@@ -151,5 +151,18 @@
         <value/>
       </prop>
     </group>
+    <group oor:name="View">
+      <info>
+        <desc>Compatibility options affecting GUI</desc>
+      </info>
+      <prop oor:name="MSCompatibleFormsMenu" oor:type="xs:boolean" oor:nillable="false">
+        <!-- UIHints: Tools - Options - Writer - Compatibility - Global Options -->
+        <info>
+          <desc>Specifies whether Forms menu should be customized for an MSO workflow. The MS compatible Forms menu contains only MS compatible form controls.</desc>
+          <label>Reorganize Forms menu to have it MS compatible.</label>
+        </info>
+        <value>false</value>
+      </prop>
+    </group>
   </component>
 </oor:component-schema>
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 07e9aa06022c..7b76258c99d5 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -51,10 +51,14 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
     , m_pWrtShell(nullptr)
     , m_pImpl(new SwCompatibilityOptPage_Impl)
     , m_nSavedOptions(0)
+    , m_bSavedMSFormsMenuOption(false)
 {
     get(m_pMain, "compatframe");
+    get(m_pGlobalOptionsFrame, "globalcompatframe");
     get(m_pFormattingLB, "format");
+    get(m_pGlobalOptionsLB, "globaloptions");
     get(m_pOptionsLB, "options");
+    get(m_pGlobalOptionsCLB, "globaloptioncheckboxs");
     get(m_pDefaultPB, "default");
 
     for ( int i = (static_cast<int>(SvtCompatibilityEntry::Index::Module) + 1); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
@@ -76,6 +80,16 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
     m_pOptionsLB->SetStyle( m_pOptionsLB->GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
     m_pOptionsLB->SetHighlightRange();
 
+    SvTreeListEntry* pEntry = m_pGlobalOptionsCLB->SvTreeListBox::InsertEntry( m_pGlobalOptionsLB->GetEntry( 0 ) );
+    if ( pEntry )
+    {
+        m_pGlobalOptionsCLB->SetCheckButtonState( pEntry, SvButtonState::Unchecked );
+    }
+    m_pGlobalOptionsLB->Clear();
+
+    m_pGlobalOptionsCLB->SetStyle( m_pGlobalOptionsCLB->GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
+    m_pGlobalOptionsCLB->SetHighlightRange();
+
     InitControls( rSet );
 
     // set handler
@@ -92,8 +106,11 @@ void SwCompatibilityOptPage::dispose()
 {
     m_pImpl.reset();
     m_pMain.clear();
+    m_pGlobalOptionsFrame.clear();
     m_pFormattingLB.clear();
+    m_pGlobalOptionsLB.clear();
     m_pOptionsLB.clear();
+    m_pGlobalOptionsCLB.clear();
     m_pDefaultPB.clear();
     SfxTabPage::dispose();
 }
@@ -185,6 +202,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
     else
     {
         m_pMain->Disable();
+        m_pGlobalOptionsFrame->Disable();
     }
     const OUString& rText = m_pMain->get_label();
     m_pMain->set_label(rText.replaceAll("%DOCNAME", sDocTitle));
@@ -428,6 +446,14 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet*  )
     if ( bModified )
         WriteOptions();
 
+    bool bNewMSFormsMenuOption = m_pGlobalOptionsCLB->IsChecked(0);
+    if (m_bSavedMSFormsMenuOption != bNewMSFormsMenuOption)
+    {
+        m_aViewConfigItem.SetMSOCompatibleFormsMenu(bNewMSFormsMenuOption);
+        m_bSavedMSFormsMenuOption = bNewMSFormsMenuOption;
+        bModified = true;
+    }
+
     return bModified;
 }
 
@@ -438,6 +464,9 @@ void SwCompatibilityOptPage::Reset( const SfxItemSet*  )
     sal_uLong nOptions = GetDocumentOptions();
     SetCurrentOptions( nOptions );
     m_nSavedOptions = nOptions;
+
+    m_pGlobalOptionsCLB->CheckEntryPos( 0, m_aViewConfigItem.HasMSOCompatibleFormsMenu() );
+    m_bSavedMSFormsMenuOption = m_aViewConfigItem.HasMSOCompatibleFormsMenu();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/optcomp.hxx b/sw/source/uibase/inc/optcomp.hxx
index fe6c3eca0ee1..aa76d70bc09c 100644
--- a/sw/source/uibase/inc/optcomp.hxx
+++ b/sw/source/uibase/inc/optcomp.hxx
@@ -25,6 +25,7 @@
 #include <vcl/layout.hxx>
 #include <vcl/lstbox.hxx>
 #include <unotools/compatibility.hxx>
+#include <unotools/compatibilityviewoptions.hxx>
 #include <svx/checklbx.hxx>
 #include <rtl/ustring.hxx>
 
@@ -36,11 +37,16 @@ class SwCompatibilityOptPage : public SfxTabPage
 private:
     // controls
     VclPtr<VclFrame>               m_pMain;
+    VclPtr<VclFrame>               m_pGlobalOptionsFrame;
     VclPtr<ListBox>                m_pFormattingLB;
+    VclPtr<ListBox>                m_pGlobalOptionsLB;
     VclPtr<SvxCheckListBox>        m_pOptionsLB;
+    VclPtr<SvxCheckListBox>        m_pGlobalOptionsCLB;
     VclPtr<PushButton>             m_pDefaultPB;
     // config item
     SvtCompatibilityOptions m_aConfigItem;
+    // config item
+    SvtCompatibilityViewOptions m_aViewConfigItem;
     // text of the user entry
     OUString                m_sUserEntry;
     // shell of the current document
@@ -49,6 +55,7 @@ private:
     std::unique_ptr<SwCompatibilityOptPage_Impl> m_pImpl;
     // saved options after "Reset"; used in "FillItemSet" for comparison
     sal_uLong                   m_nSavedOptions;
+    bool                        m_bSavedMSFormsMenuOption;
 
     // handler
     DECL_LINK(SelectHdl, ListBox&, void);
diff --git a/sw/uiconfig/swriter/ui/optcompatpage.ui b/sw/uiconfig/swriter/ui/optcompatpage.ui
index b44020d57991..8f4a5342c75d 100644
--- a/sw/uiconfig/swriter/ui/optcompatpage.ui
+++ b/sw/uiconfig/swriter/ui/optcompatpage.ui
@@ -2,12 +2,14 @@
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
   <requires lib="LibreOffice" version="1.0"/>
-  <object class="GtkGrid" id="OptCompatPage">
+  <object class="GtkBox" id="OptCompatPage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
     <property name="border_width">6</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">12</property>
     <child>
       <object class="GtkFrame" id="compatframe">
         <property name="visible">True</property>
@@ -116,5 +118,82 @@
         <property name="height">1</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkFrame" id="globalcompatframe">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="label_xalign">0</property>
+        <property name="shadow_type">none</property>
+        <child>
+          <object class="GtkAlignment" id="alignment5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="top_padding">6</property>
+            <property name="left_padding">12</property>
+            <child>
+              <object class="GtkGrid" id="grid2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="row_spacing">5</property>
+                <child>
+                  <object class="svxcorelo-SvxCheckListBox" id="globaloptioncheckboxs:border">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection" id="Check List Box-selection1"/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBoxText" id="globaloptions">
+                    <property name="can_focus">False</property>
+                    <property name="no_show_all">True</property>
+                    <property name="entry_text_column">0</property>
+                    <property name="id_column">1</property>
+                    <items>
+                      <item translatable="yes" context="optcompatpage|globalcompatoptions">Reorganize Forms menu to have it MS compatible</item>
+                    </items>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child type="label">
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes" context="optcompatpage|label2">Global compatibility options</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
   </object>
 </interface>
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk
index 0bfcbad5e383..19fcd7cfce1c 100644
--- a/unotools/Library_utl.mk
+++ b/unotools/Library_utl.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,utl,\
     unotools/source/config/bootstrap \
     unotools/source/config/cmdoptions \
     unotools/source/config/compatibility \
+    unotools/source/config/compatibilityviewoptions \
     unotools/source/config/configitem \
     unotools/source/config/configmgr \
     unotools/source/config/confignode \
diff --git a/unotools/source/config/compatibilityviewoptions.cxx b/unotools/source/config/compatibilityviewoptions.cxx
new file mode 100644
index 000000000000..52e02446608b
--- /dev/null
+++ b/unotools/source/config/compatibilityviewoptions.cxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <unotools/compatibilityviewoptions.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include "itemholder1.hxx"
+
+#define ROOTNODE_COMPATIBILITY_VIEW "Office.Compatibility/View"
+
+#define PROPERTYNAME_MSCOMPATIBLEFORMSMENU "MSCompatibleFormsMenu"
+
+#define PROPERTYHANDLE_MSCOMPATIBLEFORMSMENU 0
+
+class SvtCompatibilityViewOptions_Impl : public utl::ConfigItem
+{
+private:
+    bool m_bShowMSCompatibleFormsMenu;
+
+public:
+    SvtCompatibilityViewOptions_Impl();
+    virtual ~SvtCompatibilityViewOptions_Impl() override;
+
+    /**
+            @short      Called for notify of configmanager.
+
+                        This method is called from the ConfigManager before application ends or from the
+                        PropertyChangeListener if the sub tree broadcasts changes. You must update your
+                        internal values.
+
+            @see        baseclass ConfigItem
+
+            @param      "seqPropertyNames" is the list of properties which should be updated.
+        */
+    virtual void Notify(const css::uno::Sequence<OUString>& seqPropertyNames) override;
+
+    bool HasMSOCompatibleFormsMenu() const { return m_bShowMSCompatibleFormsMenu; }
+    void SetMSOCompatibleFormsMenu(bool bSet)
+    {
+        bool bModified = (m_bShowMSCompatibleFormsMenu != bSet);
+        if (bModified)
+        {
+            m_bShowMSCompatibleFormsMenu = bSet;
+            SetModified();
+            Commit();
+        }
+    }
+
+private:
+    virtual void ImplCommit() override;
+
+    /**
+            @short      Return list of fix key names of our configuration management which represent our module tree.
+
+                        This method returns a static const list of key names. We need it to get needed values from our
+                        configuration management.
+
+            @return     A list of needed configuration keys is returned.
+        */
+    static css::uno::Sequence<OUString> const& impl_GetPropertyNames();
+};
+
+SvtCompatibilityViewOptions_Impl::SvtCompatibilityViewOptions_Impl()
+    : ConfigItem(ROOTNODE_COMPATIBILITY_VIEW)
+    , m_bShowMSCompatibleFormsMenu(false)
+{
+    // Use our static list of configuration keys to get his values.
+    css::uno::Sequence<OUString> seqNames = impl_GetPropertyNames();
+    css::uno::Sequence<css::uno::Any> seqValues = GetProperties(seqNames);
+    assert(seqNames.getLength() == seqValues.getLength());
+
+    if (seqValues[PROPERTYHANDLE_MSCOMPATIBLEFORMSMENU].hasValue())
+    {
+        assert(seqValues[PROPERTYHANDLE_MSCOMPATIBLEFORMSMENU].getValueTypeClass()
+               == css::uno::TypeClass_BOOLEAN);
+        seqValues[PROPERTYHANDLE_MSCOMPATIBLEFORMSMENU] >>= m_bShowMSCompatibleFormsMenu;
+    }
+
+    EnableNotification(seqNames);
+}
+
+SvtCompatibilityViewOptions_Impl::~SvtCompatibilityViewOptions_Impl()
+{
+    assert(!IsModified()); // should have been committed
+}
+
+void SvtCompatibilityViewOptions_Impl::Notify(const css::uno::Sequence<OUString>& seqPropertyNames)
+{
+    // Use given list of updated properties to get his values from configuration directly!
+    css::uno::Sequence<css::uno::Any> seqValues = GetProperties(seqPropertyNames);
+    assert(seqPropertyNames.getLength() == seqValues.getLength());
+
+    for (sal_Int32 nProperty = 0; nProperty < seqPropertyNames.getLength(); ++nProperty)
+    {
+        if (seqPropertyNames[nProperty] == PROPERTYNAME_MSCOMPATIBLEFORMSMENU)
+        {
+            assert(seqValues[nProperty].getValueTypeClass() == css::uno::TypeClass_BOOLEAN);
+            seqValues[nProperty] >>= m_bShowMSCompatibleFormsMenu;
+        }
+    }
+}
+
+void SvtCompatibilityViewOptions_Impl::ImplCommit()
+{
+    // Get names of supported properties, create a list for values and copy current values to it.
+    css::uno::Sequence<OUString> seqNames = impl_GetPropertyNames();
+    css::uno::Sequence<css::uno::Any> seqValues(seqNames.getLength());
+
+    seqValues[PROPERTYHANDLE_MSCOMPATIBLEFORMSMENU] <<= m_bShowMSCompatibleFormsMenu;
+
+    // Set properties in configuration.
+    PutProperties(seqNames, seqValues);
+}
+
+css::uno::Sequence<OUString> const& SvtCompatibilityViewOptions_Impl::impl_GetPropertyNames()
+{
+    static const css::uno::Sequence<OUString> seqPropertyNames{ OUString(
+        PROPERTYNAME_MSCOMPATIBLEFORMSMENU) };
+    return seqPropertyNames;
+}
+
+namespace
+{
+std::weak_ptr<SvtCompatibilityViewOptions_Impl> theOptions;
+}
+
+SvtCompatibilityViewOptions::SvtCompatibilityViewOptions()
+{
+    // Global access, must be guarded (multithreading!).
+    osl::MutexGuard aGuard(GetOwnStaticMutex());
+
+    m_pImpl = theOptions.lock();
+    if (!m_pImpl)
+    {
+        m_pImpl = std::make_shared<SvtCompatibilityViewOptions_Impl>();
+        theOptions = m_pImpl;
+        ItemHolder1::holdConfigItem(EItem::CompatibilityView);
+    }
+}
+
+SvtCompatibilityViewOptions::~SvtCompatibilityViewOptions()
+{
+    // Global access, must be guarded (multithreading!)
+    osl::MutexGuard aGuard(GetOwnStaticMutex());
+    m_pImpl.reset();
+}
+
+bool SvtCompatibilityViewOptions::HasMSOCompatibleFormsMenu() const
+{
+    return m_pImpl->HasMSOCompatibleFormsMenu();
+}
+
+void SvtCompatibilityViewOptions::SetMSOCompatibleFormsMenu(bool bSet)
+{
+    m_pImpl->SetMSOCompatibleFormsMenu(bSet);
+}
+
+osl::Mutex& SvtCompatibilityViewOptions::GetOwnStaticMutex()
+{
+    static osl::Mutex ourMutex;
+
+    return ourMutex;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx
index c0444dc9f1ec..70d1880ca6ca 100644
--- a/unotools/source/config/itemholder1.cxx
+++ b/unotools/source/config/itemholder1.cxx
@@ -27,6 +27,7 @@
 #include <unotools/useroptions.hxx>
 #include <unotools/cmdoptions.hxx>
 #include <unotools/compatibility.hxx>
+#include <unotools/compatibilityviewoptions.hxx>
 #include <unotools/defaultoptions.hxx>
 #include <unotools/dynamicmenuoptions.hxx>
 #include <unotools/eventcfg.hxx>
@@ -130,6 +131,10 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem)
             rItem.pItem.reset( new SvtCompatibilityOptions() );
             break;
 
+        case EItem::CompatibilityView :
+            rItem.pItem.reset( new SvtCompatibilityViewOptions() );
+            break;
+
         case EItem::DefaultOptions :
             rItem.pItem.reset( new SvtDefaultOptions() );
             break;


More information about the Libreoffice-commits mailing list