diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-23 15:01:34 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-05-25 00:17:07 +0200 |
commit | 4490eb8c9c701510a3370c900a6c6ec9e4f8a70d (patch) | |
tree | 198f6b6bf6c1527c68ac4b6ec43fbfd9aee0cf94 | |
parent | 385116041c1ca91d6df2c037a5a95460a1f0fb09 (diff) |
Convert V_DECL_PTRARR_DEL(SwFlySaveArr) to std::vector
I can't use boost::ptr_vector here because the code moves objects
around with free'ing them.
Change-Id: I42b8f347e2bac51bd63e2c42d6ebab2e7ad4b61c
-rw-r--r-- | sw/source/filter/rtf/rtffly.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/rtf/swparrtf.cxx | 28 | ||||
-rw-r--r-- | sw/source/filter/rtf/swparrtf.hxx | 15 |
3 files changed, 37 insertions, 28 deletions
diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index 826cb7e50726..e31d4d3d1bd2 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -75,8 +75,6 @@ using namespace ::com::sun::star; // steht in shellio.hxx extern SwCntntNode* GoNextNds( SwNodeIndex * pIdx, sal_Bool bChk ); -SV_IMPL_PTRARR( SwFlySaveArr, SwFlySave* ) - inline const SwFmtFrmSize GetFrmSize(const SfxItemSet& rSet, sal_Bool bInP=sal_True) { return (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE,bInP); @@ -226,7 +224,7 @@ void SwRTFParser::SetFlysInDoc() rtfFmtMap aPrevFmts; SwFrmFmt* pParent = pDoc->GetFrmFmtFromPool( RES_POOLFRM_FRAME ); - for( sal_uInt16 n = 0; n < aFlyArr.Count(); ++n ) + for( sal_uInt16 n = 0; n < aFlyArr.size(); ++n ) { SwFlySave* pFlySave = aFlyArr[ n ]; @@ -276,7 +274,7 @@ void SwRTFParser::SetFlysInDoc() // liegt Ende und Start vom Naechsten im gleichen Node, dann muss // gesplittet werden - if( n + 1 < aFlyArr.Count() && pFlySave->nEndCnt && + if( n + 1 < (sal_uInt16)aFlyArr.size() && pFlySave->nEndCnt && pFlySave->nEndNd == aFlyArr[ n + 1 ]->nSttNd ) { SwCntntNode *const pCNd = pFlySave->nEndNd.GetNode().GetCntntNode(); @@ -523,7 +521,7 @@ void SwRTFParser::SetFlysInDoc() } } - aFlyArr.Remove(0, aFlyArr.Count()); + aFlyArr.clear(); } // clips the text box to the min or max position if it is outside our min or max boundry @@ -979,7 +977,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) // ein neues FlyFormat anlegen oder das alte benutzen ? // (teste ob es die selben Attribute besitzt!) SwFlySave* pFlySave = 0; - sal_uInt16 nFlyArrCnt = aFlyArr.Count(); + sal_uInt16 nFlyArrCnt = aFlyArr.size(); /* #i5263# There were not enough frame properties found to actually justify creating @@ -1007,7 +1005,8 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) pFlySavePrev->nEndNd=pFlySave->nSttNd; } } - aFlyArr.Insert( pFlySave, nFlyArrCnt++ ); + aFlyArr.push_back( pFlySave ); + nFlyArrCnt++; // #i83368# - reset mbReadCellWhileReadSwFly = false; } @@ -1090,7 +1089,8 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) !pPam->GetPoint()->nContent.GetIndex() ) { // dann zerstoere den FlySave wieder. - aFlyArr.DeleteAndDestroy( --nFlyArrCnt ); + delete aFlyArr[ --nFlyArrCnt ]; + aFlyArr.erase( aFlyArr.begin() + nFlyArrCnt ); // Remove the properties that have been parsed before in the paragraph GetAttrStack().pop_back(); @@ -1237,12 +1237,12 @@ void SwRTFParser::InsPicture( const String& rGrfNm, const Graphic* pGrf, if( pGrfAttrSet ) pGrfNd->SetAttr( *pGrfAttrSet ); - SwFlySave* pFlySave = aFlyArr[ aFlyArr.Count()-1 ]; + SwFlySave* pFlySave = aFlyArr[ aFlyArr.size()-1 ]; pFlySave->nSttNd = rIdx.GetIndex() - 1; - if( 1 < aFlyArr.Count() ) + if( 1 < aFlyArr.size() ) { - pFlySave = aFlyArr[ aFlyArr.Count() - 2 ]; + pFlySave = aFlyArr[ aFlyArr.size() - 2 ]; if( pFlySave->nEndNd == rIdx ) pFlySave->nEndNd = rIdx.GetIndex() - 1; } diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 221b512248bf..396de09a7fb4 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -398,7 +398,7 @@ void SwRTFParser::Continue( int nToken ) // ein am 1. Absatz verankerter Fly falsch eingefuegt if( SVPAR_ACCEPTED == eState ) { - if( aFlyArr.Count() ) + if( !aFlyArr.empty() ) SetFlysInDoc(); pRelNumRule->SetOultineRelSpaces( *pSttNdIdx, pPam->GetPoint()->nNode ); } @@ -475,7 +475,7 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_False ).nNode.GetIndex() ) for (rtfSections::myrDummyIter aI = maSegments.maDummyPageNos.rbegin(); aI != aDEnd; ++aI) pDoc->DelPageDesc(*aI); - if( aFlyArr.Count() ) + if( !aFlyArr.empty() ) SetFlysInDoc(); // jetzt noch den letzten ueberfluessigen Absatz loeschen @@ -1145,9 +1145,6 @@ SwRTFParser::~SwRTFParser() delete pPam; delete pRelNumRule; - if (aFlyArr.Count()) - aFlyArr.DeleteAndDestroy( 0, aFlyArr.Count() ); - if (pGrfAttrSet) DELETEZ( pGrfAttrSet ); } @@ -3546,9 +3543,9 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) // save the fly array - after read, all flys may be set into // the header/footer - SwFlySaveArr aSaveArray( 255 < aFlyArr.Count() ? aFlyArr.Count() : 255 ); - aSaveArray.Insert( &aFlyArr, 0 ); - aFlyArr.Remove( 0, aFlyArr.Count() ); + SwFlySaveArr aSaveArray(aFlyArr); + aSaveArray.reserve(255); + aFlyArr.clear(); sal_Bool bSetFlyInDoc = sal_True; const SwNodeIndex* pSttIdx = 0; @@ -3665,7 +3662,7 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) break; } - sal_uInt16 nOldFlyArrCnt = aFlyArr.Count(); + sal_uInt16 nOldFlyArrCnt = aFlyArr.size(); if( !pSttIdx ) SkipGroup(); else @@ -3718,7 +3715,7 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) } SetAllAttrOfStk(); - if( aFlyArr.Count() && bSetFlyInDoc ) + if( !aFlyArr.empty() && bSetFlyInDoc ) SetFlysInDoc(); // sollte der letze Node leer sein, dann loesche ihn @@ -3730,12 +3727,13 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) if( pTxtAttr && RES_TXTATR_FLYCNT == pTxtAttr->Which() ) { // is add a new fly ? - if( nOldFlyArrCnt < aFlyArr.Count() ) + if( nOldFlyArrCnt < aFlyArr.size() ) { - SwFlySave* pFlySave = aFlyArr[ aFlyArr.Count()-1 ]; + SwFlySave* pFlySave = aFlyArr.back(); pFlySave->aFlySet.ClearItem( RES_ANCHOR ); pHdFtFmt->SetFmtAttr( pFlySave->aFlySet ); - aFlyArr.DeleteAndDestroy( aFlyArr.Count() - 1 ); + delete aFlyArr.back(); + aFlyArr.pop_back(); } else { @@ -3758,8 +3756,8 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) mbIsFootnote = bOldIsFootnote; GetAttrStack() = aSaveStack; - aFlyArr.Insert( &aSaveArray, 0 ); - aSaveArray.Remove( 0, aSaveArray.Count() ); + std::copy(aSaveArray.begin(), aSaveArray.end(), aFlyArr.begin() ); + aSaveArray.clear(); bContainsPara = bContainsParaCache; } diff --git a/sw/source/filter/rtf/swparrtf.hxx b/sw/source/filter/rtf/swparrtf.hxx index feab4083ab7e..ff9fa97c9362 100644 --- a/sw/source/filter/rtf/swparrtf.hxx +++ b/sw/source/filter/rtf/swparrtf.hxx @@ -146,8 +146,19 @@ struct SwListEntry bRuleUsed = sal_False; } }; -typedef SwFlySave* SwFlySavePtr; -SV_DECL_PTRARR_DEL( SwFlySaveArr, SwFlySavePtr, 0 ) +class SwFlySaveArr : public std::vector<SwFlySave*> +{ +public: + SwFlySaveArr() : vector() {} + SwFlySaveArr(const SwFlySaveArr& other) : vector(other) {} + + ~SwFlySaveArr() + { + for(const_iterator it = begin(); it != end(); ++it) + delete *it; + } +}; + typedef std::deque< SwListEntry > SwListArr; struct DocPageInformation |