diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-03 01:53:40 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-03 10:20:10 -0400 |
commit | 05173270c11a997096671c035c18692cfd6b51dc (patch) | |
tree | 486ee3ab0b5a77c2f36f897fd89b442169a01f9f /editeng | |
parent | 221cbbf64a20b87443f378fcb2ed22068867f494 (diff) |
Removed the last SC_DECL_PTRARR from editdoc.hxx.
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 100 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.hxx | 23 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 32 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 64 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 8 |
6 files changed, 148 insertions, 83 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 4d253d958caf..373e608297ff 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -68,6 +68,8 @@ #include <tools/shl.hxx> #include <com/sun/star/i18n/ScriptType.hpp> +#include <limits> + #include <boost/bind.hpp> using namespace ::com::sun::star; @@ -408,48 +410,104 @@ TextPortionList::~TextPortionList() void TextPortionList::Reset() { - for ( sal_uInt16 nPortion = 0; nPortion < Count(); nPortion++ ) - delete GetObject( nPortion ); - Remove( 0, Count() ); + maPortions.clear(); +} + +void TextPortionList::DeleteFromPortion(size_t nDelFrom) +{ + DBG_ASSERT( ( nDelFrom < maPortions.size() ) || ( (nDelFrom == 0) && maPortions.empty() ), "DeleteFromPortion: Out of range" ); + PortionsType::iterator it = maPortions.begin(); + std::advance(it, nDelFrom); + maPortions.erase(it, maPortions.end()); +} + +size_t TextPortionList::Count() const +{ + return maPortions.size(); +} + +const TextPortion* TextPortionList::operator[](size_t nPos) const +{ + return &maPortions[nPos]; +} + +TextPortion* TextPortionList::operator[](size_t nPos) +{ + return &maPortions[nPos]; +} + +void TextPortionList::Append(TextPortion* p) +{ + maPortions.push_back(p); +} + +void TextPortionList::Insert(size_t nPos, TextPortion* p) +{ + maPortions.insert(maPortions.begin()+nPos, p); } -void TextPortionList::DeleteFromPortion( sal_uInt16 nDelFrom ) +void TextPortionList::Remove(size_t nPos) { - DBG_ASSERT( ( nDelFrom < Count() ) || ( (nDelFrom == 0) && (Count() == 0) ), "DeleteFromPortion: Out of range" ); - for ( sal_uInt16 nP = nDelFrom; nP < Count(); nP++ ) - delete GetObject( nP ); - Remove( nDelFrom, Count()-nDelFrom ); + maPortions.erase(maPortions.begin()+nPos); } -sal_uInt16 TextPortionList::FindPortion( sal_uInt16 nCharPos, sal_uInt16& nPortionStart, sal_Bool bPreferStartingPortion ) const +namespace { + +class FindTextPortionByAddress : std::unary_function<TextPortion, bool> +{ + const TextPortion* mp; +public: + FindTextPortionByAddress(const TextPortion* p) : mp(p) {} + bool operator() (const TextPortion& v) const + { + return &v == mp; + } +}; + +} + +size_t TextPortionList::GetPos(const TextPortion* p) const +{ + PortionsType::const_iterator it = + std::find_if(maPortions.begin(), maPortions.end(), FindTextPortionByAddress(p)); + + if (it == maPortions.end()) + return std::numeric_limits<size_t>::max(); // not found. + + return std::distance(maPortions.begin(), it); +} + +size_t TextPortionList::FindPortion( + sal_uInt16 nCharPos, sal_uInt16& nPortionStart, bool bPreferStartingPortion) const { // When nCharPos at portion limit, the left portion is found sal_uInt16 nTmpPos = 0; - for ( sal_uInt16 nPortion = 0; nPortion < Count(); nPortion++ ) + size_t n = maPortions.size(); + for (size_t i = 0; i < n; ++i) { - TextPortion* pPortion = GetObject( nPortion ); - nTmpPos = nTmpPos + pPortion->GetLen(); + const TextPortion& rPortion = maPortions[i]; + nTmpPos = nTmpPos + rPortion.GetLen(); if ( nTmpPos >= nCharPos ) { // take this one if we don't prefer the starting portion, or if it's the last one - if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == Count() - 1 ) ) + if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( i == n-1 ) ) { - nPortionStart = nTmpPos - pPortion->GetLen(); - return nPortion; + nPortionStart = nTmpPos - rPortion.GetLen(); + return i; } } } OSL_FAIL( "FindPortion: Not found!" ); - return ( Count() - 1 ); + return n - 1; } -sal_uInt16 TextPortionList::GetStartPos( sal_uInt16 nPortion ) +sal_uInt16 TextPortionList::GetStartPos(size_t nPortion) { sal_uInt16 nPos = 0; - for ( sal_uInt16 n = 0; n < nPortion; n++ ) + for (size_t i = 0; i < nPortion; ++i) { - TextPortion* pPortion = GetObject( n ); - nPos = nPos + pPortion->GetLen(); + const TextPortion& rPortion = maPortions[i]; + nPos = nPos + rPortion.GetLen(); } return nPos; } @@ -987,7 +1045,7 @@ Size EditLine::CalcTextSize( ParaPortion& rParaPortion ) for ( sal_uInt16 n = nStartPortion; n <= nEndPortion; n++ ) { - pPortion = rParaPortion.GetTextPortions().GetObject(n); + pPortion = rParaPortion.GetTextPortions()[n]; switch ( pPortion->GetKind() ) { case PORTIONKIND_TEXT: diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 5bdce4cd589c..bd05ae1fb528 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -427,19 +427,28 @@ public: // ------------------------------------------------------------------------- // class TextPortionList // ------------------------------------------------------------------------- -typedef TextPortion* TextPortionPtr; -SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0 ) - -class TextPortionList : public TextPortionArray +class TextPortionList { + typedef boost::ptr_vector<TextPortion> PortionsType; + PortionsType maPortions; + public: TextPortionList(); ~TextPortionList(); void Reset(); - sal_uInt16 FindPortion( sal_uInt16 nCharPos, sal_uInt16& rPortionStart, sal_Bool bPreferStartingPortion = sal_False ) const; - sal_uInt16 GetStartPos( sal_uInt16 nPortion ); - void DeleteFromPortion( sal_uInt16 nDelFrom ); + size_t FindPortion( + sal_uInt16 nCharPos, sal_uInt16& rPortionStart, bool bPreferStartingPortion = false) const; + sal_uInt16 GetStartPos(size_t nPortion); + void DeleteFromPortion(size_t nDelFrom); + size_t Count() const; + const TextPortion* operator[](size_t nPos) const; + TextPortion* operator[](size_t nPos); + + void Append(TextPortion* p); + void Insert(size_t nPos, TextPortion* p); + void Remove(size_t nPos); + size_t GetPos(const TextPortion* p) const; }; class ParaPortion; diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index e33ee5a8e200..b01c8309ca60 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -675,7 +675,7 @@ void ImpEditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sa aEditCursor.Left() = aEditCursor.Right() = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY|GETCRSR_PREFERPORTIONSTART ).Left(); sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, sal_True ); - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; if ( pTextPortion->GetKind() == PORTIONKIND_TAB ) { aEditCursor.Right() += pTextPortion->GetSize().Width(); @@ -844,7 +844,7 @@ void ImpEditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sa if ( IsInsertMode() && !aEditSelection.HasRange() && ( pEditEngine->pImpEditEngine->HasDifferentRTLLevels( aPaM.GetNode() ) ) ) { sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, nShowCursorFlags & GETCRSR_PREFERPORTIONSTART ? sal_True : sal_False ); - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft(); if ( nRTLLevel%2 ) nCursorDir = CURSOR_DIRECTION_RTL; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index aec30e18e09a..6a01a0f648fe 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1032,7 +1032,7 @@ EditPaM ImpEditEngine::CursorVisualStartEnd( EditView* pEditView, const EditPaM& sal_uInt16 nTmp; sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTmp, sal_True ); - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft(); sal_Bool bPortionRTL = (nRTLLevel%2) ? sal_True : sal_False; @@ -1096,7 +1096,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM // Check if we are within a portion and don't have overwrite mode, then it's easy... sal_uInt16 nPortionStart; sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, sal_False ); - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; sal_Bool bPortionBoundary = ( aPaM.GetIndex() == nPortionStart ) || ( aPaM.GetIndex() == (nPortionStart+pTextPortion->GetLen()) ); sal_uInt16 nRTLLevel = pTextPortion->GetRightToLeft(); @@ -1107,7 +1107,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM { sal_uInt16 nTmp; sal_uInt16 nNextTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex()+1, nTmp, bLogicalBackward ? sal_False : sal_True ); - TextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nNextTextPortion ); + const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nNextTextPortion]; nRTLLevelNextPortion = pNextTextPortion->GetRightToLeft(); } @@ -1176,7 +1176,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM sal_uInt16 nPortionStart; sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, bBeforePortion ); - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[nTextPortion]; sal_Bool bRTLPortion = (pTextPortion->GetRightToLeft() % 2) != 0; // -1: We are 'behind' the character @@ -1205,7 +1205,7 @@ EditPaM ImpEditEngine::CursorVisualLeftRight( EditView* pEditView, const EditPaM sal_uInt16 _nPortionStart; // sal_uInt16 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nPortionStart, !bRTLPortion ); sal_uInt16 _nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), _nPortionStart, sal_True ); - TextPortion* _pTextPortion = pParaPortion->GetTextPortions().GetObject( _nTextPortion ); + const TextPortion* _pTextPortion = pParaPortion->GetTextPortions()[_nTextPortion]; if ( bVisualToLeft && !bRTLPortion && ( _pTextPortion->GetRightToLeft() % 2 ) ) aPaM.GetIndex()++; else if ( !bVisualToLeft && bRTLPortion && ( bWasBehind || !(_pTextPortion->GetRightToLeft() % 2 )) ) @@ -2018,7 +2018,7 @@ sal_Bool ImpEditEngine::HasDifferentRTLLevels( const ContentNode* pNode ) sal_uInt16 nRTLLevel = IsRightToLeft( nPara ) ? 1 : 0; for ( sal_uInt16 n = 0; n < pParaPortion->GetTextPortions().Count(); n++ ) { - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject( n ); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n]; if ( pTextPortion->GetRightToLeft() != nRTLLevel ) { bHasDifferentRTLLevels = sal_True; @@ -3165,7 +3165,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, sal_uInt16 nPos = pLine->GetStart(); for ( sal_uInt16 nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ ) { - TextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( nTP ); + const TextPortion* pTextPortion = pPortion->GetTextPortions()[nTP]; switch ( pTextPortion->GetKind() ) { case PORTIONKIND_FIELD: @@ -3720,7 +3720,7 @@ sal_uInt16 ImpEditEngine::GetChar( // Search best matching portion with GetPortionXOffset() for ( sal_uInt16 i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ ) { - TextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( i ); + const TextPortion* pPortion = pParaPortion->GetTextPortions()[i]; long nXLeft = GetPortionXOffset( pParaPortion, pLine, i ); long nXRight = nXLeft + pPortion->GetSize().Width(); if ( ( nXLeft <= nXPos ) && ( nXRight >= nXPos ) ) @@ -3846,7 +3846,7 @@ long ImpEditEngine::GetPortionXOffset( for ( sal_uInt16 i = pLine->GetStartPortion(); i < nTextPortion; i++ ) { - TextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( i ); + const TextPortion* pPortion = pParaPortion->GetTextPortions()[i]; switch ( pPortion->GetKind() ) { case PORTIONKIND_FIELD: @@ -3863,7 +3863,7 @@ long ImpEditEngine::GetPortionXOffset( sal_uInt16 nPara = GetEditDoc().GetPos( pParaPortion->GetNode() ); sal_Bool bR2LPara = IsRightToLeft( nPara ); - TextPortion* pDestPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pDestPortion = pParaPortion->GetTextPortions()[nTextPortion]; if ( pDestPortion->GetKind() != PORTIONKIND_TAB ) { if ( !bR2LPara && pDestPortion->GetRightToLeft() ) @@ -3872,7 +3872,7 @@ long ImpEditEngine::GetPortionXOffset( sal_uInt16 nTmpPortion = nTextPortion+1; while ( nTmpPortion <= pLine->GetEndPortion() ) { - TextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( pNextTextPortion->GetRightToLeft() && ( pNextTextPortion->GetKind() != PORTIONKIND_TAB ) ) nX += pNextTextPortion->GetSize().Width(); else @@ -3884,7 +3884,7 @@ long ImpEditEngine::GetPortionXOffset( while ( nTmpPortion > pLine->GetStartPortion() ) { --nTmpPortion; - TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + const TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( pPrevTextPortion->GetRightToLeft() && ( pPrevTextPortion->GetKind() != PORTIONKIND_TAB ) ) nX -= pPrevTextPortion->GetSize().Width(); else @@ -3897,7 +3897,7 @@ long ImpEditEngine::GetPortionXOffset( sal_uInt16 nTmpPortion = nTextPortion+1; while ( nTmpPortion <= pLine->GetEndPortion() ) { - TextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + const TextPortion* pNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( !pNextTextPortion->IsRightToLeft() && ( pNextTextPortion->GetKind() != PORTIONKIND_TAB ) ) nX += pNextTextPortion->GetSize().Width(); else @@ -3909,7 +3909,7 @@ long ImpEditEngine::GetPortionXOffset( while ( nTmpPortion > pLine->GetStartPortion() ) { --nTmpPortion; - TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + const TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( !pPrevTextPortion->IsRightToLeft() && ( pPrevTextPortion->GetKind() != PORTIONKIND_TAB ) ) nX -= pPrevTextPortion->GetSize().Width(); else @@ -3947,7 +3947,7 @@ long ImpEditEngine::GetXPos( OSL_ENSURE( ( nTextPortion >= pLine->GetStartPortion() ) && ( nTextPortion <= pLine->GetEndPortion() ), "GetXPos: Portion not in current line! " ); - TextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); + const TextPortion* pPortion = pParaPortion->GetTextPortions()[nTextPortion]; long nX = GetPortionXOffset( pParaPortion, pLine, nTextPortion ); @@ -3967,7 +3967,7 @@ long ImpEditEngine::GetXPos( { if ( (nTextPortion+1) < pParaPortion->GetTextPortions().Count() ) { - TextPortion* pNextPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion+1 ); + const TextPortion* pNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1]; if ( pNextPortion->GetKind() != PORTIONKIND_TAB ) { if ( !bPreferPortionStart ) diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 315ff3b61631..091c329885d5 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -685,7 +685,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) { TextPortion* pDummyPortion = new TextPortion( 0 ); pParaPortion->GetTextPortions().Reset(); - pParaPortion->GetTextPortions().Insert( pDummyPortion, 0 ); + pParaPortion->GetTextPortions().Append(pDummyPortion); } else if ( bQuickFormat ) { @@ -891,7 +891,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) while ( ( nTmpWidth < nXWidth ) && !bEOL && ( nTmpPortion < pParaPortion->GetTextPortions().Count() ) ) { nPortionStart = nTmpPos; - pPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + pPortion = pParaPortion->GetTextPortions()[nTmpPortion]; if ( pPortion->GetKind() == PORTIONKIND_HYPHENATOR ) { // Throw away a Portion, if necessary correct the one before, @@ -900,7 +900,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) if ( nTmpPortion && pPortion->GetLen() ) { nTmpPortion--; - TextPortion* pPrev = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + TextPortion* pPrev = pParaPortion->GetTextPortions()[nTmpPortion]; DBG_ASSERT( pPrev->GetKind() == PORTIONKIND_TEXT, "Portion?!" ); nTmpWidth -= pPrev->GetSize().Width(); nTmpPos = nTmpPos - pPrev->GetLen(); @@ -909,7 +909,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) } delete pPortion; DBG_ASSERT( nTmpPortion < pParaPortion->GetTextPortions().Count(), "No more Portions left!" ); - pPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); + pPortion = pParaPortion->GetTextPortions()[nTmpPortion]; } DBG_ASSERT( pPortion->GetKind() != PORTIONKIND_HYPHENATOR, "CreateLines: Hyphenator-Portion!" ); DBG_ASSERT( pPortion->GetLen() || bProcessingEmptyLine, "Empty Portion in CreateLines ?!" ); @@ -1099,7 +1099,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) long nWidthAfterTab = 0; for ( sal_uInt16 n = aCurrentTab.nTabPortion+1; n <= nTmpPortion; n++ ) { - TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( n ); + const TextPortion* pTP = pParaPortion->GetTextPortions()[n]; nWidthAfterTab += pTP->GetSize().Width(); } long nW = nWidthAfterTab; // Length before tab position @@ -1117,7 +1117,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) sal_uInt16 nDecPos = aText.Search( aCurrentTab.aTabStop.GetDecimal() ); if ( nDecPos != STRING_NOTFOUND ) { - nW -= pParaPortion->GetTextPortions().GetObject( nTmpPortion )->GetSize().Width(); + nW -= pParaPortion->GetTextPortions()[nTmpPortion]->GetSize().Width(); nW += aTmpFont.QuickGetTextSize( GetRefDevice(), *pParaPortion->GetNode(), nTmpPos, nDecPos, NULL ).Width(); aCurrentTab.bValid = sal_False; } @@ -1132,7 +1132,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) nW = nMaxW; aCurrentTab.bValid = sal_False; } - TextPortion* pTabPortion = pParaPortion->GetTextPortions().GetObject( aCurrentTab.nTabPortion ); + const TextPortion* pTabPortion = pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion]; pTabPortion->GetSize().Width() = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nW - nStartX; nTmpWidth = aCurrentTab.nStartPosX + pTabPortion->GetSize().Width() + nWidthAfterTab; } @@ -1171,7 +1171,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) DBG_ASSERT( pPortion && (pPortion->GetKind() == PORTIONKIND_TEXT), "Len>1, but no TextPortion?" ); nTmpWidth -= pPortion ? pPortion->GetSize().Width() : 0; sal_uInt16 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine ); - TextPortion* p = pParaPortion->GetTextPortions().GetObject( nP ); + const TextPortion* p = pParaPortion->GetTextPortions()[nP]; DBG_ASSERT( p, "Portion ?!" ); nTmpWidth += p->GetSize().Width(); } @@ -1277,7 +1277,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) sal_uInt16 nTPos = pLine->GetStart(); for ( sal_uInt16 nP = pLine->GetStartPortion(); nP <= pLine->GetEndPortion(); nP++ ) { - TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( nP ); + const TextPortion* pTP = pParaPortion->GetTextPortions()[nP]; // problem with hard font height attribute, when everthing but the line break has this attribute if ( pTP->GetKind() != PORTIONKIND_LINEBREAK ) { @@ -1373,7 +1373,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) // Width from HangingPunctuation was set to 0 in ImpBreakLine, // check for rel width now, maybe create compression... long n = nMaxLineWidth - aTextSize.Width(); - TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( pLine->GetEndPortion() ); + const TextPortion* pTP = pParaPortion->GetTextPortions()[pLine->GetEndPortion()]; sal_uInt16 nPosInArray = pLine->GetEnd()-1-pLine->GetStart(); long nNewValue = ( nPosInArray ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 ) + n; pLine->GetCharPosArray()[ nPosInArray ] = nNewValue; @@ -1526,7 +1526,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) // normaly CreateAndInsertEmptyLine would be called, but I want to use // CreateLines, so I need Polygon code only here... TextPortion* pDummyPortion = new TextPortion( 0 ); - pParaPortion->GetTextPortions().Insert( pDummyPortion, pParaPortion->GetTextPortions().Count() ); + pParaPortion->GetTextPortions().Append(pDummyPortion); pLine = new EditLine; pParaPortion->GetLines().Insert(++nLine, pLine); bForceOneRun = sal_True; @@ -1608,7 +1608,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uIn pDummyPortion->GetSize() = aTmpFont.GetPhysTxtSize( pRefDev, String() ); if ( IsFixedCellHeight() ) pDummyPortion->GetSize().Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetHeight() ); - pParaPortion->GetTextPortions().Insert( pDummyPortion, pParaPortion->GetTextPortions().Count() ); + pParaPortion->GetTextPortions().Append(pDummyPortion); FormatterFontMetric aFormatterMetrics; RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont ); pTmpLine->SetMaxAscent( aFormatterMetrics.nMaxAscent ); @@ -1920,7 +1920,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te if ( bCompressBlank || bHangingPunctuation ) { - TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( nEndPortion ); + const TextPortion* pTP = pParaPortion->GetTextPortions()[nEndPortion]; DBG_ASSERT( pTP->GetKind() == PORTIONKIND_TEXT, "BlankRubber: No TextPortion!" ); DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion at the beginning of the line?" ); sal_uInt16 nPosInArray = nBreakPos - 1 - pLine->GetStart(); @@ -1935,7 +1935,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te String aHyphText( CH_HYPH ); if ( cAlternateReplChar ) { - TextPortion* pPrev = pParaPortion->GetTextPortions().GetObject( nEndPortion ); + TextPortion* pPrev = pParaPortion->GetTextPortions()[nEndPortion]; DBG_ASSERT( pPrev && pPrev->GetLen(), "Hyphenate: Prev portion?!" ); pPrev->SetLen( pPrev->GetLen() - 1 ); pHyphPortion->SetLen( 1 ); @@ -1957,7 +1957,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te pHyphPortion->GetSize().Height() = GetRefDevice()->GetTextHeight(); pHyphPortion->GetSize().Width() = GetRefDevice()->GetTextWidth( aHyphText ); - pParaPortion->GetTextPortions().Insert( pHyphPortion, ++nEndPortion ); + pParaPortion->GetTextPortions().Insert(++nEndPortion, pHyphPortion); } pLine->SetEndPortion( nEndPortion ); } @@ -2211,11 +2211,11 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP sal_uInt16 nSplitPortion; sal_uInt16 nTmpPos = 0; - TextPortion* pTextPortion = 0; + TextPortion* pTextPortion = NULL; sal_uInt16 nPortions = pPortion->GetTextPortions().Count(); for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ ) { - TextPortion* pTP = pPortion->GetTextPortions().GetObject(nSplitPortion); + TextPortion* pTP = pPortion->GetTextPortions()[nSplitPortion]; nTmpPos = nTmpPos + pTP->GetLen(); if ( nTmpPos >= nPos ) { @@ -2234,7 +2234,7 @@ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nP sal_uInt16 nOverlapp = nTmpPos - nPos; pTextPortion->GetLen() = pTextPortion->GetLen() - nOverlapp; TextPortion* pNewPortion = new TextPortion( nOverlapp ); - pPortion->GetTextPortions().Insert( pNewPortion, nSplitPortion+1 ); + pPortion->GetTextPortions().Insert(nSplitPortion+1, pNewPortion); // Set sizes if ( pCurLine ) { @@ -2317,7 +2317,7 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& r sal_uInt16 nP; for ( nP = 0; nP < pParaPortion->GetTextPortions().Count(); nP++ ) { - TextPortion* pTmpPortion = pParaPortion->GetTextPortions().GetObject(nP); + const TextPortion* pTmpPortion = pParaPortion->GetTextPortions()[nP]; nPortionStart = nPortionStart + pTmpPortion->GetLen(); if ( nPortionStart >= nStartPos ) { @@ -2328,13 +2328,13 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& r } } DBG_ASSERT( nP < pParaPortion->GetTextPortions().Count() || !pParaPortion->GetTextPortions().Count(), "Nothing to delete: CreateTextPortions" ); - if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions().GetObject(nInvPortion)->GetLen() > nStartPos ) ) + if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions()[nInvPortion]->GetLen() > nStartPos ) ) { // prefer one in front ... // But only if it was in the middle of the portion of, otherwise it // might be the only one in the row in front! nInvPortion--; - nPortionStart = nPortionStart - pParaPortion->GetTextPortions().GetObject(nInvPortion)->GetLen(); + nPortionStart = nPortionStart - pParaPortion->GetTextPortions()[nInvPortion]->GetLen(); } pParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion ); @@ -2349,7 +2349,7 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& r while ( i != aPositions.end() ) { TextPortion* pNew = new TextPortion( static_cast<sal_uInt16>(*i++) - static_cast<sal_uInt16>(*nInvPos++) ); - pParaPortion->GetTextPortions().Insert( pNew, pParaPortion->GetTextPortions().Count()); + pParaPortion->GetTextPortions().Append(pNew); } DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "No Portions?!" ); @@ -2387,7 +2387,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt else { TextPortion* pNewPortion = new TextPortion( nNewChars ); - pParaPortion->GetTextPortions().Insert( pNewPortion, nNewPortionPos ); + pParaPortion->GetTextPortions().Insert(nNewPortionPos, pNewPortion); } } else @@ -2453,7 +2453,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt // No HYPHENATOR portion is allowed to get stuck right at the end... DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "RecalcTextPortions: Nothing left! "); sal_uInt16 nLastPortion = pParaPortion->GetTextPortions().Count() - 1; - pTP = pParaPortion->GetTextPortions().GetObject( nLastPortion ); + pTP = pParaPortion->GetTextPortions()[nLastPortion]; if ( pTP->GetKind() == PORTIONKIND_HYPHENATOR ) { // Discard portion; if possible, correct the ones before, @@ -2461,7 +2461,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt pParaPortion->GetTextPortions().Remove( nLastPortion ); if ( nLastPortion && pTP->GetLen() ) { - TextPortion* pPrev = pParaPortion->GetTextPortions().GetObject( nLastPortion - 1 ); + TextPortion* pPrev = pParaPortion->GetTextPortions()[nLastPortion - 1]; DBG_ASSERT( pPrev->GetKind() == PORTIONKIND_TEXT, "Portion?!" ); pPrev->SetLen( pPrev->GetLen() + pTP->GetLen() ); pPrev->GetSize().Width() = (-1); @@ -2924,7 +2924,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta for ( sal_uInt16 y = pLine->GetStartPortion(); y <= pLine->GetEndPortion(); y++ ) { DBG_ASSERT( pPortion->GetTextPortions().Count(), "Line without Textportion in Paint!" ); - TextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( y ); + const TextPortion* pTextPortion = pPortion->GetTextPortions()[y]; DBG_ASSERT( pTextPortion, "NULL-Pointer in Portion iterator in UpdateViews" ); long nPortionXOffset = GetPortionXOffset( pPortion, pLine, y ); @@ -4421,7 +4421,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* { sal_Bool bFoundCompressedPortion = sal_False; long nCompressed = 0; - TextPortionList aCompressedPortions; + std::vector<TextPortion*> aCompressedPortions; sal_uInt16 nPortion = pLine->GetEndPortion(); TextPortion* pTP = pParaPortion->GetTextPortions()[ nPortion ]; @@ -4431,7 +4431,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* { bFoundCompressedPortion = sal_True; nCompressed += pTP->GetExtraInfos()->nOrgWidth - pTP->GetSize().Width(); - aCompressedPortions.Insert( pTP, aCompressedPortions.Count() ); + aCompressedPortions.push_back(pTP); } pTP = ( nPortion > pLine->GetStartPortion() ) ? pParaPortion->GetTextPortions()[ --nPortion ] : NULL; } @@ -4447,14 +4447,14 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* nCompressPercent /= nCompressed; } - for ( sal_uInt16 n = 0; n < aCompressedPortions.Count(); n++ ) + for (size_t i = 0, n = aCompressedPortions.size(); i < n; ++i) { - pTP = aCompressedPortions[n]; + pTP = aCompressedPortions[i]; pTP->GetExtraInfos()->bCompressed = sal_False; pTP->GetSize().Width() = pTP->GetExtraInfos()->nOrgWidth; if ( nCompressPercent ) { - sal_uInt16 nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP ); + size_t nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP ); sal_uInt16 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion ); DBG_ASSERT( nTxtPortionStart >= pLine->GetStart(), "Portion doesn't belong to the line!!!" ); sal_Int32* pDXArray = &pLine->GetCharPosArray()[0]+( nTxtPortionStart-pLine->GetStart() ); @@ -4464,8 +4464,6 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* } } } - - aCompressedPortions.Remove( 0, aCompressedPortions.Count() ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 6617eb310442..dd45a57bcc4c 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -631,7 +631,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) // start at 0, so the index is right ... for ( sal_uInt16 n = 0; n <= nEndPortion; n++ ) { - TextPortion* pTextPortion = pParaPortion->GetTextPortions().GetObject(n); + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n]; if ( n < nStartPortion ) { nIndex = nIndex + pTextPortion->GetLen(); @@ -1150,9 +1150,9 @@ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemP sal_uInt16 n; for ( n = 0; n < nCount; n++ ) { - TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n]; + const TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n]; TextPortion* pNew = new TextPortion( *pTextPortion ); - pX->aTextPortions.Insert( pNew, pX->aTextPortions.Count() ); + pX->aTextPortions.Append(pNew); } // The lines @@ -1346,7 +1346,7 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed { TextPortion* pTextPortion = pXP->aTextPortions[_n]; TextPortion* pNew = new TextPortion( *pTextPortion ); - pParaPortion->GetTextPortions().Insert( pNew, _n ); + pParaPortion->GetTextPortions().Insert(_n, pNew); } // The lines |