diff options
| author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-27 15:39:06 +0200 |
|---|---|---|
| committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-29 15:10:19 +0200 |
| commit | c39978f41dccbeb2e973c919a67d9b1d974f8f3c (patch) | |
| tree | 1a688fd28ac0f97d3afd742de382bf79937790b4 | |
| parent | 8f008bf4b968f219d2fe97ef8175ef6be0555943 (diff) | |
tdf#161846 use unordered_map in SfxItemPropertyMap
with large property maps, even a binary search starts
showing up, but we can do a O(1) search here by using a map
Change-Id: Ie7916076073e6dd393f0a1fb5a0db1b973999408
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171173
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
25 files changed, 69 insertions, 74 deletions
diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index 8782217fd394..8737b2ea77d1 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -209,7 +209,7 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertyMapEntry* pMap, } -const SfxItemPropertyMapEntry* SvxItemPropertySet::getPropertyMapEntry(std::u16string_view rName) const +const SfxItemPropertyMapEntry* SvxItemPropertySet::getPropertyMapEntry(const OUString& rName) const { return m_aPropertyMap.getByName( rName ); } diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 7c4c3fbfbc26..5e935f0569d0 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -1058,7 +1058,7 @@ beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropert throw beans::UnknownPropertyException(); } -beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(std::u16string_view PropertyName, sal_Int32 nPara /* = -1 */) +beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(const OUString& PropertyName, sal_Int32 nPara /* = -1 */) { SolarMutexGuard aGuard; @@ -1364,9 +1364,9 @@ void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault() if( pForwarder ) { - for (const SfxItemPropertyMapEntry* entry : mpPropSet->getPropertyMap().getPropertyEntries()) + for (auto const & rPair : mpPropSet->getPropertyMap().getPropertyEntries()) { - _setPropertyToDefault( pForwarder, entry, -1 ); + _setPropertyToDefault( pForwarder, rPair.second, -1 ); } } } diff --git a/include/editeng/unoipset.hxx b/include/editeng/unoipset.hxx index 87a6f29c10a4..7ffff801a27e 100644 --- a/include/editeng/unoipset.hxx +++ b/include/editeng/unoipset.hxx @@ -52,7 +52,7 @@ public: css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const; const SfxItemPropertyMap& getPropertyMap() const { return m_aPropertyMap;} - const SfxItemPropertyMapEntry* getPropertyMapEntry(std::u16string_view rName) const; + const SfxItemPropertyMapEntry* getPropertyMapEntry(const OUString& rName) const; }; struct SvxIDPropertyCombine diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index 38efd32e0aaf..9cb53b5b3063 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -286,7 +286,7 @@ protected: SAL_DLLPRIVATE css::beans::PropertyState _getPropertyState( const SfxItemPropertyMapEntry* pMap, sal_Int32 nPara = -1 ); /// @throws css::beans::UnknownPropertyException /// @throws css::uno::RuntimeException - SAL_DLLPRIVATE css::beans::PropertyState _getPropertyState( std::u16string_view PropertyName, sal_Int32 nPara = -1 ); + SAL_DLLPRIVATE css::beans::PropertyState _getPropertyState( const OUString& PropertyName, sal_Int32 nPara = -1 ); /// @throws css::beans::UnknownPropertyException /// @throws css::uno::RuntimeException SAL_DLLPRIVATE css::uno::Sequence< css::beans::PropertyState > _getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName, sal_Int32 nPara = -1 ); diff --git a/include/svl/itemprop.hxx b/include/svl/itemprop.hxx index f3db2f2eb6d9..ddd636272ea4 100644 --- a/include/svl/itemprop.hxx +++ b/include/svl/itemprop.hxx @@ -69,29 +69,23 @@ struct SfxItemPropertyMapEntry } }; -struct SfxItemPropertyMapCompare -{ - bool operator() ( const SfxItemPropertyMapEntry * lhs, const SfxItemPropertyMapEntry * rhs ) const - { - return lhs->aName < rhs->aName; - } -}; class SVL_DLLPUBLIC SfxItemPropertyMap { - o3tl::sorted_vector< const SfxItemPropertyMapEntry*, SfxItemPropertyMapCompare > m_aMap; - mutable css::uno::Sequence< css::beans::Property > m_aPropSeq; public: SfxItemPropertyMap( std::span<const SfxItemPropertyMapEntry> pEntries ); SfxItemPropertyMap( const SfxItemPropertyMap& rSource ); ~SfxItemPropertyMap(); - const SfxItemPropertyMapEntry* getByName( std::u16string_view rName ) const; + const SfxItemPropertyMapEntry* getByName( const OUString & rName ) const; css::uno::Sequence< css::beans::Property > const & getProperties() const; /// @throws css::beans::UnknownPropertyException css::beans::Property getPropertyByName( const OUString & rName ) const; - bool hasPropertyByName( std::u16string_view rName ) const; + bool hasPropertyByName( const OUString & rName ) const; - const o3tl::sorted_vector< const SfxItemPropertyMapEntry*, SfxItemPropertyMapCompare >& getPropertyEntries() const { return m_aMap; } + const std::unordered_map< OUString, const SfxItemPropertyMapEntry* >& getPropertyEntries() const { return m_aMap; } +private: + std::unordered_map< OUString, const SfxItemPropertyMapEntry* > m_aMap; + mutable css::uno::Sequence< css::beans::Property > m_aPropSeq; }; class SVL_DLLPUBLIC SfxItemPropertySet final diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index 6f70aae74724..6cee920595ab 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -308,7 +308,7 @@ Sequence< PropertyValue > SAL_CALL std::vector<PropertyValue> aProps; aProps.reserve(aPropertyMap.getPropertyEntries().size()); - for(auto pEntry : aPropertyMap.getPropertyEntries()) + for(auto const & [aName, pEntry] : aPropertyMap.getPropertyEntries()) aProps.push_back(PropertyValue(pEntry->aName, pEntry->nWID, aConfig.GetProperty(pEntry->nWID), css::beans::PropertyState_DIRECT_VALUE)); diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index 549307b941e4..02ae0243f04e 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -280,8 +280,9 @@ namespace uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo(); SvxUnoPropertyMapProvider aMap; const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap(); - for (const auto pProp : rPropertyMap.getPropertyEntries()) + for (const auto & rPair : rPropertyMap.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pProp = rPair.second; if ( xInfo->hasPropertyByName(pProp->aName) ) { const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID); @@ -300,8 +301,9 @@ namespace const uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo(); SvxUnoPropertyMapProvider aMap; const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap(); - for (const auto pProp : rPropertyMap.getPropertyEntries()) + for (const auto & rPair : rPropertyMap.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pProp = rPair.second; if ( SfxItemState::SET == _rItemSet.GetItemState(pProp->nWID) && xInfo->hasPropertyByName(pProp->aName) ) { if ( ( pProp->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY ) diff --git a/sc/inc/optuno.hxx b/sc/inc/optuno.hxx index 27b0c3d6dc56..6e28c6dad6cb 100644 --- a/sc/inc/optuno.hxx +++ b/sc/inc/optuno.hxx @@ -40,12 +40,12 @@ class ScDocOptionsHelper public: static bool setPropertyValue( ScDocOptions& rOptions, const SfxItemPropertyMap& rPropMap, - std::u16string_view aPropertyName, + const OUString& rPropertyName, const css::uno::Any& aValue ); static css::uno::Any getPropertyValue( const ScDocOptions& rOptions, const SfxItemPropertyMap& rPropMap, - std::u16string_view PropertyName ); + const OUString& rPropertyName ); }; // empty doc object to supply only doc options diff --git a/sc/inc/styleuno.hxx b/sc/inc/styleuno.hxx index f524cf8bc615..550e712fe9fa 100644 --- a/sc/inc/styleuno.hxx +++ b/sc/inc/styleuno.hxx @@ -169,21 +169,21 @@ private: OUString aStyleName; SfxStyleSheetBase* pStyle_cached; - const SfxItemSet* GetStyleItemSet_Impl( std::u16string_view rPropName, const SfxItemPropertyMapEntry*& rpEntry ); + const SfxItemSet* GetStyleItemSet_Impl( const OUString& rPropName, const SfxItemPropertyMapEntry*& rpEntry ); /// @throws css::beans::UnknownPropertyException /// @throws css::uno::RuntimeException - css::beans::PropertyState getPropertyState_Impl( std::u16string_view PropertyName ); + css::beans::PropertyState getPropertyState_Impl( const OUString& PropertyName ); /// @throws css::beans::UnknownPropertyException /// @throws css::lang::WrappedTargetException /// @throws css::uno::RuntimeException - css::uno::Any getPropertyDefault_Impl( std::u16string_view aPropertyName ); + css::uno::Any getPropertyDefault_Impl( const OUString& aPropertyName ); /// @throws css::beans::UnknownPropertyException /// @throws css::lang::WrappedTargetException /// @throws css::uno::RuntimeException - css::uno::Any getPropertyValue_Impl( std::u16string_view aPropertyName ); + css::uno::Any getPropertyValue_Impl( const OUString& aPropertyName ); /// @throws css::lang::IllegalArgumentException /// @throws css::uno::RuntimeException - void setPropertyValue_Impl( std::u16string_view rPropertyName, + void setPropertyValue_Impl( const OUString& rPropertyName, const SfxItemPropertyMapEntry* pEntry, const css::uno::Any* pValue ); diff --git a/sc/source/ui/unoobj/optuno.cxx b/sc/source/ui/unoobj/optuno.cxx index ce885684a254..3d475f74ef8c 100644 --- a/sc/source/ui/unoobj/optuno.cxx +++ b/sc/source/ui/unoobj/optuno.cxx @@ -30,7 +30,7 @@ using namespace com::sun::star; bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions, const SfxItemPropertyMap& rPropMap, - std::u16string_view aPropertyName, const uno::Any& aValue ) + const OUString& aPropertyName, const uno::Any& aValue ) { //! use map (with new identifiers) @@ -103,7 +103,7 @@ bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions, uno::Any ScDocOptionsHelper::getPropertyValue( const ScDocOptions& rOptions, const SfxItemPropertyMap& rPropMap, - std::u16string_view aPropertyName ) + const OUString& aPropertyName ) { uno::Any aRet; const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName( aPropertyName ); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index 417fded19368..659a271a05e0 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -1161,7 +1161,7 @@ uno::Reference<container::XIndexReplace> ScStyleObj::CreateEmptyNumberingRules() // beans::XPropertyState -const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( std::u16string_view rPropName, +const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( const OUString& rPropName, const SfxItemPropertyMapEntry*& rpResultEntry ) { SfxStyleSheetBase* pStyle = GetStyle_Impl( true ); @@ -1195,7 +1195,7 @@ const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( std::u16string_view rPropNam return nullptr; } -beans::PropertyState ScStyleObj::getPropertyState_Impl( std::u16string_view aPropertyName ) +beans::PropertyState ScStyleObj::getPropertyState_Impl( const OUString& aPropertyName ) { beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE; @@ -1279,7 +1279,7 @@ void SAL_CALL ScStyleObj::setPropertyToDefault( const OUString& aPropertyName ) setPropertyValue_Impl( aPropertyName, pEntry, nullptr ); } -uno::Any ScStyleObj::getPropertyDefault_Impl( std::u16string_view aPropertyName ) +uno::Any ScStyleObj::getPropertyDefault_Impl( const OUString& aPropertyName ) { uno::Any aAny; @@ -1531,7 +1531,7 @@ void SAL_CALL ScStyleObj::setPropertyValue( const OUString& aPropertyName, const setPropertyValue_Impl( aPropertyName, pEntry, &aValue ); } -void ScStyleObj::setPropertyValue_Impl( std::u16string_view rPropertyName, const SfxItemPropertyMapEntry* pEntry, const uno::Any* pValue ) +void ScStyleObj::setPropertyValue_Impl( const OUString& rPropertyName, const SfxItemPropertyMapEntry* pEntry, const uno::Any* pValue ) { SfxStyleSheetBase* pStyle = GetStyle_Impl( true ); if ( !(pStyle && pEntry) ) @@ -1872,7 +1872,7 @@ void ScStyleObj::setPropertyValue_Impl( std::u16string_view rPropertyName, const static_cast<SfxStyleSheet*>(GetStyle_Impl())->Broadcast(SfxHint(SfxHintId::DataChanged)); } -uno::Any ScStyleObj::getPropertyValue_Impl( std::u16string_view aPropertyName ) +uno::Any ScStyleObj::getPropertyValue_Impl( const OUString& aPropertyName ) { uno::Any aAny; SfxStyleSheetBase* pStyle = GetStyle_Impl( true ); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 68698580dbac..f061d3744f20 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1482,8 +1482,9 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor const SfxPoolItem* pItem = nullptr; if ( rNewSet.GetItemState( nWhich, true, &pItem ) == SfxItemState::SET && pItem ) { - for ( const auto pEntry : rMap.getPropertyEntries()) + for ( const auto & rPair : rMap.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; if ( pEntry->nWID == nWhich ) { css::uno::Any aVal; diff --git a/sd/inc/stlsheet.hxx b/sd/inc/stlsheet.hxx index 93044bdfd2f2..fc3db5d68cd2 100644 --- a/sd/inc/stlsheet.hxx +++ b/sd/inc/stlsheet.hxx @@ -140,7 +140,7 @@ public: private: /// @throws css::uno::RuntimeException - static const SfxItemPropertyMapEntry* getPropertyMapEntry( std::u16string_view rPropertyName ); + static const SfxItemPropertyMapEntry* getPropertyMapEntry( const OUString& rPropertyName ); void setPropertyValue_Impl(const OUString& aPropertyName, const css::uno::Any& aValue); css::uno::Any getPropertyValue_Impl(const OUString& PropertyName); diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 885ea80c5dce..4c61c8d72b1c 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -1502,7 +1502,7 @@ Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) } /** this is used because our property map is not sorted yet */ -const SfxItemPropertyMapEntry* SdStyleSheet::getPropertyMapEntry( std::u16string_view rPropertyName ) +const SfxItemPropertyMapEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) { return GetStylePropertySet().getPropertyMapEntry(rPropertyName); } diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 931ed7b5656e..d5a3056b5499 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2831,8 +2831,9 @@ void SdMasterPage::setBackground( const Any& rValue ) Reference< beans::XPropertySetInfo > xSetInfo( xInputSet->getPropertySetInfo(), UNO_SET_THROW ); Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY ); - for( const auto pProp : ImplGetPageBackgroundPropertySet()->getPropertyMap().getPropertyEntries() ) + for( const auto & rPair : ImplGetPageBackgroundPropertySet()->getPropertyMap().getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pProp = rPair.second; const OUString& rPropName = pProp->aName; if( xSetInfo->hasPropertyByName( rPropName ) ) { diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index 95e01bbaa984..278ed2abd4ee 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -97,8 +97,9 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) if( maUsrAnys.AreThereOwnUsrAnys() ) { - for( const auto pProp : mpPropSet->getPropertyMap().getPropertyEntries() ) + for( const auto & rPair : mpPropSet->getPropertyMap().getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pProp = rPair.second; uno::Any* pAny = maUsrAnys.GetUsrAnyForID( *pProp ); if( pAny ) { @@ -399,7 +400,7 @@ uno::Any SAL_CALL SdUnoPageBackground::getPropertyDefault( const OUString& aProp } /** this is used because our property map is not sorted yet */ -const SfxItemPropertyMapEntry* SdUnoPageBackground::getPropertyMapEntry( std::u16string_view rPropertyName ) const noexcept +const SfxItemPropertyMapEntry* SdUnoPageBackground::getPropertyMapEntry( const OUString& rPropertyName ) const noexcept { return mpPropSet->getPropertyMap().getByName(rPropertyName); } diff --git a/sd/source/ui/unoidl/unopback.hxx b/sd/source/ui/unoidl/unopback.hxx index c2834d9298ee..59b4b73bba67 100644 --- a/sd/source/ui/unoidl/unopback.hxx +++ b/sd/source/ui/unoidl/unopback.hxx @@ -51,7 +51,7 @@ class SdUnoPageBackground final : public ::cppu::WeakImplHelper< std::unique_ptr<SfxItemSet> mpSet; SdrModel* mpDoc; - const SfxItemPropertyMapEntry* getPropertyMapEntry( std::u16string_view rPropertyName ) const noexcept; + const SfxItemPropertyMapEntry* getPropertyMapEntry( const OUString& rPropertyName ) const noexcept; public: SdUnoPageBackground( SdDrawDocument* pDoc = nullptr, const SfxItemSet* pSet = nullptr); virtual ~SdUnoPageBackground() noexcept override; diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx index dec177455d5b..923bd7c0b260 100644 --- a/svl/source/items/itemprop.cxx +++ b/svl/source/items/itemprop.cxx @@ -41,7 +41,7 @@ SfxItemPropertyMap::SfxItemPropertyMap( std::span<const SfxItemPropertyMapEntry> for (const auto & pEntry : pEntries) { assert(!pEntry.aName.isEmpty() && "empty name? might be something left an empty entry at the end of this array"); - m_aMap.insert( &pEntry ); + m_aMap.insert( { pEntry.aName, &pEntry } ); } } @@ -51,23 +51,12 @@ SfxItemPropertyMap::~SfxItemPropertyMap() { } -const SfxItemPropertyMapEntry* SfxItemPropertyMap::getByName( std::u16string_view rName ) const +const SfxItemPropertyMapEntry* SfxItemPropertyMap::getByName( const OUString & rName ) const { - struct Compare - { - bool operator() ( const SfxItemPropertyMapEntry* lhs, std::u16string_view rhs ) const - { - return lhs->aName < rhs; - } - bool operator() ( std::u16string_view lhs, const SfxItemPropertyMapEntry* rhs ) const - { - return lhs < rhs->aName; - } - }; - auto it = std::lower_bound(m_aMap.begin(), m_aMap.end(), rName, Compare()); - if (it == m_aMap.end() || Compare()(rName, *it)) + auto it = m_aMap.find(rName); + if (it == m_aMap.end()) return nullptr; - return *it; + return it->second; } uno::Sequence<beans::Property> const & SfxItemPropertyMap::getProperties() const @@ -77,8 +66,9 @@ uno::Sequence<beans::Property> const & SfxItemPropertyMap::getProperties() const m_aPropSeq.realloc( m_aMap.size() ); beans::Property* pPropArray = m_aPropSeq.getArray(); sal_uInt32 n = 0; - for( const SfxItemPropertyMapEntry* pEntry : m_aMap ) + for( const auto & rPair : m_aMap ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; pPropArray[n].Name = pEntry->aName; pPropArray[n].Handle = pEntry->nWID; pPropArray[n].Type = pEntry->aType; @@ -104,7 +94,7 @@ beans::Property SfxItemPropertyMap::getPropertyByName( const OUString& rName ) c return aProp; } -bool SfxItemPropertyMap::hasPropertyByName( std::u16string_view rName ) const +bool SfxItemPropertyMap::hasPropertyByName( const OUString & rName ) const { return getByName(rName) != nullptr; } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index b547db4b436a..22998fc08feb 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -523,8 +523,9 @@ static void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemProper const SfxItemPropertyMap& rSrc = rPropSet.getPropertyMap(); - for(const SfxItemPropertyMapEntry* pSrcProp : rSrc.getPropertyEntries()) + for(const auto & rPair : rSrc.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pSrcProp = rPair.second; const sal_uInt16 nWID = pSrcProp->nWID; if(SfxItemPool::IsWhich(nWID) && (nWID < OWN_ATTR_VALUE_START || nWID > OWN_ATTR_VALUE_END) @@ -532,8 +533,9 @@ static void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemProper rSet.Put(rSet.GetPool()->GetUserOrPoolDefaultItem(nWID)); } - for(const SfxItemPropertyMapEntry* pSrcProp : rSrc.getPropertyEntries()) + for(const auto & rPair : rSrc.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pSrcProp = rPair.second; if(pSrcProp->nWID) { uno::Any* pUsrAny = rAnys.GetUsrAnyForID(*pSrcProp); diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index d7f8dc3f22ef..036ec451aafd 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -183,7 +183,7 @@ namespace SwUnoCursorHelper css::uno::Any GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet & rPropSet, - std::u16string_view rPropertyName); + const OUString& rPropertyName); /// @throws css::beans::UnknownPropertyException /// @throws css::uno::RuntimeException css::uno::Sequence< css::beans::PropertyState > GetPropertyStates( @@ -204,14 +204,14 @@ namespace SwUnoCursorHelper void SetPropertyToDefault( SwPaM & rPaM, const SfxItemPropertySet & rPropSet, - std::u16string_view rPropertyName); + const OUString& rPropertyName); /// @throws css::beans::UnknownPropertyException /// @throws css::lang::WrappedTargetException /// @throws css::uno::RuntimeException css::uno::Any GetPropertyDefault( SwPaM const & rPaM, const SfxItemPropertySet & rPropSet, - std::u16string_view rPropertyName); + const OUString& rPropertyName); bool SetPageDesc( const css::uno::Any& rValue, diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index d1b9e4932f3a..3c828b8e7d99 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1499,8 +1499,9 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( { const SfxItemPropertyMap& rPropMap = aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_CURSOR )->getPropertyMap(); - for ( const auto pEntry : rPropMap.getPropertyEntries() ) + for ( const auto & rPair : rPropMap.getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; const SfxPoolItem* pItem = pSet->GetItem( pEntry->nWID ); if ( pItem ) { @@ -1688,8 +1689,9 @@ void SwAccessibleParagraph::_getRunAttributesImpl( const SfxItemPropertyMap& rPropMap = aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_CURSOR )->getPropertyMap(); - for ( const auto pEntry : rPropMap.getPropertyEntries() ) + for ( const auto & rPair : rPropMap.getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; const SfxPoolItem* pItem( nullptr ); // #i82637# - Found character attributes, whose value equals the value of // the corresponding default character attributes, are excluded. diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 88c2baafd61d..cf2e54d42e5d 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -303,8 +303,9 @@ static uno::Any GetParaListAutoFormat(SwTextNode const& rNode) SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap()); std::vector<beans::NamedValue> props; // have to iterate the map, not the item set? - for (auto const pEntry : rMap.getPropertyEntries()) + for (auto const & rPair : rMap.getPropertyEntries()) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; if (SfxItemPropertySet::getPropertyState(*pEntry, *pSet) == PropertyState_DIRECT_VALUE) { Any value; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 253765e889a5..530eb215cf22 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -307,7 +307,7 @@ static sal_Int32 lcl_PropName2TokenPos(std::u16string_view rPropertyName) return SAL_MAX_INT32; } -static sal_uInt16 GetFieldTypeMId( std::u16string_view rProperty, const SwFieldType& rTyp ) +static sal_uInt16 GetFieldTypeMId( const OUString& rProperty, const SwFieldType& rTyp ) { sal_uInt16 nId = lcl_GetPropMapIdForFieldType( rTyp.Which() ); const SfxItemPropertySet* pSet = aSwMapProvider.GetPropertySet( nId ); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index ad86db593144..84bc53608a26 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1861,7 +1861,7 @@ SwXTextCursor::setString(const OUString& aString) uno::Any SwUnoCursorHelper::GetPropertyValue( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - std::u16string_view rPropertyName) + const OUString& rPropertyName) { uno::Any aAny; SfxItemPropertyMapEntry const*const pEntry = @@ -2153,7 +2153,7 @@ lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc, void SwUnoCursorHelper::SetPropertyToDefault( SwPaM& rPaM, const SfxItemPropertySet& rPropSet, - std::u16string_view rPropertyName) + const OUString& rPropertyName) { SwDoc& rDoc = rPaM.GetDoc(); SfxItemPropertyMapEntry const*const pEntry = @@ -2191,7 +2191,7 @@ void SwUnoCursorHelper::SetPropertyToDefault( uno::Any SwUnoCursorHelper::GetPropertyDefault( SwPaM const & rPaM, const SfxItemPropertySet& rPropSet, - std::u16string_view rPropertyName) + const OUString& rPropertyName) { SfxItemPropertyMapEntry const*const pEntry = rPropSet.getPropertyMap().getByName(rPropertyName); diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a6efe66e988a..ebabef689cef 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -521,7 +521,7 @@ public: : mrMap(rMap) { } - bool AllowsKey(std::u16string_view rName) + bool AllowsKey(const OUString& rName) { return mrMap.hasPropertyByName(rName); } @@ -4186,8 +4186,9 @@ uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() // TODO: Optimize - and fix! the old iteration filled each WhichId // only once but there are more properties than WhichIds - for( const auto pEntry : rMap.getPropertyEntries() ) + for( const auto & rPair : rMap.getPropertyEntries() ) { + const SfxItemPropertyMapEntry* pEntry = rPair.second; if ( pEntry->nWID == nWID ) { beans::PropertyValue aPropertyValue; |
