From 715a6ea8cb3aa6c80edbb22909aac3f18b7daec6 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 2 Oct 2023 11:31:09 +0200 Subject: tdf#156756 Icon sizes for the toolbar wrong MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So my change in commit 0558926c2f9201a12b4c46efc36b8a4080af4d46 Author: Noel Grandin Date: Tue Jun 6 10:42:10 2023 +0200 use more officecfg for SvtMiscOptions Made an existing bug much worse. The underlying bug started in commit fd92b09db497a7dfd594a5418f87856dc3886bf9 Author: Caolán McNamara Date: Tue Feb 14 13:12:38 2023 +0000 tdf#153541 notify listeners when any of the icon sizes change which resulted in changes to icon sizes not being saved to the registry, because the registry layer would throw an exception when called from SvtMiscOptions_Impl::ImplCommit, because it does not like being passed null values for SidebarIconSize and NotebookbarIconSize properties. So I have done two things (1) finish removing handling of SymbolSet from the SvtMiscOptions_Impl code, and just use the officecfg:: layer. (2) Change the ImplCommit code to only pass down properties for which it actually has valid values. Change-Id: Ib7c09cac373060f5437b81c63e9b12411fdc1c68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157483 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svtools/source/config/miscopt.cxx | 86 ++++++++++----------------------------- 1 file changed, 22 insertions(+), 64 deletions(-) (limited to 'svtools') diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx index f09d07feabed..725654602d1d 100644 --- a/svtools/source/config/miscopt.cxx +++ b/svtools/source/config/miscopt.cxx @@ -45,7 +45,6 @@ constexpr OUStringLiteral ROOTNODE_MISC = u"Office.Common/Misc"; // PROPERTYHANDLE defines must be sequential from zero for Commit/Load constexpr OUStringLiteral PROPERTYNAME_SYMBOLSET = u"SymbolSet"; -#define PROPERTYHANDLE_SYMBOLSET 0 constexpr OUStringLiteral PROPERTYNAME_ICONTHEME = u"SymbolStyle"; #define PROPERTYHANDLE_SYMBOLSTYLE 1 constexpr OUStringLiteral PROPERTYNAME_SIDEBARICONSIZE = u"SidebarIconSize"; @@ -62,8 +61,6 @@ class SvtMiscOptions_Impl : public ConfigItem { private: ::std::vector> aList; - sal_Int16 m_nSymbolsSize; - bool m_bIsSymbolsSizeRO; bool m_bIsSymbolsStyleRO; bool m_bIconThemeWasSetAutomatically; @@ -95,8 +92,6 @@ public: // public interface - void SetSymbolsSize( sal_Int16 nSet ); - static OUString GetIconTheme(); enum class SetModifiedFlag { SET, DONT_SET }; @@ -146,8 +141,6 @@ SvtMiscOptions_Impl::SvtMiscOptions_Impl() // Init baseclasses first : ConfigItem( ROOTNODE_MISC ) - , m_nSymbolsSize( 0 ) - , m_bIsSymbolsSizeRO( false ) , m_bIsSymbolsStyleRO( false ) , m_bIconThemeWasSetAutomatically( false ) { @@ -170,16 +163,6 @@ SvtMiscOptions_Impl::SvtMiscOptions_Impl() continue; switch( nProperty ) { - case PROPERTYHANDLE_SYMBOLSET : - { - if( !(seqValues[nProperty] >>= m_nSymbolsSize) ) - { - OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" ); - } - m_bIsSymbolsSizeRO = seqRO[nProperty]; - break; - } - case PROPERTYHANDLE_SYMBOLSTYLE : { OUString aIconTheme; @@ -226,13 +209,6 @@ void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames ) continue; switch( comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProperty]) ) { - case PROPERTYHANDLE_SYMBOLSET : { - if( !(seqValues[nProperty] >>= m_nSymbolsSize) ) - { - OSL_FAIL("Wrong type of \"Misc\\SymbolSet\"!" ); - } - } - break; case PROPERTYHANDLE_SYMBOLSTYLE : { OUString aIconTheme; if (seqValues[nProperty] >>= aIconTheme) @@ -261,13 +237,6 @@ void SvtMiscOptions_Impl::CallListeners() elem.Call( nullptr ); } -void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet ) -{ - m_nSymbolsSize = nSet; - SetModified(); - CallListeners(); -} - OUString SvtMiscOptions_Impl::GetIconTheme() { return Application::GetSettings().GetStyleSettings().DetermineIconTheme(); @@ -313,41 +282,24 @@ void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames ) void SvtMiscOptions_Impl::ImplCommit() { - // Get names of supported properties, create a list for values and copy current values to it. - Sequence< OUString > seqNames = GetPropertyNames (); - sal_Int32 nCount = seqNames.getLength(); - Sequence< Any > seqValues ( nCount ); - auto seqValuesRange = asNonConstRange(seqValues); - for( sal_Int32 nProperty=0; nProperty seqNames { PROPERTYNAME_ICONTHEME }; + sal_Int32 nCount = seqNames.getLength(); + Sequence< Any > seqValues ( nCount ); + auto seqValuesRange = asNonConstRange(seqValues); + OUString value; + if (m_bIconThemeWasSetAutomatically) { + value = "auto"; } + else { + value = GetIconTheme(); + } + seqValuesRange[1] <<= value; + // Set properties in configuration. + PutProperties( seqNames, seqValues ); } - // Set properties in configuration. - PutProperties( seqNames, seqValues ); } @@ -404,7 +356,13 @@ sal_Int16 SvtMiscOptions::GetSymbolsSize() void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet ) { - m_pImpl->SetSymbolsSize( nSet ); + if (!officecfg::Office::Common::Misc::SymbolSet::isReadOnly()) + { + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::SymbolSet::set(nSet, batch); + batch->commit(); + m_pImpl->CallListeners(); + } } sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() -- cgit