diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2014-06-08 01:59:29 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2014-09-30 09:56:39 +0200 |
commit | afb2ea42e413ce328fd6bd06d0d3f3d8816c5887 (patch) | |
tree | 0111bad4a3047eb33c4872eadd48ade92509fa7c | |
parent | 9f10d125f6dc622e7cd7f303e28ecf9efede0035 (diff) |
Change SwFrmFmts to o3tl::sorted_vector like API
This changes the SwFrmFmts class std::vector inheritance to private
and extends the class to a o3tl::sorted_vector compatible API.
This should just be a cleanup patch and is a preparation for the
change of SwFrmFmts from vector to o3tl::sorted_vector.
For simple list cases, this also adds a SwFrmFmtsV, a std::vector
version of SwFrmFmts.
(cherry picked from commit 1eee8d38ee5107ff6c3aaa2583854a88c1e8bb0e)
Conflicts:
sw/inc/format.hxx
sw/inc/frmfmt.hxx
sw/source/core/doc/CntntIdxStore.cxx
sw/source/core/doc/DocumentLinksAdministrationManager.cxx
sw/source/core/doc/docnew.cxx
sw/source/core/doc/textboxhelper.cxx
sw/source/core/layout/atrfrm.cxx
sw/source/filter/basflt/shellio.cxx
Change-Id: I2e91cb4d650b1c46c531885869d201edba84e5a6
-rw-r--r-- | sw/inc/docary.hxx | 59 | ||||
-rw-r--r-- | sw/inc/format.hxx | 2 | ||||
-rw-r--r-- | sw/inc/frmfmt.hxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/docdde.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/doc/docedt.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 117 | ||||
-rw-r--r-- | sw/source/core/doc/doclay.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 32 | ||||
-rw-r--r-- | sw/source/core/frmedt/fecopy.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/layout/frmtool.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/itratr.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/undo/rolbck.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/undo/unattr.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/undo/undraw.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/undo/untbl.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/basflt/shellio.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 2 |
19 files changed, 239 insertions, 91 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 94b077ac8f80..ebb85d402d5b 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -59,7 +59,7 @@ template<typename Value> class SwFmtsBaseModify : public std::vector<Value>, public SwFmtsBase { public: - typedef std::vector<Value>::const_iterator const_iterator; + typedef typename std::vector<Value>::const_iterator const_iterator; private: const bool mCleanup; @@ -99,12 +99,65 @@ public: virtual ~SwGrfFmtColls() {} }; +typedef std::vector<SwFrmFmt*> SwFrmFmtsBase; + /// Specific frame formats (frames, DrawObjects). -class SW_DLLPUBLIC SwFrmFmts : public SwFmtsBaseModify<SwFrmFmt*> +/// Mimics o3tl::sorted_vector interface +class SW_DLLPUBLIC SwFrmFmts : private SwFrmFmtsBase, public SwFmtsBase { public: - virtual ~SwFrmFmts() {} + typedef SwFrmFmtsBase::const_iterator const_iterator; + typedef SwFrmFmtsBase::size_type size_type; + typedef SwFrmFmtsBase::value_type value_type; + typedef std::pair<const_iterator,bool> find_insert_type; + + virtual ~SwFrmFmts(); + + void DeleteAndDestroyAll( bool offset = false ); + + using SwFrmFmtsBase::clear; + using SwFrmFmtsBase::empty; + using SwFrmFmtsBase::reserve; + using SwFrmFmtsBase::size; + + find_insert_type insert( const value_type& x ); + size_type erase( const value_type& x ); + void erase( size_type index ); + void erase( const_iterator const& position ); + + const value_type& front() const { return SwFrmFmtsBase::front(); } + const value_type& back() const { return SwFrmFmtsBase::back(); } + const value_type& operator[]( size_t index ) const + { return SwFrmFmtsBase::operator[]( index ); } + + const_iterator find( const value_type& x ) const; + + const_iterator begin() const { return SwFrmFmtsBase::begin(); } + const_iterator end() const { return SwFrmFmtsBase::end(); } + + bool Contains( const value_type& x ) const; + + virtual size_t GetFmtCount() const SAL_OVERRIDE + { return SwFrmFmtsBase::size(); } + virtual SwFmt* GetFmt(size_t idx) const SAL_OVERRIDE + { return (SwFmt*) SwFrmFmtsBase::operator[](idx); } + void dumpAsXml(xmlTextWriterPtr w, const char* pName); + + bool newDefault( const value_type& x ); + +private: + typedef SwFrmFmtsBase::iterator iterator; + iterator begin_nonconst() { return SwFrmFmtsBase::begin(); } + iterator end_nonconst() { return SwFrmFmtsBase::end(); } + void newDefault( const_iterator const& position ); +}; + +/// Unsorted, undeleting SwFrmFmt vector +class SwFrmFmtsV : public SwFmtsBaseModify<SwFrmFmt*> +{ +public: + virtual ~SwFrmFmtsV() {} }; class SwCharFmts : public SwFmtsBaseModify<SwCharFmt*> diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index bf565f4dde6e..3599b579de30 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -102,7 +102,7 @@ public: inline sal_Bool IsDefault() const { return DerivedFrom() == 0; } inline const String& GetName() const { return aFmtName; } - void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False ); + virtual void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False ); inline void SetName( const sal_Char* pNewName, sal_Bool bBroadcast=sal_False); diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index bf016ee46765..742abca3397f 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -33,29 +33,34 @@ class IMapObject; class SwRect; class SwContact; class SdrObject; +class SwFrmFmts; /// Style of a layout element. class SW_DLLPUBLIC SwFrmFmt: public SwFmt { friend class SwDoc; friend class SwPageDesc; ///< Is allowed to call protected CTor. + friend class SwFrmFmts; ///< Is allowed to update the list backref. ::com::sun::star::uno::WeakReference< ::com::sun::star::uno::XInterface> m_wXObject; + // The assigned list. + SwFrmFmts *list; + protected: SwFrmFmt( SwAttrPool& rPool, const sal_Char* pFmtNm, SwFrmFmt *pDrvdFrm, sal_uInt16 nFmtWhich = RES_FRMFMT, const sal_uInt16* pWhichRange = 0 ) : SwFmt( rPool, pFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange), - pDrvdFrm, nFmtWhich ) + pDrvdFrm, nFmtWhich ), list( 0 ) {} SwFrmFmt( SwAttrPool& rPool, const String &rFmtNm, SwFrmFmt *pDrvdFrm, sal_uInt16 nFmtWhich = RES_FRMFMT, const sal_uInt16* pWhichRange = 0 ) : SwFmt( rPool, rFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange), - pDrvdFrm, nFmtWhich ) + pDrvdFrm, nFmtWhich ), list( 0 ) {} virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ); @@ -131,6 +136,8 @@ public: DECL_FIXEDMEMPOOL_NEWDEL_DLL(SwFrmFmt) void RegisterToFormat( SwFmt& rFmt ); + + virtual void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False ); }; // The FlyFrame-Format diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/docdde.cxx index 502ed342eae5..0ea1024ff044 100644 --- a/sw/source/core/doc/docdde.cxx +++ b/sw/source/core/doc/docdde.cxx @@ -163,9 +163,9 @@ bool SwDoc::GetData( const OUString& rItem, const String& rMimeType, } _FindItem aPara( GetAppCharClass().lowercase( rItem )); - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + for (SwFrmFmts::const_iterator it = mpTblFrmFmtTbl->begin(); it != mpTblFrmFmtTbl->end(); it++) { - if (!(lcl_FindTable(pFmt, &aPara))) + if (!(lcl_FindTable(*it, &aPara))) break; } if( aPara.pTblNd ) @@ -209,9 +209,9 @@ bool SwDoc::SetData( const OUString& rItem, const String& rMimeType, String sItem(GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + for (SwFrmFmts::const_iterator it = mpTblFrmFmtTbl->begin(); it != mpTblFrmFmtTbl->end(); it++) { - if (!(lcl_FindTable(pFmt, &aPara))) + if (!(lcl_FindTable(*it, &aPara))) break; } if( aPara.pTblNd ) @@ -270,9 +270,9 @@ bool SwDoc::SetData( const OUString& rItem, const String& rMimeType, _FindItem aPara( GetAppCharClass().lowercase(rItem) ); // tables - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + for (SwFrmFmts::const_iterator it = mpTblFrmFmtTbl->begin(); it != mpTblFrmFmtTbl->end(); it++) { - if (!(lcl_FindTable(pFmt, &aPara))) + if (!(lcl_FindTable(*it, &aPara))) break; } if(aPara.pTblNd @@ -315,9 +315,9 @@ bool SwDoc::SelectServerObj( const String& rStr, SwPaM*& rpPam, if( sCmp.EqualsAscii( pMarkToTable ) ) { sName = rCC.lowercase( sName ); - BOOST_FOREACH( const SwFrmFmt* pFmt, *mpTblFrmFmtTbl ) + for (SwFrmFmts::const_iterator it = mpTblFrmFmtTbl->begin(); it != mpTblFrmFmtTbl->end(); it++) { - if (!(lcl_FindTable(pFmt, &aPara))) + if (!(lcl_FindTable(*it, &aPara))) break; } if( aPara.pTblNd ) diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index b0794e66d1ef..d3fdd5052a7a 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -181,7 +181,7 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx, aPos.nContent.Assign( 0, 0 ); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); aAnchor.SetAnchor( &aPos ); - pFmt->GetDoc()->GetSpzFrmFmts()->push_back( pFmt ); + pFmt->GetDoc()->GetSpzFrmFmts()->insert( pFmt ); pFmt->SetFmtAttr( aAnchor ); SwCntntNode* pCNd = aPos.nNode.GetNode().GetCntntNode(); if( pCNd && pCNd->getLayoutFrm( pFmt->GetDoc()->GetCurrentLayout(), 0, 0, sal_False ) ) @@ -315,7 +315,7 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, if( i > rTbl.size() ) i = rTbl.size(); else if( pFmt != rTbl[i] ) - i = rTbl.GetPos( pFmt ); + i = std::distance(rTbl.begin(), rTbl.find( pFmt )); } pDoc->DelLayoutFmt( pFmt ); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index a4e9b74c1f81..64b554237938 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1372,8 +1372,8 @@ void SwDoc::DelCharFmt(sal_uInt16 nFmt, bool bBroadcast) GetIDocumentUndoRedo().AppendUndo(pUndo); } - delete (*mpCharFmtTbl)[nFmt]; mpCharFmtTbl->erase(mpCharFmtTbl->begin() + nFmt); + delete pDel; SetModified(); } @@ -1395,10 +1395,8 @@ void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, bool bBroadcast ) } else { - // The format has to be in the one or the other, we'll see in which one. - SwFrmFmts::iterator it = std::find( mpFrmFmtTbl->begin(), mpFrmFmtTbl->end(), pFmt ); - if ( it != mpFrmFmtTbl->end() ) + if ( mpFrmFmtTbl->Contains( pFmt ) ) { if (bBroadcast) BroadcastStyleOperation(pFmt->GetName(), @@ -1412,17 +1410,17 @@ void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, bool bBroadcast ) GetIDocumentUndoRedo().AppendUndo(pUndo); } - delete *it; - mpFrmFmtTbl->erase(it); + mpFrmFmtTbl->erase( pFmt ); + delete pFmt; } else { - SwFrmFmts::iterator it2 = std::find( GetSpzFrmFmts()->begin(), GetSpzFrmFmts()->end(), pFmt ); - OSL_ENSURE( it2 != GetSpzFrmFmts()->end(), "FrmFmt not found." ); - if( it2 != GetSpzFrmFmts()->end() ) + bool contains = GetSpzFrmFmts()->Contains( pFmt ); + OSL_ENSURE( contains, "FrmFmt not found." ); + if( contains ) { - delete *it2; - GetSpzFrmFmts()->erase( it2 ); + GetSpzFrmFmts()->erase( pFmt ); + delete pFmt; } } } @@ -1430,10 +1428,10 @@ void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, bool bBroadcast ) void SwDoc::DelTblFrmFmt( SwTableFmt *pFmt ) { - SwFrmFmts::iterator it = std::find( mpTblFrmFmtTbl->begin(), mpTblFrmFmtTbl->end(), pFmt ); + SwFrmFmts::const_iterator it = mpTblFrmFmtTbl->find( pFmt ); OSL_ENSURE( it != mpTblFrmFmtTbl->end(), "Fmt not found," ); - delete *it; - mpTblFrmFmtTbl->erase(it); + mpTblFrmFmtTbl->erase( it ); + delete pFmt; } /// Create the formats @@ -1441,7 +1439,7 @@ SwFlyFrmFmt *SwDoc::MakeFlyFrmFmt( const String &rFmtName, SwFrmFmt *pDerivedFrom ) { SwFlyFrmFmt *pFmt = new SwFlyFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom ); - GetSpzFrmFmts()->push_back(pFmt); + GetSpzFrmFmts()->insert(pFmt); SetModified(); return pFmt; } @@ -1450,7 +1448,7 @@ SwDrawFrmFmt *SwDoc::MakeDrawFrmFmt( const String &rFmtName, SwFrmFmt *pDerivedFrom ) { SwDrawFrmFmt *pFmt = new SwDrawFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom); - GetSpzFrmFmts()->push_back(pFmt); + GetSpzFrmFmts()->insert(pFmt); SetModified(); return pFmt; } @@ -1494,7 +1492,7 @@ SwTableFmt* SwDoc::MakeTblFrmFmt( const String &rFmtName, SwFrmFmt *pDerivedFrom ) { SwTableFmt* pFmt = new SwTableFmt( GetAttrPool(), rFmtName, pDerivedFrom ); - mpTblFrmFmtTbl->push_back( pFmt ); + mpTblFrmFmtTbl->insert( pFmt ); SetModified(); return pFmt; @@ -1508,7 +1506,7 @@ SwFrmFmt *SwDoc::MakeFrmFmt(const String &rFmtName, SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom ); pFmt->SetAuto(bAuto); - mpFrmFmtTbl->push_back( pFmt ); + mpFrmFmtTbl->insert( pFmt ); SetModified(); if (bBroadcast) @@ -2655,4 +2653,87 @@ namespace docfunc } } +SwFrmFmts::~SwFrmFmts() +{ + DeleteAndDestroyAll(); +} + +void SwFrmFmts::DeleteAndDestroyAll( bool keepDefault ) +{ + if ( empty() ) + return; + const int _offset = keepDefault ? 1 : 0; + for( const_iterator it = begin() + _offset; it != end(); ++it ) + delete *it; + if ( _offset ) + SwFrmFmtsBase::erase( begin_nonconst() + _offset, end_nonconst() ); + else + clear(); +} + +SwFrmFmts::find_insert_type SwFrmFmts::insert( const value_type& x ) +{ + SwFrmFmtsBase::push_back( x ); + SAL_WARN_IF(x->list != 0, "sw", "Inserting already assigned item"); + x->list = this; + return std::make_pair(end() - 1 , true); +} + +SwFrmFmts::size_type SwFrmFmts::erase( const value_type& x ) +{ + const_iterator const ret = find( x ); + SAL_WARN_IF(x->list != this, "sw", "Removing invalid / unassigned item"); + if (ret != end()) { + SwFrmFmtsBase::erase( begin_nonconst() + (ret - begin()) ); + x->list = 0; + return 1; + } + return 0; +} + +void SwFrmFmts::erase( size_type index ) +{ + erase( begin_nonconst() + index ); +} + +void SwFrmFmts::erase( const_iterator const& position ) +{ + (*position)->list = 0; + SwFrmFmtsBase::erase( begin_nonconst() + (position - begin()) ); +} + +SwFrmFmts::const_iterator SwFrmFmts::find( const value_type& x ) const +{ + return std::find( begin(), end(), x ); +} + +bool SwFrmFmts::Contains( const SwFrmFmts::value_type& x ) const +{ + return (x->list == this); +} + +bool SwFrmFmts::newDefault( const value_type& x ) +{ + bool inserted = false; + const_iterator it = find( x ); + if (it == end()) { + push_back( x ); + it = end() - 1; + inserted = true; + } + newDefault( it ); + return inserted; +} + +void SwFrmFmts::newDefault( const_iterator const& position ) +{ + if (position == begin()) + return; + SwFrmFmt *tmp; + tmp = front(); + erase( position ); + SwFrmFmtsBase::operator[]( 0 ) = *position; + insert( tmp ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 74a9ac2b3a7b..805dff0aba32 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -2022,7 +2022,7 @@ void SwDoc::SetAllUniqueFlyNames() if( 255 < ( n = GetSpzFrmFmts()->size() )) n = 255; - SwFrmFmts aArr; + SwFrmFmtsV aArr; aArr.reserve( n ); SwFrmFmt* pFlyFmt; bool bContainsAtPageObjWithContentAnchor = false; diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index a055e200758b..283e35e0200a 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -353,7 +353,7 @@ SwDoc::SwDoc() * DefaultFormats and are also in the list. */ /* Formats */ - mpFrmFmtTbl->push_back(mpDfltFrmFmt); + mpFrmFmtTbl->insert(mpDfltFrmFmt); mpCharFmtTbl->push_back(mpDfltCharFmt); /* FmtColls */ @@ -422,16 +422,6 @@ SwDoc::SwDoc() ResetModified(); } -static void DeleteAndDestroy(SwFrmFmts& rFmts, int aStartIdx, int aEndIdx) -{ - if (aEndIdx < aStartIdx) - return; - for( SwFrmFmts::const_iterator it = rFmts.begin() + aStartIdx; - it != rFmts.begin() + aEndIdx; ++it ) - delete *it; - rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx); -} - static void DeleteAndDestroy(SwTxtFmtColls& rFmts, int aStartIdx, int aEndIdx) { if (aEndIdx < aStartIdx) @@ -577,10 +567,10 @@ SwDoc::~SwDoc() // Any of the FrmFormats can still have indices registered. // These need to be destroyed now at the latest. - BOOST_FOREACH( SwFrmFmt* pFmt, *mpFrmFmtTbl ) - lcl_DelFmtIndizes( pFmt ); - BOOST_FOREACH( SwFrmFmt* pFmt, *mpSpzFrmFmtTbl ) - lcl_DelFmtIndizes( pFmt ); + for (SwFrmFmts::const_iterator it = mpFrmFmtTbl->begin(); it != mpFrmFmtTbl->end(); it++) + lcl_DelFmtIndizes( *it ); + for (SwFrmFmts::const_iterator it = mpSpzFrmFmtTbl->begin(); it != mpSpzFrmFmtTbl->end(); it++) + lcl_DelFmtIndizes( *it ); BOOST_FOREACH( SwSectionFmt* pFmt, *mpSectionFmtTbl ) lcl_DelFmtIndizes( pFmt ); @@ -635,7 +625,7 @@ SwDoc::~SwDoc() // All Flys need to be destroyed before the Drawing Model, // because Flys can still contain DrawContacts, when no // Layout could be constructed due to a read error. - DeleteAndDestroy( *mpSpzFrmFmtTbl, 0, mpSpzFrmFmtTbl->size() ); + mpSpzFrmFmtTbl->DeleteAndDestroyAll(); // Only now destroy the Model, the drawing objects - which are also // contained in the Undo - need to remove their attributes from the @@ -877,12 +867,12 @@ void SwDoc::ClearDoc() if( mpCurrentView ) { // search the FrameFormat of the root frm. This is not allowed to delete - mpFrmFmtTbl->erase( std::find( mpFrmFmtTbl->begin(), mpFrmFmtTbl->end(), mpCurrentView->GetLayout()->GetFmt() ) ); - DeleteAndDestroy(*mpFrmFmtTbl, 1, mpFrmFmtTbl->size()); - mpFrmFmtTbl->push_back( mpCurrentView->GetLayout()->GetFmt() ); + mpFrmFmtTbl->erase( mpCurrentView->GetLayout()->GetFmt() ); + mpFrmFmtTbl->DeleteAndDestroyAll( true ); + mpFrmFmtTbl->insert( mpCurrentView->GetLayout()->GetFmt() ); } - else //swmod 071029//swmod 071225 - DeleteAndDestroy(*mpFrmFmtTbl, 1, mpFrmFmtTbl->size()); + else + mpFrmFmtTbl->DeleteAndDestroyAll( true ); mxForbiddenCharsTable.clear(); diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 19eddcd79e3d..db51e555df76 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -149,11 +149,8 @@ sal_Bool SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) SwFrmFmts& rSpzFrmFmts = *(SwFrmFmts*)pClpDoc->GetSpzFrmFmts(); if( rSpzFrmFmts[ 0 ] != pFlyFmt ) { - SwFrmFmts::iterator it = std::find( rSpzFrmFmts.begin(), rSpzFrmFmts.end(), pFlyFmt ); - OSL_ENSURE( it != rSpzFrmFmts.end(), "Fly not contained in Spz-Array" ); - - rSpzFrmFmts.erase( it ); - rSpzFrmFmts.insert( rSpzFrmFmts.begin(), pFlyFmt ); + bool inserted = rSpzFrmFmts.newDefault( pFlyFmt ); + OSL_ENSURE( !inserted, "Fly not contained in Spz-Array" ); } if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 06a290a10b4b..d02976c5111c 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2410,6 +2410,28 @@ SfxPoolItem* SwHeaderAndFooterEatSpacingItem::Clone( SfxItemPool* ) const TYPEINIT1( SwFrmFmt, SwFmt ); IMPL_FIXEDMEMPOOL_NEWDEL_DLL( SwFrmFmt ) +void SwFrmFmt::SetName( const String& rNewName, sal_Bool bBroadcast ) +{ + SwFrmFmts *_list = list; + SwFrmFmts::const_iterator it; + bool move_entry = false; + + if (list) { + it = list->find( this ); + SAL_WARN_IF( list->end() == it, "sw", "SwFrmFmt not found in expected list" ); +// move_entry = (it != list->begin()); + if (move_entry) + // Clears list + list->erase( it ); + } + + SwFmt::SetName( rNewName, bBroadcast ); + + if (_list && move_entry) + // Sets list + _list->insert( this ); +} + void SwFrmFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) { SwFmtHeader *pH = 0; diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 2ee6ab2b0ecd..51e8c6f35b93 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1130,14 +1130,15 @@ static void lcl_AppendAllObjs( const SwFrmFmts *pTbl, const SwFrm* pSib ) //because we neither use character bound frames nor objects which //are anchored to character bounds. - SwFrmFmts aCpy( *pTbl ); + SwFrmFmtsV aCpy; + aCpy.insert(aCpy.end(), pTbl->begin(), pTbl->end()); sal_uInt16 nOldCnt = USHRT_MAX; while ( !aCpy.empty() && aCpy.size() != nOldCnt ) { nOldCnt = aCpy.size(); - SwFrmFmts::iterator it = aCpy.begin(); + SwFrmFmtsV::iterator it = aCpy.begin(); while ( it != aCpy.end() ) { SwFrmFmt *pFmt = *it; diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index fba4898bbf84..4689290d730e 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -621,8 +621,8 @@ void SwTxtNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMa if( pTmp ) { aNodeArgs.nIndx = nIndex; - BOOST_FOREACH( SwFrmFmt *pFmt, *pTmp ) - lcl_MinMaxNode( pFmt, &aNodeArgs ); + for (SwFrmFmts::const_iterator it = pTmp->begin(); it != pTmp->end(); it++ ) + lcl_MinMaxNode( *it, &aNodeArgs ); } } if( aNodeArgs.nLeftRest < 0 ) diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 59cfec65def5..016ce12a69cb 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -877,8 +877,7 @@ void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) { ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); - sal_uInt16 nPos = pDoc->GetSpzFrmFmts()->GetPos( &m_rFmt ); - if ( USHRT_MAX != nPos ) // Format does still exist + if ( pDoc->GetSpzFrmFmts()->Contains( &m_rFmt ) ) // Format does still exist { SwFmtAnchor aTmp( m_rFmt.GetAnchor() ); @@ -916,12 +915,12 @@ SwHistoryChangeFlyChain::SwHistoryChangeFlyChain( SwFlyFrmFmt& rFmt, void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool ) { - if ( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pFlyFmt ) ) + if ( pDoc->GetSpzFrmFmts()->Contains( m_pFlyFmt ) ) { SwFmtChain aChain; if ( m_pPrevFmt && - USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pPrevFmt ) ) + pDoc->GetSpzFrmFmts()->Contains( m_pPrevFmt ) ) { aChain.SetPrev( m_pPrevFmt ); SwFmtChain aTmp( m_pPrevFmt->GetChain() ); @@ -930,7 +929,7 @@ void SwHistoryChangeFlyChain::SetInDoc( SwDoc* pDoc, bool ) } if ( m_pNextFmt && - USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( m_pNextFmt ) ) + pDoc->GetSpzFrmFmts()->Contains( m_pNextFmt ) ) { aChain.SetNext( m_pNextFmt ); SwFmtChain aTmp( m_pNextFmt->GetChain() ); diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 5f0474dba310..111d06b42dd2 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -282,13 +282,11 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) // no break! case RES_DRAWFRMFMT: case RES_FLYFRMFMT: - nPos = pDoc->GetSpzFrmFmts()->GetPos( - static_cast<SwFrmFmt*>(m_pFmt) ); - if ( USHRT_MAX == nPos ) - { - nPos = pDoc->GetFrmFmts()->GetPos( - static_cast<SwFrmFmt*>(m_pFmt) ); - } + if ((pDoc->GetSpzFrmFmts()->Contains( + static_cast<SwFrmFmt*>(m_pFmt))) + || (pDoc->GetFrmFmts()->Contains( + static_cast<SwFrmFmt*>(m_pFmt))) ) + nPos = 1; break; } diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 56e0c8a1e6bc..ab3e3f4f86e4 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -56,7 +56,7 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrm) // add again into array SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.push_back( pFrmFmt ); + rFlyFmts.insert( pFrmFmt ); // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page if ( RES_DRAWFRMFMT == pFrmFmt->Which() ) @@ -216,7 +216,7 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) // delete from array SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFrmFmt )); + rFlyFmts.erase( pFrmFmt ); } SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, sal_uLong nNodeIdx, xub_StrLen nCntIdx ) @@ -533,7 +533,7 @@ void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (SwFrmFmt*) pOldFmt ) ) + if( rDoc.GetFrmFmts()->Contains( (SwFrmFmt*) pOldFmt ) ) { if( bAnchorChgd ) pFrmFmt->DelFrms(); @@ -606,7 +606,7 @@ void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (SwFrmFmt*) pNewFmt ) ) + if( rDoc.GetFrmFmts()->find( (SwFrmFmt*) pNewFmt ) != rDoc.GetFrmFmts()->end() ) { if( bAnchorChgd ) diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index e9ba3a388cbc..44db52a3ddb1 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -240,7 +240,7 @@ void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &) SwUndoGroupObjImpl& rSave = *( pObjArr + n ); ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx ); - rFlyFmts.push_back( rSave.pFmt ); + rFlyFmts.insert( rSave.pFmt ); pObj = rSave.pObj; @@ -289,7 +289,7 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) // re-insert group object ::lcl_RestoreAnchor( pObjArr->pFmt, pObjArr->nNodeIdx ); - rFlyFmts.push_back( pObjArr->pFmt ); + rFlyFmts.insert( pObjArr->pFmt ); SwDrawContact *pContact = new SwDrawContact( pObjArr->pFmt, pObjArr->pObj ); // #i26791# - correction: connect object to layout @@ -391,7 +391,7 @@ void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) // re-insert group object ::lcl_RestoreAnchor( pObjArr->pFmt, pObjArr->nNodeIdx ); - rFlyFmts.push_back( pObjArr->pFmt ); + rFlyFmts.insert( pObjArr->pFmt ); SwDrawContact *pContact = new SwDrawContact( pObjArr->pFmt, pObjArr->pObj ); pContact->ConnectToLayout(); @@ -434,7 +434,7 @@ void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &) SwUndoGroupObjImpl& rSave = *( pObjArr + n ); ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx ); - rFlyFmts.push_back( rSave.pFmt ); + rFlyFmts.insert( rSave.pFmt ); // #i45952# - notify that position attributes are already set OSL_ENSURE( rSave.pFmt->ISA(SwDrawFrmFmt), @@ -532,7 +532,7 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx ); - rFlyFmts.push_back( rSave.pFmt ); + rFlyFmts.insert( rSave.pFmt ); SdrObject *pObj = rSave.pObj; SwDrawContact *pContact = new SwDrawContact( rSave.pFmt, pObj ); pContact->_Changed( *pObj, SDRUSERCALL_INSERTED, NULL ); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 4ed6fa724a0e..4e8e02c668ed 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -117,7 +117,7 @@ class _SaveTable _SaveLine* pLine; const SwTable* pSwTable; SfxItemSets aSets; - SwFrmFmts aFrmFmts; + SwFrmFmtsV aFrmFmts; sal_uInt16 nLineCount; bool bModifyBox : 1; bool bSaveFormula : 1; diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index a17f91d54094..0e70a2d1889d 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -138,7 +138,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) RedlineMode_t ePostReadRedlineMode( nsRedlineMode_t::REDLINE_IGNORE ); // Array von FlyFormaten - SwFrmFmts aFlyFrmArr; + SwFrmFmtsV aFlyFrmArr; // only read templates? then ignore multi selection! sal_Bool bFmtsOnly = po->aOpt.IsFmtsOnly(); @@ -160,8 +160,8 @@ sal_uLong SwReader::Read( const Reader& rOptions ) // Speicher mal alle Fly's if( pCrsr ) { - std::copy(pDoc->GetSpzFrmFmts()->begin(), - pDoc->GetSpzFrmFmts()->end(), std::back_inserter(aFlyFrmArr)); + aFlyFrmArr.insert(aFlyFrmArr.end(), pDoc->GetSpzFrmFmts()->begin(), + pDoc->GetSpzFrmFmts()->end()); } xub_StrLen nSttCntnt = pPam->GetPoint()->nContent.GetIndex(); diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 5e7add30c33f..1eb40f5e9485 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -781,7 +781,7 @@ sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrmFmt& rFmt ) const { // no Layout for this format, then recalc the ordnum SwFrmFmt* pFmt = (SwFrmFmt*)&rFmt; - nOrdNum = pDoc->GetSpzFrmFmts()->GetPos( pFmt ); + nOrdNum = std::distance(pDoc->GetSpzFrmFmts()->begin(), pDoc->GetSpzFrmFmts()->find( pFmt ) ); const SdrModel* pModel = pDoc->GetDrawModel(); if( pModel ) |