[Libreoffice-commits] core.git: include/unotools officecfg/registry sw/source sw/uiconfig unotools/Library_utl.mk unotools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Feb 16 14:58:22 UTC 2019


 include/unotools/compatibilityviewoptions.hxx                     |   40 ++
 include/unotools/itemholderbase.hxx                               |    1 
 officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs |   13 
 sw/source/ui/config/optcomp.cxx                                   |   29 +
 sw/source/uibase/inc/optcomp.hxx                                  |    7 
 sw/uiconfig/swriter/ui/optcompatpage.ui                           |   81 ++++
 unotools/Library_utl.mk                                           |    1 
 unotools/source/config/compatibilityviewoptions.cxx               |  171 ++++++++++
 unotools/source/config/itemholder1.cxx                            |    5 
 9 files changed, 347 insertions(+), 1 deletion(-)

New commits:
commit 11669b9cf970d953d41b8dd2c5ce85d6fa7e31ef
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: Sat Feb 16 15:58:02 2019 +0100

    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.
    
    Change-Id: I54668ae9808a1ca3c3b7fe81f2f201720257b3fb
    Reviewed-on: https://gerrit.libreoffice.org/67902
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai 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 1204eacc6314..dbb622ece3ad 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