diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-02 14:42:48 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-08-02 23:34:02 +0200 |
commit | d81c7f47c98d88dc30822dd9e0550461afe77dbf (patch) | |
tree | 1d5a9eef87c72776fe99c5c993792439a2856a7b | |
parent | efe1a44e473497be1be99c10dcefbc77f36041e3 (diff) |
STL'ify DECLARE_CONTAINER_SORT_DEL(SvXMLAutoStylePoolParentsP_Impl)
Change-Id: I54f1595198b65058d3dd7f3304e0acb75cd55291
-rw-r--r-- | xmloff/source/style/impastp1.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/style/impastp3.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/style/impastp4.cxx | 33 | ||||
-rw-r--r-- | xmloff/source/style/impastpl.hxx | 16 |
4 files changed, 33 insertions, 40 deletions
diff --git a/xmloff/source/style/impastp1.cxx b/xmloff/source/style/impastp1.cxx index b1a0bd6bef14..ca700020b237 100644 --- a/xmloff/source/style/impastp1.cxx +++ b/xmloff/source/style/impastp1.cxx @@ -51,7 +51,7 @@ XMLFamilyData_Impl::XMLFamilyData_Impl( mnCount( 0 ), mnName( 0 ), maStrPrefix( rStrPrefix ), bAsFamily( bAsFam ) { - mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 ); + mpParentList = new SvXMLAutoStylePoolParentsP_Impl; mpNameList = new SvXMLAutoStylePoolNamesP_Impl; } @@ -72,7 +72,7 @@ XMLFamilyData_Impl::~XMLFamilyData_Impl() void XMLFamilyData_Impl::ClearEntries() { delete mpParentList; - mpParentList = new SvXMLAutoStylePoolParentsP_Impl( 5, 5 ); + mpParentList = new SvXMLAutoStylePoolParentsP_Impl; DBG_ASSERT( !pCache || !pCache->size(), "auto style pool cache is not empty!" ); if( pCache ) { diff --git a/xmloff/source/style/impastp3.cxx b/xmloff/source/style/impastp3.cxx index eceed9ed2de9..d89dc48e4914 100644 --- a/xmloff/source/style/impastp3.cxx +++ b/xmloff/source/style/impastp3.cxx @@ -169,24 +169,4 @@ OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamily return sName; } -/////////////////////////////////////////////////////////////////////////////// -// -// Sort-function for sorted list of SvXMLAutoStylePoolParent_Impl-elements -// - -int SvXMLAutoStylePoolParentPCmp_Impl( const SvXMLAutoStylePoolParentP_Impl& r1, - const SvXMLAutoStylePoolParentP_Impl& r2) -{ - return (int)r1.GetParent().compareTo( r2.GetParent() ); -} - -/////////////////////////////////////////////////////////////////////////////// -// -// Implementation of sorted list of SvXMLAutoStylePoolParent_Impl-elements -// - -IMPL_CONTAINER_SORT( SvXMLAutoStylePoolParentsP_Impl, - SvXMLAutoStylePoolParentP_Impl, - SvXMLAutoStylePoolParentPCmp_Impl ) - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx index 02b380f4be87..3eecb55438bd 100644 --- a/xmloff/source/style/impastp4.cxx +++ b/xmloff/source/style/impastp4.cxx @@ -181,15 +181,16 @@ sal_Bool SvXMLAutoStylePoolP_Impl::Add(OUString& rName, sal_Int32 nFamily, SvXMLAutoStylePoolParentP_Impl *pParent = 0; SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList; - sal_uLong nPos; - if( pParents->Seek_Entry( &aTmp, &nPos ) ) + SvXMLAutoStylePoolParentsP_Impl::const_iterator const it2 = + pParents->find(&aTmp); + if (it2 != pParents->end()) { - pParent = pParents->GetObject( nPos ); + pParent = *it2; } else { pParent = new SvXMLAutoStylePoolParentP_Impl( rParent ); - pParents->Insert( pParent ); + pParents->insert( pParent ); } if( pParent->Add( rFamily, rProperties, rName, bDontSeek ) ) @@ -228,15 +229,16 @@ sal_Bool SvXMLAutoStylePoolP_Impl::AddNamed(const OUString& rName, sal_Int32 nFa SvXMLAutoStylePoolParentP_Impl *pParent = 0; SvXMLAutoStylePoolParentsP_Impl *pParents = rFamily.mpParentList; - sal_uLong nPos; - if( pParents->Seek_Entry( &aTmp, &nPos ) ) + SvXMLAutoStylePoolParentsP_Impl::const_iterator const it2 = + pParents->find(&aTmp); + if (it2 != pParents->end()) { - pParent = pParents->GetObject( nPos ); + pParent = *it2; } else { pParent = new SvXMLAutoStylePoolParentP_Impl( rParent ); - pParents->Insert( pParent ); + pParents->insert( pParent ); } if( pParent->AddNamed( rFamily, rProperties, rName ) ) @@ -271,9 +273,12 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily, rFamily.mpParentList; SvXMLAutoStylePoolParentP_Impl aTmp( rParent ); - sal_uLong nPos; - if( pParents->Seek_Entry( &aTmp, &nPos ) ) - sName = pParents->GetObject( nPos )->Find( rFamily, rProperties ); + SvXMLAutoStylePoolParentsP_Impl::const_iterator const it2 = + pParents->find(&aTmp); + if (it2 != pParents->end()) + { + sName = (*it2)->Find( rFamily, rProperties ); + } } return sName; @@ -322,11 +327,9 @@ void SvXMLAutoStylePoolP_Impl::exportXML( aExpStyles[i].mpProperties = 0; } - sal_uInt32 nParents = pParents->Count(); - for( i=0; i < nParents; i++ ) + for (size_t k = 0; k < pParents->size(); k++) { - const SvXMLAutoStylePoolParentP_Impl* pParent = - pParents->GetObject( i ); + const SvXMLAutoStylePoolParentP_Impl *const pParent = (*pParents)[k]; size_t nProperties = pParent->GetPropertiesList().size(); for( size_t j = 0; j < nProperties; j++ ) { diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx index 941471dde7c1..205674038860 100644 --- a/xmloff/source/style/impastpl.hxx +++ b/xmloff/source/style/impastpl.hxx @@ -31,13 +31,13 @@ #include <boost/ptr_container/ptr_set.hpp> #include <sal/types.h> -#include <svl/cntnrsrt.hxx> #include <rtl/ustring.hxx> #include <set> #include <vector> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <o3tl/sorted_vector.hxx> #include <xmloff/maptype.hxx> #include <xmloff/xmlexppr.hxx> @@ -154,8 +154,18 @@ public: } }; -DECLARE_CONTAINER_SORT_DEL( SvXMLAutoStylePoolParentsP_Impl, - SvXMLAutoStylePoolParentP_Impl ) +struct SvXMLAutoStylePoolParentPCmp_Impl +{ + bool operator()( SvXMLAutoStylePoolParentP_Impl* const& lhs, SvXMLAutoStylePoolParentP_Impl* const& rhs) const + { + return lhs->GetParent().compareTo( rhs->GetParent() ) < 0; + } +}; +class SvXMLAutoStylePoolParentsP_Impl : public o3tl::sorted_vector<SvXMLAutoStylePoolParentP_Impl*, SvXMLAutoStylePoolParentPCmp_Impl> +{ +public: + ~SvXMLAutoStylePoolParentsP_Impl() { DeleteAndDestroyAll(); } +}; /////////////////////////////////////////////////////////////////////////////// // |