diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2015-06-20 20:23:44 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2016-08-29 13:13:14 +0200 |
commit | efb68beb538b97148c3dbf54ce46c3a8bc49cd92 (patch) | |
tree | 3d0e0d46e58b6884bdd943b80b6783b13e5ba8a2 | |
parent | d460ec312a5510955828be1ff35f92faef89e755 (diff) |
Don't inheritate from boost::multi_index
Drops all using statements and the namespace aliases.
This is more in the spirit of tdf#75757.
Change-Id: Id7c81baea0e2d1af151b7b9bdce8d9fe5f7a2089
-rw-r--r-- | sw/inc/docary.hxx | 49 | ||||
-rw-r--r-- | sw/inc/pagedesc.hxx | 38 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 29 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/layout/pagedesc.cxx | 20 |
5 files changed, 79 insertions, 62 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index e4a0b263bfcf..93def1f8bc65 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -148,37 +148,37 @@ public: SwGrfFormatColls() : SwFormatsModifyBase( DestructorPolicy::KeepElements ) {} }; -namespace bmi = boost::multi_index; - // Like o3tl::find_partialorder_ptrequals // We don't allow duplicated object entries! -struct type_name_key:bmi::composite_key< +struct type_name_key:boost::multi_index::composite_key< SwFrameFormat*, - bmi::const_mem_fun<SwFormat,sal_uInt16,&SwFormat::Which>, - bmi::const_mem_fun<SwFormat,const OUString&,&SwFormat::GetName>, - bmi::identity<SwFrameFormat*> // the actual object pointer + boost::multi_index::const_mem_fun<SwFormat,sal_uInt16,&SwFormat::Which>, + boost::multi_index::const_mem_fun<SwFormat,const OUString&,&SwFormat::GetName>, + boost::multi_index::identity<SwFrameFormat*> // the actual object pointer >{}; typedef boost::multi_index_container< SwFrameFormat*, - bmi::indexed_by< - bmi::random_access<>, - bmi::ordered_unique< type_name_key > + boost::multi_index::indexed_by< + boost::multi_index::random_access<>, + boost::multi_index::ordered_unique< type_name_key > > > SwFrameFormatsBase; /// Specific frame formats (frames, DrawObjects). -class SW_DLLPUBLIC SwFrameFormats : public SwFrameFormatsBase, public SwFormatsBase +class SW_DLLPUBLIC SwFrameFormats : public SwFormatsBase { // function updating ByName index via modify friend void SwFrameFormat::SetName( const OUString&, bool ); - typedef nth_index<0>::type ByPos; - typedef nth_index<1>::type ByTypeAndName; + typedef SwFrameFormatsBase::nth_index<0>::type ByPos; + typedef SwFrameFormatsBase::nth_index<1>::type ByTypeAndName; typedef ByPos::iterator iterator; - using ByPos::modify; + SwFrameFormatsBase m_Array; + ByPos &m_PosIndex; + ByTypeAndName &m_TypeAndNameIndex; public: typedef ByPos::const_iterator const_iterator; @@ -186,12 +186,13 @@ public: typedef SwFrameFormatsBase::size_type size_type; typedef SwFrameFormatsBase::value_type value_type; + SwFrameFormats(); // frees all SwFrameFormat! virtual ~SwFrameFormats(); - using SwFrameFormatsBase::clear; - using SwFrameFormatsBase::empty; - using SwFrameFormatsBase::size; + void clear() { return m_Array.clear(); } + bool empty() const { return m_Array.empty(); } + size_t size() const { return m_Array.size(); } // Only fails, if you try to insert the same object twice std::pair<const_iterator,bool> push_back( const value_type& x ); @@ -215,20 +216,20 @@ public: std::pair<const_range_iterator,const_range_iterator> rangeFind( const value_type& x ) const; // So we can actually check for end() - const_range_iterator rangeEnd() const { return ByTypeAndName::end(); } + const_range_iterator rangeEnd() const { return m_TypeAndNameIndex.end(); } inline const_iterator rangeProject( const_range_iterator const& position ) - { return project<0>( position ); } + { return m_Array.project<0>( position ); } const value_type& operator[]( size_t index_ ) const - { return ByPos::operator[]( index_ ); } - const value_type& front() const { return ByPos::front(); } - const value_type& back() const { return ByPos::back(); } - const_iterator begin() const { return ByPos::begin(); } - const_iterator end() const { return ByPos::end(); } + { return m_PosIndex.operator[]( index_ ); } + const value_type& front() const { return m_PosIndex.front(); } + const value_type& back() const { return m_PosIndex.back(); } + const_iterator begin() const { return m_PosIndex.begin(); } + const_iterator end() const { return m_PosIndex.end(); } void dumpAsXml(struct _xmlTextWriter* pWriter, const char* pName) const; - virtual size_t GetFormatCount() const { return size(); } + virtual size_t GetFormatCount() const { return m_Array.size(); } virtual SwFormat* GetFormat(size_t idx) const { return operator[]( idx ); } bool Contains( const value_type& x ) const; diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index c2fdf05d0503..13eb80bb01c5 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -378,40 +378,44 @@ namespace sw { class PageFootnoteHint final : public SfxHint {}; } -namespace bmi = boost::multi_index; - typedef boost::multi_index_container< SwPageDesc*, - bmi::indexed_by< - bmi::random_access<>, - bmi::ordered_unique< bmi::identity<SwPageDesc*> > + boost::multi_index::indexed_by< + boost::multi_index::random_access<>, + boost::multi_index::ordered_unique< + boost::multi_index::identity<SwPageDesc*> > > > SwPageDescsBase; -class SwPageDescs : private SwPageDescsBase +class SwPageDescs { // function updating ByName index via modify friend bool SwPageDesc::SetName( const OUString& rNewName ); - typedef nth_index<0>::type ByPos; - typedef nth_index<1>::type ByName; + typedef SwPageDescsBase::nth_index<0>::type ByPos; + typedef SwPageDescsBase::nth_index<1>::type ByName; typedef ByPos::iterator iterator; - using ByPos::modify; iterator find_( const OUString &name ) const; + SwPageDescsBase m_Array; + ByPos &m_PosIndex; + ByName &m_NameIndex; + public: typedef ByPos::const_iterator const_iterator; typedef SwPageDescsBase::size_type size_type; typedef SwPageDescsBase::value_type value_type; + SwPageDescs(); + // frees all SwPageDesc! virtual ~SwPageDescs(); - using SwPageDescsBase::clear; - using SwPageDescsBase::empty; - using SwPageDescsBase::size; + void clear() { return m_Array.clear(); } + bool empty() const { return m_Array.empty(); } + size_t size() const { return m_Array.size(); } std::pair<const_iterator,bool> push_back( const value_type& x ); void erase( const value_type& x ); @@ -421,11 +425,11 @@ public: const_iterator find( const OUString &name ) const { return find_( name ); } const value_type& operator[]( size_t index_ ) const - { return ByPos::operator[]( index_ ); } - const value_type& front() const { return ByPos::front(); } - const value_type& back() const { return ByPos::back(); } - const_iterator begin() const { return ByPos::begin(); } - const_iterator end() const { return ByPos::end(); } + { return m_PosIndex.operator[]( index_ ); } + const value_type& front() const { return m_PosIndex.front(); } + const value_type& back() const { return m_PosIndex.back(); } + const_iterator begin() const { return m_PosIndex.begin(); } + const_iterator end() const { return m_PosIndex.end(); } bool contains( const value_type& x ) const { return x->m_pdList == this; } diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 983705acd629..bfa42d90b3c4 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -2031,6 +2031,12 @@ namespace docfunc } } +SwFrameFormats::SwFrameFormats() + : m_PosIndex( m_Array.get<0>() ) + , m_TypeAndNameIndex( m_Array.get<1>() ) +{ +} + SwFrameFormats::~SwFrameFormats() { DeleteAndDestroyAll( false ); @@ -2038,16 +2044,15 @@ SwFrameFormats::~SwFrameFormats() SwFrameFormats::iterator SwFrameFormats::find( const value_type& x ) const { - const ByTypeAndName &pd_named = SwFrameFormatsBase::get<1>(); - ByTypeAndName::iterator it = pd_named.find( boost::make_tuple(x->Which(), x->GetName(), x) ); - return project<0>( it ); + ByTypeAndName::iterator it = m_TypeAndNameIndex.find( + boost::make_tuple(x->Which(), x->GetName(), x) ); + return m_Array.project<0>( it ); } std::pair<SwFrameFormats::const_range_iterator,SwFrameFormats::const_range_iterator> SwFrameFormats::rangeFind( sal_uInt16 type, const OUString& name ) const { - const ByTypeAndName &pd_named = SwFrameFormatsBase::get<1>(); - return pd_named.equal_range( boost::make_tuple(type, name) ); + return m_TypeAndNameIndex.equal_range( boost::make_tuple(type, name) ); } std::pair<SwFrameFormats::const_range_iterator,SwFrameFormats::const_range_iterator> @@ -2063,7 +2068,7 @@ void SwFrameFormats::DeleteAndDestroy(int aStartIdx, int aEndIdx) for (const_iterator it = begin() + aStartIdx; it != begin() + aEndIdx; ++it) delete *it; - ByPos::erase( begin() + aStartIdx, begin() + aEndIdx); + m_PosIndex.erase( begin() + aStartIdx, begin() + aEndIdx); } void SwFrameFormats::DeleteAndDestroyAll( bool keepDefault ) @@ -2074,7 +2079,7 @@ void SwFrameFormats::DeleteAndDestroyAll( bool keepDefault ) for( const_iterator it = begin() + _offset; it != end(); ++it ) delete *it; if ( _offset ) - SwFrameFormatsBase::erase( begin() + _offset, end() ); + m_PosIndex.erase( begin() + _offset, end() ); else clear(); } @@ -2090,7 +2095,7 @@ std::pair<SwFrameFormats::const_iterator,bool> SwFrameFormats::push_back( const SAL_WARN_IF(x->m_ffList != nullptr, "sw", "Inserting already assigned item"); assert(x->m_ffList == nullptr); x->m_ffList = this; - return ByPos::push_back( x ); + return m_PosIndex.push_back( x ); } bool SwFrameFormats::erase( const value_type& x ) @@ -2099,7 +2104,7 @@ bool SwFrameFormats::erase( const value_type& x ) SAL_WARN_IF(x->m_ffList != this, "sw", "Removing invalid / unassigned item"); if (ret != end()) { assert( x == *ret ); - ByPos::erase( ret ); + m_PosIndex.erase( ret ); x->m_ffList = nullptr; return true; } @@ -2114,7 +2119,7 @@ void SwFrameFormats::erase( size_type index_ ) void SwFrameFormats::erase( const_iterator const& position ) { (*position)->m_ffList = nullptr; - ByPos::erase( begin() + (position - begin()) ); + m_PosIndex.erase( begin() + (position - begin()) ); } bool SwFrameFormats::Contains( const SwFrameFormats::value_type& x ) const @@ -2124,7 +2129,7 @@ bool SwFrameFormats::Contains( const SwFrameFormats::value_type& x ) const bool SwFrameFormats::newDefault( const value_type& x ) { - std::pair<iterator,bool> res = ByPos::push_front( x ); + std::pair<iterator,bool> res = m_PosIndex.push_front( x ); if( ! res.second ) newDefault( res.first ); return res.second; @@ -2134,7 +2139,7 @@ void SwFrameFormats::newDefault( const_iterator const& position ) { if (position == begin()) return; - ByPos::relocate( begin(), position ); + m_PosIndex.relocate( begin(), position ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 577a4b111050..54dd491bd5f3 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2541,7 +2541,8 @@ void SwFrameFormat::SetName( const OUString& rNewName, bool bBroadcast ) #if OSL_DEBUG_LEVEL > 0 bool renamed = #endif - m_ffList->modify( it, change_name( rNewName ), change_name( m_aFormatName ) ); + m_ffList->m_PosIndex.modify( it, + change_name( rNewName ), change_name( m_aFormatName ) ); assert(renamed); if (bBroadcast) { SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName ); @@ -2852,7 +2853,7 @@ void SwFrameFormat::dumpAsXml(xmlTextWriterPtr pWriter) const void SwFrameFormats::dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) const { xmlTextWriterStartElement(pWriter, BAD_CAST(pName)); - for (const SwFrameFormat *pFormat : SwFrameFormatsBase::get<0>()) + for (const SwFrameFormat *pFormat : m_PosIndex) pFormat->dumpAsXml(pWriter); xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 42f1a505b22d..c5dce205be03 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -111,7 +111,8 @@ bool SwPageDesc::SetName( const OUString& rNewName ) SAL_WARN( "sw", "SwPageDesc not found in expected m_pdList" ); return false; } - renamed = m_pdList->modify( it, change_name( rNewName ), change_name( m_StyleName ) ); + renamed = m_pdList->m_PosIndex.modify( it, + change_name( rNewName ), change_name( m_StyleName ) ); } else m_StyleName = rNewName; @@ -480,6 +481,12 @@ SwPageDescExt::operator SwPageDesc() const return aResult; } +SwPageDescs::SwPageDescs() + : m_PosIndex( m_Array.get<0>() ) + , m_NameIndex( m_Array.get<1>() ) +{ +} + SwPageDescs::~SwPageDescs() { for(const_iterator it = begin(); it != end(); ++it) @@ -488,9 +495,8 @@ SwPageDescs::~SwPageDescs() SwPageDescs::iterator SwPageDescs::find_(const OUString &name) const { - const ByName &pd_named = get<1>(); - ByName::iterator it = pd_named.find( name ); - return iterator_to( *it ); + ByName::iterator it = m_NameIndex.find( name ); + return m_Array.iterator_to( *it ); } std::pair<SwPageDescs::const_iterator,bool> SwPageDescs::push_back( const value_type& x ) @@ -498,7 +504,7 @@ std::pair<SwPageDescs::const_iterator,bool> SwPageDescs::push_back( const value_ // SwPageDesc is not already in a SwPageDescs list! assert( x->m_pdList == nullptr ); - std::pair<iterator,bool> res = ByPos::push_back( x ); + std::pair<iterator,bool> res = m_PosIndex.push_back( x ); if( res.second ) x->m_pdList = this; return res; @@ -511,7 +517,7 @@ void SwPageDescs::erase( const value_type& x ) iterator const ret = find_( x->GetName() ); if (ret != end()) - ByPos::erase( ret ); + m_PosIndex.erase( ret ); else SAL_WARN( "sw", "SwPageDesc is not in SwPageDescs m_pdList!" ); x->m_pdList = nullptr; @@ -523,7 +529,7 @@ void SwPageDescs::erase( const_iterator const& position ) assert( (*position)->m_pdList == this ); (*position)->m_pdList = nullptr; - ByPos::erase( position ); + m_PosIndex.erase( position ); } void SwPageDescs::erase( size_type index_ ) |