diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-07-18 10:07:02 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-07-18 12:22:55 +0100 |
commit | 9042604f1ba0e1e6e0dc8b8f45f9b67169fd462e (patch) | |
tree | b7621764e765fcfb2d0d7ab710a1ba4f08b2dd1a | |
parent | 531743675c53a9ef33dd3dc098bc6b5ca14d3f11 (diff) |
de-stupid-operator-ize plcf and keep nIdx within legal limits
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 23 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 7 |
3 files changed, 23 insertions, 19 deletions
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 0d499c0693d0..91384ee455af 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -831,7 +831,7 @@ bool SwWW8ImplReader::GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, bool bReusable = (0 != SVBT16ToShort( ((WW8_TXBXS*)pT0)->fReusable )); while( bReusable ) { - (*pT)++; + pT->advance(); if( !pT->Get( rStartCp, pT0 ) ) { OSL_ENSURE( !this, "+Wo ist der Grafik-Text (2-a) ?" ); @@ -840,7 +840,7 @@ bool SwWW8ImplReader::GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, bReusable = (0 != SVBT16ToShort( ((WW8_TXBXS*)pT0)->fReusable )); } } - (*pT)++; + pT->advance(); if( !pT->Get( rEndCp, pT0 ) ) { OSL_ENSURE( !this, "+Wo ist der Grafik-Text (3) ?" ); @@ -868,7 +868,8 @@ bool SwWW8ImplReader::GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, return false; } // ggfs. entsprechende Anzahl Eintraege weitergehen - for(sal_uInt16 iSequence = 0; iSequence < nSequence; iSequence++) (*pT)++; + for (sal_uInt16 iSequence = 0; iSequence < nSequence; ++iSequence) + pT->advance(); // dann die tatsaechlichen Start und Ende ermitteln if( (!pT->Get( rStartCp, pT0 )) || ( nMinStartCp > rStartCp ) ) @@ -880,9 +881,8 @@ bool SwWW8ImplReader::GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, rEndCp = rStartCp; // kein Error: leerer String! else { - (*pT)++; - if( (!pT->Get( rEndCp, pT0 )) - || ( nMaxEndCp < rEndCp-1 ) ) + pT->advance(); + if ( (!pT->Get(rEndCp, pT0)) || (nMaxEndCp < rEndCp-1) ) { OSL_ENSURE( !this, "+Wo ist der Grafik-Text (6) ?" ); return false; diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index f1c8b3cfde4e..efd0f9873b50 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1779,7 +1779,7 @@ static bool WW8SkipField(WW8PLCFspecial& rPLCF) if (!rPLCF.Get(nP, pData)) // Ende des PLCFspecial ? return false; - rPLCF++; + rPLCF.advance(); if((((sal_uInt8*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ? return true; // Bei Fehler nicht abbrechen @@ -1800,7 +1800,7 @@ static bool WW8SkipField(WW8PLCFspecial& rPLCF) { // Field Separator ? - rPLCF++; + rPLCF.advance(); if( !rPLCF.Get( nP, pData ) ) return false; @@ -1813,7 +1813,7 @@ static bool WW8SkipField(WW8PLCFspecial& rPLCF) return false; } } - rPLCF++; + rPLCF.advance(); return true; } @@ -1828,7 +1828,7 @@ static bool WW8GetFieldPara(WW8PLCFspecial& rPLCF, WW8FieldDesc& rF) if( !rPLCF.Get( rF.nSCode, pData ) ) // Ende des PLCFspecial ? goto Err; - rPLCF++; + rPLCF.advance(); if((((sal_uInt8*)pData)[0] & 0x1f ) != 0x13 ) // Kein Anfang ? goto Err; @@ -1851,8 +1851,9 @@ static bool WW8GetFieldPara(WW8PLCFspecial& rPLCF, WW8FieldDesc& rF) goto Err; } - if((((sal_uInt8*)pData)[0] & 0x1f ) == 0x14 ){ // Field Separator ? - rPLCF++; + if ((((sal_uInt8*)pData)[0] & 0x1f ) == 0x14 ) // Field Separator ? + { + rPLCF.advance(); if( !rPLCF.Get( rF.nLRes, pData ) ) goto Err; @@ -1875,7 +1876,7 @@ static bool WW8GetFieldPara(WW8PLCFspecial& rPLCF, WW8FieldDesc& rF) rF.nLen = rF.nSRes - rF.nSCode + 2; // Gesamtlaenge } - rPLCF++; + rPLCF.advance(); if((((sal_uInt8*)pData)[0] & 0x1f ) == 0x15 ) { // Field Ende ? @@ -3804,7 +3805,7 @@ bool WW8PLCFx_FLD::EndPosIsFieldEnd() { long n = pPLCF->GetIdx(); - (*pPLCF)++; + pPLCF->advance(); void* pData; sal_Int32 nTest; @@ -3842,7 +3843,7 @@ void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc* p) p->nStartPos = nP; - (*pPLCF)++; + pPLCF->advance(); if (!pPLCF->Get(nP, pData)) // Ende des PLCFspecial ? { p->nStartPos = WW8_CP_MAX; // PLCF fertig abgearbeitet @@ -3858,7 +3859,7 @@ void WW8PLCFx_FLD::GetSprms(WW8PLCFxDesc* p) WW8PLCFx& WW8PLCFx_FLD::operator ++( int ) { - (*pPLCF)++; + pPLCF->advance(); return *this; } @@ -4120,7 +4121,7 @@ WW8PLCFx& WW8PLCFx_Book::operator ++( int ) { if( pBook[0] && pBook[1] && nIMax ) { - (*pBook[nIsEnd])++; + (*pBook[nIsEnd]).advance(); sal_uLong l0 = pBook[0]->Where(); sal_uLong l1 = pBook[1]->Where(); diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 899e16dcec8a..1d94aa189fd6 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -242,8 +242,11 @@ public: sal_Int32 GetPos( long nInIdx ) const { return ( nInIdx >= nIMax ) ? SAL_MAX_INT32 : pPLCF_PosArray[nInIdx]; } - WW8PLCFspecial& operator ++( int ) { nIdx++; return *this; } - WW8PLCFspecial& operator --( int ) { nIdx--; return *this; } + void advance() + { + if (nIdx <= nIMax) + ++nIdx; + } }; /** simple Iterator for SPRMs */ |