From a6859a1fee2f0f3a35cfc381d5ae547eb13fd620 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 28 Jul 2020 21:33:29 +0100 Subject: replace and drop SvtCompatibilityViewOptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iab187468cf25b4a4afc7c79578677156ff224df9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99651 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- framework/source/layoutmanager/layoutmanager.cxx | 5 +- include/unotools/compatibilityviewoptions.hxx | 44 ------ include/unotools/itemholderbase.hxx | 1 - sw/source/ui/config/optcomp.cxx | 11 +- sw/source/uibase/inc/optcomp.hxx | 3 - unotools/Library_utl.mk | 1 - .../source/config/compatibilityviewoptions.cxx | 170 --------------------- unotools/source/config/itemholder1.cxx | 5 - 8 files changed, 9 insertions(+), 231 deletions(-) delete mode 100644 include/unotools/compatibilityviewoptions.hxx delete mode 100644 unotools/source/config/compatibilityviewoptions.cxx diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 2bbcb79f86db..460afbff22e8 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -59,7 +59,7 @@ #include #include #include -#include +#include #include #include @@ -143,8 +143,7 @@ void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName) SolarMutexGuard aWriteLock; // Create a customized menu if compatibility mode is on - SvtCompatibilityViewOptions aCompOptions; - if( aCompOptions.HasMSOCompatibleFormsMenu() && m_aModuleIdentifier == "com.sun.star.text.TextDocument" ) + if (m_aModuleIdentifier == "com.sun.star.text.TextDocument" && officecfg::Office::Compatibility::View::MSCompatibleFormsMenu::get()) { implts_createMSCompatibleMenuBar(rMenuBarName); } diff --git a/include/unotools/compatibilityviewoptions.hxx b/include/unotools/compatibilityviewoptions.hxx deleted file mode 100644 index 6030c5834f4e..000000000000 --- a/include/unotools/compatibilityviewoptions.hxx +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- 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 -#include - -namespace osl -{ -class Mutex; -} - -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 final : 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 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 eeb5fa6ee9c0..857eb34808b1 100644 --- a/include/unotools/itemholderbase.hxx +++ b/include/unotools/itemholderbase.hxx @@ -37,7 +37,6 @@ enum class EItem CmdOptions , ColorConfig , // 2 Compatibility , - CompatibilityView , CTLOptions , // 2 DefaultOptions , diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx index 13a11016f681..293e798e09b4 100644 --- a/sw/source/ui/config/optcomp.cxx +++ b/sw/source/ui/config/optcomp.cxx @@ -85,7 +85,7 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(weld::Container* pPage, weld::Dia m_xGlobalOptionsCLB->set_sensitive(!bReadOnly); m_xGlobalOptionsCLB->append(); - const bool bChecked = m_aViewConfigItem.HasMSOCompatibleFormsMenu(); + const bool bChecked = officecfg::Office::Compatibility::View::MSCompatibleFormsMenu::get(); m_xGlobalOptionsCLB->set_toggle(0, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); m_xGlobalOptionsCLB->set_text(0, m_xGlobalOptionsLB->get_text(0), 0); @@ -432,7 +432,10 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet* ) bool bNewMSFormsMenuOption = m_xGlobalOptionsCLB->get_toggle(0); if (m_bSavedMSFormsMenuOption != bNewMSFormsMenuOption) { - m_aViewConfigItem.SetMSOCompatibleFormsMenu(bNewMSFormsMenuOption); + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Compatibility::View::MSCompatibleFormsMenu::set(bNewMSFormsMenuOption, batch); + batch->commit(); + m_bSavedMSFormsMenuOption = bNewMSFormsMenuOption; bModified = true; @@ -458,8 +461,8 @@ void SwCompatibilityOptPage::Reset( const SfxItemSet* ) SetCurrentOptions( nOptions ); m_nSavedOptions = nOptions; - m_xGlobalOptionsCLB->set_toggle(0, m_aViewConfigItem.HasMSOCompatibleFormsMenu() ? TRISTATE_TRUE : TRISTATE_FALSE); - m_bSavedMSFormsMenuOption = m_aViewConfigItem.HasMSOCompatibleFormsMenu(); + m_bSavedMSFormsMenuOption = officecfg::Office::Compatibility::View::MSCompatibleFormsMenu::get(); + m_xGlobalOptionsCLB->set_toggle(0, m_bSavedMSFormsMenuOption ? TRISTATE_TRUE : TRISTATE_FALSE); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/optcomp.hxx b/sw/source/uibase/inc/optcomp.hxx index e087d3852362..8af469e6a679 100644 --- a/sw/source/uibase/inc/optcomp.hxx +++ b/sw/source/uibase/inc/optcomp.hxx @@ -22,7 +22,6 @@ #include #include #include -#include #include class SwWrtShell; @@ -33,8 +32,6 @@ class SwCompatibilityOptPage : public SfxTabPage private: // config item SvtCompatibilityOptions m_aConfigItem; - // config item - SvtCompatibilityViewOptions m_aViewConfigItem; // text of the user entry OUString m_sUserEntry; // shell of the current document diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index 84be1bb84b70..a452df6192a1 100644 --- a/unotools/Library_utl.mk +++ b/unotools/Library_utl.mk @@ -59,7 +59,6 @@ $(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 deleted file mode 100644 index b7a64f43f4d1..000000000000 --- a/unotools/source/config/compatibilityviewoptions.cxx +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- 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 -#include -#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& 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 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 seqNames = impl_GetPropertyNames(); - css::uno::Sequence 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& seqPropertyNames) -{ - // Use given list of updated properties to get his values from configuration directly! - css::uno::Sequence 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 seqNames = impl_GetPropertyNames(); - css::uno::Sequence seqValues(seqNames.getLength()); - - seqValues[PROPERTYHANDLE_MSCOMPATIBLEFORMSMENU] <<= m_bShowMSCompatibleFormsMenu; - - // Set properties in configuration. - PutProperties(seqNames, seqValues); -} - -css::uno::Sequence const& SvtCompatibilityViewOptions_Impl::impl_GetPropertyNames() -{ - static const css::uno::Sequence seqPropertyNames{ OUString( - PROPERTYNAME_MSCOMPATIBLEFORMSMENU) }; - return seqPropertyNames; -} - -namespace -{ -std::weak_ptr 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(); - 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 81c0137cd8dc..e9b82997602c 100644 --- a/unotools/source/config/itemholder1.cxx +++ b/unotools/source/config/itemholder1.cxx @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -130,10 +129,6 @@ 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; -- cgit v1.2.3