diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-16 20:21:19 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-16 21:31:45 -0400 |
commit | defbcb229a08f0a147cfdc2c8476684694ad184f (patch) | |
tree | dad99b89d28d26ce2a3c7430c8fbec5993e2dd5a /xmloff | |
parent | 1b183738aecc32219920a698196c72afebcdd8c0 (diff) |
Using ptr_vector for this simplifes it a bit...
Change-Id: Id772a260475de7e9c8599616eff189851af6b356
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/style/impastp3.cxx | 31 | ||||
-rw-r--r-- | xmloff/source/style/impastp4.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/impastpl.hxx | 14 |
3 files changed, 19 insertions, 28 deletions
diff --git a/xmloff/source/style/impastp3.cxx b/xmloff/source/style/impastp3.cxx index c99fd9e4d7c9..e9baa3c707bb 100644 --- a/xmloff/source/style/impastp3.cxx +++ b/xmloff/source/style/impastp3.cxx @@ -22,14 +22,8 @@ using namespace std; -// Class SvXMLAutoStylePoolParent_Impl -// dtor class SvXMLAutoStylePoolParent_Impl - SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl() { - for( size_t i = maPropertiesList.size(); i > 0; ) - delete maPropertiesList[ --i ]; - maPropertiesList.clear(); } // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list @@ -39,13 +33,11 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, c { sal_Bool bAdded = sal_False; SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0; - size_t i = 0; sal_Int32 nProperties = rProperties.size(); - size_t nCount = maPropertiesList.size(); - - for( i = 0; i < nCount; i++ ) + size_t i = 0; + for (size_t n = maPropertiesList.size(); i < n; ++i) { - SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ]; + SvXMLAutoStylePoolPropertiesP_Impl* pIS = &maPropertiesList[i]; if( nProperties > (sal_Int32)pIS->GetProperties().size() ) { continue; @@ -64,7 +56,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, c if( !pProperties ) { pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties ); - SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); + PropertiesListType::iterator it = maPropertiesList.begin(); ::std::advance( it, i ); maPropertiesList.insert( it, pProperties ); bAdded = sal_True; @@ -84,13 +76,11 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, c sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName ) { sal_Bool bAdded = sal_False; - size_t i = 0; sal_Int32 nProperties = rProperties.size(); - size_t nCount = maPropertiesList.size(); - - for( i = 0; i < nCount; i++ ) + size_t i = 0; + for (size_t n = maPropertiesList.size(); i < n; ++i) { - SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ]; + SvXMLAutoStylePoolPropertiesP_Impl* pIS = &maPropertiesList[i]; if( nProperties > (sal_Int32)pIS->GetProperties().size() ) { continue; @@ -107,7 +97,7 @@ sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl& rFamilyDa new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties ); // ignore the generated name pProperties->SetName( rName ); - SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin(); + PropertiesListType::iterator it = maPropertiesList.begin(); ::std::advance( it, i ); maPropertiesList.insert( it, pProperties ); bAdded = sal_True; @@ -124,10 +114,9 @@ OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamily { OUString sName; vector< XMLPropertyState>::size_type nItems = rProperties.size(); - size_t nCount = maPropertiesList.size(); - for( size_t i = 0; i < nCount; i++ ) + for (size_t i = 0, n = maPropertiesList.size(); i < n; ++i) { - SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ]; + const SvXMLAutoStylePoolPropertiesP_Impl* pIS = &maPropertiesList[i]; if( nItems > pIS->GetProperties().size() ) { continue; diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx index 5f5dffa79f4c..3c4aeb159538 100644 --- a/xmloff/source/style/impastp4.cxx +++ b/xmloff/source/style/impastp4.cxx @@ -292,7 +292,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML( for( size_t j = 0; j < nProperties; j++ ) { const SvXMLAutoStylePoolPropertiesP_Impl* pProperties = - rParent.GetPropertiesList()[ j ]; + &rParent.GetPropertiesList()[j]; sal_uLong nPos = pProperties->GetPos(); DBG_ASSERT( nPos < nCount, "SvXMLAutoStylePool_Impl::exportXML: wrong position" ); diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx index b004115a4705..d3b6cf66438c 100644 --- a/xmloff/source/style/impastpl.hxx +++ b/xmloff/source/style/impastpl.hxx @@ -33,6 +33,7 @@ #include <boost/noncopyable.hpp> #include <boost/ptr_container/ptr_set.hpp> +#include <boost/ptr_container/ptr_vector.hpp> class SvXMLAutoStylePoolP; class SvXMLAutoStylePoolParentP_Impl; @@ -94,14 +95,15 @@ public: void SetName( const OUString& rNew ) { msName = rNew; } }; -typedef SvXMLAutoStylePoolPropertiesP_Impl* SvXMLAutoStylePoolPropertiesPPtr; -typedef ::std::vector< SvXMLAutoStylePoolPropertiesPPtr > SvXMLAutoStylePoolPropertiesPList_Impl; - // Parents of AutoStylePool's class SvXMLAutoStylePoolParentP_Impl { - OUString msParent; - SvXMLAutoStylePoolPropertiesPList_Impl maPropertiesList; +public: + typedef boost::ptr_vector<SvXMLAutoStylePoolPropertiesP_Impl> PropertiesListType; + +private: + OUString msParent; + PropertiesListType maPropertiesList; public: @@ -120,7 +122,7 @@ public: const OUString& GetParent() const { return msParent; } - const SvXMLAutoStylePoolPropertiesPList_Impl& GetPropertiesList() const + const PropertiesListType& GetPropertiesList() const { return maPropertiesList; } |