Kaydet (Commit) 593e4c36 authored tarafından Daniel Di Marco's avatar Daniel Di Marco Kaydeden (comit) Ivan Timofeev

SvUShorts -> std::vector

üst a6347e09
...@@ -75,9 +75,9 @@ void SwCache::Check() ...@@ -75,9 +75,9 @@ void SwCache::Check()
OSL_ENSURE( pObj != pRekursive, "Recursion in SwCache." ); OSL_ENSURE( pObj != pRekursive, "Recursion in SwCache." );
} }
OSL_ENSURE( bFirstFound, "First not Found." ); OSL_ENSURE( bFirstFound, "First not Found." );
OSL_ENSURE( (nCnt + aFreePositions.Count()) == Count(), "Lost Chain." ); OSL_ENSURE( (nCnt + aFreePositions.size()) == Count(), "Lost Chain." );
if ( Count() == nCurMax ) if ( Count() == nCurMax )
OSL_ENSURE( (nCurMax - nCnt) == aFreePositions.Count(), "Lost FreePositions." ); OSL_ENSURE( (nCurMax - nCnt) == aFreePositions.size(), "Lost FreePositions." );
} }
#endif #endif
...@@ -98,7 +98,6 @@ SwCache::SwCache( const sal_uInt16 nInitSize, const sal_uInt16 nGrowSize ...@@ -98,7 +98,6 @@ SwCache::SwCache( const sal_uInt16 nInitSize, const sal_uInt16 nGrowSize
#endif #endif
) : ) :
SwCacheObjArr( (sal_uInt8)nInitSize, (sal_uInt8)nGrowSize ), SwCacheObjArr( (sal_uInt8)nInitSize, (sal_uInt8)nGrowSize ),
aFreePositions( 5, 5 ),
pRealFirst( 0 ), pRealFirst( 0 ),
pFirst( 0 ), pFirst( 0 ),
pLast( 0 ), pLast( 0 ),
...@@ -227,7 +226,7 @@ void SwCache::Flush( const sal_uInt8 ) ...@@ -227,7 +226,7 @@ void SwCache::Flush( const sal_uInt8 )
{ {
pTmp = (SwCacheObj*)pObj; pTmp = (SwCacheObj*)pObj;
pObj = pTmp->GetNext(); pObj = pTmp->GetNext();
aFreePositions.Insert( pTmp->GetCachePos(), aFreePositions.Count() ); aFreePositions.push_back( pTmp->GetCachePos() );
*(pData + pTmp->GetCachePos()) = (void*)0; *(pData + pTmp->GetCachePos()) = (void*)0;
delete pTmp; delete pTmp;
INCREMENT( nFlushedObjects ); INCREMENT( nFlushedObjects );
...@@ -379,13 +378,13 @@ void SwCache::DeleteObj( SwCacheObj *pObj ) ...@@ -379,13 +378,13 @@ void SwCache::DeleteObj( SwCacheObj *pObj )
if ( pObj->GetNext() ) if ( pObj->GetNext() )
pObj->GetNext()->SetPrev( pObj->GetPrev() ); pObj->GetNext()->SetPrev( pObj->GetPrev() );
aFreePositions.Insert( pObj->GetCachePos(), aFreePositions.Count() ); aFreePositions.push_back( pObj->GetCachePos() );
*(pData + pObj->GetCachePos()) = (void*)0; *(pData + pObj->GetCachePos()) = (void*)0;
delete pObj; delete pObj;
CHECK; CHECK;
if ( Count() > nCurMax && if ( Count() > nCurMax &&
(nCurMax <= (Count() - aFreePositions.Count())) ) (nCurMax <= (Count() - aFreePositions.size())) )
{ {
//Falls moeglich wieder verkleinern, dazu muessen allerdings ausreichend //Falls moeglich wieder verkleinern, dazu muessen allerdings ausreichend
//Freie Positionen bereitstehen. //Freie Positionen bereitstehen.
...@@ -402,7 +401,7 @@ void SwCache::DeleteObj( SwCacheObj *pObj ) ...@@ -402,7 +401,7 @@ void SwCache::DeleteObj( SwCacheObj *pObj )
else else
pTmpObj->SetCachePos( i ); pTmpObj->SetCachePos( i );
} }
aFreePositions.Remove( 0, aFreePositions.Count() ); aFreePositions.clear();
} }
CHECK; CHECK;
} }
...@@ -434,14 +433,14 @@ sal_Bool SwCache::Insert( SwCacheObj *pNew ) ...@@ -434,14 +433,14 @@ sal_Bool SwCache::Insert( SwCacheObj *pNew )
nPos = Count(); nPos = Count();
SwCacheObjArr::C40_INSERT( SwCacheObj, pNew, nPos ); SwCacheObjArr::C40_INSERT( SwCacheObj, pNew, nPos );
} }
else if ( aFreePositions.Count() ) else if ( !aFreePositions.empty() )
{ {
//Es exitieren Platzhalter, also den letzten benutzen. //Es exitieren Platzhalter, also den letzten benutzen.
INCREMENT( nInsertFree ); INCREMENT( nInsertFree );
const sal_uInt16 nFreePos = aFreePositions.Count() - 1; const sal_uInt16 nFreePos = aFreePositions.size() - 1;
nPos = aFreePositions[ nFreePos ]; nPos = aFreePositions[ nFreePos ];
*(pData + nPos) = pNew; *(pData + nPos) = pNew;
aFreePositions.Remove( nFreePos ); aFreePositions.erase( aFreePositions.begin() + nFreePos );
} }
else else
{ {
...@@ -505,7 +504,7 @@ sal_Bool SwCache::Insert( SwCacheObj *pNew ) ...@@ -505,7 +504,7 @@ sal_Bool SwCache::Insert( SwCacheObj *pNew )
void SwCache::SetLRUOfst( const sal_uInt16 nOfst ) void SwCache::SetLRUOfst( const sal_uInt16 nOfst )
{ {
if ( !pRealFirst || ((Count() - aFreePositions.Count()) < nOfst) ) if ( !pRealFirst || ((Count() - aFreePositions.size()) < nOfst) )
return; return;
CHECK; CHECK;
......
...@@ -1905,9 +1905,9 @@ void SwTOXBaseSection::UpdatePageNum() ...@@ -1905,9 +1905,9 @@ void SwTOXBaseSection::UpdatePageNum()
for( sal_uInt16 nCnt = 0; nCnt < aSortArr.Count(); ++nCnt ) for( sal_uInt16 nCnt = 0; nCnt < aSortArr.Count(); ++nCnt )
{ {
// Schleife ueber alle SourceNodes // Schleife ueber alle SourceNodes
SvUShorts aNums; //Die Seitennummern std::vector<sal_uInt16> aNums; //Die Seitennummern
SvPtrarr aDescs; //Die PageDescriptoren passend zu den Seitennummern. SvPtrarr aDescs; //Die PageDescriptoren passend zu den Seitennummern.
SvUShorts* pMainNums = 0; // contains page numbers of main entries std::vector<sal_uInt16> *pMainNums = 0; // contains page numbers of main entries
// process run in lines // process run in lines
sal_uInt16 nRange = 0; sal_uInt16 nRange = 0;
...@@ -1961,12 +1961,12 @@ void SwTOXBaseSection::UpdatePageNum() ...@@ -1961,12 +1961,12 @@ void SwTOXBaseSection::UpdatePageNum()
} }
// sortiert einfuegen // sortiert einfuegen
for( i = 0; i < aNums.Count() && aNums[i] < nPage; ++i ) for( i = 0; i < aNums.size() && aNums[i] < nPage; ++i )
; ;
if( i >= aNums.Count() || aNums[ i ] != nPage ) if( i >= aNums.size() || aNums[ i ] != nPage )
{ {
aNums.Insert( nPage, i ); aNums.insert(aNums.begin() + i, nPage);
aDescs.Insert( (void*)pAktPage->GetPageDesc(), i ); aDescs.Insert( (void*)pAktPage->GetPageDesc(), i );
} }
// is it a main entry? // is it a main entry?
...@@ -1974,8 +1974,8 @@ void SwTOXBaseSection::UpdatePageNum() ...@@ -1974,8 +1974,8 @@ void SwTOXBaseSection::UpdatePageNum()
rTOXSource.bMainEntry) rTOXSource.bMainEntry)
{ {
if(!pMainNums) if(!pMainNums)
pMainNums = new SvUShorts; pMainNums = new std::vector<sal_uInt16>;
pMainNums->Insert(nPage, pMainNums->Count()); pMainNums->push_back(nPage);
} }
} }
} }
...@@ -1990,7 +1990,7 @@ void SwTOXBaseSection::UpdatePageNum() ...@@ -1990,7 +1990,7 @@ void SwTOXBaseSection::UpdatePageNum()
aIntl ); aIntl );
} }
DELETEZ(pMainNums); DELETEZ(pMainNums);
aNums.Remove(0, aNums.Count()); aNums.clear();
} }
} }
// nach dem Setzen der richtigen Seitennummer, das Mapping-Array // nach dem Setzen der richtigen Seitennummer, das Mapping-Array
...@@ -2002,22 +2002,22 @@ void SwTOXBaseSection::UpdatePageNum() ...@@ -2002,22 +2002,22 @@ void SwTOXBaseSection::UpdatePageNum()
Beschreibung: Austausch der Seitennummer-Platzhalter Beschreibung: Austausch der Seitennummer-Platzhalter
--------------------------------------------------------------------*/ --------------------------------------------------------------------*/
// search for the page no in the array of main entry page numbers // search for the page no in the array of main entry page numbers
sal_Bool lcl_HasMainEntry( const SvUShorts* pMainEntryNums, sal_uInt16 nToFind ) sal_Bool lcl_HasMainEntry( const std::vector<sal_uInt16>* pMainEntryNums, sal_uInt16 nToFind )
{ {
for(sal_uInt16 i = 0; pMainEntryNums && i < pMainEntryNums->Count(); ++i) for(sal_uInt16 i = 0; pMainEntryNums && i < pMainEntryNums->size(); ++i)
if(nToFind == (*pMainEntryNums)[i]) if(nToFind == (*pMainEntryNums)[i])
return sal_True; return sal_True;
return sal_False; return sal_False;
} }
void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
const SvUShorts& rNums, const std::vector<sal_uInt16>& rNums,
const SvPtrarr & rDescs, const SvPtrarr & rDescs,
const SvUShorts* pMainEntryNums, const std::vector<sal_uInt16>* pMainEntryNums,
const SwTOXInternational& rIntl ) const SwTOXInternational& rIntl )
{ {
//collect starts end ends of main entry character style //collect starts end ends of main entry character style
SvUShorts* pCharStyleIdx = pMainEntryNums ? new SvUShorts : 0; std::vector<sal_uInt16>* pCharStyleIdx = pMainEntryNums ? new std::vector<sal_uInt16> : 0;
String sSrchStr( cNumRepl ); String sSrchStr( cNumRepl );
sSrchStr.AppendAscii( sPageDeli ) += cNumRepl; sSrchStr.AppendAscii( sPageDeli ) += cNumRepl;
...@@ -2026,7 +2026,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2026,7 +2026,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
xub_StrLen nEndPos = pNd->GetTxt().Search( sSrchStr ); xub_StrLen nEndPos = pNd->GetTxt().Search( sSrchStr );
sal_uInt16 i; sal_uInt16 i;
if( STRING_NOTFOUND == nEndPos || !rNums.Count() ) if( STRING_NOTFOUND == nEndPos || rNums.empty() )
return; return;
if( STRING_NOTFOUND == nStartPos || nStartPos > nEndPos) if( STRING_NOTFOUND == nStartPos || nStartPos > nEndPos)
...@@ -2040,7 +2040,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2040,7 +2040,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
if( pCharStyleIdx && lcl_HasMainEntry( pMainEntryNums, nBeg )) if( pCharStyleIdx && lcl_HasMainEntry( pMainEntryNums, nBeg ))
{ {
sal_uInt16 nTemp = 0; sal_uInt16 nTemp = 0;
pCharStyleIdx->Insert( nTemp, pCharStyleIdx->Count()); pCharStyleIdx->push_back( nTemp );
} }
// Platzhalter loeschen // Platzhalter loeschen
...@@ -2062,7 +2062,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2062,7 +2062,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
} }
pNd->EraseText(aPos, nEndPos - nStartPos + 2); pNd->EraseText(aPos, nEndPos - nStartPos + 2);
for( i = 1; i < rNums.Count(); ++i) for( i = 1; i < rNums.size(); ++i)
{ {
SvxNumberType aType( ((SwPageDesc*)rDescs[i])->GetNumType() ); SvxNumberType aType( ((SwPageDesc*)rDescs[i])->GetNumType() );
if( TOX_INDEX == SwTOXBase::GetType() ) if( TOX_INDEX == SwTOXBase::GetType() )
...@@ -2100,8 +2100,9 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2100,8 +2100,9 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
aNumStr.AppendAscii( sPageDeli ); aNumStr.AppendAscii( sPageDeli );
//the change of the character style must apply after sPageDeli is appended //the change of the character style must apply after sPageDeli is appended
if(pCharStyleIdx && bMainEntryChanges) if(pCharStyleIdx && bMainEntryChanges)
pCharStyleIdx->Insert(aNumStr.Len(), {
pCharStyleIdx->Count()); pCharStyleIdx->push_back(aNumStr.Len());
}
aNumStr += aType.GetNumStr( nBeg ); aNumStr += aType.GetNumStr( nBeg );
nCount = 0; nCount = 0;
} }
...@@ -2110,7 +2111,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2110,7 +2111,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
else else
{ // Alle Nummern eintragen { // Alle Nummern eintragen
aNumStr += aType.GetNumStr( sal_uInt16(rNums[i]) ); aNumStr += aType.GetNumStr( sal_uInt16(rNums[i]) );
if(i != (rNums.Count()-1)) if(i != (rNums.size()-1))
aNumStr.AppendAscii( sPageDeli ); aNumStr.AppendAscii( sPageDeli );
} }
} }
...@@ -2145,11 +2146,11 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2145,11 +2146,11 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
} }
//now the main entries should get there character style //now the main entries should get there character style
if(pCharStyleIdx && pCharStyleIdx->Count() && GetMainEntryCharStyle().Len()) if(pCharStyleIdx && !pCharStyleIdx->empty() && GetMainEntryCharStyle().Len())
{ {
// eventually the last index must me appended // eventually the last index must me appended
if(pCharStyleIdx->Count()&0x01) if(pCharStyleIdx->size()&0x01)
pCharStyleIdx->Insert(aNumStr.Len(), pCharStyleIdx->Count()); pCharStyleIdx->push_back(aNumStr.Len());
//search by name //search by name
SwDoc* pDoc = pNd->GetDoc(); SwDoc* pDoc = pNd->GetDoc();
...@@ -2165,7 +2166,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, ...@@ -2165,7 +2166,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd,
//find the page numbers in aNumStr and set the character style //find the page numbers in aNumStr and set the character style
xub_StrLen nOffset = pNd->GetTxt().Len() - aNumStr.Len(); xub_StrLen nOffset = pNd->GetTxt().Len() - aNumStr.Len();
SwFmtCharFmt aCharFmt(pCharFmt); SwFmtCharFmt aCharFmt(pCharFmt);
for(sal_uInt16 j = 0; j < pCharStyleIdx->Count(); j += 2) for(sal_uInt16 j = 0; j < pCharStyleIdx->size(); j += 2)
{ {
xub_StrLen nStartIdx = (*pCharStyleIdx)[j] + nOffset; xub_StrLen nStartIdx = (*pCharStyleIdx)[j] + nOffset;
xub_StrLen nEndIdx = (*pCharStyleIdx)[j + 1] + nOffset; xub_StrLen nEndIdx = (*pCharStyleIdx)[j + 1] + nOffset;
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <section.hxx> #include <section.hxx>
class SwTOXInternational; class SwTOXInternational;
class SvUShorts;
class SvStringsDtor; class SvStringsDtor;
class SvPtrarr; class SvPtrarr;
class SwPageDesc; class SwPageDesc;
...@@ -83,9 +82,9 @@ class SwTOXBaseSection : public SwTOXBase, public SwSection ...@@ -83,9 +82,9 @@ class SwTOXBaseSection : public SwTOXBase, public SwSection
// Seitennummerplatzhalter gegen aktuelle Nummern austauschen // Seitennummerplatzhalter gegen aktuelle Nummern austauschen
void _UpdatePageNum( SwTxtNode* pNd, void _UpdatePageNum( SwTxtNode* pNd,
const SvUShorts& rNums, const std::vector<sal_uInt16>& rNums,
const SvPtrarr &rDescs, const SvPtrarr &rDescs,
const SvUShorts* pMainEntryNums, const std::vector<sal_uInt16>* pMainEntryNums,
const SwTOXInternational& rIntl ); const SwTOXInternational& rIntl );
// Bereich fuer Stichwort einfuegen suchen // Bereich fuer Stichwort einfuegen suchen
......
...@@ -58,12 +58,13 @@ ...@@ -58,12 +58,13 @@
* *
*/ */
#include <vector>
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
#include <tools/string.hxx> #include <tools/string.hxx>
#endif #endif
#ifndef _SVSTDARR_HXX #ifndef _SVSTDARR_HXX
#define _SVSTDARR_USHORTS
#include <svl/svstdarr.hxx> #include <svl/svstdarr.hxx>
#endif #endif
...@@ -73,7 +74,7 @@ SV_DECL_PTRARR_DEL(SwCacheObjArr,SwCacheObj*,1,1) ...@@ -73,7 +74,7 @@ SV_DECL_PTRARR_DEL(SwCacheObjArr,SwCacheObj*,1,1)
class SwCache : public SwCacheObjArr class SwCache : public SwCacheObjArr
{ {
SvUShorts aFreePositions; //Freie Positionen fuer das Insert wenn std::vector<sal_uInt16> aFreePositions; //Freie Positionen fuer das Insert wenn
//die Maximalgrenze nicht erreicht ist. //die Maximalgrenze nicht erreicht ist.
//Immer wenn ein Objekt ausgetragen wird, //Immer wenn ein Objekt ausgetragen wird,
//so wird seine Position hier eingetragen. //so wird seine Position hier eingetragen.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment