[Libreoffice-commits] core.git: include/unotools sw/source unotools/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 26 18:50:51 UTC 2021


 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(-)

New commits:
commit 78adf246d5e99d0f5d91d2e03c1379b154289d8d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 26 10:54:36 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jul 26 20:50:16 2021 +0200

    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 <noel.grandin at collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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 <unotools/unotoolsdllapi.h>
 #include <rtl/ustring.hxx>
 #include <memory>
+#include <vector>
 
 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<SvtCompatibilityOptions_Impl> 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<OUString>( SvtCompatibilityEntry::Index::Name );
-
+        const OUString sEntryName = rEntry.getValue<OUString>( 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<bool>( SvtCompatibilityEntry::Index::UsePrtMetrics ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddSpacing ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddSpacingAtPages ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseOurTabStops ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::NoExtLeading ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseLineSpacing ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddTableSpacing ),
-            aEntry.getValue<bool>(SvtCompatibilityEntry::Index::AddTableLineSpacing),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseObjectPositioning ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseOurTextWrapping ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ProtectForm ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys ),
-            aEntry.getValue<bool>( SvtCompatibilityEntry::Index::EmptyDbFieldHidesPara ) );
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::UsePrtMetrics ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddSpacing ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddSpacingAtPages ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseOurTabStops ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::NoExtLeading ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseLineSpacing ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddTableSpacing ),
+            rEntry.getValue<bool>(SvtCompatibilityEntry::Index::AddTableLineSpacing),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseObjectPositioning ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseOurTextWrapping ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::ProtectForm ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ),
+            rEntry.getValue<bool>( SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys ),
+            rEntry.getValue<bool>( 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<bool>( 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<int>(SvtCompatibilityEntry::Index::Name); i < static_cast<int>(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<int>(SvtCompatibilityEntry::Index::Name); i < static_cast<int>(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


More information about the Libreoffice-commits mailing list