diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-20 16:36:51 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-06-20 16:48:03 +0200 |
commit | 1015cd4ff73ee25e55b4da8c8bc55a41e652da87 (patch) | |
tree | 0b91a6dd5e278cda1c582ba122e40d4877920d0d /sw | |
parent | ccfc7bd12dd89f2ec4fd4e9339710ccb4c6532da (diff) |
Convert SV_DECL_PTRARR_DEL of Sw*Fmts to std::vector
- I had to convert SwFrmFmts, SwSpzFrmFmts, SwCharFmts, SwSectionsFmts,
SwTextFormatColl, SwGrfFmtColl all together because of the code that wants
to work with any of them.
- Introduce a pure virtual base class SwFmtsBase, since there are a handful
of methods that want to work with any of the std::vector<Sw*Fmt> types.
- the class SwSpzFrmFmts was dropped, and the code changed to use SwFrmFmts
instead, since the 2 types are identical.
Change-Id: I8c4056b5aedd574a33666e2d649a8b849958441c
Signed-off-by: Fridrich Štrba <fridrich.strba@bluewin.ch>
Diffstat (limited to 'sw')
99 files changed, 734 insertions, 577 deletions
diff --git a/sw/CppunitTest_sw_swdoc_test.mk b/sw/CppunitTest_sw_swdoc_test.mk index 94ebab35597f..dc4490b9ae2b 100644 --- a/sw/CppunitTest_sw_swdoc_test.mk +++ b/sw/CppunitTest_sw_swdoc_test.mk @@ -58,6 +58,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_swdoc_test, \ svt \ svx \ svxcore \ + sw \ swd \ test \ tk \ diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ab09943300f1..c65863328bf2 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -131,6 +131,7 @@ class SwField; class SwTxtFld; class SwFldTypes; class SwFlyFrmFmt; +class SwFmtsBase; class SwFmt; class SwFmtINetFmt; class SwFmtRefMark; @@ -162,7 +163,6 @@ class SwSectionFmt; class SwSectionFmts; class SwSectionData; class SwSelBoxes; -class SwSpzFrmFmts; class SwTOXBase; class SwTOXBaseSection; class SwTOXMark; @@ -315,7 +315,7 @@ class SW_DLLPUBLIC SwDoc : SwFrmFmts *pFrmFmtTbl; // Format table SwCharFmts *pCharFmtTbl; - SwSpzFrmFmts *pSpzFrmFmtTbl; + SwFrmFmts *pSpzFrmFmtTbl; SwSectionFmts *pSectionFmtTbl; SwFrmFmts *pTblFrmFmtTbl; // For tables SwTxtFmtColls *pTxtFmtCollTbl; // FormatCollections @@ -634,13 +634,13 @@ private: sal_Int8 SetFlyFrmAnchor( SwFrmFmt& rFlyFmt, SfxItemSet& rSet, sal_Bool bNewFrms ); typedef SwFmt* (SwDoc:: *FNCopyFmt)( const String&, SwFmt*, sal_Bool, sal_Bool ); - SwFmt* CopyFmt( const SwFmt& rFmt, const SvPtrarr& rFmtArr, + SwFmt* CopyFmt( const SwFmt& rFmt, const SwFmtsBase& rFmtArr, FNCopyFmt fnCopyFmt, const SwFmt& rDfltFmt ); - void CopyFmtArr( const SvPtrarr& rSourceArr, SvPtrarr& rDestArr, + void CopyFmtArr( const SwFmtsBase& rSourceArr, SwFmtsBase& rDestArr, FNCopyFmt fnCopyFmt, SwFmt& rDfltFmt ); void CopyPageDescHeaderFooterImpl( bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ); - SwFmt* FindFmtByName( const SvPtrarr& rFmtArr, + SwFmt* FindFmtByName( const SwFmtsBase& rFmtArr, const String& rName ) const; VirtualDevice& CreateVirtualDevice_() const; @@ -1202,8 +1202,8 @@ public: const SwCharFmts* GetCharFmts() const { return pCharFmtTbl;} /* LayoutFormats (frames, DrawObjects), sometimes const sometimes not */ - const SwSpzFrmFmts* GetSpzFrmFmts() const { return pSpzFrmFmtTbl; } - SwSpzFrmFmts* GetSpzFrmFmts() { return pSpzFrmFmtTbl; } + const SwFrmFmts* GetSpzFrmFmts() const { return pSpzFrmFmtTbl; } + SwFrmFmts* GetSpzFrmFmts() { return pSpzFrmFmtTbl; } const SwFrmFmt *GetDfltFrmFmt() const { return pDfltFrmFmt; } SwFrmFmt *GetDfltFrmFmt() { return pDfltFrmFmt; } @@ -1224,7 +1224,7 @@ public: sal_Bool bBroadcast = sal_False, sal_Bool bAuto = sal_True); void DelFrmFmt( SwFrmFmt *pFmt, sal_Bool bBroadcast = sal_False ); SwFrmFmt* FindFrmFmtByName( const String& rName ) const - { return (SwFrmFmt*)FindFmtByName( (SvPtrarr&)*pFrmFmtTbl, rName ); } + { return (SwFrmFmt*)FindFmtByName( (SwFmtsBase&)*pFrmFmtTbl, rName ); } SwCharFmt *MakeCharFmt(const String &rFmtName, SwCharFmt *pDerivedFrom, sal_Bool bBroadcast = sal_False, @@ -1232,7 +1232,7 @@ public: void DelCharFmt(sal_uInt16 nFmt, sal_Bool bBroadcast = sal_False); void DelCharFmt(SwCharFmt* pFmt, sal_Bool bBroadcast = sal_False); SwCharFmt* FindCharFmtByName( const String& rName ) const - { return (SwCharFmt*)FindFmtByName( (SvPtrarr&)*pCharFmtTbl, rName ); } + { return (SwCharFmt*)FindFmtByName( (SwFmtsBase&)*pCharFmtTbl, rName ); } /* Formatcollections (styles) */ // TXT @@ -1258,7 +1258,7 @@ public: bool bReset = true, bool bResetListAttrs = false ); SwTxtFmtColl* FindTxtFmtCollByName( const String& rName ) const - { return (SwTxtFmtColl*)FindFmtByName( (SvPtrarr&)*pTxtFmtCollTbl, rName ); } + { return (SwTxtFmtColl*)FindFmtByName( (SwFmtsBase&)*pTxtFmtCollTbl, rName ); } void ChkCondColls(); @@ -1268,7 +1268,7 @@ public: SwGrfFmtColl *MakeGrfFmtColl(const String &rFmtName, SwGrfFmtColl *pDerivedFrom); SwGrfFmtColl* FindGrfFmtCollByName( const String& rName ) const - { return (SwGrfFmtColl*)FindFmtByName( (SvPtrarr&)*pGrfFmtCollTbl, rName ); } + { return (SwGrfFmtColl*)FindFmtByName( (SwFmtsBase&)*pGrfFmtCollTbl, rName ); } // Table formating const SwFrmFmts* GetTblFrmFmts() const { return pTblFrmFmtTbl; } diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 2a8642229da0..6c7f99402d03 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -33,6 +33,7 @@ #include <algorithm> class SwFieldType; +class SwFmt; class SwFrmFmt; class SwCharFmt; class SwTOXType; @@ -42,6 +43,8 @@ class SwNumRule; class SwRedline; class SwUnoCrsr; class SwOLENode; +class SwTxtFmtColl; +class SwGrfFmtColl; namespace com { namespace sun { namespace star { namespace i18n { struct ForbiddenCharacters; // comes from the I18N UNO interface @@ -50,18 +53,70 @@ namespace com { namespace sun { namespace star { namespace i18n { #include <swtypes.hxx> #include <svl/svarray.hxx> -// PageDescriptor-interface -// typedef SwPageDesc * SwPageDescPtr; -// SV_DECL_PTRARR_DEL(SwPageDescs, SwPageDescPtr,1); +// provides some methods for generic operations on lists that contain +// SwFmt* subclasses. +class SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const = 0; + virtual SwFmt* GetFmt(size_t idx) const = 0; + virtual ~SwFmtsBase() = 0; +}; -typedef SwFrmFmt* SwFrmFmtPtr; -SV_DECL_PTRARR_DEL(SwFrmFmts,SwFrmFmtPtr,4) +class SwGrfFmtColls : public std::vector<SwGrfFmtColl*>, public SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const { return size(); } + virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); } + sal_uInt16 GetPos(const SwGrfFmtColl* pFmt) const; + // free's any remaining child objects + virtual ~SwGrfFmtColls() {} +}; // Specific frame formats (frames, DrawObjects). -SV_DECL_PTRARR_DEL(SwSpzFrmFmts,SwFrmFmtPtr,0) +class SW_DLLPUBLIC SwFrmFmts : public std::vector<SwFrmFmt*>, public SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const { return size(); } + virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); } + sal_uInt16 GetPos(const SwFrmFmt* pFmt) const; + bool Contains(const SwFrmFmt* pFmt) const; + // free's any remaining child objects + virtual ~SwFrmFmts(); +}; -typedef SwCharFmt* SwCharFmtPtr; -SV_DECL_PTRARR_DEL(SwCharFmts,SwCharFmtPtr,4) +class SwCharFmts : public std::vector<SwCharFmt*>, public SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const { return size(); } + virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); } + sal_uInt16 GetPos(const SwCharFmt* pFmt) const; + bool Contains(const SwCharFmt* pFmt) const; + // free's any remaining child objects + virtual ~SwCharFmts(); +}; + +class SwTxtFmtColls : public std::vector<SwTxtFmtColl*>, public SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const { return size(); } + virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); } + sal_uInt16 GetPos(const SwTxtFmtColl* pFmt) const; + bool Contains(const SwTxtFmtColl* pFmt) const; + virtual ~SwTxtFmtColls() {} +}; + +// Array of Undo-history. +class SW_DLLPUBLIC SwSectionFmts : public std::vector<SwSectionFmt*>, public SwFmtsBase +{ +public: + virtual size_t GetFmtCount() const { return size(); } + virtual SwFmt* GetFmt(size_t idx) const { return (SwFmt*)operator[](idx); } + sal_uInt16 GetPos(const SwSectionFmt* pFmt) const; + bool Contains(const SwSectionFmt* pFmt) const; + // free's any remaining child objects + virtual ~SwSectionFmts(); +}; class SwFldTypes : public std::vector<SwFieldType*> { public: @@ -77,10 +132,6 @@ public: sal_uInt16 GetPos(const SwTOXType* pTOXType) const; }; -// Array of Undo-history. -typedef SwSectionFmt* SwSectionFmtPtr; -SV_DECL_PTRARR_DEL(SwSectionFmts,SwSectionFmtPtr,0) - class SW_DLLPUBLIC SwNumRuleTbl : public std::vector<SwNumRule*> { public: // the destructor will free all objects still in the vector diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx index 3451a4b2cf31..80bfbf87235e 100644 --- a/sw/inc/fmtcol.hxx +++ b/sw/inc/fmtcol.hxx @@ -154,9 +154,6 @@ public: */ }; -typedef SwTxtFmtColl* SwTxtFmtCollPtr; -SV_DECL_PTRARR(SwTxtFmtColls,SwTxtFmtCollPtr,2) - class SwGrfFmtColl: public SwFmtColl { friend class SwDoc; @@ -177,9 +174,6 @@ public: TYPEINFO(); // Already in base class Client. }; -typedef SwGrfFmtColl* SwGrfFmtCollPtr; -SV_DECL_PTRARR(SwGrfFmtColls,SwGrfFmtCollPtr,2) - // FEATURE::CONDCOLL // Conditional styles. enum Master_CollConditions diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index ec77f94ead03..976b7699b42d 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -305,7 +305,7 @@ sal_Bool SwCrsrShell::GotoNextTOXBase( const String* pName ) const SwSectionFmts& rFmts = GetDoc()->GetSections(); SwCntntNode* pFnd = 0; - for( sal_uInt16 n = rFmts.Count(); n; ) + for( sal_uInt16 n = rFmts.size(); n; ) { const SwSection* pSect = rFmts[ --n ]->GetSection(); const SwSectionNode* pSectNd; @@ -352,7 +352,7 @@ sal_Bool SwCrsrShell::GotoPrevTOXBase( const String* pName ) const SwSectionFmts& rFmts = GetDoc()->GetSections(); SwCntntNode* pFnd = 0; - for( sal_uInt16 n = rFmts.Count(); n; ) + for( sal_uInt16 n = rFmts.size(); n; ) { const SwSection* pSect = rFmts[ --n ]->GetSection(); const SwSectionNode* pSectNd; @@ -2083,7 +2083,7 @@ sal_Bool SwCrsrShell::SelectNxtPrvHyperlink( sal_Bool bNext ) { const SwTxtNode* pTxtNd; const SwCharFmts* pFmts = GetDoc()->GetCharFmts(); - for( sal_uInt16 n = pFmts->Count(); 1 < n; ) + for( sal_uInt16 n = pFmts->size(); 1 < n; ) { SwIterator<SwTxtINetFmt,SwCharFmt> aIter(*(*pFmts)[--n]); @@ -2117,8 +2117,8 @@ sal_Bool SwCrsrShell::SelectNxtPrvHyperlink( sal_Bool bNext ) } // then check all the Flys with a URL or imapge map { - const SwSpzFrmFmts* pFmts = GetDoc()->GetSpzFrmFmts(); - for( sal_uInt16 n = 0, nEnd = pFmts->Count(); n < nEnd; ++n ) + const SwFrmFmts* pFmts = GetDoc()->GetSpzFrmFmts(); + for( sal_uInt16 n = 0, nEnd = pFmts->size(); n < nEnd; ++n ) { SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)(*pFmts)[ n ]; const SwFmtURL& rURLItem = pFmt->GetURL(); diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index e40f43a50608..c3b3a320e454 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -700,7 +700,7 @@ sal_Bool SwPaM::HasReadonlySel( bool bFormView ) const if( nSttIdx + 3 < nEndIdx ) { const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = rFmts.Count(); n; ) + for( sal_uInt16 n = rFmts.size(); n; ) { const SwSectionFmt* pFmt = rFmts[ --n ]; if( pFmt->GetProtect().IsCntntProtected() ) diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 0bca531664df..a700610e0d59 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -311,7 +311,7 @@ sal_Bool SwCursor::IsSelOvr( int eFlags ) } const SwSectionFmts& rFmts = pDoc->GetSections(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { const SwSectionFmt* pFmt = rFmts[n]; const SvxProtectItem& rProtect = pFmt->GetProtect(); diff --git a/sw/source/core/crsr/trvlreg.cxx b/sw/source/core/crsr/trvlreg.cxx index 6001220d5bd2..5f61e69a2c6a 100644 --- a/sw/source/core/crsr/trvlreg.cxx +++ b/sw/source/core/crsr/trvlreg.cxx @@ -253,7 +253,7 @@ sal_Bool SwCursor::GotoRegion( const String& rName ) { sal_Bool bRet = sal_False; const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = rFmts.Count(); n; ) + for( sal_uInt16 n = rFmts.size(); n; ) { const SwSectionFmt* pFmt = rFmts[ --n ]; const SwNodeIndex* pIdx; diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index b14e07d0cd7f..03fdce558399 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -468,7 +468,7 @@ const String lcl_AnchoredFrames(const SwNode & rNode) const SwDoc * pDoc = rNode.GetDoc(); if (pDoc) { - const SwSpzFrmFmts * pFrmFmts = pDoc->GetSpzFrmFmts(); + const SwFrmFmts * pFrmFmts = pDoc->GetSpzFrmFmts(); if (pFrmFmts) { diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 54e6e421ba47..cd2804dc4902 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -2098,7 +2098,7 @@ void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, sal_Bool GetNodes()._Copy( aRange, aEndOfDoc ); } const SwTxtFmtColls *pColl = pExtDoc->GetTxtFmtColls(); - for( i = 0; i < pColl->Count(); ++i ) + for( i = 0; i < pColl->size(); ++i ) (*pColl)[ i ]->ResetFmtAttr( RES_PAGEDESC, RES_BREAK ); SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() ); ++aEndOfDoc; @@ -2228,7 +2228,7 @@ bool SwDoc::RemoveInvisibleContent() SwSectionFmts& rSectFmts = GetSections(); sal_uInt16 n; - for( n = rSectFmts.Count(); n; ) + for( n = rSectFmts.size(); n; ) { SwSectionFmt* pSectFmt = rSectFmts[ --n ]; // don't add sections in Undo/Redo @@ -2245,8 +2245,9 @@ bool SwDoc::RemoveInvisibleContent() pParent = pTmp; } - if( USHRT_MAX == aSectFmts.GetPos( pSect->GetFmt() ) ) - aSectFmts.Insert( pSect->GetFmt(), 0 ); + SwSectionFmts::iterator it = std::find( aSectFmts.begin(), aSectFmts.end(), pSect->GetFmt() ); + if ( it != aSectFmts.end() ) + aSectFmts.insert( aSectFmts.begin(), pSect->GetFmt() ); } if( pSect->GetCondition().Len() ) { @@ -2257,7 +2258,7 @@ bool SwDoc::RemoveInvisibleContent() } } - if( 0 != ( n = aSectFmts.Count() )) + if( 0 != ( n = aSectFmts.size() )) { while( n ) { @@ -2295,7 +2296,7 @@ bool SwDoc::RemoveInvisibleContent() } } - aSectFmts.Remove( 0, aSectFmts.Count() ); + aSectFmts.clear(); } } @@ -2339,7 +2340,7 @@ bool SwDoc::HasInvisibleContent() const const SwSectionFmts& rSectFmts = GetSections(); sal_uInt16 n; - for( n = rSectFmts.Count(); !bRet && (n > 0); ) + for( n = rSectFmts.size(); !bRet && (n > 0); ) { SwSectionFmt* pSectFmt = rSectFmts[ --n ]; // don't add sections in Undo/Redo @@ -2666,7 +2667,7 @@ SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, sal_Bool bTblCrsr ) void SwDoc::ChkCondColls() { - for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->Count(); n++) + for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->size(); n++) { SwTxtFmtColl *pColl = (*pTxtFmtCollTbl)[n]; if (RES_CONDTXTFMTCOLL == pColl->Which()) diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index 1275c7939de4..8c502cccf2ff 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -170,11 +170,10 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve case EVENT_OBJECT_URLITEM: case EVENT_OBJECT_IMAGE: { - const SwFrmFmtPtr pFmt = (SwFrmFmtPtr)rCallEvent.PTR.pFmt; + const SwFrmFmt* pFmt = (SwFrmFmt*)rCallEvent.PTR.pFmt; if( bCheckPtr ) { - sal_uInt16 nPos = GetSpzFrmFmts()->GetPos( pFmt ); - if( USHRT_MAX != nPos ) + if ( GetSpzFrmFmts()->Contains( pFmt ) ) bCheckPtr = sal_False; // misuse as a flag } if( !bCheckPtr ) @@ -187,13 +186,12 @@ sal_uInt16 SwDoc::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCallEve const IMapObject* pIMapObj = rCallEvent.PTR.IMAP.pIMapObj; if( bCheckPtr ) { - const SwFrmFmtPtr pFmt = (SwFrmFmtPtr)rCallEvent.PTR.IMAP.pFmt; - sal_uInt16 nPos = GetSpzFrmFmts()->GetPos( pFmt ); + const SwFrmFmt* pFmt = (SwFrmFmt*)rCallEvent.PTR.IMAP.pFmt; const ImageMap* pIMap; - if( USHRT_MAX != nPos && + if( GetSpzFrmFmts()->Contains( pFmt ) && 0 != (pIMap = pFmt->GetURL().GetMap()) ) { - for( nPos = pIMap->GetIMapObjectCount(); nPos; ) + for( sal_uInt16 nPos = pIMap->GetIMapObjectCount(); nPos; ) if( pIMapObj == pIMap->GetIMapObject( --nPos )) { bCheckPtr = sal_False; // misuse as a flag diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 327babec15e6..1937bc99b0a1 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1341,7 +1341,7 @@ void _SaveCntntIdx(SwDoc* pDoc, continue; } } - aSave.SetCount( pDoc->GetSpzFrmFmts()->Count() ); + aSave.SetCount( pDoc->GetSpzFrmFmts()->size() ); while( aSave.GetCount() && &rFmt != (*pDoc->GetSpzFrmFmts())[ aSave.DecCount() ] ) @@ -1356,7 +1356,7 @@ void _SaveCntntIdx(SwDoc* pDoc, } else // No layout, so it's a bit more expensive ... { - for( aSave.SetCount( pDoc->GetSpzFrmFmts()->Count() ); + for( aSave.SetCount( pDoc->GetSpzFrmFmts()->size() ); aSave.GetCount() ; ) { SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ @@ -1447,7 +1447,7 @@ void _RestoreCntntIdx(SwDoc* pDoc, { SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode(); const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl(); - SwSpzFrmFmts* pSpz = pDoc->GetSpzFrmFmts(); + SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts(); IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); sal_uInt16 n = 0; while( n < rSaveArr.size() ) @@ -1608,7 +1608,7 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr, { const SwDoc* pDoc = rNd.GetDoc(); const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl(); - const SwSpzFrmFmts* pSpz = pDoc->GetSpzFrmFmts(); + const SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts(); const IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); SwCntntNode* pCNd = (SwCntntNode*)rNd.GetCntntNode(); diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx index a481045046e5..f48fab46734d 100644 --- a/sw/source/core/doc/docchart.cxx +++ b/sw/source/core/doc/docchart.cxx @@ -108,7 +108,7 @@ void SwDoc::DoUpdateAllCharts() if( pVSh ) { const SwFrmFmts& rTblFmts = *GetTblFrmFmts(); - for( sal_uInt16 n = 0; n < rTblFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rTblFmts.size(); ++n ) { SwTable* pTmpTbl; const SwTableNode* pTblNd; @@ -171,7 +171,7 @@ void SwDoc::SetTableName( SwFrmFmt& rTblFmt, const String &rNewName ) { SwFrmFmt* pFmt; const SwFrmFmts& rTbl = *GetTblFrmFmts(); - for( sal_uInt16 i = rTbl.Count(); i; ) + for( sal_uInt16 i = rTbl.size(); i; ) if( !( pFmt = rTbl[ --i ] )->IsDefault() && pFmt->GetName() == rNewName && IsUsed( *pFmt ) ) { diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/docdde.cxx index dc87ce0bef25..edc6c87598bb 100644 --- a/sw/source/core/doc/docdde.cxx +++ b/sw/source/core/doc/docdde.cxx @@ -45,6 +45,7 @@ #include <pam.hxx> #include <docary.hxx> #include <MarkManager.hxx> +#include <boost/foreach.hpp> using namespace ::com::sun::star; @@ -85,10 +86,9 @@ struct _FindItem {} }; -sal_Bool lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs, bool bCaseSensitive ) +static bool lcl_FindSection( const SwSectionFmt* pSectFmt, _FindItem * const pItem, bool bCaseSensitive ) { - _FindItem * const pItem( static_cast<_FindItem*>(pArgs) ); - SwSection* pSect = rpSectFmt->GetSection(); + SwSection* pSect = pSectFmt->GetSection(); if( pSect ) { String sNm( (bCaseSensitive) @@ -101,52 +101,43 @@ sal_Bool lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs, bool bC { // found, so get the data const SwNodeIndex* pIdx; - if( 0 != (pIdx = rpSectFmt->GetCntnt().GetCntntIdx() ) && - &rpSectFmt->GetDoc()->GetNodes() == &pIdx->GetNodes() ) + if( 0 != (pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) && + &pSectFmt->GetDoc()->GetNodes() == &pIdx->GetNodes() ) { // a table in the normal NodesArr pItem->pSectNd = pIdx->GetNode().GetSectionNode(); - return sal_False; + return false; } // If the name is already correct, but not the rest then we don't have them. // The names are always unique. } } - return sal_True; -} -sal_Bool lcl_FindSectionCaseSensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) -{ - return lcl_FindSection( rpSectFmt, pArgs, true ); -} -sal_Bool lcl_FindSectionCaseInsensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) -{ - return lcl_FindSection( rpSectFmt, pArgs, false ); + return true; } -sal_Bool lcl_FindTable( const SwFrmFmtPtr& rpTableFmt, void* pArgs ) +static bool lcl_FindTable( const SwFrmFmt* pTableFmt, _FindItem * const pItem ) { - _FindItem * const pItem( static_cast<_FindItem*>(pArgs) ); - String sNm( GetAppCharClass().lowercase( rpTableFmt->GetName() )); + String sNm( GetAppCharClass().lowercase( pTableFmt->GetName() )); if (sNm.Equals( pItem->m_Item )) { SwTable* pTmpTbl; SwTableBox* pFBox; - if( 0 != ( pTmpTbl = SwTable::FindTable( rpTableFmt ) ) && + if( 0 != ( pTmpTbl = SwTable::FindTable( pTableFmt ) ) && 0 != ( pFBox = pTmpTbl->GetTabSortBoxes()[0] ) && pFBox->GetSttNd() && - &rpTableFmt->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) + &pTableFmt->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) { // a table in the normal NodesArr pItem->pTblNd = (SwTableNode*) pFBox->GetSttNd()->FindTableNode(); - return sal_False; + return false; } // If the name is already correct, but not the rest then we don't have them. // The names are always unique. } - return sal_True; + return true; } @@ -165,8 +156,11 @@ bool SwDoc::GetData( const rtl::OUString& rItem, const String& rMimeType, // Do we already have the Item? String sItem( bCaseSensitive ? rItem : GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), - bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + BOOST_FOREACH( const SwSectionFmt* pFmt, *pSectionFmtTbl ) + { + if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) + break; + } if( aPara.pSectNd ) { // found, so get the data @@ -178,8 +172,11 @@ bool SwDoc::GetData( const rtl::OUString& rItem, const String& rMimeType, } _FindItem aPara( GetAppCharClass().lowercase( rItem )); - ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach( 0, pTblFrmFmtTbl->Count(), - lcl_FindTable, &aPara ); + BOOST_FOREACH( const SwFrmFmt* pFmt, *pTblFrmFmtTbl ) + { + if (!(lcl_FindTable(pFmt, &aPara))) + break; + } if( aPara.pTblNd ) { return SwServerObject( *aPara.pTblNd ).GetData( rValue, rMimeType ); @@ -204,7 +201,11 @@ bool SwDoc::SetData( const rtl::OUString& rItem, const String& rMimeType, // Do we already have the Item? String sItem( bCaseSensitive ? rItem : GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - pSectionFmtTbl->ForEach( 0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + BOOST_FOREACH( const SwSectionFmt* pFmt, *pSectionFmtTbl ) + { + if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) + break; + } if( aPara.pSectNd ) { // found, so get the data @@ -217,7 +218,11 @@ bool SwDoc::SetData( const rtl::OUString& rItem, const String& rMimeType, String sItem(GetAppCharClass().lowercase(rItem)); _FindItem aPara( sItem ); - pTblFrmFmtTbl->ForEach( 0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara ); + BOOST_FOREACH( const SwFrmFmt* pFmt, *pTblFrmFmtTbl ) + { + if (!(lcl_FindTable(pFmt, &aPara))) + break; + } if( aPara.pTblNd ) { return SwServerObject( *aPara.pTblNd ).SetData( rMimeType, rValue ); @@ -251,7 +256,12 @@ bool SwDoc::SetData( const rtl::OUString& rItem, const String& rMimeType, _FindItem aPara(bCaseSensitive ? rItem : GetAppCharClass().lowercase(rItem)); // sections - ((SwSectionFmts&)*pSectionFmtTbl).ForEach(0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara); + BOOST_FOREACH( const SwSectionFmt* pFmt, *pSectionFmtTbl ) + { + if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) + break; + } + if(aPara.pSectNd && (0 == (pObj = aPara.pSectNd->GetSection().GetObject()))) { @@ -269,7 +279,11 @@ bool SwDoc::SetData( const rtl::OUString& rItem, const String& rMimeType, _FindItem aPara( GetAppCharClass().lowercase(rItem) ); // tables - ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach(0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara); + BOOST_FOREACH( const SwFrmFmt* pFmt, *pTblFrmFmtTbl ) + { + if (!(lcl_FindTable(pFmt, &aPara))) + break; + } if(aPara.pTblNd && (0 == (pObj = aPara.pTblNd->GetTable().GetObject()))) { @@ -310,8 +324,11 @@ sal_Bool SwDoc::SelectServerObj( const String& rStr, SwPaM*& rpPam, if( sCmp.EqualsAscii( pMarkToTable ) ) { sName = rCC.lowercase( sName ); - ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach( 0, pTblFrmFmtTbl->Count(), - lcl_FindTable, &aPara ); + BOOST_FOREACH( const SwFrmFmt* pFmt, *pTblFrmFmtTbl ) + { + if (!(lcl_FindTable(pFmt, &aPara))) + break; + } if( aPara.pTblNd ) { rpRange = new SwNodeRange( *aPara.pTblNd, 0, @@ -389,10 +406,13 @@ sal_Bool SwDoc::SelectServerObj( const String& rStr, SwPaM*& rpPam, // _FindItem aPara( bCaseSensitive ? sItem : String(rCC.lowercase( sItem )) ); - if( pSectionFmtTbl->Count() ) + if( !pSectionFmtTbl->empty() ) { - ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), - bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + BOOST_FOREACH( const SwSectionFmt* pFmt, *pSectionFmtTbl ) + { + if (!(lcl_FindSection(pFmt, &aPara, bCaseSensitive))) + break; + } if( aPara.pSectNd ) { rpRange = new SwNodeRange( *aPara.pSectNd, 1, diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index c805779dd470..e72196633e57 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -207,8 +207,7 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx, aPos.nContent.Assign( 0, 0 ); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); aAnchor.SetAnchor( &aPos ); - pFmt->GetDoc()->GetSpzFrmFmts()->Insert( - pFmt, pFmt->GetDoc()->GetSpzFrmFmts()->Count() ); + pFmt->GetDoc()->GetSpzFrmFmts()->push_back( pFmt ); pFmt->SetFmtAttr( aAnchor ); SwCntntNode* pCNd = aPos.nNode.GetNode().GetCntntNode(); if( pCNd && pCNd->getLayoutFrm( pFmt->GetDoc()->GetCurrentLayout(), 0, 0, sal_False ) ) @@ -218,8 +217,8 @@ void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx, void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ) { - SwSpzFrmFmts& rFmts = *rRg.aStart.GetNode().GetDoc()->GetSpzFrmFmts(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + SwFrmFmts& rFmts = *rRg.aStart.GetNode().GetDoc()->GetSpzFrmFmts(); + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { SwFrmFmt *const pFmt = static_cast<SwFrmFmt*>(rFmts[n]); SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); @@ -233,7 +232,7 @@ void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ) pFmt, sal_False ); rArr.push_back( aSave ); pFmt->DelFrms(); - rFmts.Remove( n--, 1 ); + rFmts.erase( rFmts.begin() + n-- ); } } } @@ -241,7 +240,7 @@ void _SaveFlyInRange( const SwNodeRange& rRg, _SaveFlyArr& rArr ) void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, _SaveFlyArr& rArr, bool bMoveAllFlys ) { - SwSpzFrmFmts& rFmts = *rPam.GetPoint()->nNode.GetNode().GetDoc()->GetSpzFrmFmts(); + SwFrmFmts& rFmts = *rPam.GetPoint()->nNode.GetNode().GetDoc()->GetSpzFrmFmts(); SwFrmFmt* pFmt; const SwFmtAnchor* pAnchor; @@ -258,7 +257,7 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, const SwNodeIndex* pCntntIdx; - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { sal_Bool bInsPos = sal_False; pFmt = (SwFrmFmt*)rFmts[n]; @@ -294,7 +293,7 @@ void _SaveFlyInRange( const SwPaM& rPam, const SwNodeIndex& rInsPos, pFmt, bInsPos ); rArr.push_back( aSave ); pFmt->DelFrms(); - rFmts.Remove( n--, 1 ); + rFmts.erase( rFmts.begin() + n-- ); } } } @@ -308,8 +307,8 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, const sal_Bool bDelFwrd = rMkNdIdx.GetIndex() <= rPtNdIdx.GetIndex(); SwDoc* pDoc = rMkNdIdx.GetNode().GetDoc(); - SwSpzFrmFmts& rTbl = *pDoc->GetSpzFrmFmts(); - for ( sal_uInt16 i = rTbl.Count(); i; ) + SwFrmFmts& rTbl = *pDoc->GetSpzFrmFmts(); + for ( sal_uInt16 i = rTbl.size(); i; ) { SwFrmFmt *pFmt = rTbl[--i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); @@ -339,8 +338,8 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, SwNodeIndex( *rCntnt.GetCntntIdx()-> GetNode().EndOfSectionNode() )); // Position could have been moved! - if( i > rTbl.Count() ) - i = rTbl.Count(); + if( i > rTbl.size() ) + i = rTbl.size(); else if( pFmt != rTbl[i] ) i = rTbl.GetPos( pFmt ); } @@ -348,8 +347,8 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx, pDoc->DelLayoutFmt( pFmt ); // DelLayoutFmt can also trigger the deletion of objects. - if( i > rTbl.Count() ) - i = rTbl.Count(); + if( i > rTbl.size() ) + i = rTbl.size(); } } } @@ -1158,7 +1157,7 @@ bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos, // Save the paragraph-bound Flys, so that they can be moved. _SaveFlyArr aSaveFlyArr; - if( GetSpzFrmFmts()->Count() ) + if( !GetSpzFrmFmts()->empty() ) _SaveFlyInRange( rRange, aSaveFlyArr ); // Set it to before the Position, so that it cannot be moved further. @@ -2596,7 +2595,7 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) // What's with Flys? { // If there are FlyFrames left, delete these too - for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->size(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 44b47a7a17fc..559bac2d05d8 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1691,7 +1691,7 @@ void SwDoc::GetAllUsedDB( std::vector<String>& rDBNameList, } SwSectionFmts& rArr = GetSections(); - for (sal_uInt16 n = rArr.Count(); n; ) + for (sal_uInt16 n = rArr.size(); n; ) { SwSection* pSect = rArr[ --n ]->GetSection(); @@ -1844,7 +1844,7 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, String sFormel; SwSectionFmts& rArr = GetSections(); - for (sal_uInt16 n = rArr.Count(); n; ) + for (sal_uInt16 n = rArr.size(); n; ) { SwSection* pSect = rArr[ --n ]->GetSection(); @@ -2234,7 +2234,7 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) sal_uInt16 nArrStt = 0; sal_uLong nSttCntnt = rDoc.GetNodes().GetEndOfExtras().GetIndex(); - for (sal_uInt16 n = rArr.Count(); n; ) + for (sal_uInt16 n = rArr.size(); n; ) { SwSection* pSect = rArr[ --n ]->GetSection(); if( pSect && pSect->IsHidden() && pSect->GetCondition().Len() && diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 388f11d0f89e..f57fcecc7008 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -73,8 +73,8 @@ using namespace ::com::sun::star; sal_uInt16 SwDoc::GetFlyCount( FlyCntType eType ) const { - const SwSpzFrmFmts& rFmts = *GetSpzFrmFmts(); - sal_uInt16 nSize = rFmts.Count(); + const SwFrmFmts& rFmts = *GetSpzFrmFmts(); + sal_uInt16 nSize = rFmts.size(); sal_uInt16 nCount = 0; const SwNodeIndex* pIdx; for ( sal_uInt16 i = 0; i < nSize; i++) @@ -115,9 +115,9 @@ sal_uInt16 SwDoc::GetFlyCount( FlyCntType eType ) const // If you change this, also update SwXFrameEnumeration in unocoll. SwFrmFmt* SwDoc::GetFlyNum( sal_uInt16 nIdx, FlyCntType eType ) { - SwSpzFrmFmts& rFmts = *GetSpzFrmFmts(); + SwFrmFmts& rFmts = *GetSpzFrmFmts(); SwFrmFmt* pRetFmt = 0; - sal_uInt16 nSize = rFmts.Count(); + sal_uInt16 nSize = rFmts.size(); const SwNodeIndex* pIdx; sal_uInt16 nCount = 0; for( sal_uInt16 i = 0; !pRetFmt && i < nSize; ++i ) @@ -886,7 +886,7 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) pTxtNd->GetTxt().Len() ) return SW_CHAIN_NOT_EMPTY; - sal_uInt16 nArrLen = GetSpzFrmFmts()->Count(); + sal_uInt16 nArrLen = GetSpzFrmFmts()->size(); for( sal_uInt16 n = 0; n < nArrLen; ++n ) { const SwFmtAnchor& rAnchor = (*GetSpzFrmFmts())[ n ]->GetAnchor(); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index eeefa153a4c5..73df01b596e9 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -80,24 +80,16 @@ using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; -SV_IMPL_PTRARR(SwFrmFmts,SwFrmFmtPtr) -SV_IMPL_PTRARR(SwCharFmts,SwCharFmtPtr) - -// Specific frame formats (frames) -SV_IMPL_PTRARR(SwSpzFrmFmts,SwFrmFmtPtr) - /* * Internal functions */ -sal_Bool SetTxtFmtCollNext( const SwTxtFmtCollPtr& rpTxtColl, void* pArgs ) +static void SetTxtFmtCollNext( SwTxtFmtColl* pTxtColl, const SwTxtFmtColl* pDel ) { - SwTxtFmtColl *pDel = (SwTxtFmtColl*) pArgs; - if ( &rpTxtColl->GetNextTxtFmtColl() == pDel ) + if ( &pTxtColl->GetNextTxtFmtColl() == pDel ) { - rpTxtColl->SetNextTxtFmtColl( *rpTxtColl ); + pTxtColl->SetNextTxtFmtColl( *pTxtColl ); } - return sal_True; } /* @@ -1313,7 +1305,8 @@ void SwDoc::DelCharFmt(sal_uInt16 nFmt, sal_Bool bBroadcast) GetIDocumentUndoRedo().AppendUndo(pUndo); } - pCharFmtTbl->DeleteAndDestroy(nFmt); + delete (*pCharFmtTbl)[nFmt]; + pCharFmtTbl->erase(pCharFmtTbl->begin() + nFmt); SetModified(); } @@ -1322,7 +1315,6 @@ void SwDoc::DelCharFmt( SwCharFmt *pFmt, sal_Bool bBroadcast ) { sal_uInt16 nFmt = pCharFmtTbl->GetPos( pFmt ); OSL_ENSURE( USHRT_MAX != nFmt, "Fmt not found," ); - DelCharFmt( nFmt, bBroadcast ); } @@ -1338,8 +1330,8 @@ void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, sal_Bool bBroadcast ) { // The format has to be in the one or the other, we'll see in which one. - sal_uInt16 nPos; - if ( USHRT_MAX != ( nPos = pFrmFmtTbl->GetPos( pFmt )) ) + SwFrmFmts::iterator it = std::find( pFrmFmtTbl->begin(), pFrmFmtTbl->end(), pFmt ); + if ( it != pFrmFmtTbl->end() ) { if (bBroadcast) BroadcastStyleOperation(pFmt->GetName(), @@ -1353,23 +1345,28 @@ void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, sal_Bool bBroadcast ) GetIDocumentUndoRedo().AppendUndo(pUndo); } - pFrmFmtTbl->DeleteAndDestroy( nPos ); + delete *it; + pFrmFmtTbl->erase(it); } else { - nPos = GetSpzFrmFmts()->GetPos( pFmt ); - OSL_ENSURE( nPos != USHRT_MAX, "FrmFmt not found." ); - if( USHRT_MAX != nPos ) - GetSpzFrmFmts()->DeleteAndDestroy( nPos ); + SwFrmFmts::iterator it2 = std::find( GetSpzFrmFmts()->begin(), GetSpzFrmFmts()->end(), pFmt ); + OSL_ENSURE( it2 != GetSpzFrmFmts()->end(), "FrmFmt not found." ); + if( it2 != GetSpzFrmFmts()->end() ) + { + delete *it2; + GetSpzFrmFmts()->erase( it2 ); + } } } } void SwDoc::DelTblFrmFmt( SwTableFmt *pFmt ) { - sal_uInt16 nPos = pTblFrmFmtTbl->GetPos( pFmt ); - OSL_ENSURE( USHRT_MAX != nPos, "Fmt not found," ); - pTblFrmFmtTbl->DeleteAndDestroy( nPos ); + SwFrmFmts::iterator it = std::find( pTblFrmFmtTbl->begin(), pTblFrmFmtTbl->end(), pFmt ); + OSL_ENSURE( it != pTblFrmFmtTbl->end(), "Fmt not found," ); + delete *it; + pTblFrmFmtTbl->erase(it); } /* @@ -1379,7 +1376,7 @@ SwFlyFrmFmt *SwDoc::MakeFlyFrmFmt( const String &rFmtName, SwFrmFmt *pDerivedFrom ) { SwFlyFrmFmt *pFmt = new SwFlyFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom ); - GetSpzFrmFmts()->Insert(pFmt, GetSpzFrmFmts()->Count()); + GetSpzFrmFmts()->push_back(pFmt); SetModified(); return pFmt; } @@ -1388,7 +1385,7 @@ SwDrawFrmFmt *SwDoc::MakeDrawFrmFmt( const String &rFmtName, SwFrmFmt *pDerivedFrom ) { SwDrawFrmFmt *pFmt = new SwDrawFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom); - GetSpzFrmFmts()->Insert(pFmt,GetSpzFrmFmts()->Count()); + GetSpzFrmFmts()->push_back(pFmt); SetModified(); return pFmt; } @@ -1396,14 +1393,13 @@ SwDrawFrmFmt *SwDoc::MakeDrawFrmFmt( const String &rFmtName, sal_uInt16 SwDoc::GetTblFrmFmtCount(sal_Bool bUsed) const { - sal_uInt16 nCount = pTblFrmFmtTbl->Count(); + sal_uInt16 nCount = pTblFrmFmtTbl->size(); if(bUsed) { SwAutoFmtGetDocNode aGetHt( &GetNodes() ); for ( sal_uInt16 i = nCount; i; ) { if((*pTblFrmFmtTbl)[--i]->GetInfo( aGetHt )) - --nCount; } } @@ -1433,7 +1429,7 @@ SwTableFmt* SwDoc::MakeTblFrmFmt( const String &rFmtName, SwFrmFmt *pDerivedFrom ) { SwTableFmt* pFmt = new SwTableFmt( GetAttrPool(), rFmtName, pDerivedFrom ); - pTblFrmFmtTbl->Insert( pFmt, pTblFrmFmtTbl->Count() ); + pTblFrmFmtTbl->push_back( pFmt ); SetModified(); return pFmt; @@ -1447,7 +1443,7 @@ SwFrmFmt *SwDoc::MakeFrmFmt(const String &rFmtName, SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), rFmtName, pDerivedFrom ); pFmt->SetAuto(bAuto); - pFrmFmtTbl->Insert( pFmt, pFrmFmtTbl->Count()); + pFrmFmtTbl->push_back( pFmt ); SetModified(); if (bBroadcast) @@ -1483,7 +1479,7 @@ SwCharFmt *SwDoc::MakeCharFmt( const String &rFmtName, sal_Bool ) { SwCharFmt *pFmt = new SwCharFmt( GetAttrPool(), rFmtName, pDerivedFrom ); - pCharFmtTbl->Insert( pFmt, pCharFmtTbl->Count() ); + pCharFmtTbl->push_back( pFmt ); pFmt->SetAuto( sal_False ); SetModified(); @@ -1525,7 +1521,7 @@ SwTxtFmtColl* SwDoc::MakeTxtFmtColl( const String &rFmtName, { SwTxtFmtColl *pFmtColl = new SwTxtFmtColl( GetAttrPool(), rFmtName, pDerivedFrom ); - pTxtFmtCollTbl->Insert(pFmtColl, pTxtFmtCollTbl->Count()); + pTxtFmtCollTbl->push_back(pFmtColl); pFmtColl->SetAuto( sal_False ); SetModified(); @@ -1560,7 +1556,7 @@ SwConditionTxtFmtColl* SwDoc::MakeCondTxtFmtColl( const String &rFmtName, { SwConditionTxtFmtColl*pFmtColl = new SwConditionTxtFmtColl( GetAttrPool(), rFmtName, pDerivedFrom ); - pTxtFmtCollTbl->Insert(pFmtColl, pTxtFmtCollTbl->Count()); + pTxtFmtCollTbl->push_back(pFmtColl); pFmtColl->SetAuto( sal_False ); SetModified(); @@ -1579,7 +1575,7 @@ SwGrfFmtColl* SwDoc::MakeGrfFmtColl( const String &rFmtName, { SwGrfFmtColl *pFmtColl = new SwGrfFmtColl( GetAttrPool(), rFmtName, pDerivedFrom ); - pGrfFmtCollTbl->Insert( pFmtColl, pGrfFmtCollTbl->Count() ); + pGrfFmtCollTbl->push_back( pFmtColl ); pFmtColl->SetAuto( sal_False ); SetModified(); return pFmtColl; @@ -1607,10 +1603,10 @@ void SwDoc::DelTxtFmtColl(sal_uInt16 nFmtColl, sal_Bool bBroadcast) } // Remove the FmtColl - pTxtFmtCollTbl->Remove(nFmtColl); + pTxtFmtCollTbl->erase(pTxtFmtCollTbl->begin() + nFmtColl); // Correct next - pTxtFmtCollTbl->ForEach( 1, pTxtFmtCollTbl->Count(), - &SetTxtFmtCollNext, pDel ); + for( SwTxtFmtColls::const_iterator it = pTxtFmtCollTbl->begin() + 1; it != pTxtFmtCollTbl->end(); ++it ) + SetTxtFmtCollNext( *it, pDel ); delete pDel; SetModified(); } @@ -1734,17 +1730,17 @@ sal_Bool SwDoc::SetTxtFmtColl( const SwPaM &rRg, // ---- Copy the formats to itself (SwDoc) ---------------------- SwFmt* SwDoc::CopyFmt( const SwFmt& rFmt, - const SvPtrarr& rFmtArr, + const SwFmtsBase& rFmtArr, FNCopyFmt fnCopyFmt, const SwFmt& rDfltFmt ) { // It's no autoformat, default format or collection format, // then search for it. if( !rFmt.IsAuto() || !rFmt.GetRegisteredIn() ) - for( sal_uInt16 n = 0; n < rFmtArr.Count(); n++ ) + for( sal_uInt16 n = 0; n < rFmtArr.GetFmtCount(); n++ ) { // Does the Doc already contain the template? - if( ((SwFmt*)rFmtArr[n])->GetName().Equals( rFmt.GetName() )) - return (SwFmt*)rFmtArr[n]; + if( rFmtArr.GetFmt(n)->GetName().Equals( rFmt.GetName() )) + return (SwFmt*)rFmtArr.GetFmt(n); } // Search for the "parent" first @@ -1805,7 +1801,7 @@ SwTxtFmtColl* SwDoc::CopyTxtColl( const SwTxtFmtColl& rColl ) { pNewColl = new SwConditionTxtFmtColl( GetAttrPool(), rColl.GetName(), pParent); - pTxtFmtCollTbl->Insert( pNewColl, pTxtFmtCollTbl->Count() ); + pTxtFmtCollTbl->push_back( pNewColl ); pNewColl->SetAuto( sal_False ); SetModified(); @@ -1895,8 +1891,8 @@ SwPageDesc* lcl_FindPageDesc( const SwPageDescs& rArr, const String& rName ) return 0; } -void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr, - SvPtrarr& rDestArr, +void SwDoc::CopyFmtArr( const SwFmtsBase& rSourceArr, + SwFmtsBase& rDestArr, FNCopyFmt fnCopyFmt, SwFmt& rDfltFmt ) { @@ -1904,9 +1900,9 @@ void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr, SwFmt* pSrc, *pDest; // 1st step: Create all formats (skip the 0th - it's the default one) - for( nSrc = rSourceArr.Count(); nSrc > 1; ) + for( nSrc = rSourceArr.GetFmtCount(); nSrc > 1; ) { - pSrc = (SwFmt*)rSourceArr[ --nSrc ]; + pSrc = (SwFmt*)rSourceArr.GetFmt( --nSrc ); if( pSrc->IsDefault() || pSrc->IsAuto() ) continue; @@ -1921,9 +1917,9 @@ void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr, } // 2nd step: Copy all attributes, set the right parents - for( nSrc = rSourceArr.Count(); nSrc > 1; ) + for( nSrc = rSourceArr.GetFmtCount(); nSrc > 1; ) { - pSrc = (SwFmt*)rSourceArr[ --nSrc ]; + pSrc = (SwFmt*)rSourceArr.GetFmt( --nSrc ); if( pSrc->IsDefault() || pSrc->IsAuto() ) continue; @@ -2206,16 +2202,16 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles ) SetModified(); } -SwFmt* SwDoc::FindFmtByName( const SvPtrarr& rFmtArr, +SwFmt* SwDoc::FindFmtByName( const SwFmtsBase& rFmtArr, const String& rName ) const { SwFmt* pFnd = 0; - for( sal_uInt16 n = 0; n < rFmtArr.Count(); n++ ) + for( sal_uInt16 n = 0; n < rFmtArr.GetFmtCount(); n++ ) { // Does the Doc already contain the template? - if( ((SwFmt*)rFmtArr[n])->GetName() == rName ) + if( rFmtArr.GetFmt(n)->GetName() == rName ) { - pFnd = (SwFmt*)rFmtArr[n]; + pFnd = (SwFmt*)rFmtArr.GetFmt(n); break; } } @@ -2514,7 +2510,7 @@ namespace docfunc const SwTxtFmtColls* pTxtFmtColls( rDoc.GetTxtFmtColls() ); if ( pTxtFmtColls ) { - const sal_uInt16 nCount = pTxtFmtColls->Count(); + const sal_uInt16 nCount = pTxtFmtColls->size(); for ( sal_uInt16 i = 0; i < nCount; ++i ) { SwTxtFmtColl* pTxtFmtColl = (*pTxtFmtColls)[i]; @@ -2547,4 +2543,40 @@ namespace docfunc } } +SwFmtsBase::~SwFmtsBase() {} + +sal_uInt16 SwFrmFmts::GetPos(const SwFrmFmt* p) const +{ + const_iterator it = std::find(begin(), end(), p); + return it == end() ? USHRT_MAX : it - begin(); +} + +bool SwFrmFmts::Contains(const SwFrmFmt* p) const +{ + return std::find(begin(), end(), p) != end(); +} + +SwFrmFmts::~SwFrmFmts() +{ + for(const_iterator it = begin(); it != end(); ++it) + delete *it; +} + +sal_uInt16 SwCharFmts::GetPos(const SwCharFmt* p) const +{ + const_iterator it = std::find(begin(), end(), p); + return it == end() ? USHRT_MAX : it - begin(); +} + +bool SwCharFmts::Contains(const SwCharFmt* p) const +{ + return std::find(begin(), end(), p) != end(); +} + +SwCharFmts::~SwCharFmts() +{ + for(const_iterator it = begin(); it != end(); ++it) + delete *it; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index d4990827d270..d3a4cf5f5206 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -191,7 +191,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const String& rPath, bool bOutline, c { // Look for the 1st level OutlineTemplate const SwTxtFmtColls& rFmtColls =*GetTxtFmtColls(); - for( sal_uInt16 n = rFmtColls.Count(); n; ) + for( sal_uInt16 n = rFmtColls.size(); n; ) if ( rFmtColls[ --n ]->GetAttrOutlineLevel() == 1 )//<-end,zhaojianwei { pSplitColl = rFmtColls[ n ]; @@ -330,7 +330,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const String& rPath, bool bOutline, c // We need to have a Layout for the HTMLFilter, so that // TextFrames/Controls/OLE objects can be exported correctly as graphics. if( SPLITDOC_TO_HTML == eDocType && - pDoc->GetSpzFrmFmts()->Count() ) + !pDoc->GetSpzFrmFmts()->empty() ) { SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 ); } @@ -377,7 +377,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const String& rPath, bool bOutline, c CorrAbs( aSIdx, aEIdx, *aTmp.GetPoint(), sal_True); // If FlyFrames are still around, delete these too - for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->size(); ++n ) { SwFrmFmt* pFly = (*GetSpzFrmFmts())[n]; const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); @@ -496,8 +496,8 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const String& rPath, bool bOutline, c if( get(IDocumentSettingAccess::GLOBAL_DOCUMENT) ) { // save all remaining sections - while( GetSections().Count() ) - DelSectionFmt( GetSections()[ 0 ] ); + while( !GetSections().empty() ) + DelSectionFmt( GetSections().front() ); SfxFilterContainer* pFCntnr = pDocShell->GetFactory().GetFilterContainer(); pFilter = pFCntnr->GetFilter4EA( pFilter->GetTypeName(), SFX_FILTER_EXPORT ); diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 1b040159eaa0..5dbff900a0ea 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -282,13 +282,13 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) const SwNodeIndex* pCntntIdx = pFmt->GetCntnt().GetCntntIdx(); if ( pCntntIdx ) { - const SwSpzFrmFmts* pTbl = pFmt->GetDoc()->GetSpzFrmFmts(); + const SwFrmFmts* pTbl = pFmt->GetDoc()->GetSpzFrmFmts(); if ( pTbl ) { std::vector<SwFrmFmt*> aToDeleteFrmFmts; const sal_uLong nNodeIdxOfFlyFmt( pCntntIdx->GetIndex() ); - for ( sal_uInt16 i = 0; i < pTbl->Count(); ++i ) + for ( sal_uInt16 i = 0; i < pTbl->size(); ++i ) { SwFrmFmt* pTmpFmt = (*pTbl)[i]; const SwFmtAnchor &rAnch = pTmpFmt->GetAnchor(); @@ -1026,7 +1026,7 @@ void SwDoc::GetAllFlyFmts( SwPosFlyFrms& rPosFlyFmts, SwFrmFmt *pFly; // collect all anchored somehow to paragraphs - for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->size(); ++n ) { pFly = (*GetSpzFrmFmts())[ n ]; bool bDrawFmt = bDrawAlso ? RES_DRAWFRMFMT == pFly->Which() : false; @@ -1175,7 +1175,7 @@ lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, SwTxtFmtColl * pColl = NULL; if( pType ) { - for( sal_uInt16 i = pTxtFmtCollTbl->Count(); i; ) + for( sal_uInt16 i = pTxtFmtCollTbl->size(); i; ) { if( (*pTxtFmtCollTbl)[ --i ]->GetName().Equals(pType->GetName()) ) { @@ -1531,7 +1531,7 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, SwTxtFmtColl *pColl = NULL; if( pType ) { - for( sal_uInt16 i = pTxtFmtCollTbl->Count(); i; ) + for( sal_uInt16 i = pTxtFmtCollTbl->size(); i; ) { if( (*pTxtFmtCollTbl)[ --i ]->GetName().Equals(pType->GetName()) ) { @@ -1941,15 +1941,15 @@ static String lcl_GetUniqueFlyName( const SwDoc* pDoc, sal_uInt16 nDefStrId ) String aName( aId ); xub_StrLen nNmLen = aName.Len(); - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); + const SwFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); - sal_uInt16 nNum, nTmp, nFlagSize = ( rFmts.Count() / 8 ) +2; + sal_uInt16 nNum, nTmp, nFlagSize = ( rFmts.size() / 8 ) +2; sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ]; sal_uInt16 n; memset( pSetFlags, 0, nFlagSize ); - for( n = 0; n < rFmts.Count(); ++n ) + for( n = 0; n < rFmts.size(); ++n ) { const SwFrmFmt* pFlyFmt = rFmts[ n ]; if( RES_FLYFRMFMT == pFlyFmt->Which() && @@ -1957,13 +1957,13 @@ static String lcl_GetUniqueFlyName( const SwDoc* pDoc, sal_uInt16 nDefStrId ) { // Only get and set the Flag nNum = static_cast< sal_uInt16 >( pFlyFmt->GetName().Copy( nNmLen ).ToInt32() ); - if( nNum-- && nNum < rFmts.Count() ) + if( nNum-- && nNum < rFmts.size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } } // All numbers are flagged accordingly, so determine the right one - nNum = rFmts.Count(); + nNum = rFmts.size(); for( n = 0; n < nFlagSize; ++n ) if( 0xff != ( nTmp = pSetFlags[ n ] )) { @@ -1995,8 +1995,8 @@ String SwDoc::GetUniqueFrameName() const const SwFlyFrmFmt* SwDoc::FindFlyByName( const String& rName, sal_Int8 nNdTyp ) const { - const SwSpzFrmFmts& rFmts = *GetSpzFrmFmts(); - for( sal_uInt16 n = rFmts.Count(); n; ) + const SwFrmFmts& rFmts = *GetSpzFrmFmts(); + for( sal_uInt16 n = rFmts.size(); n; ) { const SwFrmFmt* pFlyFmt = rFmts[ --n ]; const SwNodeIndex* pIdx; @@ -2050,13 +2050,14 @@ void SwDoc::SetAllUniqueFlyNames() String sGrfNm( nGrfId ); String sOLENm( nOLEId ); - if( 255 < ( n = GetSpzFrmFmts()->Count() )) + if( 255 < ( n = GetSpzFrmFmts()->size() )) n = 255; - SwSpzFrmFmts aArr( (sal_Int8)n ); - SwFrmFmtPtr pFlyFmt; + SwFrmFmts aArr; + aArr.reserve( (sal_Int8)n ); + SwFrmFmt* pFlyFmt; sal_Bool bLoadedFlag = sal_True; // something for the Layout - for( n = GetSpzFrmFmts()->Count(); n; ) + for( n = GetSpzFrmFmts()->size(); n; ) { if( RES_FLYFRMFMT == (pFlyFmt = (*GetSpzFrmFmts())[ --n ])->Which() ) { @@ -2077,7 +2078,7 @@ void SwDoc::SetAllUniqueFlyNames() } else // we want to set that afterwards - aArr.Insert( pFlyFmt, aArr.Count() ); + aArr.push_back( pFlyFmt ); } if( bLoadedFlag ) @@ -2099,7 +2100,7 @@ void SwDoc::SetAllUniqueFlyNames() const SwNodeIndex* pIdx; - for( n = aArr.Count(); n; ) + for( n = aArr.size(); n; ) if( 0 != ( pIdx = ( pFlyFmt = aArr[ --n ])->GetCntnt().GetCntntIdx() ) && pIdx->GetNode().GetNodes().IsDocNodes() ) { @@ -2122,7 +2123,7 @@ void SwDoc::SetAllUniqueFlyNames() } pFlyFmt->SetName( sNm += String::CreateFromInt32( nNum )); } - aArr.Remove( 0, aArr.Count() ); + aArr.clear(); if( GetFtnIdxs().Count() ) { @@ -2181,7 +2182,7 @@ sal_Bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const { // get up by using the Anchor sal_uInt16 n; - for( n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for( n = 0; n < GetSpzFrmFmts()->size(); ++n ) { const SwFrmFmt* pFmt = (*GetSpzFrmFmts())[ n ]; const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); @@ -2199,7 +2200,7 @@ sal_Bool SwDoc::IsInHeaderFooter( const SwNodeIndex& rIdx ) const break; } } - if( n >= GetSpzFrmFmts()->Count() ) + if( n >= GetSpzFrmFmts()->size() ) { OSL_ENSURE( mbInReading, "Found a FlySection but not a Format!" ); return sal_False; diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 270d6af262a7..e8b60c3e59b4 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -128,9 +128,6 @@ const sal_Char sCharFmtStr[] = "Zeichenformat"; const sal_Char sTxtCollStr[] = "Textformatvorlage"; const sal_Char sGrfCollStr[] = "Graphikformatvorlage"; -SV_IMPL_PTRARR( SwTxtFmtColls, SwTxtFmtCollPtr) -SV_IMPL_PTRARR( SwGrfFmtColls, SwGrfFmtCollPtr) - /* * global functions... */ @@ -192,15 +189,14 @@ void StartGrammarChecking( SwDoc &rDoc ) /* * internal functions */ -sal_Bool lcl_DelFmtIndizes( const SwFrmFmtPtr& rpFmt, void* ) +static void lcl_DelFmtIndizes( SwFmt* pFmt ) { - SwFmtCntnt &rFmtCntnt = (SwFmtCntnt&)rpFmt->GetCntnt(); + SwFmtCntnt &rFmtCntnt = (SwFmtCntnt&)pFmt->GetCntnt(); if ( rFmtCntnt.GetCntntIdx() ) rFmtCntnt.SetNewCntntIdx( 0 ); - SwFmtAnchor &rFmtAnchor = (SwFmtAnchor&)rpFmt->GetAnchor(); + SwFmtAnchor &rFmtAnchor = (SwFmtAnchor&)pFmt->GetAnchor(); if ( rFmtAnchor.GetCntntAnchor() ) rFmtAnchor.SetAnchor( 0 ); - return sal_True; } /* @@ -222,7 +218,7 @@ SwDoc::SwDoc() pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ), pFrmFmtTbl( new SwFrmFmts() ), pCharFmtTbl( new SwCharFmts() ), - pSpzFrmFmtTbl( new SwSpzFrmFmts() ), + pSpzFrmFmtTbl( new SwFrmFmts() ), pSectionFmtTbl( new SwSectionFmts() ), pTblFrmFmtTbl( new SwFrmFmts() ), pTxtFmtCollTbl( new SwTxtFmtColls() ), @@ -376,14 +372,14 @@ SwDoc::SwDoc() * DefaultFormats and are also in the list. */ /* Formats */ - pFrmFmtTbl->Insert(pDfltFrmFmt, 0 ); - pCharFmtTbl->Insert(pDfltCharFmt, 0 ); + pFrmFmtTbl->push_back(pDfltFrmFmt); + pCharFmtTbl->push_back(pDfltCharFmt); /* FmtColls */ // TXT - pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 ); + pTxtFmtCollTbl->push_back(pDfltTxtFmtColl); // GRF - pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 ); + pGrfFmtCollTbl->push_back(pDfltGrfFmtColl); // Create PageDesc, EmptyPageFmt and ColumnFmt if ( aPageDescs.empty() ) @@ -444,6 +440,46 @@ 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) + return; + for( SwTxtFmtColls::const_iterator it = rFmts.begin() + aStartIdx; + it != rFmts.begin() + aEndIdx; ++it ) + delete *it; + rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx); +} + +static void DeleteAndDestroy(SwCharFmts& rFmts, int aStartIdx, int aEndIdx) +{ + if (aEndIdx < aStartIdx) + return; + for( SwCharFmts::const_iterator it = rFmts.begin() + aStartIdx; + it != rFmts.begin() + aEndIdx; ++it ) + delete *it; + rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx); +} + +static void DeleteAndDestroy(SwGrfFmtColls& rFmts, int aStartIdx, int aEndIdx) +{ + if (aEndIdx < aStartIdx) + return; + for( SwGrfFmtColls::const_iterator it = rFmts.begin() + aStartIdx; + it != rFmts.begin() + aEndIdx; ++it ) + delete *it; + rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx); +} + /* * Speciality: a member of the class SwDoc is located at * position 0 in the array of the Format and GDI objects. @@ -559,9 +595,12 @@ SwDoc::~SwDoc() // Any of the FrmFormats can still have indices registered. // These need to be destroyed now at the latest. - pFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this ); - pSpzFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this ); - ((SwFrmFmts&)*pSectionFmtTbl).ForEach( &lcl_DelFmtIndizes, this ); + BOOST_FOREACH( SwFrmFmt* pFmt, *pFrmFmtTbl ) + lcl_DelFmtIndizes( pFmt ); + BOOST_FOREACH( SwFrmFmt* pFmt, *pSpzFrmFmtTbl ) + lcl_DelFmtIndizes( pFmt ); + BOOST_FOREACH( SwSectionFmt* pFmt, *pSectionFmtTbl ) + lcl_DelFmtIndizes( pFmt ); // The formattings that come hereafter depend on the default formattings. // [Destroy] these only after destroying the FmtIndices, because the content @@ -592,15 +631,15 @@ SwDoc::~SwDoc() // Optimization: Based on the fact that Standard is always 2nd in the // array, we should delete it as the last. With this we avoid // remangling the Formats all the time! - if( 2 < pTxtFmtCollTbl->Count() ) - pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 ); - pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 ); + if( 2 < pTxtFmtCollTbl->size() ) + DeleteAndDestroy( *pTxtFmtCollTbl, 2, pTxtFmtCollTbl->size()-2 ); + DeleteAndDestroy( *pTxtFmtCollTbl, 1, pTxtFmtCollTbl->size()-1 ); delete pTxtFmtCollTbl; OSL_ENSURE( pDfltGrfFmtColl == (*pGrfFmtCollTbl)[0], "DefaultGrfCollection must always be at the start" ); - pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 ); + DeleteAndDestroy( *pGrfFmtCollTbl, 1, pGrfFmtCollTbl->size()-1 ); // Is the result anyway - no _DEL array! // pGrfFmtCollTbl->Remove( 0, n ); delete pGrfFmtCollTbl; @@ -611,8 +650,8 @@ SwDoc::~SwDoc() * In order to not be deleted by the array's dtor, we remove them * now. */ - pFrmFmtTbl->Remove( 0 ); - pCharFmtTbl->Remove( 0 ); + pFrmFmtTbl->erase( pFrmFmtTbl->begin() ); + pCharFmtTbl->erase( pCharFmtTbl->begin() ); // Delete for pPrt DELETEZ( pPrt ); @@ -621,7 +660,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. - pSpzFrmFmtTbl->DeleteAndDestroy( 0, pSpzFrmFmtTbl->Count() ); + DeleteAndDestroy( *pSpzFrmFmtTbl, 0, pSpzFrmFmtTbl->size() ); // Only now destroy the Model, the drawing objects - which are also // contained in the Undo - need to remove their attributes from the @@ -771,7 +810,7 @@ void SwDoc::ClearDoc() // if there are still FlyFrames dangling around, delete them too sal_uInt16 n; - while ( 0 != (n = GetSpzFrmFmts()->Count()) ) + while ( 0 != (n = GetSpzFrmFmts()->size()) ) DelLayoutFmt((*pSpzFrmFmtTbl)[n-1]); OSL_ENSURE( !pDrawModel || !pDrawModel->GetPage(0)->GetObjCount(), "not all DrawObjects removed from the page" ); @@ -836,21 +875,21 @@ void SwDoc::ClearDoc() // Optimization: Based on the fact that Standard is always 2nd in the // array, we should delete it as the last. With this we avoid // remangling the Formats all the time! - if( 2 < pTxtFmtCollTbl->Count() ) - pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 ); - pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 ); - pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 ); - pCharFmtTbl->DeleteAndDestroy( 1, pCharFmtTbl->Count()-1 ); + if( 2 < pTxtFmtCollTbl->size() ) + DeleteAndDestroy( *pTxtFmtCollTbl, 2, pTxtFmtCollTbl->size()-2 ); + DeleteAndDestroy( *pTxtFmtCollTbl, 1, pTxtFmtCollTbl->size()-1 ); + DeleteAndDestroy( *pGrfFmtCollTbl, 1, pGrfFmtCollTbl->size()-1 ); + DeleteAndDestroy( *pCharFmtTbl, 1, pCharFmtTbl->size()-1 ); if( pCurrentView ) { // search the FrameFormat of the root frm. This is not allowed to delete - pFrmFmtTbl->Remove( pFrmFmtTbl->GetPos( pCurrentView->GetLayout()->GetFmt() ) ); - pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 ); - pFrmFmtTbl->Insert( pCurrentView->GetLayout()->GetFmt(), pFrmFmtTbl->Count() ); + pFrmFmtTbl->erase( std::find( pFrmFmtTbl->begin(), pFrmFmtTbl->end(), pCurrentView->GetLayout()->GetFmt() ) ); + DeleteAndDestroy( *pFrmFmtTbl, 1, pFrmFmtTbl->size()-1 ); + pFrmFmtTbl->push_back( pCurrentView->GetLayout()->GetFmt() ); } else //swmod 071029//swmod 071225 - pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 ); + DeleteAndDestroy( *pFrmFmtTbl, 1, pFrmFmtTbl->size()-1 ); xForbiddenCharsTable.clear(); @@ -1208,9 +1247,9 @@ void SwDoc::Paste( const SwDoc& rSource ) this->DelFullPara(aPara); } //additionally copy page bound frames - if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() ) + if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->size() ) { - for ( sal_uInt16 i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i ) + for ( sal_uInt16 i = 0; i < rSource.GetSpzFrmFmts()->size(); ++i ) { sal_Bool bInsWithFmt = sal_True; const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i]; @@ -1235,4 +1274,22 @@ void SwDoc::Paste( const SwDoc& rSource ) UpdateFlds(NULL, false); } +sal_uInt16 SwTxtFmtColls::GetPos(const SwTxtFmtColl* p) const +{ + const_iterator it = std::find(begin(), end(), p); + return it == end() ? USHRT_MAX : it - begin(); +} + +bool SwTxtFmtColls::Contains(const SwTxtFmtColl* p) const +{ + return std::find(begin(), end(), p) != end(); +} + +sal_uInt16 SwGrfFmtColls::GetPos(const SwGrfFmtColl* p) const +{ + const_iterator it = std::find(begin(), end(), p); + return it == end() ? USHRT_MAX : it - begin(); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 7caae4dd4ad7..5ba43b4071ee 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -156,7 +156,7 @@ void SwDoc::SetOutlineNumRule( const SwNumRule& rRule ) void SwDoc::PropagateOutlineRule() { - for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->Count(); n++) + for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->size(); n++) { SwTxtFmtColl *pColl = (*pTxtFmtCollTbl)[n]; @@ -211,7 +211,7 @@ sal_Bool SwDoc::OutlineUpDown( const SwPaM& rPam, short nOffset ) SwTxtFmtColl* aCollArr[ MAXLEVEL ]; memset( aCollArr, 0, sizeof( SwTxtFmtColl* ) * MAXLEVEL ); - for( n = 0; n < pTxtFmtCollTbl->Count(); ++n ) + for( n = 0; n < pTxtFmtCollTbl->size(); ++n ) { if((*pTxtFmtCollTbl)[ n ]->IsAssignedToListLevelOfOutlineStyle()) { diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 7f31f84d5ee5..29284de06325 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -312,7 +312,7 @@ sal_Bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End(); // Set index to the Selection's start - for ( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n ) + for ( sal_uInt16 n = 0; n < GetSpzFrmFmts()->size(); ++n ) { SwFrmFmt *const pFmt = static_cast<SwFrmFmt*>((*GetSpzFrmFmts())[n]); SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 11488d743e5c..ffeb89cdcc4b 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -641,11 +641,11 @@ String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, sal_uInt16 nNum = 0; sal_uInt16 nTmp = 0; - sal_uInt16 nFlagSize = ( pSectionFmtTbl->Count() / 8 ) +2; + sal_uInt16 nFlagSize = ( pSectionFmtTbl->size() / 8 ) +2; sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ]; memset( pSetFlags, 0, nFlagSize ); - for( n = 0; n < pSectionFmtTbl->Count(); ++n ) + for( n = 0; n < pSectionFmtTbl->size(); ++n ) if( 0 != ( pSectNd = (*pSectionFmtTbl)[ n ]->GetSectionNode( sal_False ) )&& TOX_CONTENT_SECTION == (pSect = &pSectNd->GetSection())->GetType()) { @@ -654,7 +654,7 @@ String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, { // Calculate number and set the Flag nNum = (sal_uInt16)rNm.Copy( nNmLen ).ToInt32(); - if( nNum-- && nNum < pSectionFmtTbl->Count() ) + if( nNum-- && nNum < pSectionFmtTbl->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } if( pChkStr && pChkStr->Equals( rNm ) ) @@ -664,7 +664,7 @@ String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType, if( !pChkStr ) { // All Numbers have been flagged accordingly, so get the right Number - nNum = pSectionFmtTbl->Count(); + nNum = pSectionFmtTbl->size(); for( n = 0; n < nFlagSize; ++n ) if( 0xff != ( nTmp = pSetFlags[ n ] )) { @@ -1513,7 +1513,7 @@ void SwTOXBaseSection::UpdateTable( const SwTxtNode* pOwnChapterNode ) SwNodes& rNds = pDoc->GetNodes(); const SwFrmFmts& rArr = *pDoc->GetTblFrmFmts(); - for( sal_uInt16 n = 0; n < rArr.Count(); ++n ) + for( sal_uInt16 n = 0; n < rArr.size(); ++n ) { ::SetProgressState( 0, pDoc->GetDocShell() ); diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 484b9778adf7..e781cc80b9a1 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -842,7 +842,7 @@ SwNumRule& SwNumRule::CopyNumRule( SwDoc* pDoc, const SwNumRule& rNumRule ) { Set( n, rNumRule.aFmts[ n ] ); if( aFmts[ n ] && aFmts[ n ]->GetCharFmt() && - USHRT_MAX == pDoc->GetCharFmts()->GetPos( aFmts[n]->GetCharFmt() )) + !pDoc->GetCharFmts()->Contains( aFmts[n]->GetCharFmt() )) // If we copy across different Documents, then copy the // corresponding CharFormat into the new Document. aFmts[n]->SetCharFmt( pDoc->CopyCharFmt( *aFmts[n]-> diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index 467bb384f692..c0f2cafd376d 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -325,7 +325,7 @@ SwTxtFmtColl* SwDoc::GetTxtCollFromPool( sal_uInt16 nId, bool bRegardLanguage ) SwTxtFmtColl* pNewColl; sal_uInt16 nOutLvlBits = 0; - for( sal_uInt16 n = 0; n < pTxtFmtCollTbl->Count(); ++n ) + for( sal_uInt16 n = 0; n < pTxtFmtCollTbl->size(); ++n ) { if( nId == ( pNewColl = (*pTxtFmtCollTbl)[ n ] )->GetPoolFmtId() ) { @@ -375,7 +375,7 @@ SwTxtFmtColl* SwDoc::GetTxtCollFromPool( sal_uInt16 nId, bool bRegardLanguage ) ? pDfltTxtFmtColl : GetTxtCollFromPool( nParent )); pNewColl->SetPoolFmtId( nId ); - pTxtFmtCollTbl->Insert( pNewColl, pTxtFmtCollTbl->Count() ); + pTxtFmtCollTbl->push_back( pNewColl ); } switch( nId ) @@ -1060,7 +1060,7 @@ bool SwDoc::IsPoolTxtCollUsed( sal_uInt16 nId ) const SwTxtFmtColl* pNewColl = 0; sal_Bool bFnd = sal_False; - for( sal_uInt16 n = 0; !bFnd && n < pTxtFmtCollTbl->Count(); ++n ) + for( sal_uInt16 n = 0; !bFnd && n < pTxtFmtCollTbl->size(); ++n ) { pNewColl = (*pTxtFmtCollTbl)[ n ]; if( nId == pNewColl->GetPoolFmtId() ) @@ -1081,7 +1081,7 @@ SwFmt* SwDoc::GetFmtFromPool( sal_uInt16 nId ) SwFmt *pNewFmt = 0; SwFmt *pDeriveFmt = 0; - SvPtrarr* pArray[ 2 ]; + SwFmtsBase* pArray[ 2 ]; sal_uInt16 nArrCnt = 1, nRCId = 0; sal_uInt16* pWhichRange = 0; @@ -1134,8 +1134,8 @@ SwFmt* SwDoc::GetFmtFromPool( sal_uInt16 nId ) OSL_ENSURE( nRCId, "invalid Id" ); while( nArrCnt-- ) - for( sal_uInt16 n = 0; n < (*pArray[nArrCnt]).Count(); ++n ) - if( nId == ( pNewFmt = (SwFmt*)(*pArray[ nArrCnt ] )[ n ] )-> + for( sal_uInt16 n = 0; n < (*pArray[nArrCnt]).GetFmtCount(); ++n ) + if( nId == ( pNewFmt = (*pArray[ nArrCnt ] ).GetFmt( n ) )-> GetPoolFmtId() ) { return pNewFmt; @@ -1369,7 +1369,7 @@ SwCharFmt* SwDoc::GetCharFmtFromPool( sal_uInt16 nId ) bool SwDoc::IsPoolFmtUsed( sal_uInt16 nId ) const { SwFmt *pNewFmt = 0; - const SvPtrarr* pArray[ 2 ]; + const SwFmtsBase* pArray[ 2 ]; sal_uInt16 nArrCnt = 1; sal_Bool bFnd = sal_True; @@ -1393,8 +1393,8 @@ bool SwDoc::IsPoolFmtUsed( sal_uInt16 nId ) const { bFnd = sal_False; while( nArrCnt-- && !bFnd ) - for( sal_uInt16 n = 0; !bFnd && n < (*pArray[nArrCnt]).Count(); ++n ) - if( nId == ( pNewFmt = (SwFmt*)(*pArray[ nArrCnt ] )[ n ] )-> + for( sal_uInt16 n = 0; !bFnd && n < (*pArray[nArrCnt]).GetFmtCount(); ++n ) + if( nId == ( pNewFmt = (*pArray[ nArrCnt ] ).GetFmt( n ) )-> GetPoolFmtId() ) bFnd = sal_True; } diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 7f6cbf0d5e78..582370dca267 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -570,7 +570,7 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, } // If we still have FlyFrames hanging around, delete them too - for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n ) { SwFrmFmt *const pFly = (*pDoc->GetSpzFrmFmts())[n]; SwFmtAnchor const*const pAnchor = &pFly->GetAnchor(); diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index a698cd6a2e1c..c94534c1fecc 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -434,7 +434,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const if( !pDoc->IsCopyIsMove() ) { const SwFrmFmts& rTblFmts = *pDoc->GetTblFrmFmts(); - for( sal_uInt16 n = rTblFmts.Count(); n; ) + for( sal_uInt16 n = rTblFmts.size(); n; ) if( rTblFmts[ --n ]->GetName() == sTblName ) { sTblName = pDoc->GetUniqueTblName(); @@ -543,9 +543,9 @@ void SwTxtNode::CopyCollFmt( SwTxtNode& rDestNd ) sal_Bool lcl_ChkFlyFly( SwDoc* pDoc, sal_uLong nSttNd, sal_uLong nEndNd, sal_uLong nInsNd ) { - const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); + const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - for( sal_uInt16 n = 0; n < rFrmFmtTbl.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n ) { SwFrmFmt const*const pFmt = rFrmFmtTbl[n]; SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); @@ -1402,7 +1402,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, // beibehalten. SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); ::std::set< _ZSortFly > aSet; - sal_uInt16 nArrLen = GetSpzFrmFmts()->Count(); + sal_uInt16 nArrLen = GetSpzFrmFmts()->size(); for ( sal_uInt16 n = 0; n < nArrLen; ++n ) { diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 4666c0515d47..12c59d7676cc 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -516,17 +516,17 @@ SwSectionFmt* SwDoc::MakeSectionFmt( SwSectionFmt *pDerivedFrom ) if( !pDerivedFrom ) pDerivedFrom = (SwSectionFmt*)pDfltFrmFmt; SwSectionFmt* pNew = new SwSectionFmt( pDerivedFrom, this ); - pSectionFmtTbl->Insert( pNew, pSectionFmtTbl->Count() ); + pSectionFmtTbl->push_back( pNew ); return pNew; } void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, sal_Bool bDelNodes ) { - sal_uInt16 nPos = pSectionFmtTbl->GetPos( pFmt ); + SwSectionFmts::iterator itFmtPos = std::find( pSectionFmtTbl->begin(), pSectionFmtTbl->end(), pFmt ); GetIDocumentUndoRedo().StartUndo(UNDO_DELSECTION, NULL); - if( USHRT_MAX != nPos ) + if( pSectionFmtTbl->end() != itFmtPos ) { const SwNodeIndex* pIdx = pFmt->GetCntnt( sal_False ).GetCntntIdx(); const SfxPoolItem* pFtnEndAtTxtEnd; @@ -575,12 +575,12 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, sal_Bool bDelNodes ) // A ClearRedo could result in a rekursive call of this function and delete some section // formats => the position iside the SectionFmtTbl could have changed - nPos = pSectionFmtTbl->GetPos( pFmt ); + itFmtPos = std::find( pSectionFmtTbl->begin(), pSectionFmtTbl->end(), pFmt ); // ACHTUNG: erst aus dem Array entfernen und dann loeschen. // Der Section-DTOR versucht selbst noch sein Format // zu loeschen! - pSectionFmtTbl->Remove( nPos ); + pSectionFmtTbl->erase( itFmtPos ); //FEATURE::CONDCOLL sal_uLong nCnt = 0, nSttNd = 0; if( pIdx && &GetNodes() == &pIdx->GetNodes() && @@ -1426,14 +1426,14 @@ String SwDoc::GetUniqueSectionName( const String* pChkStr ) const xub_StrLen nNmLen = aName.Len(); sal_uInt16 nNum = 0; - sal_uInt16 nTmp, nFlagSize = ( pSectionFmtTbl->Count() / 8 ) +2; + sal_uInt16 nTmp, nFlagSize = ( pSectionFmtTbl->size() / 8 ) +2; sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ]; memset( pSetFlags, 0, nFlagSize ); const SwSectionNode* pSectNd; sal_uInt16 n; - for( n = 0; n < pSectionFmtTbl->Count(); ++n ) + for( n = 0; n < pSectionFmtTbl->size(); ++n ) if( 0 != ( pSectNd = (*pSectionFmtTbl)[ n ]->GetSectionNode( sal_False ) )) { const String& rNm = pSectNd->GetSection().GetSectionName(); @@ -1441,7 +1441,7 @@ String SwDoc::GetUniqueSectionName( const String* pChkStr ) const { // Nummer bestimmen und das Flag setzen nNum = static_cast<sal_uInt16>(rNm.Copy( nNmLen ).ToInt32()); - if( nNum-- && nNum < pSectionFmtTbl->Count() ) + if( nNum-- && nNum < pSectionFmtTbl->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } if( pChkStr && pChkStr->Equals( rNm ) ) @@ -1451,7 +1451,7 @@ String SwDoc::GetUniqueSectionName( const String* pChkStr ) const if( !pChkStr ) { // alle Nummern entsprechend geflag, also bestimme die richtige Nummer - nNum = pSectionFmtTbl->Count(); + nNum = pSectionFmtTbl->size(); for( n = 0; n < nFlagSize; ++n ) if( 0xff != ( nTmp = pSetFlags[ n ] )) { diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index a6efdba97ea6..5822c63010e4 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1640,8 +1640,8 @@ sal_Bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // #i28006# Fly frames have to be restored even if the table was // #alone in the section - const SwSpzFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts(); - for( sal_uInt16 n = 0; n < rFlyArr.Count(); ++n ) + const SwFrmFmts& rFlyArr = *GetDoc()->GetSpzFrmFmts(); + for( sal_uInt16 n = 0; n < rFlyArr.size(); ++n ) { SwFrmFmt *const pFmt = (SwFrmFmt*)rFlyArr[n]; const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); @@ -3886,13 +3886,13 @@ String SwDoc::GetUniqueTblName() const String aName( aId ); xub_StrLen nNmLen = aName.Len(); - sal_uInt16 nNum, nTmp, nFlagSize = ( pTblFrmFmtTbl->Count() / 8 ) +2; + sal_uInt16 nNum, nTmp, nFlagSize = ( pTblFrmFmtTbl->size() / 8 ) +2; sal_uInt16 n; sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ]; memset( pSetFlags, 0, nFlagSize ); - for( n = 0; n < pTblFrmFmtTbl->Count(); ++n ) + for( n = 0; n < pTblFrmFmtTbl->size(); ++n ) { const SwFrmFmt* pFmt = (*pTblFrmFmtTbl)[ n ]; if( !pFmt->IsDefault() && IsUsed( *pFmt ) && @@ -3900,13 +3900,13 @@ String SwDoc::GetUniqueTblName() const { // Nummer bestimmen und das Flag setzen nNum = static_cast<sal_uInt16>(pFmt->GetName().Copy( nNmLen ).ToInt32()); - if( nNum-- && nNum < pTblFrmFmtTbl->Count() ) + if( nNum-- && nNum < pTblFrmFmtTbl->size() ) pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } } // alle Nummern entsprechend geflag, also bestimme die richtige Nummer - nNum = pTblFrmFmtTbl->Count(); + nNum = pTblFrmFmtTbl->size(); for( n = 0; n < nFlagSize; ++n ) if( 0xff != ( nTmp = pSetFlags[ n ] )) { @@ -3925,11 +3925,11 @@ SwTableFmt* SwDoc::FindTblFmtByName( const String& rName, sal_Bool bAll ) const { const SwFmt* pRet = 0; if( bAll ) - pRet = FindFmtByName( (SvPtrarr&)*pTblFrmFmtTbl, rName ); + pRet = FindFmtByName( *pTblFrmFmtTbl, rName ); else { // dann nur die, die im Doc gesetzt sind - for( sal_uInt16 n = 0; n < pTblFrmFmtTbl->Count(); ++n ) + for( sal_uInt16 n = 0; n < pTblFrmFmtTbl->size(); ++n ) { const SwFrmFmt* pFmt = (*pTblFrmFmtTbl)[ n ]; if( !pFmt->IsDefault() && IsUsed( *pFmt ) && @@ -4507,7 +4507,7 @@ sal_Bool SwDoc::UnProtectTbls( const SwPaM& rPam ) SwFrmFmts& rFmts = *GetTblFrmFmts(); SwTable* pTbl; const SwTableNode* pTblNd; - for( sal_uInt16 n = rFmts.Count(); n ; ) + for( sal_uInt16 n = rFmts.size(); n ; ) if( 0 != (pTbl = SwTable::FindTable( rFmts[ --n ] )) && 0 != (pTblNd = pTbl->GetTableNode() ) && pTblNd->GetNodes().IsDocNodes() ) diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index f79573203267..86200b8a2f0f 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -558,10 +558,10 @@ const SwPageDesc* SwNode::FindPageDesc( sal_Bool bCalcLay, { // dann erstmal den richtigen Anker finden const SwFrmFmt* pFmt = 0; - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); + const SwFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); sal_uInt16 n; - for( n = 0; n < rFmts.Count(); ++n ) + for( n = 0; n < rFmts.size(); ++n ) { SwFrmFmt* pFrmFmt = rFmts[ n ]; const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); @@ -584,7 +584,7 @@ const SwPageDesc* SwNode::FindPageDesc( sal_Bool bCalcLay, while( pFlyNd ) { // dann ueber den Anker nach oben "hangeln" - for( n = 0; n < rFmts.Count(); ++n ) + for( n = 0; n < rFmts.size(); ++n ) { const SwFrmFmt* pFrmFmt = rFmts[ n ]; const SwNodeIndex* pIdx = pFrmFmt->GetCntnt(). @@ -610,7 +610,7 @@ const SwPageDesc* SwNode::FindPageDesc( sal_Bool bCalcLay, break; } } - if( n >= rFmts.Count() ) + if( n >= rFmts.size() ) { OSL_ENSURE( !this, "Fly-Section aber kein Format gefunden" ); return sal_False; @@ -765,8 +765,8 @@ SwFrmFmt* SwNode::GetFlyFmt() const if( !pRet ) { // dann gibts noch harten steinigen Weg uebers Dokument: - const SwSpzFrmFmts& rFrmFmtTbl = *GetDoc()->GetSpzFrmFmts(); - for( sal_uInt16 n = 0; n < rFrmFmtTbl.Count(); ++n ) + const SwFrmFmts& rFrmFmtTbl = *GetDoc()->GetSpzFrmFmts(); + for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n ) { SwFrmFmt* pFmt = rFrmFmtTbl[n]; const SwFmtCntnt& rCntnt = pFmt->GetCntnt(); diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 7ee67d7eef03..d94e417d7772 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -103,10 +103,6 @@ public: TYPEINIT1(SwSectionFmt,SwFrmFmt ); TYPEINIT1(SwSection,SwClient ); -typedef SwSection* SwSectionPtr; - -SV_IMPL_PTRARR(SwSectionFmts,SwSectionFmt*) - SwSectionData::SwSectionData(SectionType const eType, String const& rName) : m_eType(eType) @@ -675,7 +671,7 @@ SwSectionFmt::~SwSectionFmt() // noch anzeigen muessen! if( rSect.IsHiddenFlag() ) { - SwSectionPtr pParentSect = rSect.GetParent(); + SwSection* pParentSect = rSect.GetParent(); if( !pParentSect || !pParentSect->IsHiddenFlag() ) { // Nodes wieder anzeigen @@ -973,7 +969,7 @@ void SwSectionFmt::UpdateParent() // Parent wurde veraendert if( !GetDepends() ) return; - SwSectionPtr pSection = 0; + SwSection* pSection = 0; const SvxProtectItem* pProtect(0); // edit in readonly sections const SwFmtEditInReadonly* pEditInReadonly = 0; @@ -990,7 +986,7 @@ void SwSectionFmt::UpdateParent() // Parent wurde veraendert pSection = GetSection(); if( GetRegisteredIn() ) { - const SwSectionPtr pPS = GetParentSection(); + const SwSection* pPS = GetParentSection(); pProtect = &pPS->GetFmt()->GetProtect(); // edit in readonly sections pEditInReadonly = &pPS->GetFmt()->GetEditInReadonly(); @@ -1030,10 +1026,10 @@ void SwSectionFmt::UpdateParent() // Parent wurde veraendert else if( !pSection && pLast->IsA( TYPE(SwSection) ) ) { - pSection = (SwSectionPtr)pLast; + pSection = (SwSection*)pLast; if( GetRegisteredIn() ) { - const SwSectionPtr pPS = GetParentSection(); + const SwSection* pPS = GetParentSection(); pProtect = &pPS->GetFmt()->GetProtect(); // edit in readonly sections pEditInReadonly = &pPS->GetFmt()->GetEditInReadonly(); @@ -1596,7 +1592,7 @@ void SwIntrnlSectRefLink::Closed() // kennzeichnen und das Flag umsetzen const SwSectionFmts& rFmts = pDoc->GetSections(); - for( sal_uInt16 n = rFmts.Count(); n; ) + for( sal_uInt16 n = rFmts.size(); n; ) if( rFmts[ --n ] == &rSectFmt ) { ViewShell* pSh; @@ -1744,6 +1740,22 @@ sal_Bool SwIntrnlSectRefLink::IsInRange( sal_uLong nSttNd, sal_uLong nEndNd, pSttNd->EndOfSectionIndex() < nEndNd; } +sal_uInt16 SwSectionFmts::GetPos(const SwSectionFmt* p) const +{ + const_iterator it = std::find(begin(), end(), p); + return it == end() ? USHRT_MAX : it - begin(); +} + +bool SwSectionFmts::Contains(const SwSectionFmt* p) const +{ + return std::find(begin(), end(), p) != end(); +} + +SwSectionFmts::~SwSectionFmts() +{ + for(const_iterator it = begin(); it != end(); ++it) + delete *it; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index a2e8e04dd6a2..1ecaa7bf853d 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -690,7 +690,7 @@ SwDrawContact::~SwDrawContact() void SwDrawContact::GetTextObjectsFromFmt( std::list<SdrTextObj*>& rTextObjects, SwDoc* pDoc ) { - for( sal_Int32 n=0; n<pDoc->GetSpzFrmFmts()->Count(); n++ ) + for( sal_Int32 n=0; n<(sal_Int32)pDoc->GetSpzFrmFmts()->size(); n++ ) { SwFrmFmt* pFly = (*pDoc->GetSpzFrmFmts())[n]; if( pFly->IsA( TYPE(SwDrawFrmFmt) ) ) @@ -1853,8 +1853,8 @@ void SwDrawContact::ConnectToLayout( const SwFmtAnchor* pAnch ) else { const SwNodeIndex& rIdx = pAnch->GetCntntAnchor()->nNode; - SwSpzFrmFmts& rFmts = *(pDrawFrmFmt->GetDoc()->GetSpzFrmFmts()); - for( sal_uInt16 i = 0; i < rFmts.Count(); ++i ) + SwFrmFmts& rFmts = *(pDrawFrmFmt->GetDoc()->GetSpzFrmFmts()); + for( sal_uInt16 i = 0; i < rFmts.size(); ++i ) { SwFrmFmt* pFlyFmt = rFmts[i]; if( pFlyFmt->GetCntnt().GetCntntIdx() && diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index e2c57c36b0b7..40047278093d 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -373,8 +373,8 @@ sal_Bool SwAutoFormat::HasObjects( const SwNode& rNd ) // Is there something bound to the paragraph in the paragraph // like borders, DrawObjects, ... sal_Bool bRet = sal_False; - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + const SwFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { const SwFmtAnchor& rAnchor = rFmts[ n ]->GetAnchor(); if ((FLY_AT_PAGE != rAnchor.GetAnchorId()) && diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 8d9afd047343..97274674f37c 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -39,6 +39,7 @@ #include <SwRewriter.hxx> #include <numrule.hxx> #include <swundo.hxx> +#include <docary.hxx> /************************************* * FormatColl @@ -54,7 +55,7 @@ SwTxtFmtColl& SwEditShell::GetDfltTxtFmtColl() const sal_uInt16 SwEditShell::GetTxtFmtCollCount() const { - return GetDoc()->GetTxtFmtColls()->Count(); + return GetDoc()->GetTxtFmtColls()->size(); } diff --git a/sw/source/core/edit/edfmt.cxx b/sw/source/core/edit/edfmt.cxx index 3917006704a7..38ba4be3720e 100644 --- a/sw/source/core/edit/edfmt.cxx +++ b/sw/source/core/edit/edfmt.cxx @@ -46,7 +46,7 @@ sal_uInt16 SwEditShell::GetCharFmtCount() const { - return GetDoc()->GetCharFmts()->Count(); + return GetDoc()->GetCharFmts()->size(); } diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index 89386258daac..8ebd9321960a 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -75,7 +75,7 @@ sal_uInt16 SwEditShell::GetGlobalDocContent( SwGlblDocContents& rArr ) const const SwSectionFmts& rSectFmts = pMyDoc->GetSections(); sal_uInt16 n; - for( n = rSectFmts.Count(); n; ) + for( n = rSectFmts.size(); n; ) { const SwSection* pSect = rSectFmts[ --n ]->GetGlobalDocSection(); if( pSect ) diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 8a9d5eb709ca..91d32a80c31f 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -217,7 +217,7 @@ sal_Bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) { const String& rTblName = pTblNd->GetTable().GetFrmFmt()->GetName(); const SwFrmFmts& rTblFmts = *pInsDoc->GetTblFrmFmts(); - for( sal_uInt16 n = rTblFmts.Count(); n; ) + for( sal_uInt16 n = rTblFmts.size(); n; ) if( rTblFmts[ --n ]->GetName() == rTblName ) { bCpyTblNm = sal_False; diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 0c154d910721..7889328e405e 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -773,7 +773,7 @@ sal_uInt16 SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr ) const SwTxtNode* pTxtNd; const SwCharFmts* pFmts = GetDoc()->GetCharFmts(); - for( sal_uInt16 n = pFmts->Count(); 1 < n; ) + for( sal_uInt16 n = pFmts->size(); 1 < n; ) { SwIterator<SwTxtINetFmt,SwCharFmt> aIter(*(*pFmts)[--n]); for( SwTxtINetFmt* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() ) diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index 598ebcdf7712..86ce8b4160fa 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -125,14 +125,14 @@ const SwSection* SwEditShell::GetAnySection( sal_Bool bOutOfTab, const Point* pP sal_uInt16 SwEditShell::GetSectionFmtCount() const { - return GetDoc()->GetSections().Count(); + return GetDoc()->GetSections().size(); } sal_Bool SwEditShell::IsAnySectionInDoc( sal_Bool bChkReadOnly, sal_Bool bChkHidden, sal_Bool bChkTOX ) const { const SwSectionFmts& rFmts = GetDoc()->GetSections(); - sal_uInt16 nCnt = rFmts.Count(); + sal_uInt16 nCnt = rFmts.size(); sal_uInt16 n; for( n = 0; n < nCnt; ++n ) diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index bbe4460d2d20..0e5edc1bdd04 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -259,7 +259,7 @@ sal_uInt16 SwEditShell::GetTOXCount() const { const SwSectionFmts& rFmts = GetDoc()->GetSections(); sal_uInt16 nRet = 0; - for( sal_uInt16 n = rFmts.Count(); n; ) + for( sal_uInt16 n = rFmts.size(); n; ) { const SwSection* pSect = rFmts[ --n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && @@ -273,7 +273,7 @@ sal_uInt16 SwEditShell::GetTOXCount() const const SwTOXBase* SwEditShell::GetTOX( sal_uInt16 nPos ) const { const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = 0, nCnt = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0, nCnt = 0; n < rFmts.size(); ++n ) { const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx index 0ebd62c9fd96..4f267fe087dc 100644 --- a/sw/source/core/edit/edws.cxx +++ b/sw/source/core/edit/edws.cxx @@ -184,7 +184,7 @@ sal_uInt16 SwEditShell::GetCntType() const sal_Bool SwEditShell::HasOtherCnt() const { - if ( GetDoc()->GetSpzFrmFmts()->Count() ) + if ( !GetDoc()->GetSpzFrmFmts()->empty() ) return sal_True; const SwNodes &rNds = GetDoc()->GetNodes(); diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 2187fed05b9a..01090714cffe 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -692,7 +692,7 @@ const SwTable* SwTableFormula::FindTable( SwDoc& rDoc, const String& rNm ) const { const SwFrmFmts& rTblFmts = *rDoc.GetTblFrmFmts(); const SwTable* pTmpTbl, *pRet = 0; - for( sal_uInt16 nFmtCnt = rTblFmts.Count(); nFmtCnt; ) + for( sal_uInt16 nFmtCnt = rTblFmts.size(); nFmtCnt; ) { SwFrmFmt* pFmt = rTblFmts[ --nFmtCnt ]; // falls wir von Sw3Writer gerufen werden, dann ist dem diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index b3f88fb146bd..540d20193371 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -111,7 +111,7 @@ sal_Bool SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) } // also delete surrounding FlyFrames if any - for( sal_uInt16 n = 0; n < pClpDoc->GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < pClpDoc->GetSpzFrmFmts()->size(); ++n ) { SwFlyFrmFmt* pFly = (SwFlyFrmFmt*)(*pClpDoc->GetSpzFrmFmts())[n]; pClpDoc->DelLayoutFmt( pFly ); @@ -155,14 +155,14 @@ sal_Bool SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) // assure the "RootFmt" is the first element in Spz-Array // (if necessary Flys were copied in Flys) - SwSpzFrmFmts& rSpzFrmFmts = *(SwSpzFrmFmts*)pClpDoc->GetSpzFrmFmts(); + SwFrmFmts& rSpzFrmFmts = *(SwFrmFmts*)pClpDoc->GetSpzFrmFmts(); if( rSpzFrmFmts[ 0 ] != pFlyFmt ) { - sal_uInt16 nPos = rSpzFrmFmts.GetPos( pFlyFmt ); - OSL_ENSURE( nPos != USHRT_MAX, "Fly not contained in Spz-Array" ); + SwFrmFmts::iterator it = std::find( rSpzFrmFmts.begin(), rSpzFrmFmts.end(), pFlyFmt ); + OSL_ENSURE( it != rSpzFrmFmts.end(), "Fly not contained in Spz-Array" ); - rSpzFrmFmts.Remove( nPos ); - rSpzFrmFmts.Insert( pFlyFmt, 0 ); + rSpzFrmFmts.erase( it ); + rSpzFrmFmts.insert( rSpzFrmFmts.begin(), pFlyFmt ); } if ( FLY_AS_CHAR == aAnchor.GetAnchorId() ) @@ -894,13 +894,13 @@ sal_Bool SwFEShell::Paste( SwDoc* pClpDoc, sal_Bool bIncludingPageFrames ) break; // exit the "while-loop" } else if( *aCpyPam.GetPoint() == *aCpyPam.GetMark() && - pClpDoc->GetSpzFrmFmts()->Count() ) + pClpDoc->GetSpzFrmFmts()->size() ) { // we need a DrawView if( !Imp()->GetDrawView() ) MakeDrawView(); - for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->Count(); ++i ) + for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i ) { sal_Bool bInsWithFmt = sal_True; const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i]; @@ -1082,13 +1082,13 @@ sal_Bool SwFEShell::Paste( SwDoc* pClpDoc, sal_Bool bIncludingPageFrames ) GetDoc()->DelFullPara(aPara); } //additionally copy page bound frames - if( bIncludingPageFrames && pClpDoc->GetSpzFrmFmts()->Count() ) + if( bIncludingPageFrames && pClpDoc->GetSpzFrmFmts()->size() ) { // create a draw view if necessary if( !Imp()->GetDrawView() ) MakeDrawView(); - for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->Count(); ++i ) + for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i ) { sal_Bool bInsWithFmt = sal_True; const SwFrmFmt& rCpyFmt = *(*pClpDoc->GetSpzFrmFmts())[i]; @@ -1190,13 +1190,13 @@ sal_Bool SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_u } // now the page bound objects // additionally copy page bound frames - if( GetDoc()->GetSpzFrmFmts()->Count() ) + if( GetDoc()->GetSpzFrmFmts()->size() ) { // create a draw view if necessary if( !rToFill.Imp()->GetDrawView() ) rToFill.MakeDrawView(); - for ( sal_uInt16 i = 0; i < GetDoc()->GetSpzFrmFmts()->Count(); ++i ) + for ( sal_uInt16 i = 0; i < GetDoc()->GetSpzFrmFmts()->size(); ++i ) { const SwFrmFmt& rCpyFmt = *(*GetDoc()->GetSpzFrmFmts())[i]; SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 92f9f842198f..30334dad6b65 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -941,7 +941,7 @@ void SwFEShell::GetPageObjs( SvPtrarr& rFillArr ) rFillArr.Remove( 0, rFillArr.Count() ); const SwFrmFmt* pFmt; - for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n ) { pFmt = (const SwFrmFmt*)(*pDoc->GetSpzFrmFmts())[n]; if (FLY_AT_PAGE == pFmt->GetAnchor().GetAnchorId()) @@ -972,7 +972,7 @@ void SwFEShell::SetPageObjsNewPage( SvPtrarr& rFillArr, int nOffset ) for( sal_uInt16 n = 0; n < rFillArr.Count(); ++n ) { pFmt = (SwFrmFmt*)rFillArr[n]; - if( USHRT_MAX != pDoc->GetSpzFrmFmts()->GetPos( pFmt )) + if( pDoc->GetSpzFrmFmts()->Contains( pFmt )) { // FlyFmt is still valid, therefore process @@ -1488,8 +1488,8 @@ SwFrmFmt* SwFEShell::WizzardGetFly() { // do not search the Fly via the layout. Now we can delete a frame // without a valid layout. ( e.g. for the wizards ) - SwSpzFrmFmts& rSpzArr = *pDoc->GetSpzFrmFmts(); - sal_uInt16 nCnt = rSpzArr.Count(); + SwFrmFmts& rSpzArr = *pDoc->GetSpzFrmFmts(); + sal_uInt16 nCnt = rSpzArr.size(); if( nCnt ) { SwNodeIndex& rCrsrNd = GetCrsr()->GetPoint()->nNode; diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index ed442cd68b9f..52d0fc275dd4 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -932,12 +932,12 @@ sal_Bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) if( bRet ) { // now check for paragraph bound flyes - const SwSpzFrmFmts& rFmts = *rPam.GetDoc()->GetSpzFrmFmts(); + const SwFrmFmts& rFmts = *rPam.GetDoc()->GetSpzFrmFmts(); sal_uLong nSttIdx = rPam.GetPoint()->nNode.GetIndex(), nEndIdx = rBox.GetSttNd()->EndOfSectionIndex(), nIdx; - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { const SwFmtAnchor& rAnchor = rFmts[n]->GetAnchor(); const SwPosition* pAPos = rAnchor.GetCntntAnchor(); diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index 9697298d0e3e..3793cdb99e9a 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -38,7 +38,7 @@ class SwFmtFrmSize; struct SwCrsrMoveState; class SwBorderAttrs; class SwVirtFlyDrawObj; -class SwSpzFrmFmts; +class SwFrmFmts; class SwAttrSetChg; class PolyPolygon; class SwFlyDrawContact; @@ -66,7 +66,7 @@ sal_Bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, sal_Bool bMove = class SwFlyFrm : public SwLayoutFrm, public SwAnchoredObject { // is allowed to lock, implemented in frmtool.cxx - friend void AppendObjs ( const SwSpzFrmFmts *, sal_uLong, SwFrm *, SwPageFrm * ); + friend void AppendObjs ( const SwFrmFmts *, sal_uLong, SwFrm *, SwPageFrm * ); friend void Notify( SwFlyFrm *, SwPageFrm *pOld, const SwRect &rOld, const SwRect* pOldPrt ); diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index aca07492dcbf..2c2e8b1ac2c5 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2643,14 +2643,14 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const const SwFmtAnchor* pAnchor = &rFmt.GetAnchor(); if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor()) { - const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); + const SwFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode(). FindFlyStartNode(); while( pFlyNd ) { // then we walk up using the anchor sal_uInt16 n; - for( n = 0; n < rFmts.Count(); ++n ) + for( n = 0; n < rFmts.size(); ++n ) { const SwFrmFmt* pFmt = rFmts[ n ]; const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); @@ -2671,7 +2671,7 @@ sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const break; } } - if( n >= rFmts.Count() ) + if( n >= rFmts.size() ) { OSL_ENSURE( !this, "Fly section but no format found" ); return sal_False; @@ -2779,8 +2779,8 @@ void SwFlyFrmFmt::MakeFrms() if ( pModify == 0 ) { const SwNodeIndex &rIdx = aAnchorAttr.GetCntntAnchor()->nNode; - SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); - for( sal_uInt16 i = 0; i < rFmts.Count(); ++i ) + SwFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts(); + for( sal_uInt16 i = 0; i < rFmts.size(); ++i ) { SwFrmFmt* pFlyFmt = rFmts[i]; if( pFlyFmt->GetCntnt().GetCntntIdx() && diff --git a/sw/source/core/layout/flypos.cxx b/sw/source/core/layout/flypos.cxx index 62498df6705e..9a70f93ff37a 100644 --- a/sw/source/core/layout/flypos.cxx +++ b/sw/source/core/layout/flypos.cxx @@ -76,7 +76,7 @@ SwPosFlyFrm::SwPosFlyFrm( const SwNodeIndex& rIdx, const SwFrmFmt* pFmt, if( !bFnd ) { - nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->Count(); + nOrdNum = pFmt->GetDoc()->GetSpzFrmFmts()->size(); nOrdNum += nArrPos; } } diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 4cf9a6c8c755..2c330680eb63 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -929,7 +929,7 @@ SwCntntNotify::~SwCntntNotify() pCnt->SetRetouche(); //fix(13870) SwDoc *pDoc = pCnt->GetNode()->GetDoc(); - if ( pDoc->GetSpzFrmFmts()->Count() && + if ( !pDoc->GetSpzFrmFmts()->empty() && !pDoc->IsLoaded() && !pDoc->IsNewDoc() ) { //Der Frm wurde wahrscheinlich zum ersten mal formatiert. @@ -944,9 +944,9 @@ SwCntntNotify::~SwCntntNotify() const SwPageFrm *pPage = 0; SwNodeIndex *pIdx = 0; - SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); + SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); - for ( sal_uInt16 i = 0; i < pTbl->Count(); ++i ) + for ( sal_uInt16 i = 0; i < pTbl->size(); ++i ) { if ( !pPage ) pPage = pCnt->FindPageFrm(); @@ -1027,10 +1027,10 @@ SwCntntNotify::~SwCntntNotify() /*************************************************************************/ -void AppendObjs( const SwSpzFrmFmts *pTbl, sal_uLong nIndex, +void AppendObjs( const SwFrmFmts *pTbl, sal_uLong nIndex, SwFrm *pFrm, SwPageFrm *pPage ) { - for ( sal_uInt16 i = 0; i < pTbl->Count(); ++i ) + for ( sal_uInt16 i = 0; i < pTbl->size(); ++i ) { SwFrmFmt *pFmt = (SwFrmFmt*)(*pTbl)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); @@ -1148,7 +1148,7 @@ bool lcl_InHeaderOrFooter( SwFrmFmt& _rFmt ) return bRetVal; } -void AppendAllObjs( const SwSpzFrmFmts *pTbl, const SwFrm* pSib ) +void AppendAllObjs( const SwFrmFmts *pTbl, const SwFrm* pSib ) { //Verbinden aller Objekte, die in der SpzTbl beschrieben sind mit dem //Layout. @@ -1156,15 +1156,14 @@ void AppendAllObjs( const SwSpzFrmFmts *pTbl, const SwFrm* pSib ) //uebrigbleiben, weil wir weder zeichengebunde Rahmen verbinden noch //Objecte die in zeichengebundenen verankert sind. - SwSpzFrmFmts aCpy( 255 ); - aCpy.Insert( pTbl, 0 ); + SwFrmFmts aCpy( *pTbl ); sal_uInt16 nOldCnt = USHRT_MAX; - while ( aCpy.Count() && aCpy.Count() != nOldCnt ) + while ( !aCpy.empty() && aCpy.size() != nOldCnt ) { - nOldCnt = aCpy.Count(); - for ( int i = 0; i < int(aCpy.Count()); ++i ) + nOldCnt = aCpy.size(); + for ( int i = 0; i < int(aCpy.size()); ++i ) { SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ sal_uInt16(i) ]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); @@ -1190,12 +1189,12 @@ void AppendAllObjs( const SwSpzFrmFmts *pTbl, const SwFrm* pSib ) } if ( bRemove ) { - aCpy.Remove( sal_uInt16(i) ); + aCpy.erase( aCpy.begin() + i ); --i; } } } - aCpy.Remove( 0, aCpy.Count() ); + aCpy.clear(); } /** local method to set 'working' position for newly inserted frames @@ -1244,7 +1243,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc, const sal_Bool bStartPercent = bPages && !nEndIndex; SwPageFrm *pPage = pLay->FindPageFrm(); - const SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); + const SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); SwFrm *pFrm = 0; sal_Bool bBreakAfter = sal_False; @@ -1340,7 +1339,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc, lcl_SetPos( *pFrm, *pLay ); pPrv = pFrm; - if ( pTbl->Count() && bObjsDirect && !bDontCreateObjects ) + if ( !pTbl->empty() && bObjsDirect && !bDontCreateObjects ) AppendObjs( pTbl, nIndex, pFrm, pPage ); } else if ( pNd->IsTableNode() ) @@ -1378,7 +1377,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc, dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) ); } } - if ( bObjsDirect && pTbl->Count() ) + if ( bObjsDirect && !pTbl->empty() ) ((SwTabFrm*)pFrm)->RegistFlys(); // OD 12.08.2003 #i17969# - consider horizontal/vertical layout // for setting position at newly inserted frame @@ -1557,7 +1556,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc, else if( pNd->IsStartNode() && SwFlyStartNode == ((SwStartNode*)pNd)->GetStartNodeType() ) { - if ( pTbl->Count() && bObjsDirect && !bDontCreateObjects ) + if ( !pTbl->empty() && bObjsDirect && !bDontCreateObjects ) { SwFlyFrm* pFly = pLay->FindFlyFrm(); if( pFly ) @@ -1790,8 +1789,8 @@ void MakeFrms( SwDoc *pDoc, const SwNodeIndex &rSttIdx, // depend on value of <bAllowMove> if( !bDontCreateObjects ) { - const SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); - if( pTbl->Count() ) + const SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); + if( !pTbl->empty() ) AppendAllObjs( pTbl, pUpper ); } diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 4aeb29fb8bcb..835d58f891a3 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -572,7 +572,7 @@ sal_uLong SwLayHelper::CalcPageCount() sal_uLong nTmp = pDoc->GetNodes().GetEndOfContent().GetIndex() - pDoc->GetNodes().GetEndOfExtras().GetIndex(); //Tables have a little overhead.. - nTmp -= pDoc->GetTblFrmFmts()->Count() * 25; + nTmp -= pDoc->GetTblFrmFmts()->size() * 25; //Fly frames, too .. nTmp -= (pDoc->GetNodes().GetEndOfAutotext().GetIndex() - pDoc->GetNodes().GetEndOfInserts().GetIndex()) / 3 * 5; @@ -683,8 +683,8 @@ bool lcl_HasTextFrmAnchoredObjs( SwTxtFrm* p_pTxtFrm ) { bool bHasTextFrmAnchoredObjs( false ); - const SwSpzFrmFmts* pSpzFrmFmts = p_pTxtFrm->GetTxtNode()->GetDoc()->GetSpzFrmFmts(); - for ( sal_uInt16 i = 0; i < pSpzFrmFmts->Count(); ++i ) + const SwFrmFmts* pSpzFrmFmts = p_pTxtFrm->GetTxtNode()->GetDoc()->GetSpzFrmFmts(); + for ( sal_uInt16 i = 0; i < pSpzFrmFmts->size(); ++i ) { SwFrmFmt *pFmt = (SwFrmFmt*)(*pSpzFrmFmts)[i]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index aa646c4e2505..5b52d3d55421 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -420,13 +420,13 @@ void lcl_FormatLay( SwLayoutFrm *pLay ) pLay->Calc(); } -void lcl_MakeObjs( const SwSpzFrmFmts &rTbl, SwPageFrm *pPage ) +void lcl_MakeObjs( const SwFrmFmts &rTbl, SwPageFrm *pPage ) { //Anlegen bzw. registrieren von Flys und Drawobjekten. //Die Formate stehen in der SpzTbl (vom Dokument). //Flys werden angelegt, DrawObjekte werden bei der Seite angemeldet. - for ( sal_uInt16 i = 0; i < rTbl.Count(); ++i ) + for ( sal_uInt16 i = 0; i < rTbl.size(); ++i ) { SdrObject *pSdrObj; SwFrmFmt *pFmt = rTbl[i]; @@ -1559,13 +1559,13 @@ void SwRootFrm::AssertFlyPages() bAssertFlyPages = sal_False; SwDoc *pDoc = GetFmt()->GetDoc(); - const SwSpzFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); + const SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts(); //Auf welche Seite will der 'letzte' Fly? sal_uInt16 nMaxPg = 0; sal_uInt16 i; - for ( i = 0; i < pTbl->Count(); ++i ) + for ( i = 0; i < pTbl->size(); ++i ) { const SwFmtAnchor &rAnch = (*pTbl)[i]->GetAnchor(); if ( !rAnch.GetCntntAnchor() && nMaxPg < rAnch.GetPageNum() ) diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index a008a13bb120..cf0099df2b33 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -74,7 +74,7 @@ #include <layouter.hxx> #include <switerator.hxx> -extern void AppendObjs( const SwSpzFrmFmts *pTbl, sal_uLong nIndex, +extern void AppendObjs( const SwFrmFmts *pTbl, sal_uLong nIndex, SwFrm *pFrm, SwPageFrm *pPage ); using namespace ::com::sun::star; @@ -1211,8 +1211,8 @@ bool SwTabFrm::Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKee pHeadline->InsertBefore( pFoll, 0 ); SwPageFrm *pPage = pHeadline->FindPageFrm(); - const SwSpzFrmFmts *pTbl = GetFmt()->GetDoc()->GetSpzFrmFmts(); - if( pTbl->Count() ) + const SwFrmFmts *pTbl = GetFmt()->GetDoc()->GetSpzFrmFmts(); + if( !pTbl->empty() ) { sal_uLong nIndex; SwCntntFrm* pFrm = pHeadline->ContainsCntnt(); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index ff70ebcea5e7..5cbc4310144f 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1768,8 +1768,8 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() // // HYPERLINKS (Graphics, Frames, OLEs ) // - const SwSpzFrmFmts* pTbl = pDoc->GetSpzFrmFmts(); - const sal_uInt16 nSpzFrmFmtsCount = pTbl->Count(); + const SwFrmFmts* pTbl = pDoc->GetSpzFrmFmts(); + const sal_uInt16 nSpzFrmFmtsCount = pTbl->size(); for( sal_uInt16 n = 0; n < nSpzFrmFmtsCount; ++n ) { const SwFrmFmt* pFrmFmt = (*pTbl)[n]; diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index a92e6c0e5d7a..b422e0c13772 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -61,6 +61,7 @@ #include <com/sun/star/i18n/ScriptType.hdl> #include <editeng/lrspitem.hxx> #include <switerator.hxx> +#include <boost/foreach.hpp> using namespace ::com::sun::star::i18n; using namespace ::com::sun::star; @@ -450,9 +451,9 @@ public: void Minimum( long nNew ) { if( nNew > nMinWidth ) nMinWidth = nNew; } }; -sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) +static void lcl_MinMaxNode( SwFrmFmt* pNd, SwMinMaxNodeArgs* pIn ) { - const SwFmtAnchor& rFmtA = ((SwFrmFmt*)rpNd)->GetAnchor(); + const SwFmtAnchor& rFmtA = pNd->GetAnchor(); bool bCalculate = false; if ((FLY_AT_PARA == rFmtA.GetAnchorId()) || @@ -463,7 +464,6 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) if (bCalculate) { - const SwMinMaxNodeArgs *pIn = (const SwMinMaxNodeArgs*)pArgs; const SwPosition *pPos = rFmtA.GetCntntAnchor(); OSL_ENSURE(pPos && pIn, "Unexpected NULL arguments"); if (!pPos || !pIn || pIn->nIndx != pPos->nNode.GetIndex()) @@ -474,27 +474,27 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) { long nMin, nMax; SwHTMLTableLayout *pLayout = 0; - MSHORT nWhich = ((SwFrmFmt*)rpNd)->Which(); + MSHORT nWhich = pNd->Which(); if( RES_DRAWFRMFMT != nWhich ) { // Enthaelt der Rahmen zu Beginn oder am Ende eine Tabelle? - const SwNodes& rNodes = static_cast<SwFrmFmt*>(rpNd)->GetDoc()->GetNodes(); - const SwFmtCntnt& rFlyCntnt = ((SwFrmFmt*)rpNd)->GetCntnt(); + const SwNodes& rNodes = pNd->GetDoc()->GetNodes(); + const SwFmtCntnt& rFlyCntnt = pNd->GetCntnt(); sal_uLong nStt = rFlyCntnt.GetCntntIdx()->GetIndex(); SwTableNode* pTblNd = rNodes[nStt+1]->GetTableNode(); if( !pTblNd ) { - SwNode *pNd = rNodes[nStt]; - pNd = rNodes[pNd->EndOfSectionIndex()-1]; - if( pNd->IsEndNode() ) - pTblNd = pNd->StartOfSectionNode()->GetTableNode(); + SwNode *pNd2 = rNodes[nStt]; + pNd2 = rNodes[pNd2->EndOfSectionIndex()-1]; + if( pNd2->IsEndNode() ) + pTblNd = pNd2->StartOfSectionNode()->GetTableNode(); } if( pTblNd ) pLayout = pTblNd->GetTable().GetHTMLTableLayout(); } - const SwFmtHoriOrient& rOrient = ((SwFrmFmt*)rpNd)->GetHoriOrient(); + const SwFmtHoriOrient& rOrient = pNd->GetHoriOrient(); sal_Int16 eHoriOri = rOrient.GetHoriOrient(); long nDiff; @@ -508,7 +508,7 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) { if( RES_DRAWFRMFMT == nWhich ) { - const SdrObject* pSObj = rpNd->FindSdrObject(); + const SdrObject* pSObj = pNd->FindSdrObject(); if( pSObj ) nMin = pSObj->GetCurrentBoundRect().GetWidth(); else @@ -517,23 +517,23 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) } else { - const SwFmtFrmSize &rSz = ( (SwFrmFmt*)rpNd )->GetFrmSize(); + const SwFmtFrmSize &rSz = pNd->GetFrmSize(); nMin = rSz.GetWidth(); } nMax = nMin; nDiff = 0; } - const SvxLRSpaceItem &rLR = ( (SwFrmFmt*)rpNd )->GetLRSpace(); + const SvxLRSpaceItem &rLR = pNd->GetLRSpace(); nMin += rLR.GetLeft(); nMin += rLR.GetRight(); nMax += rLR.GetLeft(); nMax += rLR.GetRight(); - if( SURROUND_THROUGHT == ((SwFrmFmt*)rpNd)->GetSurround().GetSurround() ) + if( SURROUND_THROUGHT == pNd->GetSurround().GetSurround() ) { - ( (SwMinMaxNodeArgs*)pArgs )->Minimum( nMin ); - return sal_True; + pIn->Minimum( nMin ); + return; } // Rahmen, die recht bzw. links ausgerichtet sind, gehen nur @@ -546,40 +546,37 @@ sal_Bool lcl_MinMaxNode( const SwFrmFmtPtr& rpNd, void* pArgs ) { if( nDiff ) { - ((SwMinMaxNodeArgs*)pArgs)->nRightRest -= - ((SwMinMaxNodeArgs*)pArgs)->nRightDiff; - ((SwMinMaxNodeArgs*)pArgs)->nRightDiff = nDiff; + pIn->nRightRest -= pIn->nRightDiff; + pIn->nRightDiff = nDiff; } if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() ) { - if( ((SwMinMaxNodeArgs*)pArgs)->nRightRest > 0 ) - ((SwMinMaxNodeArgs*)pArgs)->nRightRest = 0; + if( pIn->nRightRest > 0 ) + pIn->nRightRest = 0; } - ((SwMinMaxNodeArgs*)pArgs)->nRightRest -= nMin; + pIn->nRightRest -= nMin; break; } case text::HoriOrientation::LEFT: { if( nDiff ) { - ((SwMinMaxNodeArgs*)pArgs)->nLeftRest -= - ((SwMinMaxNodeArgs*)pArgs)->nLeftDiff; - ((SwMinMaxNodeArgs*)pArgs)->nLeftDiff = nDiff; + pIn->nLeftRest -= pIn->nLeftDiff; + pIn->nLeftDiff = nDiff; } if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() && - ((SwMinMaxNodeArgs*)pArgs)->nLeftRest < 0 ) - ((SwMinMaxNodeArgs*)pArgs)->nLeftRest = 0; - ((SwMinMaxNodeArgs*)pArgs)->nLeftRest -= nMin; + pIn->nLeftRest < 0 ) + pIn->nLeftRest = 0; + pIn->nLeftRest -= nMin; break; } default: { - ( (SwMinMaxNodeArgs*)pArgs )->nMaxWidth += nMax; - ( (SwMinMaxNodeArgs*)pArgs )->Minimum( nMin ); + pIn->nMaxWidth += nMax; + pIn->Minimum( nMin ); } } } - return sal_True; } #define FLYINCNT_MIN_WIDTH 284 @@ -623,11 +620,12 @@ void SwTxtNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rMa aNodeArgs.nRightDiff = 0; if( nIndex ) { - SwSpzFrmFmts* pTmp = (SwSpzFrmFmts*)GetDoc()->GetSpzFrmFmts(); + SwFrmFmts* pTmp = (SwFrmFmts*)GetDoc()->GetSpzFrmFmts(); if( pTmp ) { aNodeArgs.nIndx = nIndex; - pTmp->ForEach( &lcl_MinMaxNode, &aNodeArgs ); + BOOST_FOREACH( SwFrmFmt *pFmt, *pTmp ) + lcl_MinMaxNode( pFmt, &aNodeArgs ); } } if( aNodeArgs.nLeftRest < 0 ) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index e9e30a703b7a..a27754494e5e 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1256,7 +1256,7 @@ SwCharFmt* lcl_FindCharFmt( const SwCharFmts* pCharFmts, const XubString& rName if( rName.Len() ) { SwCharFmt* pFmt; - sal_uInt16 nArrLen = pCharFmts->Count(); + sal_uInt16 nArrLen = pCharFmts->size(); for( sal_uInt16 i = 1; i < nArrLen; i++ ) { pFmt = (*pCharFmts)[ i ]; diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 41f10c440839..27516ee4d46c 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -234,8 +234,7 @@ void SwHistorySetTxt::SetInDoc( SwDoc* pDoc, bool ) if ( RES_TXTATR_CHARFMT == m_pAttr->Which() ) { // ask the Doc if the CharFmt still exists - if ( USHRT_MAX == pDoc->GetCharFmts()->GetPos( - (static_cast<SwFmtCharFmt&>(*m_pAttr)).GetCharFmt() ) ) + if ( !pDoc->GetCharFmts()->Contains( (static_cast<SwFmtCharFmt&>(*m_pAttr)).GetCharFmt() ) ) return; // do not set, format does not exist } diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index dccfd83843b5..1dbce4397ffc 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -152,8 +152,7 @@ void SwUndoFmtAttr::Init() else if ( RES_FRMFMT == m_nFmtWhich ) { SwDoc* pDoc = m_pFmt->GetDoc(); - if (USHRT_MAX != pDoc->GetTblFrmFmts()->GetPos( - static_cast<const SwFrmFmtPtr>(m_pFmt))) + if ( pDoc->GetTblFrmFmts()->Contains(static_cast<const SwFrmFmt*>(m_pFmt))) { // Table Format: save table position, table formats are volatile! SwTable * pTbl = SwIterator<SwTable,SwFmt>::FirstElement( *m_pFmt ); @@ -163,8 +162,7 @@ void SwUndoFmtAttr::Init() ->FindTableNode()->GetIndex(); } } - else if (USHRT_MAX != pDoc->GetSections().GetPos( - static_cast<const SwSectionFmtPtr>(m_pFmt))) + else if ( pDoc->GetSections().Contains(static_cast<const SwSectionFmt*>(m_pFmt))) { m_nNodeIndex = m_pFmt->GetCntnt().GetCntntIdx()->GetIndex(); } @@ -242,17 +240,17 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) { case RES_TXTFMTCOLL: nPos = pDoc->GetTxtFmtColls()->GetPos( - static_cast<const SwTxtFmtCollPtr>(m_pFmt) ); + static_cast<const SwTxtFmtColl*>(m_pFmt) ); break; case RES_GRFFMTCOLL: nPos = pDoc->GetGrfFmtColls()->GetPos( - static_cast<const SwGrfFmtCollPtr>(m_pFmt) ); + static_cast<const SwGrfFmtColl*>(m_pFmt) ); break; case RES_CHRFMT: nPos = pDoc->GetCharFmts()->GetPos( - static_cast<SwCharFmtPtr>(m_pFmt) ); + static_cast<SwCharFmt*>(m_pFmt) ); break; case RES_FRMFMT: @@ -294,11 +292,11 @@ bool SwUndoFmtAttr::IsFmtInDoc( SwDoc* pDoc ) case RES_DRAWFRMFMT: case RES_FLYFRMFMT: nPos = pDoc->GetSpzFrmFmts()->GetPos( - static_cast<const SwFrmFmtPtr>(m_pFmt) ); + static_cast<const SwFrmFmt*>(m_pFmt) ); if ( USHRT_MAX == nPos ) { nPos = pDoc->GetFrmFmts()->GetPos( - static_cast<const SwFrmFmtPtr>(m_pFmt) ); + static_cast<const SwFrmFmt*>(m_pFmt) ); } break; } diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 8895c29dbc69..576456a6788e 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -57,13 +57,13 @@ ( == AUTO ), if the anchor frame has be moved via _MoveNodes(..) and DelFrms(..) */ -void lcl_MakeAutoFrms( const SwSpzFrmFmts& rSpzArr, sal_uLong nMovedIndex ) +void lcl_MakeAutoFrms( const SwFrmFmts& rSpzArr, sal_uLong nMovedIndex ) { - if( rSpzArr.Count() ) + if( !rSpzArr.empty() ) { SwFlyFrmFmt* pFmt; const SwFmtAnchor* pAnchor; - for( sal_uInt16 n = 0; n < rSpzArr.Count(); ++n ) + for( sal_uInt16 n = 0; n < rSpzArr.size(); ++n ) { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); @@ -711,14 +711,14 @@ SwRewriter SwUndoDelete::GetRewriter() const } // Every object, anchored "AtCntnt" will be reanchored at rPos -void lcl_ReAnchorAtCntntFlyFrames( const SwSpzFrmFmts& rSpzArr, SwPosition &rPos, sal_uLong nOldIdx ) +void lcl_ReAnchorAtCntntFlyFrames( const SwFrmFmts& rSpzArr, SwPosition &rPos, sal_uLong nOldIdx ) { - if( rSpzArr.Count() ) + if( !rSpzArr.empty() ) { SwFlyFrmFmt* pFmt; const SwFmtAnchor* pAnchor; const SwPosition* pAPos; - for( sal_uInt16 n = 0; n < rSpzArr.Count(); ++n ) + for( sal_uInt16 n = 0; n < rSpzArr.size(); ++n ) { pFmt = (SwFlyFrmFmt*)rSpzArr[n]; pAnchor = &pFmt->GetAnchor(); diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index d3976807ce0d..b4aee5938d4b 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -612,16 +612,16 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, if( nsDelCntntType::DELCNT_FLY & nDelCntntType ) { sal_uInt16 nChainInsPos = pHistory ? pHistory->Count() : 0; - const SwSpzFrmFmts& rSpzArr = *pDoc->GetSpzFrmFmts(); - if( rSpzArr.Count() ) + const SwFrmFmts& rSpzArr = *pDoc->GetSpzFrmFmts(); + if( !rSpzArr.empty() ) { const sal_Bool bDelFwrd = rMark.nNode.GetIndex() <= rPoint.nNode.GetIndex(); SwFlyFrmFmt* pFmt; const SwFmtAnchor* pAnchor; - sal_uInt16 n = rSpzArr.Count(); + sal_uInt16 n = rSpzArr.size(); const SwPosition* pAPos; - while( n && rSpzArr.Count() ) + while( n && !rSpzArr.empty() ) { pFmt = (SwFlyFrmFmt*)rSpzArr[--n]; pAnchor = &pFmt->GetAnchor(); @@ -643,7 +643,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, assert(pFlyHnt); pHistory->Add( pFlyHnt, 0, false ); // reset n so that no Format is skipped - n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; + n = n >= rSpzArr.size() ? rSpzArr.size() : n+1; } break; case FLY_AT_PARA: @@ -687,8 +687,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, { pHistory->Add( *pFmt, nChainInsPos ); // reset n so that no Format is skipped - n = n >= rSpzArr.Count() ? - rSpzArr.Count() : n+1; + n = n >= rSpzArr.size() ? + rSpzArr.size() : n+1; } } } @@ -704,7 +704,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, *pAPos, *pStt, *pEnd, nDelCntntType)) { pHistory->Add( *pFmt, nChainInsPos ); - n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; + n = n >= rSpzArr.size() ? rSpzArr.size() : n+1; } else if( !( nsDelCntntType::DELCNT_CHKNOCNTNT & nDelCntntType ) ) { @@ -735,7 +735,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, pHistory->Add( *pFmt, nChainInsPos ); // reset n so that no Format is skipped - n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; + n = n >= rSpzArr.size() ? rSpzArr.size() : n+1; } break; default: break; diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 58f6e5e81bff..53da1772b811 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -64,8 +64,8 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrm) SwDoc *const pDoc = & rContext.GetDoc(); // add again into array - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.Insert( pFrmFmt, rFlyFmts.Count() ); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); + rFlyFmts.push_back( pFrmFmt ); // OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page if ( RES_DRAWFRMFMT == pFrmFmt->Which() ) @@ -224,8 +224,8 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) // delete from array - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.Remove( rFlyFmts.GetPos( pFrmFmt )); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFrmFmt )); } SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, sal_uLong nNodeIdx, xub_StrLen nCntIdx ) @@ -542,7 +542,7 @@ void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pOldFmt ) ) + if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmt*)pOldFmt ) ) { if( bAnchorChgd ) pFrmFmt->DelFrms(); @@ -615,7 +615,7 @@ void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext) SwDoc & rDoc = rContext.GetDoc(); // Is the new Format still existent? - if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pNewFmt ) ) + if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmt*)pNewFmt ) ) { if( bAnchorChgd ) diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 182275693d7d..35c8dea51b80 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -242,15 +242,15 @@ void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &) // remove from array SwDoc* pDoc = pFmt->GetDoc(); - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.Remove( rFlyFmts.GetPos( pFmt )); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt )); for( sal_uInt16 n = 1; n < nSize; ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx ); - rFlyFmts.Insert( rSave.pFmt, rFlyFmts.Count() ); + rFlyFmts.push_back( rSave.pFmt ); pObj = rSave.pObj; @@ -274,7 +274,7 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) // remove from array SwDoc* pDoc = pObjArr->pFmt->GetDoc(); - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); SdrObject* pObj; for( sal_uInt16 n = 1; n < nSize; ++n ) @@ -294,12 +294,12 @@ void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) // notify UNO objects to decouple ::lcl_SendRemoveToUno( *rSave.pFmt ); - rFlyFmts.Remove( rFlyFmts.GetPos( rSave.pFmt )); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), rSave.pFmt )); } // re-insert group object ::lcl_RestoreAnchor( pObjArr->pFmt, pObjArr->nNodeIdx ); - rFlyFmts.Insert( pObjArr->pFmt, rFlyFmts.Count() ); + rFlyFmts.push_back( pObjArr->pFmt ); SwDrawContact *pContact = new SwDrawContact( pObjArr->pFmt, pObjArr->pObj ); // #i26791# - correction: connect object to layout @@ -326,8 +326,8 @@ void SwUndoDrawGroup::AddObj( sal_uInt16 nPos, SwDrawFrmFmt* pFmt, SdrObject* pO ::lcl_SendRemoveToUno( *pFmt ); // remove from array - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pFmt->GetDoc()->GetSpzFrmFmts(); - rFlyFmts.Remove( rFlyFmts.GetPos( pFmt )); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pFmt->GetDoc()->GetSpzFrmFmts(); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt )); } void SwUndoDrawGroup::SetGroupFmt( SwDrawFrmFmt* pFmt ) @@ -361,8 +361,8 @@ SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj ) ::lcl_SendRemoveToUno( *pFmt ); // remove from array - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pFmt->GetDoc()->GetSpzFrmFmts(); - rFlyFmts.Remove( rFlyFmts.GetPos( pFmt )); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pFmt->GetDoc()->GetSpzFrmFmts(); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt )); } SwUndoDrawUnGroup::~SwUndoDrawUnGroup() @@ -384,7 +384,7 @@ void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) bDelFmt = sal_True; SwDoc *const pDoc = & rContext.GetDoc(); - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); // remove from array for( sal_uInt16 n = 1; n < nSize; ++n ) @@ -396,12 +396,12 @@ void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) // notify UNO objects to decouple ::lcl_SendRemoveToUno( *rSave.pFmt ); - rFlyFmts.Remove( rFlyFmts.GetPos( rSave.pFmt )); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), rSave.pFmt )); } // re-insert group object ::lcl_RestoreAnchor( pObjArr->pFmt, pObjArr->nNodeIdx ); - rFlyFmts.Insert( pObjArr->pFmt, rFlyFmts.Count() ); + rFlyFmts.push_back( pObjArr->pFmt ); SwDrawContact *pContact = new SwDrawContact( pObjArr->pFmt, pObjArr->pObj ); pContact->ConnectToLayout(); @@ -436,15 +436,15 @@ void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &) // remove from array SwDoc* pDoc = pFmt->GetDoc(); - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.Remove( rFlyFmts.GetPos( pFmt )); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt )); for( sal_uInt16 n = 1; n < nSize; ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx ); - rFlyFmts.Insert( rSave.pFmt, rFlyFmts.Count() ); + rFlyFmts.push_back( rSave.pFmt ); // #i45952# - notify that position attributes are already set OSL_ENSURE( rSave.pFmt->ISA(SwDrawFrmFmt), @@ -537,12 +537,12 @@ SwUndoDrawDelete::~SwUndoDrawDelete() void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) { bDelFmt = sal_False; - SwSpzFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts(); + SwFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts(); for( sal_uInt16 n = 0; n < pMarkLst->GetMarkCount(); ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); ::lcl_RestoreAnchor( rSave.pFmt, rSave.nNodeIdx ); - rFlyFmts.Insert( rSave.pFmt, rFlyFmts.Count() ); + rFlyFmts.push_back( rSave.pFmt ); SdrObject *pObj = rSave.pObj; SwDrawContact *pContact = new SwDrawContact( rSave.pFmt, pObj ); pContact->_Changed( *pObj, SDRUSERCALL_INSERTED, NULL ); @@ -562,7 +562,7 @@ void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext) { bDelFmt = sal_True; - SwSpzFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts(); + SwFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts(); for( sal_uInt16 n = 0; n < pMarkLst->GetMarkCount(); ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); @@ -577,7 +577,7 @@ void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext) // notify UNO objects to decouple ::lcl_SendRemoveToUno( *pFmt ); - rFlyFmts.Remove( rFlyFmts.GetPos( pFmt )); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt )); ::lcl_SaveAnchor( pFmt, rSave.nNodeIdx ); } } @@ -595,8 +595,8 @@ void SwUndoDrawDelete::AddObj( sal_uInt16 , SwDrawFrmFmt* pFmt, // remove from array SwDoc* pDoc = pFmt->GetDoc(); - SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); - rFlyFmts.Remove( rFlyFmts.GetPos( pFmt )); + SwFrmFmts& rFlyFmts = *(SwFrmFmts*)pDoc->GetSpzFrmFmts(); + rFlyFmts.erase( std::find( rFlyFmts.begin(), rFlyFmts.end(), pFmt )); pMarkLst->InsertEntry( rMark ); } diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx index 19e99043fb82..e10d5b59d9fd 100644 --- a/sw/source/core/undo/unfmco.cxx +++ b/sw/source/core/undo/unfmco.cxx @@ -32,6 +32,7 @@ #include "ndtxt.hxx" #include <UndoCore.hxx> #include "rolbck.hxx" +#include "docary.hxx" //-------------------------------------------------- diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 11dbb4b7eeaa..95b15f3e6ce9 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -426,8 +426,8 @@ SwUndoTblToTxt::SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ) const SwTableNode* pTblNd = rTbl.GetTableNode(); sal_uLong nTblStt = pTblNd->GetIndex(), nTblEnd = pTblNd->EndOfSectionIndex(); - const SwSpzFrmFmts& rFrmFmtTbl = *pTblNd->GetDoc()->GetSpzFrmFmts(); - for( sal_uInt16 n = 0; n < rFrmFmtTbl.Count(); ++n ) + const SwFrmFmts& rFrmFmtTbl = *pTblNd->GetDoc()->GetSpzFrmFmts(); + for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n ) { SwFrmFmt* pFmt = rFrmFmtTbl[ n ]; SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); @@ -889,7 +889,7 @@ _SaveTable::_SaveTable( const SwTable& rTbl, sal_uInt16 nLnCnt, sal_Bool bSaveFm for( sal_uInt16 n = 1; n < nLnCnt; ++n ) pLn = new _SaveLine( pLn, *rTbl.GetTabLines()[ n ], *this ); - aFrmFmts.Remove( 0, aFrmFmts.Count() ); + aFrmFmts.clear(); pSwTable = 0; } @@ -925,7 +925,7 @@ sal_uInt16 _SaveTable::AddFmt( SwFrmFmt* pFmt, bool bIsLine ) } nRet = aSets.size(); aSets.push_back( pSet ); - aFrmFmts.Insert( pFmt, nRet ); + aFrmFmts.insert( aFrmFmts.begin() + nRet, pFmt ); } return nRet; } @@ -960,7 +960,7 @@ void _SaveTable::RestoreAttr( SwTable& rTbl, sal_Bool bMdfyBox ) // fill FrmFmts with defaults (0) pFmt = 0; for( n = aSets.size(); n; --n ) - aFrmFmts.Insert( pFmt, aFrmFmts.Count() ); + aFrmFmts.push_back( pFmt ); sal_uInt16 nLnCnt = nLineCount; if( USHRT_MAX == nLnCnt ) @@ -978,7 +978,7 @@ void _SaveTable::RestoreAttr( SwTable& rTbl, sal_Bool bMdfyBox ) pLn->RestoreAttr( *rTbl.GetTabLines()[ n ], *this ); } - aFrmFmts.Remove( 0, aFrmFmts.Count() ); + aFrmFmts.clear(); bModifyBox = sal_False; } @@ -1013,10 +1013,10 @@ void _SaveTable::CreateNew( SwTable& rTbl, sal_Bool bCreateFrms, // fill FrmFmts with defaults (0) pFmt = 0; for( n = aSets.size(); n; --n ) - aFrmFmts.Insert( pFmt, aFrmFmts.Count() ); + aFrmFmts.push_back( pFmt ); pLine->CreateNew( rTbl, aParent, *this ); - aFrmFmts.Remove( 0, aFrmFmts.Count() ); + aFrmFmts.clear(); // add new lines, delete old ones sal_uInt16 nOldLines = nLineCount; @@ -1093,7 +1093,7 @@ void _SaveTable::NewFrmFmt( const SwTableLine* pTblLn, const SwTableBox* pTblBx, else pFmt = pDoc->MakeTableBoxFmt(); pFmt->SetFmtAttr( *aSets[ nFmtPos ] ); - aFrmFmts.Replace( pFmt, nFmtPos ); + aFrmFmts[nFmtPos] = pFmt; } // first re-assign Frms @@ -1183,7 +1183,7 @@ void _SaveLine::CreateNew( SwTable& rTbl, SwTableBox& rParent, _SaveTable& rSTbl SwDoc* pDoc = rTbl.GetFrmFmt()->GetDoc(); pFmt = pDoc->MakeTableLineFmt(); pFmt->SetFmtAttr( *rSTbl.aSets[ nItemSet ] ); - rSTbl.aFrmFmts.Replace( pFmt, nItemSet ); + rSTbl.aFrmFmts[ nItemSet ] = pFmt; } SwTableLine* pNew = new SwTableLine( pFmt, 1, &rParent ); @@ -1337,7 +1337,7 @@ void _SaveBox::CreateNew( SwTable& rTbl, SwTableLine& rParent, _SaveTable& rSTbl SwDoc* pDoc = rTbl.GetFrmFmt()->GetDoc(); pFmt = pDoc->MakeTableBoxFmt(); pFmt->SetFmtAttr( *rSTbl.aSets[ nItemSet ] ); - rSTbl.aFrmFmts.Replace( pFmt, nItemSet ); + rSTbl.aFrmFmts[nItemSet] = pFmt; } if( ULONG_MAX == nSttNode ) // no EndBox diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 7e212c3b1c81..9888f316e013 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -59,7 +59,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) if( !nSttCntnt ) // than take the Flys along { - sal_uInt16 nArrLen = pDoc->GetSpzFrmFmts()->Count(); + sal_uInt16 nArrLen = pDoc->GetSpzFrmFmts()->size(); for( sal_uInt16 n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; @@ -112,7 +112,7 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, sal_Bool bScanFlys, { // than collect all new Flys SwDoc* pDoc = (SwDoc*)rPam.GetDoc(); - sal_uInt16 nFndPos, nArrLen = pDoc->GetSpzFrmFmts()->Count(); + sal_uInt16 nFndPos, nArrLen = pDoc->GetSpzFrmFmts()->size(); for( sal_uInt16 n = 0; n < nArrLen; ++n ) { SwFrmFmt* pFmt = (*pDoc->GetSpzFrmFmts())[n]; diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 9ddee9633e64..e64ccfeadd55 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -151,7 +151,7 @@ void SwChartLockController_Helper::LockUnlockAllCharts( sal_Bool bLock ) return; const SwFrmFmts& rTblFmts = *pDoc->GetTblFrmFmts(); - for( sal_uInt16 n = 0; n < rTblFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rTblFmts.size(); ++n ) { SwTable* pTmpTbl; const SwTableNode* pTblNd; diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 859cbd085710..ba7a538f971b 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1106,12 +1106,12 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc) : m_aFrames() { SolarMutexGuard aGuard; - const SwSpzFrmFmts* const pFmts = pDoc->GetSpzFrmFmts(); - if(!pFmts->Count()) + const SwFrmFmts* const pFmts = pDoc->GetSpzFrmFmts(); + if(pFmts->empty()) return; // #i104937# // const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()]; - const sal_uInt16 nSize = pFmts->Count(); + const sal_uInt16 nSize = pFmts->size(); ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin()); // #i104937# SwFrmFmt* pFmt( 0 ); @@ -1458,7 +1458,7 @@ sal_Int32 SwXTextSections::getCount(void) throw( uno::RuntimeException ) if(!IsValid()) throw uno::RuntimeException(); const SwSectionFmts& rSectFmts = GetDoc()->GetSections(); - sal_uInt16 nCount = rSectFmts.Count(); + sal_uInt16 nCount = rSectFmts.size(); for(sal_uInt16 i = nCount; i; i--) { if( !rSectFmts[i - 1]->IsInNodesArr()) @@ -1477,7 +1477,7 @@ uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex) SwSectionFmts& rFmts = GetDoc()->GetSections(); const SwSectionFmts& rSectFmts = GetDoc()->GetSections(); - sal_uInt16 nCount = rSectFmts.Count(); + sal_uInt16 nCount = rSectFmts.size(); for(sal_uInt16 i = 0; i < nCount; i++) { if( !rSectFmts[i]->IsInNodesArr()) @@ -1487,7 +1487,7 @@ uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex) if(nIndex == i) break; } - if(nIndex >= 0 && nIndex < rFmts.Count()) + if(nIndex >= 0 && nIndex < (sal_Int32)rFmts.size()) { SwSectionFmt* pFmt = rFmts[(sal_uInt16)nIndex]; xRet = GetObject(*pFmt); @@ -1510,7 +1510,7 @@ uno::Any SwXTextSections::getByName(const OUString& Name) String aName(Name); SwSectionFmts& rFmts = GetDoc()->GetSections(); uno::Reference< XTextSection > xSect; - for(sal_uInt16 i = 0; i < rFmts.Count(); i++) + for(sal_uInt16 i = 0; i < rFmts.size(); i++) { SwSectionFmt* pFmt = rFmts[i]; if (pFmt->IsInNodesArr() @@ -1535,7 +1535,7 @@ uno::Sequence< OUString > SwXTextSections::getElementNames(void) SolarMutexGuard aGuard; if(!IsValid()) throw uno::RuntimeException(); - sal_uInt16 nCount = GetDoc()->GetSections().Count(); + sal_uInt16 nCount = GetDoc()->GetSections().size(); SwSectionFmts& rSectFmts = GetDoc()->GetSections(); for(sal_uInt16 i = nCount; i; i--) { @@ -1571,7 +1571,7 @@ sal_Bool SwXTextSections::hasByName(const OUString& Name) if(IsValid()) { SwSectionFmts& rFmts = GetDoc()->GetSections(); - for(sal_uInt16 i = 0; i < rFmts.Count(); i++) + for(sal_uInt16 i = 0; i < rFmts.size(); i++) { const SwSectionFmt* pFmt = rFmts[i]; if (aName == pFmt->GetSection()->GetSectionName()) @@ -1602,7 +1602,7 @@ sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException ) if(IsValid()) { SwSectionFmts& rFmts = GetDoc()->GetSections(); - nCount = rFmts.Count(); + nCount = rFmts.size(); } else throw uno::RuntimeException(); diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 0993721b22f1..6167cdc5172c 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -608,7 +608,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) { // get CharStyle and set the rule - sal_uInt16 nChCount = pDoc->GetCharFmts()->Count(); + sal_uInt16 nChCount = pDoc->GetCharFmts()->size(); SwCharFmt* pCharFmt = 0; for(sal_uInt16 nCharFmt = 0; nCharFmt < nChCount; nCharFmt++) { diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 586c498a0005..c36ed8377d1c 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -853,7 +853,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, rPropertyName, rValue, aAttrSet); const SwSectionFmts& rSects = m_pImpl->m_pDoc->GetSections(); - for (sal_uInt16 i = 0; i < rSects.Count(); i++) + for (sal_uInt16 i = 0; i < rSects.size(); i++) { const SwSectionFmt* pTmpFmt = rSects[ i ]; if (pTmpFmt == pSectionFmt) @@ -2399,7 +2399,7 @@ SwXDocumentIndexes::getCount() throw (uno::RuntimeException) sal_uInt32 nRet = 0; const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && @@ -2424,7 +2424,7 @@ throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, sal_Int32 nIdx = 0; const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && @@ -2455,7 +2455,7 @@ throw (container::NoSuchElementException, lang::WrappedTargetException, String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { const SwSection* pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && @@ -2485,7 +2485,7 @@ SwXDocumentIndexes::getElementNames() throw (uno::RuntimeException) const SwSectionFmts& rFmts = GetDoc()->GetSections(); sal_Int32 nCount = 0; sal_uInt16 n; - for( n = 0; n < rFmts.Count(); ++n ) + for( n = 0; n < rFmts.size(); ++n ) { SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && @@ -2498,7 +2498,7 @@ SwXDocumentIndexes::getElementNames() throw (uno::RuntimeException) uno::Sequence< OUString > aRet(nCount); OUString* pArray = aRet.getArray(); sal_uInt16 nCnt; - for( n = 0, nCnt = 0; n < rFmts.Count(); ++n ) + for( n = 0, nCnt = 0; n < rFmts.size(); ++n ) { SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && @@ -2522,7 +2522,7 @@ throw (uno::RuntimeException) String sToFind(rName); const SwSectionFmts& rFmts = GetDoc()->GetSections(); - for( sal_uInt16 n = 0; n < rFmts.Count(); ++n ) + for( sal_uInt16 n = 0; n < rFmts.size(); ++n ) { SwSection const*const pSect = rFmts[ n ]->GetSection(); if( TOX_CONTENT_SECTION == pSect->GetType() && diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index ea121c15581e..a7b05760204b 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -230,8 +230,8 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, } else { - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); - sal_uInt16 nSize = rFmts.Count(); + const SwFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); + sal_uInt16 nSize = rFmts.size(); for ( sal_uInt16 i = 0; i < nSize; i++) { const SwFrmFmt* pFmt = rFmts[ i ]; diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 338c37666217..7ba330534936 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -530,7 +530,7 @@ lcl_UpdateSection(SwSectionFmt *const pFmt, SwDoc *const pDoc = pFmt->GetDoc(); SwSectionFmts const& rFmts = pDoc->GetSections(); UnoActionContext aContext(pDoc); - for (sal_uInt16 i = 0; i < rFmts.Count(); i++) + for (sal_uInt16 i = 0; i < rFmts.size(); i++) { if (rFmts[i]->GetSection()->GetSectionName() == rSection.GetSectionName()) @@ -1728,7 +1728,7 @@ throw (uno::RuntimeException) const SwSectionFmts& rFmts = pFmt->GetDoc()->GetSections(); sal_uInt16 nApplyPos = USHRT_MAX; - for( sal_uInt16 i = 0; i < rFmts.Count(); i++ ) + for( sal_uInt16 i = 0; i < rFmts.size(); i++ ) { if(rFmts[i]->GetSection() == pSect) { diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 255121b8e68a..d8267c62dc84 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -1262,7 +1262,7 @@ void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElemen rProperties, nIndex); //hier noch die Zeichenformate bei Bedarf setzen const SwCharFmts* pFmts = pDocShell->GetDoc()->GetCharFmts(); - sal_uInt16 nChCount = pFmts->Count(); + sal_uInt16 nChCount = pFmts->size(); for(sal_uInt16 i = 0; i < MAXLEVEL;i++) { SwNumFmt aFmt(aNumRule.Get( i )); @@ -1565,7 +1565,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex( //Vorlagenname String sValue(SW_RES(STR_POOLCOLL_HEADLINE1 + nIndex)); const SwTxtFmtColls* pColls = pDocShell->GetDoc()->GetTxtFmtColls(); - const sal_uInt16 nCount = pColls->Count(); + const sal_uInt16 nCount = pColls->size(); for(sal_uInt16 i = 0; i < nCount;++i) { SwTxtFmtColl &rTxtColl = *pColls->operator[](i); @@ -1767,7 +1767,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex( { SwDoc* pLocalDoc = pDoc ? pDoc : pDocShell->GetDoc(); const SwCharFmts* pFmts = pLocalDoc->GetCharFmts(); - sal_uInt16 nChCount = pFmts->Count(); + sal_uInt16 nChCount = pFmts->size(); SwCharFmt* pCharFmt = 0; if(sCharFmtName.Len()) @@ -1926,7 +1926,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex( String sStyleName; SwStyleNameMapper::FillUIName(uTmp, sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); const SwTxtFmtColls* pColls = pDoc->GetTxtFmtColls(); - const sal_uInt16 nCount = pColls->Count(); + const sal_uInt16 nCount = pColls->size(); for(sal_uInt16 k = 0; k < nCount; ++k) { SwTxtFmtColl &rTxtColl = *((*pColls)[k]); @@ -2081,7 +2081,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex( String sStyleName; SwStyleNameMapper::FillUIName(uTmp, sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True ); const SwTxtFmtColls* pColls = pDocShell->GetDoc()->GetTxtFmtColls(); - const sal_uInt16 nCount = pColls->Count(); + const sal_uInt16 nCount = pColls->size(); for(sal_uInt16 k = 0; k < nCount; ++k) { SwTxtFmtColl &rTxtColl = *((*pColls)[k]); diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 9c645f3c2c8b..b18b165e044b 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -483,7 +483,7 @@ sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN + RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN; nIndex = nIndex - nBaseCount; - const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count(); + const sal_uInt16 nArrLen = rDoc.GetCharFmts()->size(); for( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ]; @@ -516,7 +516,7 @@ sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN + RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN; nIndex = nIndex - nBaseCount; - const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count(); + const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->size(); for ( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i]; @@ -539,7 +539,7 @@ sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String { sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN; nIndex = nIndex - nBaseCount; - const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count(); + const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->size(); for( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ]; @@ -1744,7 +1744,7 @@ void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, SwNumRule aSetRule(*pSwXRules->GetNumRule()); const SwCharFmts* pFmts = pDoc->GetCharFmts(); - sal_uInt16 nChCount = pFmts->Count(); + sal_uInt16 nChCount = pFmts->size(); for(sal_uInt16 i = 0; i < MAXLEVEL; i++) { diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 78027ba4e382..1de094b9872b 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3469,7 +3469,7 @@ void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException ) sal_Bool bNameFound = sal_False; SwFrmFmt* pTmpFmt; const SwFrmFmts* pTbl = pFmt->GetDoc()->GetTblFrmFmts(); - for( sal_uInt16 i = pTbl->Count(); i; ) + for( sal_uInt16 i = pTbl->size(); i; ) if( !( pTmpFmt = (*pTbl)[ --i ] )->IsDefault() && pTmpFmt->GetName() == sNewTblName && pFmt->GetDoc()->IsUsed( *pTmpFmt )) diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 241aae3068ea..a1043ef8f5e0 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1668,7 +1668,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) // see if there are frames already anchored to this node std::vector<SwFrmFmt*> aAnchoredFrames; - for (int i = 0; i < m_pImpl->m_pDoc->GetSpzFrmFmts()->Count(); ++i) + for (int i = 0; i < (int)m_pImpl->m_pDoc->GetSpzFrmFmts()->size(); ++i) { SwFrmFmt* pFrmFmt = (*m_pImpl->m_pDoc->GetSpzFrmFmts())[i]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); diff --git a/sw/source/filter/ascii/wrtasc.cxx b/sw/source/filter/ascii/wrtasc.cxx index f56406ee06a2..b36d09a6121b 100644 --- a/sw/source/filter/ascii/wrtasc.cxx +++ b/sw/source/filter/ascii/wrtasc.cxx @@ -143,7 +143,7 @@ sal_uLong SwASCWriter::WriteStream() // No length !pNd->GetTxt().Len() && // Frame exists - pDoc->GetSpzFrmFmts()->Count() && + pDoc->GetSpzFrmFmts()->size() && // Only one node in the array pDoc->GetNodes().GetEndOfExtras().GetIndex() + 3 == pDoc->GetNodes().GetEndOfContent().GetIndex() && diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 73ff75ac9e8d..7cfe5e31953b 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -147,7 +147,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) RedlineMode_t ePostReadRedlineMode( nsRedlineMode_t::REDLINE_IGNORE ); // Array von FlyFormaten - SwSpzFrmFmts aFlyFrmArr; + SwFrmFmts aFlyFrmArr; // only read templates? then ignore multi selection! sal_Bool bFmtsOnly = po->aOpt.IsFmtsOnly(); @@ -168,7 +168,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) // Speicher mal alle Fly's if( pCrsr ) - aFlyFrmArr.Insert( pDoc->GetSpzFrmFmts(), 0L ); + std::copy( pDoc->GetSpzFrmFmts()->begin(), pDoc->GetSpzFrmFmts()->end(), aFlyFrmArr.begin() ); xub_StrLen nSttCntnt = pPam->GetPoint()->nContent.GetIndex(); @@ -229,7 +229,7 @@ sal_uLong SwReader::Read( const Reader& rOptions ) // Suche alle neuen Fly's und speicher sie als einzelne Undo // Objecte - for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->Count(); ++n ) + for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n ) { SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ n ]; const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor(); @@ -306,8 +306,8 @@ sal_uLong SwReader::Read( const Reader& rOptions ) } } } - if( aFlyFrmArr.Count() ) - aFlyFrmArr.Remove( 0, aFlyFrmArr.Count() ); + if( !aFlyFrmArr.empty() ) + aFlyFrmArr.clear(); pDoc->SetRedlineMode_intern( eOld ); if( pDoc->IsRedlineOn() ) diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 7c5c69cb6dad..bc8441701a76 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -638,7 +638,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, sal_Bool bUsed ) // das Default-TextStyle wir nicht mit ausgegeben !! // das 0-Style ist das Default, wird nie ausgegeben !! - sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->Count(); + sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->size(); sal_uInt16 i; for( i = 1; i < nArrLen; i++ ) @@ -651,7 +651,7 @@ void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc, sal_Bool bUsed ) } // das Default-TextStyle wir nicht mit ausgegeben !! - nArrLen = pDoc->GetCharFmts()->Count(); + nArrLen = pDoc->GetCharFmts()->size(); for( i=1; i<nArrLen; i++ ) { const SwCharFmt *pCFmt = (*pDoc->GetCharFmts())[i]; diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index 8cf47ed69645..494873488621 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -1248,13 +1248,13 @@ SwCharFmt* SwCSS1Parser::GetChrFmt( sal_uInt16 nToken2, const String& rClass ) c SwTxtFmtColl *SwCSS1Parser::GetTxtCollFromPool( sal_uInt16 nPoolId ) const { - sal_uInt16 nOldArrLen = pDoc->GetTxtFmtColls()->Count(); + sal_uInt16 nOldArrLen = pDoc->GetTxtFmtColls()->size(); SwTxtFmtColl *pColl = pDoc->GetTxtCollFromPool( nPoolId, false ); if( bIsNewDoc ) { - sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->Count(); + sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->size(); for( sal_uInt16 i=nOldArrLen; i<nArrLen; i++ ) lcl_swcss1_setEncoding( *(*pDoc->GetTxtFmtColls())[i], GetDfltEncoding() ); @@ -1265,13 +1265,13 @@ SwTxtFmtColl *SwCSS1Parser::GetTxtCollFromPool( sal_uInt16 nPoolId ) const SwCharFmt *SwCSS1Parser::GetCharFmtFromPool( sal_uInt16 nPoolId ) const { - sal_uInt16 nOldArrLen = pDoc->GetCharFmts()->Count(); + sal_uInt16 nOldArrLen = pDoc->GetCharFmts()->size(); SwCharFmt *pCharFmt = pDoc->GetCharFmtFromPool( nPoolId ); if( bIsNewDoc ) { - sal_uInt16 nArrLen = pDoc->GetCharFmts()->Count(); + sal_uInt16 nArrLen = pDoc->GetCharFmts()->size(); for( sal_uInt16 i=nOldArrLen; i<nArrLen; i++ ) lcl_swcss1_setEncoding( *(*pDoc->GetCharFmts())[i], @@ -2397,12 +2397,12 @@ void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc ) } // Change all paragraph styles that do specify a font. - sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->Count(); + sal_uInt16 nArrLen = pDoc->GetTxtFmtColls()->size(); for( i=1; i<nArrLen; i++ ) lcl_swcss1_setEncoding( *(*pDoc->GetTxtFmtColls())[i], eEnc ); // Change all character styles that do specify a font. - nArrLen = pDoc->GetCharFmts()->Count(); + nArrLen = pDoc->GetCharFmts()->size(); for( i=1; i<nArrLen; i++ ) lcl_swcss1_setEncoding( *(*pDoc->GetCharFmts())[i], eEnc ); } diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 69cc678e1cf4..7057aedd550e 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -1433,8 +1433,8 @@ void SwHTMLWriter::GetControls() } // und jetzt die in einem zeichengebundenen Rahmen - const SwSpzFrmFmts* pSpzFrmFmts = pDoc->GetSpzFrmFmts(); - for( i=0; i<pSpzFrmFmts->Count(); i++ ) + const SwFrmFmts* pSpzFrmFmts = pDoc->GetSpzFrmFmts(); + for( i=0; i<pSpzFrmFmts->size(); i++ ) { const SwFrmFmt *pFrmFmt = (*pSpzFrmFmts)[i]; if( RES_DRAWFRMFMT != pFrmFmt->Which() ) diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 789292e460cd..30b994df0d6c 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -1314,9 +1314,9 @@ void SwHTMLParser::StripTrailingPara() { sal_uLong nNodeIdx = pPam->GetPoint()->nNode.GetIndex(); - const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); + const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - for( sal_uInt16 i=0; i<rFrmFmtTbl.Count(); i++ ) + for( sal_uInt16 i=0; i<rFrmFmtTbl.size(); i++ ) { SwFrmFmt const*const pFmt = rFrmFmtTbl[i]; SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 2f0819454571..6da5da760823 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -4414,10 +4414,10 @@ sal_Bool SwHTMLParser::HasCurrentParaFlys( sal_Bool bNoSurroundOnly, // sonst: Der Absatz enthaelt irgendeinen Rahmen SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode; - const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); + const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); sal_Bool bFound = sal_False; - for ( sal_uInt16 i=0; i<rFrmFmtTbl.Count(); i++ ) + for ( sal_uInt16 i=0; i<rFrmFmtTbl.size(); i++ ) { SwFrmFmt *const pFmt = rFrmFmtTbl[i]; SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); @@ -5067,9 +5067,9 @@ void SwHTMLParser::InsertLineBreak() SwTxtNode* pTxtNd = rNodeIdx.GetNode().GetTxtNode(); if( pTxtNd ) { - const SwSpzFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); + const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts(); - for( sal_uInt16 i=0; i<rFrmFmtTbl.Count(); i++ ) + for( sal_uInt16 i=0; i<rFrmFmtTbl.size(); i++ ) { SwFrmFmt *const pFmt = rFrmFmtTbl[i]; SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor(); diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index f13f158071cf..740e97dcf175 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -208,8 +208,8 @@ sal_uLong SwHTMLWriter::WriteStream() bOldHTMLMode = pTemplate->get(IDocumentSettingAccess::HTML_MODE); pTemplate->set(IDocumentSettingAccess::HTML_MODE, true); - nOldTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->Count(); - nOldCharFmtCnt = pTemplate->GetCharFmts()->Count(); + nOldTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->size(); + nOldCharFmtCnt = pTemplate->GetCharFmts()->size(); } if( bShowProgress ) @@ -432,16 +432,16 @@ sal_uLong SwHTMLWriter::WriteStream() { // Waehrend des Exports angelegte Zeichen- und Abastzvorlagen // loeschen - sal_uInt16 nTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->Count(); + sal_uInt16 nTxtFmtCollCnt = pTemplate->GetTxtFmtColls()->size(); while( nTxtFmtCollCnt > nOldTxtFmtCollCnt ) pTemplate->DelTxtFmtColl( --nTxtFmtCollCnt ); - OSL_ENSURE( pTemplate->GetTxtFmtColls()->Count() == nOldTxtFmtCollCnt, + OSL_ENSURE( pTemplate->GetTxtFmtColls()->size() == nOldTxtFmtCollCnt, "falsche Anzahl TxtFmtColls geloescht" ); - sal_uInt16 nCharFmtCnt = pTemplate->GetCharFmts()->Count(); + sal_uInt16 nCharFmtCnt = pTemplate->GetCharFmts()->size(); while( nCharFmtCnt > nOldCharFmtCnt ) pTemplate->DelCharFmt( --nCharFmtCnt ); - OSL_ENSURE( pTemplate->GetCharFmts()->Count() == nOldCharFmtCnt, + OSL_ENSURE( pTemplate->GetCharFmts()->size() == nOldCharFmtCnt, "falsche Anzahl CharFmts geloescht" ); // HTML-Modus wieder restaurieren diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 2e8553a011fb..5c76ed20333b 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -491,10 +491,10 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_False ).nNode.GetIndex() ) { // Do not delete the paragraph if it has anchored objects: bool bAnchoredObjs = false; - const SwSpzFrmFmts* pFrmFmts = pDoc->GetSpzFrmFmts(); - if ( pFrmFmts && pFrmFmts->Count() ) + const SwFrmFmts* pFrmFmts = pDoc->GetSpzFrmFmts(); + if ( pFrmFmts && !pFrmFmts->empty() ) { - for ( sal_uInt16 nI = pFrmFmts->Count(); nI; --nI ) + for ( sal_uInt16 nI = pFrmFmts->size(); nI; --nI ) { const SwFmtAnchor & rAnchor = (*pFrmFmts)[ nI - 1 ]->GetAnchor(); if ((FLY_AT_PARA == rAnchor.GetAnchorId()) || @@ -2711,7 +2711,7 @@ void SwRTFParser::MakeStyleTab() { // search all outlined collections const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls(); - for( sal_uInt16 n = rColls.Count(); n; ) + for( sal_uInt16 n = rColls.size(); n; ) if( rColls[ --n ]->IsAssignedToListLevelOfOutlineStyle()) nValidOutlineLevels |= 1 << rColls[ n ]->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei } diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 7f1c13f1ad49..97038a72856d 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -447,7 +447,7 @@ namespace sw typedef ParaStyles::size_type mysizet; const SwTxtFmtColls *pColls = rDoc.GetTxtFmtColls(); - mysizet nCount = pColls ? pColls->Count() : 0; + mysizet nCount = pColls ? pColls->size() : 0; aStyles.reserve(nCount); for (mysizet nI = 0; nI < nCount; ++nI) aStyles.push_back((*pColls)[ static_cast< sal_uInt16 >(nI) ]); diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index b1686c591499..6e5166e4fe62 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -146,8 +146,8 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport ) m_rExport.pDoc->GetFtnInfo().GetAnchorCharFmt( *m_rExport.pDoc ); m_rExport.pDoc->GetFtnInfo().GetCharFmt( *m_rExport.pDoc ); } - sal_uInt16 nAlloc = WW8_RESERVED_SLOTS + m_rExport.pDoc->GetCharFmts()->Count() - 1 + - m_rExport.pDoc->GetTxtFmtColls()->Count() - 1; + sal_uInt16 nAlloc = WW8_RESERVED_SLOTS + m_rExport.pDoc->GetCharFmts()->size() - 1 + + m_rExport.pDoc->GetTxtFmtColls()->size() - 1; // etwas grosszuegig ( bis zu 15 frei ) pFmtA = new SwFmt*[ nAlloc ]; @@ -272,21 +272,19 @@ void MSWordStyles::BuildStylesTable() { nUsedSlots = WW8_RESERVED_SLOTS; // soviele sind reserviert fuer // Standard und HeadingX u.a. - SwFmt* pFmt; - sal_uInt16 n; - const SvPtrarr& rArr = *m_rExport.pDoc->GetCharFmts(); // erst CharFmt + const SwCharFmts& rArr = *m_rExport.pDoc->GetCharFmts(); // erst CharFmt // das Default-ZeichenStyle ( 0 ) wird nicht mit ausgegeben ! - for( n = 1; n < rArr.Count(); n++ ) + for( sal_uInt16 n = 1; n < rArr.size(); n++ ) { - pFmt = (SwFmt*)rArr[n]; + SwCharFmt* pFmt = rArr[n]; pFmtA[ BuildGetSlot( *pFmt ) ] = pFmt; } - const SvPtrarr& rArr2 = *m_rExport.pDoc->GetTxtFmtColls(); // dann TxtFmtColls + const SwTxtFmtColls& rArr2 = *m_rExport.pDoc->GetTxtFmtColls(); // dann TxtFmtColls // das Default-TextStyle ( 0 ) wird nicht mit ausgegeben ! - for( n = 1; n < rArr2.Count(); n++ ) + for( sal_uInt16 n = 1; n < rArr2.size(); n++ ) { - pFmt = (SwFmt*)rArr2[n]; + SwTxtFmtColl* pFmt = rArr2[n]; pFmtA[ BuildGetSlot( *pFmt ) ] = pFmt; } } diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 28e8c29e80da..04fe6395cf89 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2802,7 +2802,7 @@ namespace void MSWordExportBase::ExportDocument( bool bWriteAll ) { nCharFmtStart = ANZ_DEFAULT_STYLES; - nFmtCollStart = nCharFmtStart + pDoc->GetCharFmts()->Count() - 1; + nFmtCollStart = nCharFmtStart + pDoc->GetCharFmts()->size() - 1; bStyDef = bBreakBefore = bOutKF = bOutFlyFrmAttrs = bOutPageDescs = bOutTable = bOutFirstPage = diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 52cc2bc74d43..ed60d5a26a2e 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -96,6 +96,7 @@ #include <txtftn.hxx> #include <poolfmt.hxx> #include <doc.hxx> // Doc for footnotes +#include <docary.hxx> #include <pam.hxx> #include <paratr.hxx> #include <fldbas.hxx> // for SwField @@ -2162,7 +2163,7 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) // styles 1-9 and find the lowest valid outline level sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL; const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls(); - for( n = rColls.Count(); n; ) + for( n = rColls.size(); n; ) { const SwTxtFmtColl* pColl = rColls[ --n ]; sal_uInt16 nPoolId = pColl->GetPoolFmtId(); @@ -2198,7 +2199,7 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) if( nMaxMSAutoEvaluate < nTOXLvl ) { // collect this templates into the \t otion - for( n = rColls.Count(); n;) + for( n = rColls.size(); n;) { const SwTxtFmtColl* pColl = rColls[ --n ]; if (!pColl->IsAssignedToListLevelOfOutlineStyle()) diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 15eed4fe8ec6..e45e0e6989c4 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -67,7 +67,7 @@ WW8Glossary::WW8Glossary(SvStorageStreamRef &refStrm, sal_uInt8 nVersion, bool WW8Glossary::HasBareGraphicEnd(SwDoc *pDoc,SwNodeIndex &rIdx) { bool bRet=false; - for( sal_uInt16 nCnt = pDoc->GetSpzFrmFmts()->Count(); nCnt; ) + for( sal_uInt16 nCnt = pDoc->GetSpzFrmFmts()->size(); nCnt; ) { SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ --nCnt ]; if ( RES_FLYFRMFMT != pFrmFmt->Which() && diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 5a6e5ff996d8..cfda96c4e7a5 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -60,6 +60,7 @@ #include <swerror.h> #include <fltini.hxx> #include <doc.hxx> +#include <docary.hxx> #include <docsh.hxx> #include <unotextrange.hxx> #include <swmodule.hxx> @@ -437,7 +438,7 @@ void lcl_AdjustOutlineStylesForOOo( SwDoc& _rDoc ) // determine, which outline level has already a style assigned and // which of the default outline styles is created. const SwTxtFmtColls& rColls = *(_rDoc.GetTxtFmtColls()); - for ( sal_uInt16 n = 1; n < rColls.Count(); ++n ) + for ( sal_uInt16 n = 1; n < rColls.size(); ++n ) { SwTxtFmtColl* pColl = rColls[ n ]; if ( pColl->IsAssignedToListLevelOfOutlineStyle() ) diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index d6017d24f0d3..e81657904018 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -243,9 +243,9 @@ sal_uInt32 SwXMLExport::exportDoc( enum XMLTokenEnum eClass ) // The styles in pDoc also count the default style that never // gets exported -> subtract one. sal_Int32 nRef = 1; // meta.xml - nRef += pDoc->GetCharFmts()->Count() - 1; - nRef += pDoc->GetFrmFmts()->Count() - 1; - nRef += pDoc->GetTxtFmtColls()->Count() - 1; + nRef += pDoc->GetCharFmts()->size() - 1; + nRef += pDoc->GetFrmFmts()->size() - 1; + nRef += pDoc->GetTxtFmtColls()->size() - 1; nRef *= 2; // for the above styles, xmloff will increment by 2! // #i93174#: count all paragraphs for the progress bar nRef += pDoc->GetUpdatedDocStat().nAllPara; // 1: only content, no autostyle diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index ebc9ceef12a1..1993146b7ae2 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -1046,7 +1046,7 @@ void SwXMLImport::UpdateTxtCollConditions( SwDoc *pDoc ) pDoc = SwImport::GetDocFromXMLImport( *this ); const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls(); - sal_uInt16 nCount = rColls.Count(); + sal_uInt16 nCount = rColls.size(); for( sal_uInt16 i=0; i < nCount; i++ ) { SwTxtFmtColl *pColl = rColls[i]; diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 7b73e115fdbd..c76ae6cf7c0d 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -73,6 +73,7 @@ #include <swevent.hxx> #include <view.hxx> // for the current view #include <docsh.hxx> // creation of documents +#include <docary.hxx> #include <wrtsh.hxx> #include <fldbas.hxx> #include <viewopt.hxx> @@ -1267,7 +1268,7 @@ void SwDocShell::Execute(SfxRequest& rReq) } } - const sal_uInt16 nStyleCount = pDoc->GetTxtFmtColls()->Count(); + const sal_uInt16 nStyleCount = pDoc->GetTxtFmtColls()->size(); Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount); OUString* pEntries = aListBoxEntries.getArray(); sal_Int32 nIdx = 0 ; @@ -1282,8 +1283,7 @@ void SwDocShell::Execute(SfxRequest& rReq) OUString sStyle( SW_RESSTR(STR_FDLG_STYLE) ); for(sal_uInt16 i = 0; i < nStyleCount; ++i) { - SwTxtFmtColl &rTxtColl = - *pDoc->GetTxtFmtColls()->GetObject( i ); + SwTxtFmtColl &rTxtColl = *(*pDoc->GetTxtFmtColls())[ i ]; if( !rTxtColl.IsDefault() && rTxtColl.IsAtDocNodeSet() ) { pEntries[nIdx++] = sStyle + rTxtColl.GetName(); diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index 2b5d8e1cee53..ac005e02626d 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -1378,7 +1378,7 @@ void lcl_SaveStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) case SFX_STYLE_FAMILY_CHAR: { const SwCharFmts& rTbl = *rDoc.GetCharFmts(); - for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) + for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n ) { void* p = (void*)rTbl[ n ]; rArr.Insert( p, n ); @@ -1388,7 +1388,7 @@ void lcl_SaveStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) case SFX_STYLE_FAMILY_PARA: { const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls(); - for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) + for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n ) { void* p = (void*)rTbl[ n ]; rArr.Insert( p, n ); @@ -1398,7 +1398,7 @@ void lcl_SaveStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) case SFX_STYLE_FAMILY_FRAME: { const SwFrmFmts& rTbl = *rDoc.GetFrmFmts(); - for( sal_uInt16 n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) + for( sal_uInt16 n = 0, nCnt = rTbl.size(); n < nCnt; ++n ) { void* p = (void*)rTbl[ n ]; rArr.Insert( p, n ); @@ -1439,7 +1439,7 @@ void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) { std::vector<sal_uInt16> aDelArr; const SwCharFmts& rTbl = *rDoc.GetCharFmts(); - for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) + for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n ) { void* p = (void*)rTbl[ n ]; if( USHRT_MAX == rArr.GetPos( p )) @@ -1454,7 +1454,7 @@ void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) { std::vector<sal_uInt16> aDelArr; const SwTxtFmtColls& rTbl = *rDoc.GetTxtFmtColls(); - for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) + for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n ) { void* p = (void*)rTbl[ n ]; if( USHRT_MAX == rArr.GetPos( p )) @@ -1469,7 +1469,7 @@ void lcl_DeleteInfoStyles( sal_uInt16 nFamily, SvPtrarr& rArr, SwDoc& rDoc ) { SvPtrarr aDelArr; const SwFrmFmts& rTbl = *rDoc.GetFrmFmts(); - for( n = 0, nCnt = rTbl.Count(); n < nCnt; ++n ) + for( n = 0, nCnt = rTbl.size(); n < nCnt; ++n ) { void* p = (void*)rTbl[ n ]; if( USHRT_MAX == rArr.GetPos( p )) @@ -2431,7 +2431,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() if( nSearchFamily == SFX_STYLE_FAMILY_CHAR || nSearchFamily == SFX_STYLE_FAMILY_ALL ) { - const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count(); + const sal_uInt16 nArrLen = rDoc.GetCharFmts()->size(); for( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ]; @@ -2507,7 +2507,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() nSMask = SWSTYLEBIT_HTML; } - const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count(); + const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->size(); for( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwTxtFmtColl* pColl = (*rDoc.GetTxtFmtColls())[ i ]; @@ -2650,7 +2650,7 @@ SfxStyleSheetBase* SwStyleSheetIterator::First() if( nSearchFamily == SFX_STYLE_FAMILY_FRAME || nSearchFamily == SFX_STYLE_FAMILY_ALL ) { - const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count(); + const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->size(); for( sal_uInt16 i = 0; i < nArrLen; i++ ) { SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ]; diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index e35dc9e27cd7..64f57ecb566e 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -79,9 +79,6 @@ using namespace ::com::sun::star; -// sw/inc/docary.hxx -SV_IMPL_PTRARR( SwSectionFmts, SwSectionFmtPtr ) - #define FILE_NAME_LENGTH 17 static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ); @@ -819,8 +816,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl) // are copied (ClearRedo!) const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections(); - SwSectionFmts aOrigArray( 0 ); - aOrigArray.Insert( &rDocFmts, 0 ); + SwSectionFmts aOrigArray(rDocFmts); rSh.StartAllAction(); rSh.StartUndo(); @@ -875,7 +871,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl) rSh.DelSectionFmt( nNewPos ); } - aOrigArray.Remove( 0, aOrigArray.Count() ); + aOrigArray.clear(); // EndDialog must be called ahead of EndAction's end, // otherwise ScrollError can occur. @@ -1144,12 +1140,11 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OptionsHdl) aSet.Put( pSectRepr->GetLRSpace() ); const SwSectionFmts& rDocFmts = rSh.GetDoc()->GetSections(); - SwSectionFmts aOrigArray( 0 ); - aOrigArray.Insert( &rDocFmts, 0 ); + SwSectionFmts aOrigArray(rDocFmts); SwSectionFmt* pFmt = aOrigArray[pSectRepr->GetArrPos()]; long nWidth = rSh.GetSectionWidth(*pFmt); - aOrigArray.Remove( 0, aOrigArray.Count() ); + aOrigArray.clear(); if (!nWidth) nWidth = USHRT_MAX; diff --git a/sw/source/ui/shells/langhelper.cxx b/sw/source/ui/shells/langhelper.cxx index 0a3ab1234fe7..68bfdcccefb8 100644 --- a/sw/source/ui/shells/langhelper.cxx +++ b/sw/source/ui/shells/langhelper.cxx @@ -303,17 +303,17 @@ namespace SwLangHelper //Resolves: fdo#35282 Clear the language from all Text Styles, and //fallback to default document language const SwTxtFmtColls *pColls = rWrtSh.GetDoc()->GetTxtFmtColls(); - for(sal_uInt16 i = 0, nCount = pColls->Count(); i < nCount; ++i) + for(sal_uInt16 i = 0, nCount = pColls->size(); i < nCount; ++i) { - SwTxtFmtColl &rTxtColl = *pColls->GetObject( i ); + SwTxtFmtColl &rTxtColl = *(*pColls)[ i ]; rTxtColl.ResetFmtAttr(nLangWhichId); } //Resolves: fdo#35282 Clear the language from all Character Styles, //and fallback to default document language const SwCharFmts *pCharFmts = rWrtSh.GetDoc()->GetCharFmts(); - for(sal_uInt16 i = 0, nCount = pCharFmts->Count(); i < nCount; ++i) + for(sal_uInt16 i = 0, nCount = pCharFmts->size(); i < nCount; ++i) { - SwCharFmt &rCharFmt = *pCharFmts->GetObject( i ); + SwCharFmt &rCharFmt = *(*pCharFmts)[ i ]; rCharFmt.ResetFmtAttr(nLangWhichId); } diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index b70670aa597c..df3230cce9a3 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -274,7 +274,7 @@ sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) std::vector<String> aFormats; SwDoc* pDoc = pDocShell->GetDoc(); - const sal_uInt16 nArrLen = pDoc->GetFrmFmts()->Count(); + const sal_uInt16 nArrLen = pDoc->GetFrmFmts()->size(); sal_uInt16 i; for( i = 0; i < nArrLen; i++ ) { diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index b39951a3d677..8dd56f56f991 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -3097,7 +3097,7 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages( //USER STYLES const SwCharFmts *pFmts = pDoc->GetCharFmts(); - for(sal_uInt16 i = 0; i < pFmts->Count(); ++i) + for(sal_uInt16 i = 0; i < pFmts->size(); ++i) { const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet(); LanguageType nLang = LANGUAGE_DONTKNOW; @@ -3122,7 +3122,7 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages( } const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls(); - for (sal_uInt16 i = 0; i < pColls->Count(); ++i) + for (sal_uInt16 i = 0; i < pColls->size(); ++i) { const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet(); LanguageType nLang = LANGUAGE_DONTKNOW; diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx index c56fab202d29..aea4c6cd901e 100644 --- a/sw/source/ui/utlui/uitool.cxx +++ b/sw/source/ui/utlui/uitool.cxx @@ -636,7 +636,7 @@ void FillCharStyleListBox(ListBox& rToFill, SwDocShell* pDocSh, sal_Bool bSorted } // non-pool styles const SwCharFmts* pFmts = pDoc->GetCharFmts(); - for(sal_uInt16 i = 0; i < pFmts->Count(); i++) + for(sal_uInt16 i = 0; i < pFmts->size(); i++) { const SwCharFmt* pFmt = (*pFmts)[i]; if(pFmt->IsDefault()) |