Kaydet (Commit) 11669b9c authored tarafından Tamás Zolnai's avatar Tamás Zolnai

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: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst 294be303
/* -*- 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: */
...@@ -37,6 +37,7 @@ enum class EItem ...@@ -37,6 +37,7 @@ enum class EItem
CmdOptions , CmdOptions ,
ColorConfig , // 2 ColorConfig , // 2
Compatibility , Compatibility ,
CompatibilityView ,
CTLOptions , // 2 CTLOptions , // 2
DefaultOptions , DefaultOptions ,
......
...@@ -151,5 +151,18 @@ ...@@ -151,5 +151,18 @@
<value/> <value/>
</prop> </prop>
</group> </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> </component>
</oor:component-schema> </oor:component-schema>
...@@ -51,10 +51,14 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt ...@@ -51,10 +51,14 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
, m_pWrtShell(nullptr) , m_pWrtShell(nullptr)
, m_pImpl(new SwCompatibilityOptPage_Impl) , m_pImpl(new SwCompatibilityOptPage_Impl)
, m_nSavedOptions(0) , m_nSavedOptions(0)
, m_bSavedMSFormsMenuOption(false)
{ {
get(m_pMain, "compatframe"); get(m_pMain, "compatframe");
get(m_pGlobalOptionsFrame, "globalcompatframe");
get(m_pFormattingLB, "format"); get(m_pFormattingLB, "format");
get(m_pGlobalOptionsLB, "globaloptions");
get(m_pOptionsLB, "options"); get(m_pOptionsLB, "options");
get(m_pGlobalOptionsCLB, "globaloptioncheckboxs");
get(m_pDefaultPB, "default"); get(m_pDefaultPB, "default");
for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module) + 1; i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i ) 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 ...@@ -76,6 +80,16 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
m_pOptionsLB->SetStyle( m_pOptionsLB->GetStyle() | WB_HSCROLL | WB_HIDESELECTION ); m_pOptionsLB->SetStyle( m_pOptionsLB->GetStyle() | WB_HSCROLL | WB_HIDESELECTION );
m_pOptionsLB->SetHighlightRange(); 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 ); InitControls( rSet );
// set handler // set handler
...@@ -92,8 +106,11 @@ void SwCompatibilityOptPage::dispose() ...@@ -92,8 +106,11 @@ void SwCompatibilityOptPage::dispose()
{ {
m_pImpl.reset(); m_pImpl.reset();
m_pMain.clear(); m_pMain.clear();
m_pGlobalOptionsFrame.clear();
m_pFormattingLB.clear(); m_pFormattingLB.clear();
m_pGlobalOptionsLB.clear();
m_pOptionsLB.clear(); m_pOptionsLB.clear();
m_pGlobalOptionsCLB.clear();
m_pDefaultPB.clear(); m_pDefaultPB.clear();
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
...@@ -185,6 +202,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet ) ...@@ -185,6 +202,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
else else
{ {
m_pMain->Disable(); m_pMain->Disable();
m_pGlobalOptionsFrame->Disable();
} }
const OUString& rText = m_pMain->get_label(); const OUString& rText = m_pMain->get_label();
m_pMain->set_label(rText.replaceAll("%DOCNAME", sDocTitle)); m_pMain->set_label(rText.replaceAll("%DOCNAME", sDocTitle));
...@@ -428,6 +446,14 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet* ) ...@@ -428,6 +446,14 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet* )
if ( bModified ) if ( bModified )
WriteOptions(); WriteOptions();
bool bNewMSFormsMenuOption = m_pGlobalOptionsCLB->IsChecked(0);
if (m_bSavedMSFormsMenuOption != bNewMSFormsMenuOption)
{
m_aViewConfigItem.SetMSOCompatibleFormsMenu(bNewMSFormsMenuOption);
m_bSavedMSFormsMenuOption = bNewMSFormsMenuOption;
bModified = true;
}
return bModified; return bModified;
} }
...@@ -438,6 +464,9 @@ void SwCompatibilityOptPage::Reset( const SfxItemSet* ) ...@@ -438,6 +464,9 @@ void SwCompatibilityOptPage::Reset( const SfxItemSet* )
sal_uLong nOptions = GetDocumentOptions(); sal_uLong nOptions = GetDocumentOptions();
SetCurrentOptions( nOptions ); SetCurrentOptions( nOptions );
m_nSavedOptions = nOptions; m_nSavedOptions = nOptions;
m_pGlobalOptionsCLB->CheckEntryPos( 0, m_aViewConfigItem.HasMSOCompatibleFormsMenu() );
m_bSavedMSFormsMenuOption = m_aViewConfigItem.HasMSOCompatibleFormsMenu();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <vcl/layout.hxx> #include <vcl/layout.hxx>
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
#include <unotools/compatibility.hxx> #include <unotools/compatibility.hxx>
#include <unotools/compatibilityviewoptions.hxx>
#include <svx/checklbx.hxx> #include <svx/checklbx.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
...@@ -36,11 +37,16 @@ class SwCompatibilityOptPage : public SfxTabPage ...@@ -36,11 +37,16 @@ class SwCompatibilityOptPage : public SfxTabPage
private: private:
// controls // controls
VclPtr<VclFrame> m_pMain; VclPtr<VclFrame> m_pMain;
VclPtr<VclFrame> m_pGlobalOptionsFrame;
VclPtr<ListBox> m_pFormattingLB; VclPtr<ListBox> m_pFormattingLB;
VclPtr<ListBox> m_pGlobalOptionsLB;
VclPtr<SvxCheckListBox> m_pOptionsLB; VclPtr<SvxCheckListBox> m_pOptionsLB;
VclPtr<SvxCheckListBox> m_pGlobalOptionsCLB;
VclPtr<PushButton> m_pDefaultPB; VclPtr<PushButton> m_pDefaultPB;
// config item // config item
SvtCompatibilityOptions m_aConfigItem; SvtCompatibilityOptions m_aConfigItem;
// config item
SvtCompatibilityViewOptions m_aViewConfigItem;
// text of the user entry // text of the user entry
OUString m_sUserEntry; OUString m_sUserEntry;
// shell of the current document // shell of the current document
...@@ -49,6 +55,7 @@ private: ...@@ -49,6 +55,7 @@ private:
std::unique_ptr<SwCompatibilityOptPage_Impl> m_pImpl; std::unique_ptr<SwCompatibilityOptPage_Impl> m_pImpl;
// saved options after "Reset"; used in "FillItemSet" for comparison // saved options after "Reset"; used in "FillItemSet" for comparison
sal_uLong m_nSavedOptions; sal_uLong m_nSavedOptions;
bool m_bSavedMSFormsMenuOption;
// handler // handler
DECL_LINK(SelectHdl, ListBox&, void); DECL_LINK(SelectHdl, ListBox&, void);
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
<interface domain="sw"> <interface domain="sw">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/> <requires lib="LibreOffice" version="1.0"/>
<object class="GtkGrid" id="OptCompatPage"> <object class="GtkBox" id="OptCompatPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child> <child>
<object class="GtkFrame" id="compatframe"> <object class="GtkFrame" id="compatframe">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -116,5 +118,82 @@ ...@@ -116,5 +118,82 @@
<property name="height">1</property> <property name="height">1</property>
</packing> </packing>
</child> </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> </object>
</interface> </interface>
...@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,utl,\ ...@@ -59,6 +59,7 @@ $(eval $(call gb_Library_add_exception_objects,utl,\
unotools/source/config/bootstrap \ unotools/source/config/bootstrap \
unotools/source/config/cmdoptions \ unotools/source/config/cmdoptions \
unotools/source/config/compatibility \ unotools/source/config/compatibility \
unotools/source/config/compatibilityviewoptions \
unotools/source/config/configitem \ unotools/source/config/configitem \
unotools/source/config/configmgr \ unotools/source/config/configmgr \
unotools/source/config/confignode \ unotools/source/config/confignode \
......
/* -*- 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: */
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <unotools/useroptions.hxx> #include <unotools/useroptions.hxx>
#include <unotools/cmdoptions.hxx> #include <unotools/cmdoptions.hxx>
#include <unotools/compatibility.hxx> #include <unotools/compatibility.hxx>
#include <unotools/compatibilityviewoptions.hxx>
#include <unotools/defaultoptions.hxx> #include <unotools/defaultoptions.hxx>
#include <unotools/dynamicmenuoptions.hxx> #include <unotools/dynamicmenuoptions.hxx>
#include <unotools/eventcfg.hxx> #include <unotools/eventcfg.hxx>
...@@ -130,6 +131,10 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem) ...@@ -130,6 +131,10 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem)
rItem.pItem.reset( new SvtCompatibilityOptions() ); rItem.pItem.reset( new SvtCompatibilityOptions() );
break; break;
case EItem::CompatibilityView :
rItem.pItem.reset( new SvtCompatibilityViewOptions() );
break;
case EItem::DefaultOptions : case EItem::DefaultOptions :
rItem.pItem.reset( new SvtDefaultOptions() ); rItem.pItem.reset( new SvtDefaultOptions() );
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment