Kaydet (Commit) 37d735b2 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

replace homegrown map with std::map<>

Change-Id: I5f35e0aeb6cef5920891eaa338c1d9b29e0ce554
üst dd58c789
...@@ -755,114 +755,52 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries() ...@@ -755,114 +755,52 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
class SwStyleProperties_Impl class SwStyleProperties_Impl
{ {
const PropertyEntryVector_t aPropertyEntries; const PropertyEntryVector_t aPropertyEntries;
uno::Any** pAnyArr; std::map<OUString, uno::Any> m_vPropertyValues;
sal_uInt32 nArrLen;
public: public:
explicit SwStyleProperties_Impl(const SfxItemPropertyMap& rMap); explicit SwStyleProperties_Impl(const SfxItemPropertyMap& rMap)
~SwStyleProperties_Impl(); : aPropertyEntries(rMap.getPropertyEntries())
{ }
bool SetProperty(const OUString& rName, const uno::Any& rVal); ~SwStyleProperties_Impl()
bool GetProperty(const OUString& rName, uno::Any*& rpAny); { }
bool ClearProperty( const OUString& rPropertyName );
void ClearAllProperties( );
static void GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
};
SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap& rMap) :
aPropertyEntries( rMap.getPropertyEntries() ),
nArrLen(0)
{
nArrLen = aPropertyEntries.size();
pAnyArr = new uno::Any* [nArrLen];
for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
pAnyArr[i] = nullptr;
}
SwStyleProperties_Impl::~SwStyleProperties_Impl()
{
for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
delete pAnyArr[i];
delete[] pAnyArr;
}
bool SwStyleProperties_Impl::SetProperty(const OUString& rName, const uno::Any& rVal) bool AllowsKey(const OUString& rName)
{
sal_uInt32 nPos = 0;
bool bRet = false;
PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
while( aIt != aPropertyEntries.end() )
{ {
if(rName == aIt->sName) return aPropertyEntries.end() != std::find_if(aPropertyEntries.begin(), aPropertyEntries.end(),
{ [rName] (const SfxItemPropertyNamedEntry& rEntry) {return rName == rEntry.sName;} );
delete pAnyArr[nPos];
pAnyArr[nPos] = new uno::Any(rVal);
bRet = true;
break;
}
++nPos;
++aIt;
} }
return bRet; bool SetProperty(const OUString& rName, const uno::Any& rValue)
}
bool SwStyleProperties_Impl::ClearProperty( const OUString& rName )
{
bool bRet = false;
sal_uInt32 nPos = 0;
PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
while( aIt != aPropertyEntries.end() )
{ {
if( rName == aIt->sName ) if(!AllowsKey(rName))
return false;
m_vPropertyValues[rName] = rValue;
return true;
}
bool GetProperty(const OUString& rName, const uno::Any*& pAny)
{
if(!AllowsKey(rName))
{ {
delete pAnyArr[nPos]; pAny = nullptr;
pAnyArr[ nPos ] = nullptr; return false;
bRet = true;
break;
} }
++nPos; pAny = &m_vPropertyValues[rName];
++aIt; return true;
} }
return bRet; bool ClearProperty( const OUString& rName )
}
void SwStyleProperties_Impl::ClearAllProperties( )
{
for ( sal_uInt32 i = 0; i < nArrLen; i++ )
{ {
delete pAnyArr[i]; if(!AllowsKey(rName))
pAnyArr[ i ] = nullptr; return false;
m_vPropertyValues[rName] = uno::Any();
return true;
} }
} void ClearAllProperties( )
{ m_vPropertyValues.clear(); }
bool SwStyleProperties_Impl::GetProperty(const OUString& rName, uno::Any*& rpAny ) static void GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny )
{
bool bRet = false;
sal_uInt32 nPos = 0;
PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
while( aIt != aPropertyEntries.end() )
{ {
if( rName == aIt->sName ) rAny = rxPropertySet->getPropertyValue( rPropertyName );
{
rpAny = pAnyArr[nPos];
bRet = true;
break;
}
++nPos;
++aIt;
} }
const PropertyEntryVector_t& GetPropertyVector() const
return bRet; { return aPropertyEntries; }
} };
void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny )
{
rAny = rxPropertySet->getPropertyValue( rPropertyName );
}
static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily) static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
{ {
...@@ -1287,9 +1225,9 @@ void SwXStyle::ApplyDescriptorProperties() ...@@ -1287,9 +1225,9 @@ void SwXStyle::ApplyDescriptorProperties()
PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin(); PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
while(aIt != rPropertyVector.end()) while(aIt != rPropertyVector.end())
{ {
uno::Any* pAny(nullptr); const uno::Any* pAny(nullptr);
m_pPropertiesImpl->GetProperty(aIt->sName, pAny); m_pPropertiesImpl->GetProperty(aIt->sName, pAny);
if (pAny) if(pAny->hasValue())
setPropertyValue(aIt->sName, *pAny); setPropertyValue(aIt->sName, *pAny);
++aIt; ++aIt;
} }
...@@ -2423,9 +2361,9 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl( ...@@ -2423,9 +2361,9 @@ uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl(
} }
else if(m_bIsDescriptor) else if(m_bIsDescriptor)
{ {
uno::Any *pAny = nullptr; const uno::Any* pAny = nullptr;
m_pPropertiesImpl->GetProperty ( pNames[nProp], pAny ); m_pPropertiesImpl->GetProperty(pNames[nProp], pAny);
if( !pAny ) if(!pAny->hasValue())
{ {
bool bExcept = false; bool bExcept = false;
switch( m_eFamily ) switch( m_eFamily )
...@@ -3667,10 +3605,9 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl( ...@@ -3667,10 +3605,9 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
} }
else if(IsDescriptor()) else if(IsDescriptor())
{ {
uno::Any* pAny = nullptr; const uno::Any* pAny = nullptr;
GetPropImpl()->GetProperty(rPropName, pAny); GetPropImpl()->GetProperty(rPropName, pAny);
if (!pAny->hasValue())
if ( !pAny )
{ {
SwStyleProperties_Impl::GetProperty(rPropName, mxStyleData, pRet[nProp]); SwStyleProperties_Impl::GetProperty(rPropName, mxStyleData, pRet[nProp]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment