diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-02 20:16:22 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-03 10:20:08 -0400 |
commit | 659c008ffdbaa67c3c344a1b477f24700b224ee6 (patch) | |
tree | 3f133ef7fef457202f3b35be04963764569bd079 /editeng | |
parent | No more protected visibility; class inheritance is gone. (diff) | |
download | core-659c008ffdbaa67c3c344a1b477f24700b224ee6.tar.gz core-659c008ffdbaa67c3c344a1b477f24700b224ee6.zip |
One less SV_IMPL_VARARRAY.
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 17 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.hxx | 10 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 22 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 42 |
4 files changed, 56 insertions, 35 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index f593893947f2..df899c5a3440 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -397,8 +397,6 @@ EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sa return pNew; } -SV_IMPL_VARARR( CharPosArray, sal_Int32 ); - TextPortionList::TextPortionList() { } @@ -917,13 +915,20 @@ EditLine::~EditLine() DBG_DTOR( EE_EditLine, 0 ); } +EditLine::CharPosArrayType& EditLine::GetCharPosArray() +{ + return aPositions; +} + +const EditLine::CharPosArrayType& EditLine::GetCharPosArray() const +{ + return aPositions; +} + EditLine* EditLine::Clone() const { EditLine* pL = new EditLine; - if ( aPositions.Count() ) - { - pL->aPositions.Insert (aPositions.GetData(), aPositions.Count(), 0); - } + pL->aPositions = aPositions; pL->nStartPosX = nStartPosX; pL->nStart = nStart; pL->nEnd = nEnd; diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index e17618ee09a6..c71229a33934 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -444,15 +444,16 @@ public: class ParaPortion; -SV_DECL_VARARR( CharPosArray, sal_Int32, 0 ) - // ------------------------------------------------------------------------ // class EditLine // ------------------------------------------------------------------------- class EditLine { +public: + typedef std::vector<sal_Int32> CharPosArrayType; + private: - CharPosArray aPositions; + CharPosArrayType aPositions; long nTxtWidth; sal_uInt16 nStartPosX; sal_uInt16 nStart; // could be replaced by nStartPortion @@ -525,7 +526,8 @@ public: sal_Bool IsEmpty() const { return (nEnd > nStart) ? sal_False : sal_True; } - CharPosArray& GetCharPosArray() { return aPositions; } + CharPosArrayType& GetCharPosArray(); + const CharPosArrayType& GetCharPosArray() const; EditLine* Clone() const; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 3a6613c3bc36..5d5cdf24e346 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -3765,11 +3765,11 @@ sal_uInt16 ImpEditEngine::GetChar( // Search in Array... for ( sal_uInt16 x = 0; x < nMax; x++ ) { - long nTmpPosMax = pLine->GetCharPosArray().GetObject( nTmpCurIndex+x ); + long nTmpPosMax = pLine->GetCharPosArray()[nTmpCurIndex+x]; if ( nTmpPosMax > nXInPortion ) { // Check whether this or the previous... - long nTmpPosMin = x ? pLine->GetCharPosArray().GetObject( nTmpCurIndex+x-1 ) : 0; + long nTmpPosMin = x ? pLine->GetCharPosArray()[nTmpCurIndex+x-1] : 0; long nDiffLeft = nXInPortion - nTmpPosMin; long nDiffRight = nTmpPosMax - nXInPortion; OSL_ENSURE( nDiffLeft >= 0, "DiffLeft negative" ); @@ -3780,8 +3780,8 @@ sal_uInt16 ImpEditEngine::GetChar( // Skip all 0-positions, cheaper than using XBreakIterator: if ( nOffset < nMax ) { - const long nX = pLine->GetCharPosArray().GetObject(nOffset); - while ( ( (nOffset+1) < nMax ) && ( pLine->GetCharPosArray().GetObject(nOffset+1) == nX ) ) + const long nX = pLine->GetCharPosArray()[nOffset]; + while ( ( (nOffset+1) < nMax ) && ( pLine->GetCharPosArray()[nOffset+1] == nX ) ) nOffset++; } break; @@ -3966,7 +3966,7 @@ long ImpEditEngine::GetXPos( // But the array migh not be init yet, if using text ranger this method is called within CreateLines()... long nPortionTextWidth = pPortion->GetSize().Width(); if ( ( pPortion->GetKind() == PORTIONKIND_TEXT ) && pPortion->GetLen() && !GetTextRanger() ) - nPortionTextWidth = pLine->GetCharPosArray().GetObject( nTextPortionStart + pPortion->GetLen() - 1 - pLine->GetStart() ); + nPortionTextWidth = pLine->GetCharPosArray()[nTextPortionStart + pPortion->GetLen() - 1 - pLine->GetStart()]; if ( nTextPortionStart != nIndex ) { @@ -4000,19 +4000,19 @@ long ImpEditEngine::GetXPos( else if ( pPortion->GetKind() == PORTIONKIND_TEXT ) { OSL_ENSURE( nIndex != pLine->GetStart(), "Strange behavior in new GetXPos()" ); - OSL_ENSURE( pLine && pLine->GetCharPosArray().Count(), "svx::ImpEditEngine::GetXPos(), portion in an empty line?" ); + OSL_ENSURE( pLine && pLine->GetCharPosArray().size(), "svx::ImpEditEngine::GetXPos(), portion in an empty line?" ); - if( pLine->GetCharPosArray().Count() ) + if( pLine->GetCharPosArray().size() ) { sal_uInt16 nPos = nIndex - 1 - pLine->GetStart(); - if( nPos >= pLine->GetCharPosArray().Count() ) + if( nPos >= pLine->GetCharPosArray().size() ) { - nPos = pLine->GetCharPosArray().Count()-1; + nPos = pLine->GetCharPosArray().size()-1; OSL_FAIL("svx::ImpEditEngine::GetXPos(), index out of range!"); } // old code restored see #i112788 (which leaves #i74188 unfixed again) - long nPosInPortion = pLine->GetCharPosArray().GetObject( nPos ); + long nPosInPortion = pLine->GetCharPosArray()[nPos]; if ( !pPortion->IsRightToLeft() ) { @@ -4032,7 +4032,7 @@ long ImpEditEngine::GetXPos( if ( nType == CHAR_PUNCTUATIONRIGHT ) { sal_uInt16 n = nIndex - nTextPortionStart; - const sal_Int32* pDXArray = pLine->GetCharPosArray().GetData()+( nTextPortionStart-pLine->GetStart() ); + const sal_Int32* pDXArray = &pLine->GetCharPosArray()[0]+( nTextPortionStart-pLine->GetStart() ); sal_Int32 nCharWidth = ( ( (n+1) < pPortion->GetLen() ) ? pDXArray[n] : pPortion->GetSize().Width() ) - ( n ? pDXArray[n-1] : 0 ); if ( (n+1) < pPortion->GetLen() ) diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index f377bbaee01c..f7038f5be77b 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -797,7 +797,7 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) // The line before can only become longer, not smaller // => ... if ( bCalcCharPositions ) - pLine->GetCharPosArray().Remove( 0, pLine->GetCharPosArray().Count() ); + pLine->GetCharPosArray().clear(); sal_uInt16 nTmpPos = nIndex; sal_uInt16 nTmpPortion = pLine->GetStartPortion(); @@ -977,7 +977,9 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) bEOL = sal_True; bBrokenLine = sal_True; } - pLine->GetCharPosArray().Insert( pPortion->GetSize().Width(), nTmpPos-pLine->GetStart() ); + EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + size_t nPos = nTmpPos - pLine->GetStart(); + rArray.insert(rArray.begin()+nPos, pPortion->GetSize().Width()); bCompressedChars = sal_False; } break; @@ -989,7 +991,9 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) bLineBreak = sal_True; pPortion->GetKind() = PORTIONKIND_LINEBREAK; bCompressedChars = sal_False; - pLine->GetCharPosArray().Insert( pPortion->GetSize().Width(), nTmpPos-pLine->GetStart() ); + EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + size_t nPos = nTmpPos - pLine->GetStart(); + rArray.insert(rArray.begin()+nPos, pPortion->GetSize().Width()); } break; case EE_FEATURE_FIELD: @@ -1008,7 +1012,9 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) pPortion->GetSize().Width() = nXWidth; } nTmpWidth += pPortion->GetSize().Width(); - pLine->GetCharPosArray().Insert( pPortion->GetSize().Width(), nTmpPos-pLine->GetStart() ); + EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + size_t nPos = nTmpPos - pLine->GetStart(); + rArray.insert(rArray.begin()+nPos, pPortion->GetSize().Width()); pPortion->GetKind() = cChar ? PORTIONKIND_TEXT : PORTIONKIND_FIELD; // If this is the first token on the line, // and nTmpWidth > aPaperSize.Width, => infinite loop! @@ -1050,13 +1056,19 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) sal_uInt16 nLen = pPortion->GetLen(); // The array is generally flattened at the beginning // => Always simply quick inserts. - sal_uInt16 nPos = nTmpPos - pLine->GetStart(); - pLine->GetCharPosArray().Insert( pBuf, nLen, nPos ); + size_t nPos = nTmpPos - pLine->GetStart(); + EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + rArray.insert(rArray.begin()+nPos, pBuf, pBuf+nLen); } // And now check for Compression: if ( pPortion->GetLen() && GetAsianCompressionMode() ) - bCompressedChars |= ImplCalcAsianCompression( pNode, pPortion, nTmpPos, (sal_Int32*)pLine->GetCharPosArray().GetData() + (nTmpPos-pLine->GetStart()), 10000, sal_False ); + { + EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + sal_Int32* pDXArray = &rArray[0] + nTmpPos - pLine->GetStart(); + bCompressedChars |= ImplCalcAsianCompression( + pNode, pPortion, nTmpPos, pDXArray, 10000, false); + } nTmpWidth += pPortion->GetSize().Width(); @@ -1229,7 +1241,9 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) if ( bCompressedChars && pPortion && ( pPortion->GetLen() > 1 ) && pPortion->GetExtraInfos() && pPortion->GetExtraInfos()->bCompressed ) { // I need the manipulated DXArray for determining the break postion... - ImplCalcAsianCompression( pNode, pPortion, nPortionStart, const_cast<sal_Int32*>(( pLine->GetCharPosArray().GetData() + (nPortionStart-pLine->GetStart()) )), 10000, sal_True ); + sal_Int32* pDXArray = &pLine->GetCharPosArray()[0] + (nPortionStart - pLine->GetStart()); + ImplCalcAsianCompression( + pNode, pPortion, nPortionStart, pDXArray, 10000, true); } if( pPortion ) ImpBreakLine( pParaPortion, pLine, pPortion, nPortionStart, @@ -1417,10 +1431,10 @@ sal_Bool ImpEditEngine::CreateLines( sal_uInt16 nPara, sal_uInt32 nStartPosY ) // CharPosArray: if ( bCalcCharPositions ) { - sal_uInt16 nLen = pLine->GetLen(); - sal_uInt16 nCount = pLine->GetCharPosArray().Count(); - if ( nCount > nLen ) - pLine->GetCharPosArray().Remove( nLen, nCount-nLen ); + EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray(); + size_t nLen = pLine->GetLen(); + if (rArray.size() > nLen) + rArray.erase(rArray.begin()+nLen, rArray.end()); } if ( GetTextRanger() ) @@ -2983,7 +2997,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aSta aText = *pPortion->GetNode(); nTextStart = nIndex; nTextLen = pTextPortion->GetLen(); - pDXArray = pLine->GetCharPosArray().GetData()+( nIndex-pLine->GetStart() ); + pDXArray = &pLine->GetCharPosArray()[0]+( nIndex-pLine->GetStart() ); // Paint control characters (#i55716#) if ( aStatus.MarkFields() ) @@ -4443,7 +4457,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* sal_uInt16 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 = const_cast< sal_Int32* >( pLine->GetCharPosArray().GetData()+( nTxtPortionStart-pLine->GetStart() ) ); + sal_Int32* pDXArray = &pLine->GetCharPosArray()[0]+( nTxtPortionStart-pLine->GetStart() ); if ( pTP->GetExtraInfos()->pOrgDXArray ) memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray, (pTP->GetLen()-1)*sizeof(sal_Int32) ); ImplCalcAsianCompression( pParaPortion->GetNode(), pTP, nTxtPortionStart, pDXArray, (sal_uInt16)nCompressPercent, sal_True ); |