From 78adf246d5e99d0f5d91d2e03c1379b154289d8d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 26 Jul 2021 10:54:36 +0200 Subject: return SvtCompatibilityEntry from SvtCompatibilityOptions::GetList instead of converting back and forth Change-Id: Iec913494ccad65ebff76bf7b6cf5b2440fbade42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119514 Tested-by: Noel Grandin Reviewed-by: Noel Grandin --- include/unotools/compatibility.hxx | 3 +- sw/source/ui/config/optcomp.cxx | 53 +++++++++++++------------------- unotools/source/config/compatibility.cxx | 26 +++------------- 3 files changed, 27 insertions(+), 55 deletions(-) diff --git a/include/unotools/compatibility.hxx b/include/unotools/compatibility.hxx index ba8de4e784b5..85c6c2484a31 100644 --- a/include/unotools/compatibility.hxx +++ b/include/unotools/compatibility.hxx @@ -25,6 +25,7 @@ #include #include #include +#include namespace com::sun::star::beans { struct PropertyValue; } namespace osl { class Mutex; } @@ -211,7 +212,7 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions final : public utl::detail::Opt @onerror We return an empty list. *//*-*****************************************************************************************************/ - css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetList() const; + std::vector< SvtCompatibilityEntry > GetList() const; private: std::shared_ptr m_pImpl; diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx index bea377047ae9..071b2fa1c76c 100644 --- a/sw/source/ui/config/optcomp.cxx +++ b/sw/source/ui/config/optcomp.cxx @@ -206,27 +206,16 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet ) m_xMain->set_label(rText.replaceAll("%DOCNAME", sDocTitle)); // loading file formats - const Sequence< Sequence< PropertyValue > > aList = m_aConfigItem.GetList(); + const std::vector< SvtCompatibilityEntry > aList = m_aConfigItem.GetList(); - SvtCompatibilityEntry aEntry; - - for ( const Sequence< PropertyValue >& rEntry : aList ) + for ( const SvtCompatibilityEntry& rEntry : aList ) { - for ( const PropertyValue& aValue : rEntry ) - { - aEntry.setValue( SvtCompatibilityEntry::getIndex(aValue.Name), aValue.Value ); - } - - const OUString sEntryName = aEntry.getValue( SvtCompatibilityEntry::Index::Name ); - + const OUString sEntryName = rEntry.getValue( SvtCompatibilityEntry::Index::Name ); const bool bIsUserEntry = ( sEntryName == SvtCompatibilityEntry::USER_ENTRY_NAME ); - const bool bIsDefaultEntry = ( sEntryName == SvtCompatibilityEntry::DEFAULT_ENTRY_NAME ); - - aEntry.setDefaultEntry( bIsDefaultEntry ); - m_pImpl->m_aList.push_back( aEntry ); + m_pImpl->m_aList.push_back( rEntry ); - if ( aEntry.isDefaultEntry() ) + if ( rEntry.isDefaultEntry() ) continue; OUString sNewEntry; @@ -245,22 +234,22 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet ) sNewEntry = sEntryName; sal_uInt32 nOptions = convertBools2Ulong_Impl( - aEntry.getValue( SvtCompatibilityEntry::Index::UsePrtMetrics ), - aEntry.getValue( SvtCompatibilityEntry::Index::AddSpacing ), - aEntry.getValue( SvtCompatibilityEntry::Index::AddSpacingAtPages ), - aEntry.getValue( SvtCompatibilityEntry::Index::UseOurTabStops ), - aEntry.getValue( SvtCompatibilityEntry::Index::NoExtLeading ), - aEntry.getValue( SvtCompatibilityEntry::Index::UseLineSpacing ), - aEntry.getValue( SvtCompatibilityEntry::Index::AddTableSpacing ), - aEntry.getValue(SvtCompatibilityEntry::Index::AddTableLineSpacing), - aEntry.getValue( SvtCompatibilityEntry::Index::UseObjectPositioning ), - aEntry.getValue( SvtCompatibilityEntry::Index::UseOurTextWrapping ), - aEntry.getValue( SvtCompatibilityEntry::Index::ConsiderWrappingStyle ), - aEntry.getValue( SvtCompatibilityEntry::Index::ExpandWordSpace ), - aEntry.getValue( SvtCompatibilityEntry::Index::ProtectForm ), - aEntry.getValue( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ), - aEntry.getValue( SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys ), - aEntry.getValue( SvtCompatibilityEntry::Index::EmptyDbFieldHidesPara ) ); + rEntry.getValue( SvtCompatibilityEntry::Index::UsePrtMetrics ), + rEntry.getValue( SvtCompatibilityEntry::Index::AddSpacing ), + rEntry.getValue( SvtCompatibilityEntry::Index::AddSpacingAtPages ), + rEntry.getValue( SvtCompatibilityEntry::Index::UseOurTabStops ), + rEntry.getValue( SvtCompatibilityEntry::Index::NoExtLeading ), + rEntry.getValue( SvtCompatibilityEntry::Index::UseLineSpacing ), + rEntry.getValue( SvtCompatibilityEntry::Index::AddTableSpacing ), + rEntry.getValue(SvtCompatibilityEntry::Index::AddTableLineSpacing), + rEntry.getValue( SvtCompatibilityEntry::Index::UseObjectPositioning ), + rEntry.getValue( SvtCompatibilityEntry::Index::UseOurTextWrapping ), + rEntry.getValue( SvtCompatibilityEntry::Index::ConsiderWrappingStyle ), + rEntry.getValue( SvtCompatibilityEntry::Index::ExpandWordSpace ), + rEntry.getValue( SvtCompatibilityEntry::Index::ProtectForm ), + rEntry.getValue( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ), + rEntry.getValue( SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys ), + rEntry.getValue( SvtCompatibilityEntry::Index::EmptyDbFieldHidesPara ) ); m_xFormattingLB->append(OUString::number(nOptions), sNewEntry); } } diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx index c3ac4b6c532a..9c11393d0408 100644 --- a/unotools/source/config/compatibility.cxx +++ b/unotools/source/config/compatibility.cxx @@ -125,7 +125,7 @@ class SvtCompatibilityOptions_Impl : public ConfigItem void SetDefault( SvtCompatibilityEntry::Index rIdx, bool rValue ); bool GetDefault( SvtCompatibilityEntry::Index rIdx ) const; - Sequence< Sequence< PropertyValue > > GetList() const; + const std::vector< SvtCompatibilityEntry > & GetOptions() const { return m_aOptions; } /*-**************************************************************************************************** @short called for notify of configmanager @@ -238,25 +238,6 @@ bool SvtCompatibilityOptions_Impl::GetDefault( SvtCompatibilityEntry::Index rIdx return m_aDefOptions.getValue( rIdx ); } -Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions_Impl::GetList() const -{ - Sequence< PropertyValue > lProperties( SvtCompatibilityEntry::getElementCount() ); - Sequence< Sequence< PropertyValue > > lResult( m_aOptions.size() ); - - for ( int i = static_cast(SvtCompatibilityEntry::Index::Name); i < static_cast(SvtCompatibilityEntry::Index::INVALID); ++i ) - lProperties[i].Name = SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) ); - - sal_Int32 j = 0; - for ( const auto& rItem : m_aOptions ) - { - for ( int i = static_cast(SvtCompatibilityEntry::Index::Name); i < static_cast(SvtCompatibilityEntry::Index::INVALID); ++i ) - lProperties[i].Value = rItem.getValue( SvtCompatibilityEntry::Index(i) ); - lResult[ j++ ] = lProperties; - } - - return lResult; -} - void SvtCompatibilityOptions_Impl::Notify( const Sequence< OUString >& ) { SAL_WARN( "unotools.config", "SvtCompatibilityOptions_Impl::Notify() Not implemented yet! I don't know how I can handle a dynamical list of unknown properties ..." ); @@ -359,10 +340,11 @@ bool SvtCompatibilityOptions::GetDefault( SvtCompatibilityEntry::Index rIdx ) co return m_pImpl->GetDefault( rIdx ); } -Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions::GetList() const +std::vector< SvtCompatibilityEntry > SvtCompatibilityOptions::GetList() const { MutexGuard aGuard( GetOwnStaticMutex() ); - return m_pImpl->GetList(); + + return m_pImpl->GetOptions(); } namespace -- cgit